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

338 lines
9.2 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
  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. this.refreshFn({});
  118. },
  119. methods: {
  120. // 检查当前用户登录状态
  121. verifyUserInfo(){
  122. let userInfo = uni.getStorageSync('userinfo') || {};
  123. if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
  124. if(this.showLogin){
  125. this.showLogin = false;
  126. this.$url('/pages/login/index?type=userinfo');
  127. }else{
  128. this.showLogin = true;
  129. this.$url('/pages/index/index', {type: 'switch'});
  130. }
  131. }
  132. },
  133. // 切换tab
  134. change(index) {
  135. this.current = index;
  136. this.getUserOrder();
  137. },
  138. // 滑块下标值变化
  139. swiperChange(event){
  140. this.current = event.detail.current;
  141. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  142. this.getUserOrder();
  143. },
  144. goDetails(tabIndex,index) {
  145. console.log(tabIndex,index)
  146. let item = this.tab_list[tabIndex].list[index]
  147. if (item.state == 1) {
  148. this.$routerGo('/pages/order/unpay-details?order_id=' + item.id)
  149. } else if(item.state == 4){
  150. this.$routerGo('/pages/order/apply-details?order_id=' + item.id)
  151. }else {
  152. this.$routerGo('/pages/order/order-details?order_id=' + item.id)
  153. }
  154. },
  155. getUserOrder(options = {}) {
  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( Object.keys(res.metal_data).length != 0 ) {
  164. this.$routerGo('/pages/login/index?type=userinfo')
  165. }else {
  166. let isPage = res.data.has_more_page;
  167. tab_item.isPage = isPage;
  168. if (!isPage) {
  169. tab_item.loadingClass = false;
  170. tab_item.loadingText = '没有更多数据啦~';
  171. }
  172. if(options.type == 'pageRefresh'){
  173. uni.stopPullDownRefresh();
  174. }else if(options.type == 'scrollRefresh'){
  175. this.isRefresher = false;
  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. },
  185. // 页面触底,加载下一页
  186. onScrolltolower(){
  187. let tab_item = this.tab_list[this.current];
  188. if(tab_item.isPage){
  189. tab_item.page = tab_item.page + 1;
  190. this.getUserOrder();
  191. }
  192. },
  193. // scroll-view 下拉刷新
  194. onRefresherrefresh(){
  195. this.isRefresher = true;
  196. this.refreshFn({type: 'scrollRefresh'});
  197. },
  198. // 下拉刷新处理
  199. refreshFn(options){
  200. let tab_item = this.tab_list[this.current];
  201. tab_item.page = 1;
  202. tab_item.isPage = true;
  203. tab_item.loadingClass = true;
  204. tab_item.list = []
  205. tab_item.loadingText = '正在加载中';
  206. this.getUserOrder(options);
  207. }
  208. },
  209. onPullDownRefresh() {
  210. this.refreshFn({type: 'pageRefresh'});
  211. }
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. .cu-btn1 {
  216. position: relative;
  217. display: inline-flex;
  218. align-items: center;
  219. justify-content: center;
  220. box-sizing: border-box;
  221. padding: 0 30upx;
  222. font-size: 28upx;
  223. height: 60upx;
  224. line-height: 1;
  225. text-align: center;
  226. text-decoration: none;
  227. overflow: visible;
  228. margin-left: initial;
  229. transform: translate(0upx, 0upx);
  230. margin-right: initial;
  231. background-color: white!important;
  232. color: #777!important;
  233. border: 1px solid #777!important;
  234. }
  235. .font-400 {
  236. font-weight: 400;
  237. }
  238. .tag-self {
  239. position: absolute!important;
  240. top: 0!important;
  241. border-radius: 20rpx 0 20rpx 0!important;
  242. width: max-content;
  243. height: 32rpx!important;
  244. }
  245. .title {
  246. font-size: 28rpx;
  247. color: $u-content-color;
  248. height: 80rpx;
  249. }
  250. // tab
  251. .ctab {
  252. width: 100%;
  253. margin: 20rpx 0 0rpx 0rpx;
  254. padding: 0 22rpx;
  255. }
  256. // 商品列表
  257. .com {
  258. width: 100%;
  259. height: 100%;
  260. overflow: hidden;
  261. .list {
  262. border-radius: 10rpx;
  263. overflow: hidden;
  264. margin: 30rpx 32rpx;
  265. background-color: #FFFFFF;
  266. // box-shadow: 0 0 10px 5px #e5e5e5;
  267. box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  268. align-items: flex-start;
  269. .left {
  270. overflow: hidden;
  271. image {
  272. width: 186rpx;
  273. height: 186rpx;
  274. margin: 20rpx;
  275. border-radius: 10rpx;
  276. }
  277. }
  278. .right {
  279. overflow: hidden;
  280. width: 67%;
  281. .title {
  282. margin: 0rpx 20rpx 0rpx 0;
  283. color: #222222;
  284. font-size: 32rpx;
  285. }
  286. .tips {
  287. margin: 16rpx 0;
  288. overflow: hidden;
  289. .u-line-progress {
  290. width: 112rpx;
  291. overflow: hidden;
  292. margin-right: 20rpx;
  293. }
  294. .progress {
  295. color: #777777;
  296. font-size: 24rpx;
  297. }
  298. .bought {
  299. color: #777777;
  300. font-size: 24rpx;
  301. margin-right: 20rpx;
  302. }
  303. }
  304. .price {
  305. overflow: hidden;
  306. color: #FF0000;
  307. button {
  308. width: 176rpx;
  309. height: 60rpx;
  310. background: #FE9903;
  311. border-radius: 15px;
  312. font-size: 24rpx;
  313. color: #FFFFFF;
  314. margin: 0rpx 20rpx 0rpx 20rpx;
  315. border: none;
  316. line-height: 60rpx;
  317. }
  318. }
  319. }
  320. }
  321. }
  322. </style>