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

282 lines
7.1 KiB

  1. <template>
  2. <view>
  3. <view class="padding-lr" style="margin-bottom: 10rpx;margin-top: 20rpx;">
  4. <me-tabs v-model="current" :tabs="tab_list" :fixed="true" @change="change"></me-tabs>
  5. </view>
  6. <swiper :style="{height: 'calc('+ windowHeight +'px - 110rpx)', width: '750rpx'}" :current="current" @change="swiperChange">
  7. <swiper-item v-for="(tab, tabIndex) in tab_list" :key="tabIndex">
  8. <scroll-view class="com" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  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;">{{item.goods.name}}</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. <lf-price :price="item.selling_price" style="margin-top: 10rpx;" />
  23. </view>
  24. </view>
  25. </view>
  26. <view>
  27. <view class="u-border-top flex justify-between align-center text-center">
  28. <view class="text-gray lf-font-28" style="padding: 20rpx;">
  29. {{item.created_at_text}}
  30. </view>
  31. <view class="text-orange" v-if="item.state==1" style="padding: 20rpx;">
  32. {{item.comment_text}}
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 加载 -->
  38. <view class="loading-more">
  39. <text v-if="tab.list.length"
  40. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  41. <my-nocontent v-else></my-nocontent>
  42. </view>
  43. <!-- 回到顶部 -->
  44. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  45. </scroll-view>
  46. </swiper-item>
  47. </swiper>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. tab_list: [{
  55. name: '全部',
  56. type: 'all',
  57. list: [],
  58. loadingClass: true,
  59. loadingText: '正在加载中',
  60. page: 1,
  61. isPage: true
  62. }, {
  63. name: '待付款',
  64. type: 'unpaid',
  65. list: [],
  66. loadingClass: true,
  67. loadingText: '正在加载中',
  68. page: 1,
  69. isPage: true
  70. }, {
  71. name: '待核销',
  72. type: 'paid',
  73. list: [],
  74. loadingClass: true,
  75. loadingText: '正在加载中',
  76. page: 1,
  77. isPage: true
  78. },
  79. {
  80. name: '已核销',
  81. type: 'complete',
  82. list: [],
  83. loadingClass: true,
  84. loadingText: '正在加载中',
  85. page: 1,
  86. isPage: true
  87. },
  88. {
  89. name: '售后',
  90. type: 'after_sales',
  91. list: [],
  92. loadingClass: true,
  93. loadingText: '正在加载中',
  94. page: 1,
  95. isPage: true
  96. }
  97. ],
  98. current: 0, // tab下表
  99. pageSize: 10,
  100. assetsType: '', //账户类型
  101. orderType: [],
  102. windowHeight: 0, // 屏幕可用高度
  103. isRefresher: false // scroll-view下拉刷新状态,当前默认没有触发
  104. }
  105. },
  106. onLoad(e) {
  107. this.windowHeight = getApp().globalData.windowHeight;
  108. this.assetsType = e.type
  109. },
  110. onShow() {
  111. this.refreshFn({});
  112. },
  113. methods: {
  114. // 切换tab
  115. change(index) {
  116. this.current = index;
  117. this.getUserOrder();
  118. },
  119. // 滑块下标值变化
  120. swiperChange(event){
  121. this.current = event.detail.current;
  122. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  123. this.getUserOrder();
  124. },
  125. goDetails(tabIndex,index) {
  126. let item = this.tab_list[tabIndex].list[index]
  127. this.$routerGo('/pages/shopOrder/order-details?order_id=' + item.id)
  128. },
  129. getUserOrder(options = {}) {
  130. let per_page = this.pageSize;
  131. let tab_item = this.tab_list[this.current];
  132. this.$http(this.API.API_SHOPORDER, {
  133. state: this.tab_list[this.current].type,
  134. page: tab_item.page,
  135. per_page
  136. }).then(res => {
  137. let isPage = res.data.has_more_page;
  138. tab_item.isPage = isPage;
  139. if (!isPage) {
  140. tab_item.loadingClass = false;
  141. tab_item.loadingText = '没有更多数据啦~';
  142. }
  143. if(options.type == 'pageRefresh'){
  144. uni.stopPullDownRefresh();
  145. }else if(options.type == 'scrollRefresh'){
  146. this.isRefresher = false;
  147. }
  148. if (tab_item.page == 1) {
  149. tab_item.list = res.data.items;
  150. } else {
  151. tab_item.list.push(...res.data.items);
  152. }
  153. })
  154. },
  155. // 页面触底,加载下一页
  156. onScrolltolower(){
  157. let tab_item = this.tab_list[this.current];
  158. if(tab_item.isPage){
  159. tab_item.page = tab_item.page + 1;
  160. this.getUserOrder();
  161. }
  162. },
  163. // scroll-view 下拉刷新
  164. onRefresherrefresh(){
  165. this.isRefresher = true;
  166. this.refreshFn({type: 'scrollRefresh'});
  167. },
  168. // 下拉刷新处理
  169. refreshFn(options){
  170. let tab_item = this.tab_list[this.current];
  171. tab_item.page = 1;
  172. tab_item.isPage = true;
  173. tab_item.loadingClass = true;
  174. tab_item.loadingText = '正在加载中';
  175. this.getUserOrder(options);
  176. }
  177. },
  178. onPullDownRefresh() {
  179. this.refreshFn({type: 'pageRefresh'});
  180. },
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .tag-self {
  185. position: absolute!important;
  186. top: 0!important;
  187. border-radius: 20rpx 0 20rpx 0!important;
  188. width: max-content;
  189. height: 32rpx!important;
  190. }
  191. .title {
  192. font-size: 28rpx;
  193. color: $u-content-color;
  194. height: 80rpx;
  195. }
  196. // tab
  197. .ctab {
  198. width: 100%;
  199. margin: 20rpx 0 0rpx 0rpx;
  200. padding: 0 22rpx;
  201. }
  202. // 商品列表
  203. .com {
  204. width: 100%;
  205. height: 100%;
  206. overflow: hidden;
  207. .list {
  208. border-radius: 10rpx;
  209. overflow: hidden;
  210. margin: 20rpx 32rpx;
  211. background-color: #FFFFFF;
  212. // box-shadow: 0 0 10px 5px #e5e5e5;
  213. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  214. align-items: flex-start;
  215. .left {
  216. overflow: hidden;
  217. image {
  218. width: 186rpx;
  219. height: 186rpx;
  220. margin: 20rpx;
  221. border-radius: 10rpx;
  222. }
  223. }
  224. .right {
  225. overflow: hidden;
  226. width: 64%;
  227. .title {
  228. margin: 0rpx 20rpx 10rpx 0;
  229. color: #222222;
  230. font-size: 32rpx;
  231. }
  232. .tips {
  233. margin: 16rpx 0;
  234. overflow: hidden;
  235. .u-line-progress {
  236. width: 112rpx;
  237. overflow: hidden;
  238. margin-right: 20rpx;
  239. }
  240. .progress {
  241. color: #777777;
  242. font-size: 24rpx;
  243. }
  244. .bought {
  245. color: #777777;
  246. font-size: 24rpx;
  247. margin-right: 20rpx;
  248. }
  249. }
  250. .price {
  251. overflow: hidden;
  252. color: #FF0000;
  253. margin-top: 10rpx;
  254. button {
  255. width: 176rpx;
  256. height: 60rpx;
  257. background: #FE9903;
  258. border-radius: 15px;
  259. font-size: 24rpx;
  260. color: #FFFFFF;
  261. margin: 0rpx 20rpx 0rpx 20rpx;
  262. border: none;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. </style>