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

341 lines
9.3 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
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. </view>
  7. <swiper :style="{height: 'calc('+ windowHeight +'px - 110rpx)', width: '750rpx'}" :current="current" @change="swiperChange">
  8. <swiper-item v-for="(tab, tabIndex) in tab_list" :key="tabIndex">
  9. <scroll-view class="com" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  10. <view class="flex-direction justify-around list" v-for="(item, index) in tab.list" :key="item.id" @tap="goDetails(tabIndex,index)">
  11. <view class="lf-row-between">
  12. <view class="left" style="position: relative;display: flex;">
  13. <image :src="item.goods.cover" mode="aspectFill"></image>
  14. <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>
  15. </view>
  16. <view class="right">
  17. <view class="lf-line-2 title" style="line-height: 40rpx;">{{item.goods.name}}</view>
  18. <view class="lf-flex tips" style="margin: 0!important;">
  19. <text class="progress margin-right-xs">数量</text>
  20. <text class="bought">x {{item.number}}</text>
  21. </view>
  22. <view class="lf-row-between price" style="padding-right: 6rpx;">
  23. <lf-price :price="item.selling_price" style="margin-top: 10rpx;" />
  24. <button v-if="item.state==1" class="lf-font-28" style="border-radius: 30rpx;" @tap.stop="$routerGo('/pages/order/confirm-atonce?type=1&goods_id='+item.goods_id+'&goods_specs_id='+item.goods_specs_id +'&order_id='+ item.id+'&order_number='+item.number)">立即付款</button>
  25. <button v-if="item.state==2" style="border-radius: 30rpx;" class="cu-btn bg-green round margin-left-sm lf-font-28" @tap.stop="$routerGo('/pages/order/order-details?order_id='+item.id)">立即使用</button>
  26. <button v-if="item.state==4" class="cu-btn1 border margin-left-sm lf-font-28" style="border-radius: 30rpx;">等待审核</button>
  27. </view>
  28. </view>
  29. </view>
  30. <view>
  31. <view class="solid-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 24rpx 20rpx 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" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  49. </scroll-view>
  50. </swiper-item>
  51. </swiper>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. tab_list: [{
  59. name: '全部',
  60. type: 'all',
  61. list: [],
  62. loadingClass: true,
  63. loadingText: '正在加载中',
  64. page: 1,
  65. isPage: true
  66. }, {
  67. name: '待付款',
  68. type: 'unpaid',
  69. list: [],
  70. loadingClass: true,
  71. loadingText: '正在加载中',
  72. page: 1,
  73. isPage: true
  74. }, {
  75. name: '待使用',
  76. type: 'paid',
  77. list: [],
  78. loadingClass: true,
  79. loadingText: '正在加载中',
  80. page: 1,
  81. isPage: true
  82. },
  83. {
  84. name: '已完成',
  85. type: 'complete',
  86. list: [],
  87. loadingClass: true,
  88. loadingText: '正在加载中',
  89. page: 1,
  90. isPage: true
  91. },
  92. {
  93. name: '售后',
  94. type: 'after_sales',
  95. list: [],
  96. loadingClass: true,
  97. loadingText: '正在加载中',
  98. page: 1,
  99. isPage: true
  100. }
  101. ],
  102. current: 0, // tab下表
  103. pageSize: 10,
  104. assetsType: '', //账户类型
  105. orderType: [],
  106. showLogin: true,
  107. windowHeight: 0, // 屏幕可用高度
  108. isRefresher: false // scroll-view下拉刷新状态,当前默认没有触发
  109. }
  110. },
  111. onLoad(e) {
  112. this.windowHeight = getApp().globalData.windowHeight;
  113. this.assetsType = e.type;
  114. },
  115. onShow() {
  116. this.verifyUserInfo();
  117. let tab_item = this.tab_list[this.current];
  118. tab_item.page = 1;
  119. tab_item.isPage = true;
  120. tab_item.loadingClass = true;
  121. tab_item.loadingText = '正在加载中';
  122. this.getUserOrder();
  123. },
  124. methods: {
  125. // 检查当前用户登录状态
  126. verifyUserInfo(){
  127. let userInfo = uni.getStorageSync('userinfo') || {};
  128. if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
  129. if(this.showLogin){
  130. this.showLogin = false;
  131. this.$url('/pages/login/index?type=userinfo');
  132. }else{
  133. this.showLogin = true;
  134. this.$url('/pages/index/index', {type: 'switch'});
  135. }
  136. }
  137. },
  138. // 切换tab
  139. change(index) {
  140. this.current = index;
  141. this.getUserOrder();
  142. },
  143. // 滑块下标值变化
  144. swiperChange(event){
  145. this.current = event.detail.current;
  146. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  147. this.getUserOrder();
  148. },
  149. goDetails(tabIndex,index) {
  150. console.log(tabIndex,index)
  151. let item = this.tab_list[tabIndex].list[index]
  152. if (item.state == 1) {
  153. this.$routerGo('/pages/order/unpay-details?order_id=' + item.id)
  154. } else if(item.state == 4){
  155. this.$routerGo('/pages/order/apply-details?order_id=' + item.id)
  156. }else {
  157. this.$routerGo('/pages/order/order-details?order_id=' + item.id)
  158. }
  159. },
  160. getUserOrder(options = {}) {
  161. let per_page = this.pageSize;
  162. let tab_item = this.tab_list[this.current];
  163. this.$http(this.API.API_USERORDER, {
  164. state: this.tab_list[this.current].type,
  165. page: tab_item.page,
  166. per_page
  167. }).then(res => {
  168. if( Object.keys(res.metal_data).length != 0 ) {
  169. this.$routerGo('/pages/login/index?type=userinfo')
  170. }else {
  171. let isPage = res.data.has_more_page;
  172. tab_item.isPage = isPage;
  173. if (!isPage) {
  174. tab_item.loadingClass = false;
  175. tab_item.loadingText = '没有更多数据啦~';
  176. }
  177. if(options.type == 'pageRefresh'){
  178. uni.stopPullDownRefresh();
  179. }else if(options.type == 'scrollRefresh'){
  180. this.isRefresher = false;
  181. }
  182. if (tab_item.page == 1) {
  183. tab_item.list = res.data.items;
  184. } else {
  185. tab_item.list.push(...res.data.items);
  186. }
  187. }
  188. })
  189. },
  190. // 页面触底,加载下一页
  191. onScrolltolower(){
  192. let tab_item = this.tab_list[this.current];
  193. if(tab_item.isPage){
  194. tab_item.page = tab_item.page + 1;
  195. this.getUserOrder();
  196. }
  197. },
  198. // scroll-view 下拉刷新
  199. onRefresherrefresh(){
  200. this.isRefresher = true;
  201. this.refreshFn({type: 'scrollRefresh'});
  202. },
  203. // 下拉刷新处理
  204. refreshFn(options){
  205. let tab_item = this.tab_list[this.current];
  206. tab_item.page = 1;
  207. tab_item.isPage = true;
  208. tab_item.loadingClass = true;
  209. tab_item.loadingText = '正在加载中';
  210. this.getUserOrder(options);
  211. }
  212. },
  213. onPullDownRefresh() {
  214. this.refreshFn({type: 'pageRefresh'});
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .cu-btn1 {
  220. position: relative;
  221. display: inline-flex;
  222. align-items: center;
  223. justify-content: center;
  224. box-sizing: border-box;
  225. padding: 0 30upx;
  226. font-size: 28upx;
  227. height: 60upx;
  228. line-height: 1;
  229. text-align: center;
  230. text-decoration: none;
  231. overflow: visible;
  232. margin-left: initial;
  233. transform: translate(0upx, 0upx);
  234. margin-right: initial;
  235. background-color: white!important;
  236. color: #777!important;
  237. border: 1px solid #777!important;
  238. }
  239. .font-400 {
  240. font-weight: 400;
  241. }
  242. .tag-self {
  243. position: absolute!important;
  244. top: 0!important;
  245. border-radius: 20rpx 0 20rpx 0!important;
  246. width: max-content;
  247. height: 32rpx!important;
  248. }
  249. .title {
  250. font-size: 28rpx;
  251. color: $u-content-color;
  252. height: 98rpx;
  253. }
  254. // tab
  255. .ctab {
  256. width: 100%;
  257. margin: 20rpx 0 0rpx 0rpx;
  258. padding: 0 22rpx;
  259. }
  260. // 商品列表
  261. .com {
  262. width: 100%;
  263. overflow: hidden;
  264. .list {
  265. border-radius: 10rpx;
  266. overflow: hidden;
  267. margin: 30rpx 32rpx;
  268. background-color: #FFFFFF;
  269. // box-shadow: 0 0 10px 5px #e5e5e5;
  270. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  271. align-items: flex-start;
  272. .left {
  273. overflow: hidden;
  274. image {
  275. width: 186rpx;
  276. height: 186rpx;
  277. margin: 20rpx;
  278. border-radius: 10rpx;
  279. }
  280. }
  281. .right {
  282. overflow: hidden;
  283. width: 67%;
  284. .title {
  285. margin: 0rpx 20rpx 0rpx 0;
  286. color: #222222;
  287. font-size: 32rpx;
  288. }
  289. .tips {
  290. margin: 16rpx 0;
  291. overflow: hidden;
  292. .u-line-progress {
  293. width: 112rpx;
  294. overflow: hidden;
  295. margin-right: 20rpx;
  296. }
  297. .progress {
  298. color: #777777;
  299. font-size: 24rpx;
  300. }
  301. .bought {
  302. color: #777777;
  303. font-size: 24rpx;
  304. margin-right: 20rpx;
  305. }
  306. }
  307. .price {
  308. overflow: hidden;
  309. color: #FF0000;
  310. button {
  311. width: 176rpx;
  312. height: 60rpx;
  313. background: #FE9903;
  314. border-radius: 15px;
  315. font-size: 24rpx;
  316. color: #FFFFFF;
  317. margin: 0rpx 20rpx 0rpx 20rpx;
  318. border: none;
  319. line-height: 60rpx;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. </style>