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

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