时空网前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 lines
8.0 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <!-- 当设置tab-width,指定每个tab宽度时,则不使用flex布局,改用水平滑动 -->
  4. <view class="padding-lr" style="margin-bottom: 10rpx;margin-top: 20rpx;">
  5. <me-tabs v-model="current" :tabs="tab_list" :fixed="true" @change="change"></me-tabs>
  6. <!-- <u-tabs :list="tab_list" :is-scroll="true" :show-bar="false" :current="current" @change="change"></u-tabs> -->
  7. </view>
  8. <view class="com" v-for="(tab, tabIndex) in tab_list" v-if="tabIndex == current" :key="tab.id">
  9. <view class="flex-direction justify-around list" v-for="(item, index) in tab.list" :key="item.id" @tap="goDetails(tabIndex,index)">
  10. <view class="lf-row-between">
  11. <view class="left" style="position: relative;">
  12. <image :src="item.goods.cover" mode=""></image>
  13. <view class="cu-tag badge tag-self lf-font-28 font-400" :style="{'background-color':item.state_text.bg_color,'color':item.state_text.color}">{{item.state_text.text}}</view>
  14. </view>
  15. <view class="right">
  16. <view class="lf-line-2 title" style="line-height: 40rpx;">网红辣椒棒 魔鬼辣椒挑战全网第一辣 网红优惠季 </view>
  17. <view class="lf-flex tips" style="margin: 0!important;">
  18. <text class="progress margin-right-xs">数量</text>
  19. <text class="bought">x {{item.number}}</text>
  20. </view>
  21. <view class="lf-row-between price">
  22. <text class="lf-font-bold">
  23. <text class="lf-font-24"></text>
  24. <text class="lf-font-42">{{item.selling_price}}</text>
  25. </text>
  26. <button v-if="item.state==1" @tap.stop="$routerGo('/pages/order/confirm-order?type=1&goods_id='+item.goods_id+'&goods_specs_id='+item.goods_specs_id +'&order_id='+ item.id)">立即付款</button>
  27. <button v-if="item.state==2" class="cu-btn bg-green round margin-left-sm" @tap="$routerGo('/pages/order/order-details?order_id='+item.id)">立即使用</button>
  28. </view>
  29. </view>
  30. </view>
  31. <view>
  32. <view class="solid-top flex justify-between align-center text-center">
  33. <view class="text-gray lf-font-28" style="padding: 20rpx;">
  34. {{item.created_at_text}}
  35. </view>
  36. <view class="text-orange" v-if="item.state==1" style="padding: 20rpx;">
  37. {{item.comment_text}}
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 加载 -->
  43. <view class="loading-more">
  44. <text v-if="tab.list.length"
  45. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  46. <my-nocontent v-else></my-nocontent>
  47. </view>
  48. <!-- 回到顶部 -->
  49. <u-back-top :scroll-top="pageScrollTop"></u-back-top>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. tab_list: [{
  58. name: '全部',
  59. type: 'all',
  60. list: [],
  61. loadingClass: true,
  62. loadingText: '正在加载中',
  63. page: 1,
  64. isPage: true
  65. }, {
  66. name: '待付款',
  67. type: 'unpaid',
  68. list: [],
  69. loadingClass: true,
  70. loadingText: '正在加载中',
  71. page: 1,
  72. isPage: true
  73. }, {
  74. name: '待使用',
  75. type: 'paid',
  76. list: [],
  77. loadingClass: true,
  78. loadingText: '正在加载中',
  79. page: 1,
  80. isPage: true
  81. },
  82. {
  83. name: '已完成',
  84. type: 'complete',
  85. list: [],
  86. loadingClass: true,
  87. loadingText: '正在加载中',
  88. page: 1,
  89. isPage: true
  90. },
  91. {
  92. name: '售后',
  93. type: 'after_sales',
  94. list: [],
  95. loadingClass: true,
  96. loadingText: '正在加载中',
  97. page: 1,
  98. isPage: true
  99. }
  100. ],
  101. current: 0, // tab下表
  102. pageSize: 10,
  103. assetsType: '', //账户类型
  104. orderType: []
  105. }
  106. },
  107. onLoad(e) {
  108. this.assetsType = e.type;
  109. },
  110. onShow() {
  111. this.verifyUserInfo();
  112. let tab_item = this.tab_list[this.current];
  113. tab_item.page = 1;
  114. tab_item.isPage = true;
  115. tab_item.loadingClass = true;
  116. tab_item.loadingText = '正在加载中';
  117. this.getUserOrder();
  118. },
  119. methods: {
  120. // 检查当前用户登录状态
  121. verifyUserInfo(){
  122. let userInfo = uni.getStorageSync('userinfo') || {};
  123. if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
  124. this.$url('/pages/login/index?type=userinfo');
  125. }
  126. },
  127. // 切换tab
  128. change(index) {
  129. this.current = index;
  130. this.getUserOrder();
  131. },
  132. goDetails(tabIndex,index) {
  133. // this.$routerGo('/pages/order/order-details?order_id=55')
  134. console.log(tabIndex,index)
  135. let item = this.tab_list[tabIndex].list[index]
  136. if (item.state == 1) {
  137. this.$routerGo('/pages/order/unpay-details?order_id=' + item.id)
  138. } else if(item.state == 4){
  139. this.$routerGo('/pages/order/apply-details?order_id=' + item.id)
  140. }else {
  141. this.$routerGo('/pages/order/order-details?order_id=' + item.id)
  142. }
  143. },
  144. onReachBottom() {
  145. let tab_item = this.tab_list[this.current];
  146. if (tab_item.isPage) {
  147. tab_item.page = tab_item.page + 1;
  148. this.getUserOrder();
  149. }
  150. },
  151. onPullDownRefresh() {
  152. let tab_item = this.tab_list[this.current];
  153. tab_item.page = 1;
  154. tab_item.isPage = true;
  155. tab_item.loadingClass = true;
  156. tab_item.loadingText = '正在加载中';
  157. this.getUserOrder();
  158. uni.stopPullDownRefresh()
  159. },
  160. getUserOrder() {
  161. let per_page = this.pageSize;
  162. let tab_item = this.tab_list[this.current];
  163. this.$http(this.API.API_USERORDER, {
  164. state: this.tab_list[this.current].type,
  165. page: tab_item.page,
  166. per_page
  167. }).then(res => {
  168. if (res.code == 0) {
  169. console.log(res)
  170. if( Object.keys(res.metal_data).length != 0 ) {
  171. this.$routerGo('/pages/login/index?type=userinfo')
  172. }else {
  173. let isPage = res.data.has_more_page;
  174. tab_item.isPage = isPage;
  175. if (isPage) {
  176. tab_item.loadingClass = true;
  177. tab_item.loadingText = '正在加载中';
  178. } else {
  179. tab_item.loadingClass = false;
  180. tab_item.loadingText = '没有更多数据啦~';
  181. }
  182. if (tab_item.page == 1) {
  183. tab_item.list = res.data.items;
  184. } else {
  185. tab_item.list.push(...res.data.items);
  186. }
  187. }
  188. }
  189. }).catch(err => {
  190. });
  191. },
  192. //返回
  193. back() {
  194. if (this.assetsType === 'all2') {
  195. // #ifdef H5
  196. window.history.go(-2)
  197. // #endif
  198. // #ifndef H5
  199. uni.navigateBack({
  200. delta: 2
  201. });
  202. // #endif
  203. } else {
  204. // #ifdef H5
  205. window.history.go(-1)
  206. // #endif
  207. // #ifndef H5
  208. uni.navigateBack({
  209. delta: 1
  210. });
  211. // #endif
  212. }
  213. }
  214. },
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .font-400 {
  219. font-weight: 400;
  220. }
  221. .tag-self {
  222. position: absolute!important;
  223. top: 0!important;
  224. border-radius: 20rpx 0 20rpx 0!important;
  225. width: max-content;
  226. height: 32rpx!important;
  227. }
  228. .title {
  229. font-size: 28rpx;
  230. color: $u-content-color;
  231. height: 80rpx;
  232. }
  233. // tab
  234. .ctab {
  235. width: 100%;
  236. margin: 20rpx 0 0rpx 0rpx;
  237. padding: 0 22rpx;
  238. }
  239. // 商品列表
  240. .com {
  241. width: 100%;
  242. overflow: hidden;
  243. .list {
  244. border-radius: 10rpx;
  245. overflow: hidden;
  246. margin: 20rpx 32rpx;
  247. background-color: #FFFFFF;
  248. // box-shadow: 0 0 10px 5px #e5e5e5;
  249. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  250. align-items: flex-start;
  251. .left {
  252. overflow: hidden;
  253. image {
  254. width: 186rpx;
  255. height: 186rpx;
  256. margin: 20rpx;
  257. border-radius: 10rpx;
  258. }
  259. }
  260. .right {
  261. overflow: hidden;
  262. width: 64%;
  263. .title {
  264. margin: 0rpx 20rpx 10rpx 0;
  265. color: #222222;
  266. font-size: 32rpx;
  267. }
  268. .tips {
  269. margin: 16rpx 0;
  270. overflow: hidden;
  271. .u-line-progress {
  272. width: 112rpx;
  273. overflow: hidden;
  274. margin-right: 20rpx;
  275. }
  276. .progress {
  277. color: #777777;
  278. font-size: 24rpx;
  279. }
  280. .bought {
  281. color: #777777;
  282. font-size: 24rpx;
  283. margin-right: 20rpx;
  284. }
  285. }
  286. .price {
  287. overflow: hidden;
  288. color: #FF0000;
  289. margin-top: 10rpx;
  290. button {
  291. width: 176rpx;
  292. height: 60rpx;
  293. background: #FE9903;
  294. border-radius: 15px;
  295. font-size: 24rpx;
  296. color: #FFFFFF;
  297. margin: 0rpx 20rpx 0rpx 20rpx;
  298. border: none;
  299. }
  300. }
  301. }
  302. }
  303. }
  304. </style>