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

302 lines
7.0 KiB

  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;">{{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. <!-- <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. <lf-price :price="item.selling_price" style="margin-top: 10rpx;" />
  27. </view>
  28. </view>
  29. </view>
  30. <view>
  31. <view class="u-border-top flex justify-between align-center text-center">
  32. <view class="text-gray lf-font-28" style="padding: 20rpx;">
  33. {{item.created_at_text}}
  34. </view>
  35. <view class="text-orange" v-if="item.state==1" style="padding: 20rpx;">
  36. {{item.comment_text}}
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 加载 -->
  42. <view class="loading-more">
  43. <text v-if="tab.list.length"
  44. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  45. <my-nocontent v-else></my-nocontent>
  46. </view>
  47. <!-- 回到顶部 -->
  48. <u-back-top :scroll-top="pageScrollTop"></u-back-top>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. tab_list: [{
  57. name: '全部',
  58. type: 'all',
  59. list: [],
  60. loadingClass: true,
  61. loadingText: '正在加载中',
  62. page: 1,
  63. isPage: true
  64. }, {
  65. name: '待付款',
  66. type: 'unpaid',
  67. list: [],
  68. loadingClass: true,
  69. loadingText: '正在加载中',
  70. page: 1,
  71. isPage: true
  72. }, {
  73. name: '待核销',
  74. type: 'paid',
  75. list: [],
  76. loadingClass: true,
  77. loadingText: '正在加载中',
  78. page: 1,
  79. isPage: true
  80. },
  81. {
  82. name: '已核销',
  83. type: 'complete',
  84. list: [],
  85. loadingClass: true,
  86. loadingText: '正在加载中',
  87. page: 1,
  88. isPage: true
  89. },
  90. {
  91. name: '售后',
  92. type: 'after_sales',
  93. list: [],
  94. loadingClass: true,
  95. loadingText: '正在加载中',
  96. page: 1,
  97. isPage: true
  98. }
  99. ],
  100. current: 0, // tab下表
  101. pageSize: 10,
  102. assetsType: '', //账户类型
  103. orderType: []
  104. }
  105. },
  106. onLoad(e) {
  107. this.assetsType = e.type
  108. },
  109. onShow() {
  110. let tab_item = this.tab_list[this.current];
  111. tab_item.page = 1;
  112. tab_item.isPage = true;
  113. tab_item.loadingClass = true;
  114. tab_item.loadingText = '正在加载中';
  115. this.getUserOrder();
  116. },
  117. methods: {
  118. // 切换tab
  119. change(index) {
  120. this.current = index;
  121. this.getUserOrder();
  122. },
  123. goDetails(tabIndex,index) {
  124. let item = this.tab_list[tabIndex].list[index]
  125. this.$routerGo('/pages/shopOrder/order-details?order_id=' + item.id)
  126. },
  127. onReachBottom() {
  128. let tab_item = this.tab_list[this.current];
  129. if (tab_item.isPage) {
  130. tab_item.page = tab_item.page + 1;
  131. this.getUserOrder();
  132. }
  133. },
  134. onPullDownRefresh() {
  135. let tab_item = this.tab_list[this.current];
  136. tab_item.page = 1;
  137. tab_item.isPage = true;
  138. tab_item.loadingClass = true;
  139. tab_item.loadingText = '正在加载中';
  140. this.getUserOrder();
  141. uni.stopPullDownRefresh()
  142. },
  143. getUserOrder() {
  144. let per_page = this.pageSize;
  145. let tab_item = this.tab_list[this.current];
  146. this.$http(this.API.API_SHOPORDER, {
  147. state: this.tab_list[this.current].type,
  148. page: tab_item.page,
  149. per_page
  150. }).then(res => {
  151. if (res.code == 0) {
  152. console.log(res)
  153. if( Object.keys(res.metal_data).length != 0 ) {
  154. this.$routerGo('/pages/login/index?type=userinfo')
  155. }else {
  156. let isPage = res.data.has_more_page;
  157. tab_item.isPage = isPage;
  158. if (isPage) {
  159. tab_item.loadingClass = true;
  160. tab_item.loadingText = '正在加载中';
  161. } else {
  162. tab_item.loadingClass = false;
  163. tab_item.loadingText = '没有更多数据啦~';
  164. }
  165. if (tab_item.page == 1) {
  166. tab_item.list = res.data.items;
  167. } else {
  168. tab_item.list.push(...res.data.items);
  169. }
  170. }
  171. }
  172. }).catch(err => {
  173. });
  174. },
  175. //返回
  176. back() {
  177. if (this.assetsType === 'all2') {
  178. // #ifdef H5
  179. window.history.go(-2)
  180. // #endif
  181. // #ifndef H5
  182. uni.navigateBack({
  183. delta: 2
  184. });
  185. // #endif
  186. } else {
  187. // #ifdef H5
  188. window.history.go(-1)
  189. // #endif
  190. // #ifndef H5
  191. uni.navigateBack({
  192. delta: 1
  193. });
  194. // #endif
  195. }
  196. }
  197. },
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .tag-self {
  202. position: absolute!important;
  203. top: 0!important;
  204. border-radius: 20rpx 0 20rpx 0!important;
  205. width: max-content;
  206. height: 32rpx!important;
  207. }
  208. .title {
  209. font-size: 28rpx;
  210. color: $u-content-color;
  211. height: 80rpx;
  212. }
  213. // tab
  214. .ctab {
  215. width: 100%;
  216. margin: 20rpx 0 0rpx 0rpx;
  217. padding: 0 22rpx;
  218. }
  219. // 商品列表
  220. .com {
  221. width: 100%;
  222. overflow: hidden;
  223. .list {
  224. border-radius: 10rpx;
  225. overflow: hidden;
  226. margin: 20rpx 32rpx;
  227. background-color: #FFFFFF;
  228. // box-shadow: 0 0 10px 5px #e5e5e5;
  229. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  230. align-items: flex-start;
  231. .left {
  232. overflow: hidden;
  233. image {
  234. width: 186rpx;
  235. height: 186rpx;
  236. margin: 20rpx;
  237. border-radius: 10rpx;
  238. }
  239. }
  240. .right {
  241. overflow: hidden;
  242. width: 64%;
  243. .title {
  244. margin: 0rpx 20rpx 10rpx 0;
  245. color: #222222;
  246. font-size: 32rpx;
  247. }
  248. .tips {
  249. margin: 16rpx 0;
  250. overflow: hidden;
  251. .u-line-progress {
  252. width: 112rpx;
  253. overflow: hidden;
  254. margin-right: 20rpx;
  255. }
  256. .progress {
  257. color: #777777;
  258. font-size: 24rpx;
  259. }
  260. .bought {
  261. color: #777777;
  262. font-size: 24rpx;
  263. margin-right: 20rpx;
  264. }
  265. }
  266. .price {
  267. overflow: hidden;
  268. color: #FF0000;
  269. margin-top: 10rpx;
  270. button {
  271. width: 176rpx;
  272. height: 60rpx;
  273. background: #FE9903;
  274. border-radius: 15px;
  275. font-size: 24rpx;
  276. color: #FFFFFF;
  277. margin: 0rpx 20rpx 0rpx 20rpx;
  278. border: none;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. </style>