时空网前端
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.

305 lines
7.3 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <!-- 当设置tab-width,指定每个tab宽度时,则不使用flex布局,改用水平滑动 -->
  4. <view class="padding-lr margin-bottom">
  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 text-lg" :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">{{item.goods.name}}</view>
  17. <view class="lf-flex tips">
  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?goods_id='+item.goods_id+'&goods_specs_id='+item.goods_specs_id)">立即付款</button>
  27. <button v-if="item.state==2" class="cu-btn bg-green round margin-left-sm" @tap="$routerGo('/pages/order/order-details?orderid='+item.id)">立即使用</button>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="padding-bottom padding-lr padding-top-sm">
  32. <view class="u-border-top flex justify-between align-center text-center">
  33. <view class="padding-top text-gray">
  34. {{item.created_at_text}}
  35. </view>
  36. <view class="text-orange padding-top" v-if="item.state==1">
  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. this.getUserOrder()
  110. },
  111. methods: {
  112. // 切换tab
  113. change(index) {
  114. this.current = index;
  115. this.getUserOrder();
  116. },
  117. goDetails(tabIndex,index) {
  118. // this.$routerGo('/pages/order/order-details?orderid=55')
  119. console.log(tabIndex,index)
  120. let item = this.tab_list[tabIndex].list[index]
  121. if (item.state == 1) {
  122. this.$routerGo('/pages/order/unpay-details?orderid=' + item.id)
  123. } else if(item.state == 4){
  124. this.$routerGo('/pages/order/apply-details?orderid=' + item.id)
  125. }else {
  126. this.$routerGo('/pages/order/order-details?orderid=' + item.id)
  127. }
  128. },
  129. onReachBottom() {
  130. let tab_item = this.tab_list[this.current];
  131. if (tab_item.isPage) {
  132. tab_item.page = tab_item.page + 1;
  133. this.getUserOrder();
  134. }
  135. },
  136. onPullDownRefresh() {
  137. let tab_item = this.tab_list[this.current];
  138. tab_item.page = 1;
  139. tab_item.isPage = true;
  140. tab_item.loadingClass = true;
  141. tab_item.loadingText = '正在加载中';
  142. this.getUserOrder();
  143. uni.stopPullDownRefresh()
  144. },
  145. getUserOrder() {
  146. let per_page = this.pageSize;
  147. let tab_item = this.tab_list[this.current];
  148. this.$http(this.API.API_USERORDER, {
  149. state: this.tab_list[this.current].type,
  150. page: tab_item.page,
  151. per_page
  152. }).then(res => {
  153. if (res.code == 0) {
  154. console.log(res)
  155. if( Object.keys(res.metal_data).length != 0 ) {
  156. this.$routerGo('/pages/login/index?type=userinfo')
  157. }else {
  158. let isPage = res.data.has_more_page;
  159. tab_item.isPage = isPage;
  160. if (isPage) {
  161. tab_item.loadingClass = true;
  162. tab_item.loadingText = '正在加载中';
  163. } else {
  164. tab_item.loadingClass = false;
  165. tab_item.loadingText = '没有更多数据啦~';
  166. }
  167. if (tab_item.page == 1) {
  168. tab_item.list = res.data.items;
  169. } else {
  170. tab_item.list.push(...res.data.items);
  171. }
  172. }
  173. }
  174. }).catch(err => {
  175. });
  176. },
  177. //返回
  178. back() {
  179. if (this.assetsType === 'all2') {
  180. // #ifdef H5
  181. window.history.go(-2)
  182. // #endif
  183. // #ifndef H5
  184. uni.navigateBack({
  185. delta: 2
  186. });
  187. // #endif
  188. } else {
  189. // #ifdef H5
  190. window.history.go(-1)
  191. // #endif
  192. // #ifndef H5
  193. uni.navigateBack({
  194. delta: 1
  195. });
  196. // #endif
  197. }
  198. }
  199. },
  200. }
  201. </script>
  202. <style lang="scss">
  203. .tag-self {
  204. position: absolute!important;
  205. top: 0!important;
  206. border-radius: 17px 0 10px 0!important;
  207. width: max-content;
  208. height: 24px!important;
  209. }
  210. .title {
  211. font-size: 28rpx;
  212. color: $u-content-color;
  213. height: 88rpx;
  214. }
  215. // tab
  216. .ctab {
  217. width: 100%;
  218. margin: 20rpx 0 0rpx 0rpx;
  219. padding: 0 22rpx;
  220. }
  221. // 商品列表
  222. .com {
  223. width: 100%;
  224. overflow: hidden;
  225. .list {
  226. border-radius: 10rpx;
  227. overflow: hidden;
  228. margin: 20rpx 32rpx;
  229. background-color: #FFFFFF;
  230. // box-shadow: 0 0 10px 5px #e5e5e5;
  231. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  232. align-items: flex-start;
  233. .left {
  234. overflow: hidden;
  235. image {
  236. width: 204rpx;
  237. height: 204rpx;
  238. margin: 20rpx;
  239. border-radius: 10rpx;
  240. }
  241. }
  242. .right {
  243. overflow: hidden;
  244. width: 64%;
  245. .title {
  246. margin: 18rpx 20rpx 0 0;
  247. color: #222222;
  248. font-size: 32rpx;
  249. }
  250. .tips {
  251. margin: 16rpx 0;
  252. overflow: hidden;
  253. .u-line-progress {
  254. width: 112rpx;
  255. overflow: hidden;
  256. margin-right: 20rpx;
  257. }
  258. .progress {
  259. color: #777777;
  260. font-size: 24rpx;
  261. }
  262. .bought {
  263. color: #777777;
  264. font-size: 24rpx;
  265. margin-right: 20rpx;
  266. }
  267. }
  268. .price {
  269. overflow: hidden;
  270. color: #FF0000;
  271. button {
  272. width: 160rpx;
  273. height: 60rpx;
  274. background: #FE9903;
  275. border-radius: 15px;
  276. font-size: 24rpx;
  277. color: #FFFFFF;
  278. margin: 0rpx 20rpx 0rpx 20rpx;
  279. border: none;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. </style>