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

287 lines
6.6 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
  1. <template>
  2. <view>
  3. <!-- 当设置tab-width,指定每个tab宽度时,则不使用flex布局,改用水平滑动 -->
  4. <view class="padding-lr margin-bottom">
  5. <me-tabs v-model="current" :tabs="tab_list" :fixed="true"></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" @click="goDetails(item)">
  10. <view class="lf-row-between">
  11. <view class="left">
  12. <image :src="item.goods.cover" mode=""></image>
  13. <!-- <view class="cu-tag badge" style="position: relative;top: -100px;">待付款</view> -->
  14. </view>
  15. <view class="right">
  16. <view class="lf-line-2 title">{{item.goods.name}}</view>
  17. <view class="lf-flex tips">
  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?goods_id='+item.goods_id+'&goods_specs_id='+item.goods_specs_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 class="padding-bottom padding-lr padding-top-sm">
  32. <view class="u-border-top flex justify-between align-center text-center">
  33. <view class="padding-top text-gray">
  34. {{item.created_at_text}}
  35. </view>
  36. <view class="text-orange padding-top" v-if="item.state==1">
  37. 请在10分钟内付款
  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. methods: {
  112. // 切换tab
  113. change(index) {
  114. this.current = index;
  115. },
  116. goDetails(item) {
  117. if (item.state == 1) {
  118. this.$routerGo('/pages/order/unpay-details?orderid=' + item.id)
  119. } else {
  120. this.$routerGo('/pages/order/order-details?orderid=' + item.id)
  121. }
  122. },
  123. onReachBottom() {
  124. let tab_item = this.tab_list[this.current];
  125. if (tab_item.isPage) {
  126. tab_item.page = tab_item.page + 1;
  127. this.getUserOrder();
  128. }
  129. },
  130. onPullDownRefresh() {
  131. let tab_item = this.tab_list[this.current];
  132. tab_item.page = 1;
  133. tab_item.isPage = true;
  134. tab_item.loadingClass = true;
  135. tab_item.loadingText = '正在加载中';
  136. this.getUserOrder();
  137. uni.stopPullDownRefresh()
  138. },
  139. getUserOrder() {
  140. let per_page = this.pageSize;
  141. let tab_item = this.tab_list[this.current];
  142. this.$http(this.API.API_USERORDER, {
  143. state: this.tab_list[this.current].type,
  144. page: tab_item.page,
  145. per_page
  146. }).then(res => {
  147. if (res.code == 0) {
  148. console.log(res)
  149. let isPage = res.data.has_more_page;
  150. tab_item.isPage = isPage;
  151. if (isPage) {
  152. tab_item.loadingClass = true;
  153. tab_item.loadingText = '正在加载中';
  154. } else {
  155. tab_item.loadingClass = false;
  156. tab_item.loadingText = '没有更多数据啦~';
  157. }
  158. if (tab_item.page == 1) {
  159. tab_item.list = res.data.items;
  160. } else {
  161. tab_item.list.push(...res.data.items);
  162. }
  163. }
  164. }).catch(err => {
  165. });
  166. },
  167. //返回
  168. back() {
  169. if (this.assetsType === 'all2') {
  170. // #ifdef H5
  171. window.history.go(-2)
  172. // #endif
  173. // #ifndef H5
  174. uni.navigateBack({
  175. delta: 2
  176. });
  177. // #endif
  178. } else {
  179. // #ifdef H5
  180. window.history.go(-1)
  181. // #endif
  182. // #ifndef H5
  183. uni.navigateBack({
  184. delta: 1
  185. });
  186. // #endif
  187. }
  188. }
  189. },
  190. }
  191. </script>
  192. <style lang="scss">
  193. .title {
  194. font-size: 28rpx;
  195. color: $u-content-color;
  196. height: 88rpx;
  197. }
  198. // tab
  199. .ctab {
  200. width: 100%;
  201. margin: 20rpx 0 0rpx 0rpx;
  202. padding: 0 22rpx;
  203. }
  204. // 商品列表
  205. .com {
  206. width: 100%;
  207. overflow: hidden;
  208. .list {
  209. border-radius: 10rpx;
  210. overflow: hidden;
  211. margin: 20rpx 32rpx;
  212. background-color: #FFFFFF;
  213. box-shadow: 0 0 10px 5px #e5e5e5;
  214. align-items: flex-start;
  215. .left {
  216. overflow: hidden;
  217. image {
  218. width: 204rpx;
  219. height: 204rpx;
  220. margin: 20rpx;
  221. border-radius: 10rpx;
  222. }
  223. }
  224. .right {
  225. overflow: hidden;
  226. width: 64%;
  227. .title {
  228. margin: 18rpx 20rpx 0 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. button {
  254. width: 160rpx;
  255. height: 60rpx;
  256. background: #FE9903;
  257. border-radius: 15px;
  258. font-size: 24rpx;
  259. color: #FFFFFF;
  260. margin: 0rpx 20rpx 0rpx 20rpx;
  261. border: none;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. </style>