海南旅游项目 前端仓库
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.

354 lines
8.8 KiB

  1. <template>
  2. <view>
  3. <!-- tab标签 -->
  4. <view class="lf-p-r-32 lf-p-l-32">
  5. <u-tabs :list="tab_list" bg-color="#F6F6F6" :is-scroll="false" :current="current" @change="change"></u-tabs>
  6. </view>
  7. <swiper :style="{height: 'calc('+ windowHeight +'px - 110rpx)', width: '750rpx'}" :current="current"
  8. @change="swiperChange">
  9. <swiper-item v-for="(tab, tabIndex) in tab_list" :key="tabIndex">
  10. <scroll-view class="com" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher"
  11. @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  12. <view class="flex-direction justify-around list" v-for="(item, index) in tab.list" :key="item.id" @tap="goDetails(tabIndex,index)">
  13. <view class="lf-row-between">
  14. <view class="left" style="position: relative;display: flex;">
  15. <image :src="item.product.picture" mode="aspectFill"></image>
  16. </view>
  17. <view class="right">
  18. <view class="lf-line-2 title lf-font-28 lf-color-333" style="line-height: 40rpx;">{{item.product.title}}</view>
  19. <view class="lf-flex tips lf-m-t-10">
  20. <text class="progress margin-right-xs lf-color-gray">数量</text>
  21. <text class="bought lf-color-gray">x {{item.num}}</text>
  22. </view>
  23. <view class="lf-row-between price lf-m-t-16" style="padding-right: 6rpx;">
  24. <lf-price :price="item.price" style="margin-top: 10rpx;" />
  25. <button class="lf-font-24 radius-order">立即付款</button>
  26. <!-- <button class="cu-btn1 lf-color-green lf-border-green">立即使用</button> -->
  27. <!-- <button class="cu-btn1 lf-color-blue lf-border-blue">已使用</button> -->
  28. <!-- <button class="cu-btn1 lf-color-gray lf-border-gray">等待审核</button> -->
  29. </view>
  30. </view>
  31. </view>
  32. <view>
  33. <view class="solid-top flex justify-between align-center text-center">
  34. <view class="text-gray lf-font-28" style="padding: 20rpx;">
  35. {{timer(item.created_at*1000)}}
  36. </view>
  37. <view class="lf-color-price" style="padding: 20rpx 24rpx 20rpx 20rpx;">
  38. 请在10分钟内付款
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 空数据的情况 -->
  44. <view class="loading-more">
  45. <text v-if="tab.list.length"
  46. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  47. <lf-nocontent v-else></lf-nocontent>
  48. </view>
  49. <!-- 回到顶部 -->
  50. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}">
  51. </u-back-top>
  52. </scroll-view>
  53. </swiper-item>
  54. </swiper>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. tab_list: [{
  62. name: '全部',
  63. type: '',
  64. list: [],
  65. loadingClass: true,
  66. loadingText: '正在加载中',
  67. page: 1,
  68. isPage: true
  69. }, {
  70. name: '待付款',
  71. type: 0,
  72. list: [],
  73. loadingClass: true,
  74. loadingText: '正在加载中',
  75. page: 1,
  76. isPage: true
  77. }, {
  78. name: '已付款',
  79. type: 1,
  80. list: [],
  81. loadingClass: true,
  82. loadingText: '正在加载中',
  83. page: 1,
  84. isPage: true
  85. },
  86. {
  87. name: '已完成',
  88. type: 16,
  89. list: [],
  90. loadingClass: true,
  91. loadingText: '正在加载中',
  92. page: 1,
  93. isPage: true
  94. },
  95. {
  96. name: '售后',
  97. type: 6,
  98. list: [],
  99. loadingClass: true,
  100. loadingText: '正在加载中',
  101. page: 1,
  102. isPage: true
  103. }
  104. ],
  105. current: 0, // tab下表
  106. pageSize: 10,
  107. windowHeight: 0, // 屏幕可用高度
  108. showLogin: true,
  109. isRefresher: true
  110. }
  111. },
  112. onLoad(e) {
  113. this.windowHeight = getApp().globalData.windowHeight;
  114. // this.verifyUserInfo()
  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. goDetails(tabIndex,index) {
  132. console.log(tabIndex,index)
  133. let item = this.tab_list[tabIndex].list[index]
  134. if (item.state == 1) {
  135. this.$routerGo('/pages/order/unpay-details?order_id=' + item.id)
  136. } else if(item.state == 4){
  137. this.$routerGo('/pages/order/refund_detail?order_id=' + item.id)
  138. }else {
  139. this.$routerGo('/pages/order/order-details?order_id=' + item.id)
  140. }
  141. },
  142. //获取订单数据
  143. getUserOrder(options = {}) {
  144. let per_page = this.pageSize;
  145. let tab_item = this.tab_list[this.current];
  146. this.$http(this.API.API_ORDERLIST, {
  147. status: this.tab_list[this.current].type,
  148. page: tab_item.page
  149. }).then(res => {
  150. let isPage = res.data.has_more_page;
  151. tab_item.isPage = isPage;
  152. if (!isPage) {
  153. tab_item.loadingClass = false;
  154. tab_item.loadingText = '没有更多数据啦~';
  155. }
  156. if(options.type == 'pageRefresh'){
  157. uni.stopPullDownRefresh();
  158. }else if(options.type == 'scrollRefresh'){
  159. this.isRefresher = false;
  160. }
  161. if (tab_item.page == 1) {
  162. tab_item.list = res.data.data;
  163. } else {
  164. tab_item.list.push(...res.data.data);
  165. }
  166. console.log(tab_item.list)
  167. })
  168. },
  169. // 切换tab
  170. change(index) {
  171. this.current = index;
  172. this.getUserOrder();
  173. },
  174. // 滑块下标值变化
  175. swiperChange(event) {
  176. this.current = event.detail.current;
  177. if (event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  178. this.getUserOrder();
  179. },
  180. // 页面触底,加载下一页
  181. onScrolltolower(){
  182. let tab_item = this.tab_list[this.current];
  183. if(tab_item.isPage){
  184. tab_item.page = tab_item.page + 1;
  185. this.getUserOrder();
  186. }
  187. },
  188. // scroll-view 下拉刷新
  189. onRefresherrefresh(){
  190. this.isRefresher = true;
  191. this.refreshFn({type: 'scrollRefresh'});
  192. },
  193. // 下拉刷新处理
  194. refreshFn(options){
  195. let tab_item = this.tab_list[this.current];
  196. tab_item.page = 1;
  197. tab_item.isPage = true;
  198. tab_item.loadingClass = true;
  199. tab_item.list = []
  200. tab_item.loadingText = '正在加载中';
  201. this.getUserOrder(options);
  202. },
  203. timer(value, fmt) {
  204. if(!value) return;
  205. let newTime = new Date(value)
  206. if(!fmt){
  207. fmt = 'yyyy-MM-dd hh:mm';
  208. }
  209. if(/(y+)/.test(fmt)) {
  210. fmt = fmt.replace(RegExp.$1, (newTime.getFullYear() + '').substr(4 - RegExp.$1.length));
  211. }
  212. let o = {
  213. 'M+': newTime.getMonth() + 1,
  214. 'd+': newTime.getDate(),
  215. 'h+': newTime.getHours(),
  216. 'm+': newTime.getMinutes(),
  217. 's+': newTime.getSeconds()
  218. };
  219. function padLeftZero(str) {
  220. return ('00'+str).substr(str.length);
  221. }
  222. // 遍历这个对象
  223. for (let k in o) {
  224. if (new RegExp(`(${k})`).test(fmt)) {
  225. // console.log(`${k}`)
  226. let str = o[k] + '';
  227. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
  228. }
  229. }
  230. return fmt;
  231. }
  232. },
  233. onPullDownRefresh() {
  234. this.refreshFn({type: 'pageRefresh'});
  235. }
  236. }
  237. </script>
  238. <style lang="scss">
  239. page {
  240. background-color: #F6F6F6;
  241. }
  242. .radius-order {
  243. border-radius: 31.5rpx;
  244. }
  245. .font-400 {
  246. font-weight: 400;
  247. }
  248. .tag-self {
  249. position: absolute !important;
  250. top: 0 !important;
  251. border-radius: 20rpx 0 20rpx 0 !important;
  252. width: max-content;
  253. height: 32rpx !important;
  254. }
  255. .title {
  256. font-size: 28rpx;
  257. color: $u-content-color;
  258. height: 80rpx;
  259. }
  260. // tab
  261. .ctab {
  262. width: 100%;
  263. margin: 20rpx 0 0rpx 0rpx;
  264. padding: 0 22rpx;
  265. }
  266. // 商品列表
  267. .com {
  268. width: 100%;
  269. height: 100%;
  270. overflow: hidden;
  271. .list {
  272. border-radius: 20rpx;
  273. overflow: hidden;
  274. margin: 0 32rpx 30rpx 32rpx;
  275. background-color: #FFFFFF;
  276. // box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  277. align-items: flex-start;
  278. .left {
  279. overflow: hidden;
  280. image {
  281. width: 210rpx;
  282. height: 210rpx;
  283. margin: 20rpx;
  284. border-radius: 20rpx;
  285. }
  286. }
  287. .right {
  288. overflow: hidden;
  289. width: 67%;
  290. .title {
  291. margin: 0rpx 20rpx 0rpx 0;
  292. color: #222222;
  293. font-size: 32rpx;
  294. }
  295. .tips {
  296. margin: 16rpx 0;
  297. overflow: hidden;
  298. .u-line-progress {
  299. width: 112rpx;
  300. overflow: hidden;
  301. margin-right: 20rpx;
  302. }
  303. .progress {
  304. color: #777777;
  305. font-size: 24rpx;
  306. }
  307. .bought {
  308. color: #777777;
  309. font-size: 24rpx;
  310. margin-right: 20rpx;
  311. }
  312. }
  313. .price {
  314. overflow: hidden;
  315. color: #FF0000;
  316. button {
  317. width: 150rpx;
  318. height: 63rpx;
  319. background: #fff;
  320. border-radius: 31.5rpx;
  321. font-size: 24rpx;
  322. color: #FF0000;
  323. margin: 0rpx 20rpx 0rpx 20rpx;
  324. border: 1px solid #FF0000;
  325. line-height: 60rpx;
  326. padding: 0;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. </style>