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

313 lines
7.7 KiB

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