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

312 lines
7.4 KiB

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