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

366 lines
9.3 KiB

4 years ago
4 years ago
  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.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.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 col-btn0" v-if="item.status == 0" @click="$url('/pages/order/confirm_order?order_id='+item.id+'&goods_id='+item.agent_product_id+'&btn_type=1&enter_type=1')">立即付款</button>
  26. <button class="lf-font-24 radius-order col-btn0" v-if="item.status == 1" @click="$url('/pages/order/confirm_order?order_id='+item.id+'&goods_id='+item.agent_product_id+'&btn_type=2&enter_type=1')">支付尾款</button>
  27. <button class="lf-font-24 radius-order col-btn1" v-if="item.status == 2 || item.status == 3">立即使用</button>
  28. <button class="lf-font-24 radius-order col-btn16" v-if="item.status == 16">已使用</button>
  29. <button class="lf-font-24 radius-order col-btn6" v-if="item.status == 6">等待审核</button>
  30. <button class="lf-font-24 radius-order col-btn7" v-if="item.status == 7">退款成功</button>
  31. </view>
  32. </view>
  33. </view>
  34. <view>
  35. <view class="solid-top flex justify-between align-center text-center">
  36. <view class="text-gray lf-font-28" style="padding: 20rpx;">
  37. {{item.created_at}}
  38. </view>
  39. <view :class="'col-status'+item.status" style="padding: 20rpx 24rpx 20rpx 20rpx;">
  40. {{item.status_text}}
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 空数据的情况 -->
  46. <view class="loading-more">
  47. <text v-if="tab.list.length"
  48. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  49. <lf-nocontent v-else></lf-nocontent>
  50. </view>
  51. <!-- 回到顶部 -->
  52. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}">
  53. </u-back-top>
  54. </scroll-view>
  55. </swiper-item>
  56. </swiper>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. tab_list: [{
  64. name: '全部',
  65. type: '',
  66. list: [],
  67. loadingClass: true,
  68. loadingText: '正在加载中',
  69. page: 1,
  70. isPage: true
  71. }, {
  72. name: '待付款',
  73. type: 0,
  74. list: [],
  75. loadingClass: true,
  76. loadingText: '正在加载中',
  77. page: 1,
  78. isPage: true
  79. }, {
  80. name: '已付款',
  81. type: '1,2,3',
  82. list: [],
  83. loadingClass: true,
  84. loadingText: '正在加载中',
  85. page: 1,
  86. isPage: true
  87. },
  88. {
  89. name: '已完成',
  90. type: 16,
  91. list: [],
  92. loadingClass: true,
  93. loadingText: '正在加载中',
  94. page: 1,
  95. isPage: true
  96. },
  97. {
  98. name: '售后',
  99. type: '6,7,8',
  100. list: [],
  101. loadingClass: true,
  102. loadingText: '正在加载中',
  103. page: 1,
  104. isPage: true
  105. }
  106. ],
  107. current: 0, // tab下表
  108. pageSize: 10,
  109. windowHeight: 0, // 屏幕可用高度
  110. showLogin: true,
  111. isRefresher: true
  112. }
  113. },
  114. onLoad(e) {
  115. this.windowHeight = getApp().globalData.windowHeight;
  116. // this.verifyUserInfo()
  117. this.getUserOrder()
  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. goDetails(tabIndex,index) {
  134. let item = this.tab_list[tabIndex].list[index]
  135. if (item.status == 1) {
  136. this.$url('/pages/order/unpay_details?order_id=' + item.id)
  137. }else if(item.status == 6){
  138. this.$url('/pages/order/refund_detail?order_id=' + item.id)
  139. }else {
  140. this.$url('/pages/order/order_details?order_id=' + item.id)
  141. }
  142. },
  143. //获取订单数据
  144. getUserOrder(options = {}) {
  145. let per_page = this.pageSize;
  146. let tab_item = this.tab_list[this.current];
  147. this.$http(this.API.API_ORDERLIST, {
  148. status: this.tab_list[this.current].type,
  149. page: tab_item.page
  150. }).then(res => {
  151. let isPage = res.data.has_more_page;
  152. tab_item.isPage = isPage;
  153. if (!isPage) {
  154. tab_item.loadingClass = false;
  155. tab_item.loadingText = '没有更多数据啦~';
  156. }
  157. if(options.type == 'pageRefresh'){
  158. uni.stopPullDownRefresh();
  159. }else if(options.type == 'scrollRefresh'){
  160. this.isRefresher = false;
  161. }
  162. if (tab_item.page == 1) {
  163. tab_item.list = res.data.data;
  164. } else {
  165. tab_item.list.push(...res.data.data);
  166. }
  167. console.log(tab_item.list)
  168. })
  169. },
  170. // 切换tab
  171. change(index) {
  172. this.current = index;
  173. this.getUserOrder();
  174. },
  175. // 滑块下标值变化
  176. swiperChange(event) {
  177. this.current = event.detail.current;
  178. if (event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  179. this.getUserOrder();
  180. },
  181. // 页面触底,加载下一页
  182. onScrolltolower(){
  183. let tab_item = this.tab_list[this.current];
  184. if(tab_item.isPage){
  185. tab_item.page = tab_item.page + 1;
  186. this.getUserOrder();
  187. }
  188. },
  189. // scroll-view 下拉刷新
  190. onRefresherrefresh(){
  191. this.isRefresher = true;
  192. this.refreshFn({type: 'scrollRefresh'});
  193. },
  194. // 下拉刷新处理
  195. refreshFn(options){
  196. let tab_item = this.tab_list[this.current];
  197. tab_item.page = 1;
  198. tab_item.isPage = true;
  199. tab_item.loadingClass = true;
  200. tab_item.list = []
  201. tab_item.loadingText = '正在加载中';
  202. this.getUserOrder(options);
  203. }
  204. },
  205. onPullDownRefresh() {
  206. this.refreshFn({type: 'pageRefresh'});
  207. }
  208. }
  209. </script>
  210. <style lang="scss">
  211. .col-status2 {
  212. color: #0BCE5F!important;
  213. }
  214. .col-status3 {
  215. color: #0BCE5F!important;
  216. }
  217. .col-status0 {
  218. color: #FF0000!important;
  219. }
  220. .col-status1 {
  221. color: #FF0000!important;
  222. }
  223. .col-status16 {
  224. color: #1998FE!important;
  225. }
  226. .col-status6 {
  227. color: #555555!important;
  228. }
  229. .col-status7 {
  230. color: #555555!important;
  231. }
  232. .col-btn1 {
  233. color: #0BCE5F!important;
  234. border: 1px solid #0BCE5F!important;
  235. }
  236. .col-btn0 {
  237. color: #FF0000!important;
  238. border: 1px solid #FF0000!important;
  239. }
  240. .col-btn16 {
  241. color: #1998FE!important;
  242. border: 1px solid #1998FE!important;
  243. }
  244. .col-btn6 {
  245. color: #555555!important;
  246. border: 1px solid #555555!important;
  247. }
  248. .col-btn7 {
  249. color: #555555!important;
  250. border: 1px solid #555555!important;
  251. }
  252. page {
  253. background-color: #F6F6F6;
  254. }
  255. .radius-order {
  256. border-radius: 31.5rpx;
  257. }
  258. .font-400 {
  259. font-weight: 400;
  260. }
  261. .tag-self {
  262. position: absolute !important;
  263. top: 0 !important;
  264. border-radius: 20rpx 0 20rpx 0 !important;
  265. width: max-content;
  266. height: 32rpx !important;
  267. }
  268. .title {
  269. font-size: 28rpx;
  270. color: $u-content-color;
  271. height: 80rpx;
  272. }
  273. // tab
  274. .ctab {
  275. width: 100%;
  276. margin: 20rpx 0 0rpx 0rpx;
  277. padding: 0 22rpx;
  278. }
  279. // 商品列表
  280. .com {
  281. width: 100%;
  282. height: 100%;
  283. overflow: hidden;
  284. .list {
  285. border-radius: 20rpx;
  286. overflow: hidden;
  287. margin: 0 32rpx 30rpx 32rpx;
  288. background-color: #FFFFFF;
  289. // box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  290. align-items: flex-start;
  291. .left {
  292. overflow: hidden;
  293. image {
  294. width: 210rpx;
  295. height: 210rpx;
  296. margin: 20rpx;
  297. border-radius: 20rpx;
  298. }
  299. }
  300. .right {
  301. overflow: hidden;
  302. width: 67%;
  303. .title {
  304. margin: 0rpx 20rpx 0rpx 0;
  305. color: #222222;
  306. font-size: 32rpx;
  307. }
  308. .tips {
  309. margin: 16rpx 0;
  310. overflow: hidden;
  311. .u-line-progress {
  312. width: 112rpx;
  313. overflow: hidden;
  314. margin-right: 20rpx;
  315. }
  316. .progress {
  317. color: #777777;
  318. font-size: 24rpx;
  319. }
  320. .bought {
  321. color: #777777;
  322. font-size: 24rpx;
  323. margin-right: 20rpx;
  324. }
  325. }
  326. .price {
  327. overflow: hidden;
  328. color: #FF0000;
  329. button {
  330. width: 150rpx;
  331. height: 63rpx;
  332. background: #fff;
  333. border-radius: 31.5rpx;
  334. font-size: 24rpx;
  335. color: #FF0000;
  336. margin: 0rpx 20rpx 0rpx 20rpx;
  337. border: 1px solid #FF0000;
  338. line-height: 60rpx;
  339. padding: 0;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. </style>