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

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