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

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