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

365 lines
9.2 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_fromorder?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_fromorder?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-btn6" v-if="item.status == 6">等待审核</button>
  29. <button class="lf-font-24 radius-order col-btn7" v-if="item.status == 7">退款成功</button>
  30. </view>
  31. </view>
  32. </view>
  33. <view>
  34. <view class="solid-top flex justify-between align-center text-center">
  35. <view class="text-gray lf-font-28" style="padding: 20rpx;">
  36. {{item.created_at}}
  37. </view>
  38. <view :class="'col-status'+item.status" style="padding: 20rpx 24rpx 20rpx 20rpx;">
  39. {{item.status_text}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 空数据的情况 -->
  45. <view class="loading-more">
  46. <text v-if="tab.list.length"
  47. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  48. <lf-nocontent v-else></lf-nocontent>
  49. </view>
  50. <!-- 回到顶部 -->
  51. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}">
  52. </u-back-top>
  53. </scroll-view>
  54. </swiper-item>
  55. </swiper>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. tab_list: [{
  63. name: '全部',
  64. type: '',
  65. list: [],
  66. loadingClass: true,
  67. loadingText: '正在加载中',
  68. page: 1,
  69. isPage: true
  70. }, {
  71. name: '待付款',
  72. type: '0,1,4',
  73. list: [],
  74. loadingClass: true,
  75. loadingText: '正在加载中',
  76. page: 1,
  77. isPage: true
  78. }, {
  79. name: '已付款',
  80. type: '2,3,5',
  81. list: [],
  82. loadingClass: true,
  83. loadingText: '正在加载中',
  84. page: 1,
  85. isPage: true
  86. },
  87. {
  88. name: '已完成',
  89. type: 16,
  90. list: [],
  91. loadingClass: true,
  92. loadingText: '正在加载中',
  93. page: 1,
  94. isPage: true
  95. },
  96. {
  97. name: '售后',
  98. type: '6,7,8',
  99. list: [],
  100. loadingClass: true,
  101. loadingText: '正在加载中',
  102. page: 1,
  103. isPage: true
  104. }
  105. ],
  106. current: 0, // tab下表
  107. pageSize: 10,
  108. windowHeight: 0, // 屏幕可用高度
  109. showLogin: true,
  110. isRefresher: true
  111. }
  112. },
  113. onLoad(e) {
  114. this.windowHeight = getApp().globalData.windowHeight;
  115. // this.verifyUserInfo()
  116. this.getUserOrder()
  117. },
  118. methods: {
  119. // 检查当前用户登录状态
  120. verifyUserInfo(){
  121. let userInfo = uni.getStorageSync('userinfo') || {};
  122. if(!userInfo.id || !userInfo.nickname || !userInfo.avatar){
  123. if(this.showLogin){
  124. this.showLogin = false;
  125. this.$url('/pages/login/index?type=userinfo');
  126. }else{
  127. this.showLogin = true;
  128. this.$url('/pages/index/index', {type: 'switch'});
  129. }
  130. }
  131. },
  132. goDetails(tabIndex,index) {
  133. let item = this.tab_list[tabIndex].list[index]
  134. if (item.status == 1) {
  135. this.$url('/pages/order/unpay_details?order_id=' + item.id)
  136. }else if(item.status == 6){
  137. this.$url('/pages/order/refund_detail?order_id=' + item.id)
  138. }else {
  139. this.$url('/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. },
  204. onPullDownRefresh() {
  205. this.refreshFn({type: 'pageRefresh'});
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. .col-status2 {
  211. color: #0BCE5F!important;
  212. }
  213. .col-status3 {
  214. color: #0BCE5F!important;
  215. }
  216. .col-status0 {
  217. color: #FF0000!important;
  218. }
  219. .col-status1 {
  220. color: #FF0000!important;
  221. }
  222. .col-status16 {
  223. color: #1998FE!important;
  224. }
  225. .col-status6 {
  226. color: #555555!important;
  227. }
  228. .col-status7 {
  229. color: #555555!important;
  230. }
  231. .col-btn1 {
  232. color: #0BCE5F!important;
  233. border: 1px solid #0BCE5F!important;
  234. }
  235. .col-btn0 {
  236. color: #FF0000!important;
  237. border: 1px solid #FF0000!important;
  238. }
  239. .col-btn16 {
  240. color: #1998FE!important;
  241. border: 1px solid #1998FE!important;
  242. }
  243. .col-btn6 {
  244. color: #555555!important;
  245. border: 1px solid #555555!important;
  246. }
  247. .col-btn7 {
  248. color: #555555!important;
  249. border: 1px solid #555555!important;
  250. }
  251. page {
  252. background-color: #F6F6F6;
  253. }
  254. .radius-order {
  255. border-radius: 31.5rpx;
  256. }
  257. .font-400 {
  258. font-weight: 400;
  259. }
  260. .tag-self {
  261. position: absolute !important;
  262. top: 0 !important;
  263. border-radius: 20rpx 0 20rpx 0 !important;
  264. width: max-content;
  265. height: 32rpx !important;
  266. }
  267. .title {
  268. font-size: 28rpx;
  269. color: $u-content-color;
  270. height: 80rpx;
  271. }
  272. // tab
  273. .ctab {
  274. width: 100%;
  275. margin: 20rpx 0 0rpx 0rpx;
  276. padding: 0 22rpx;
  277. }
  278. // 商品列表
  279. .com {
  280. width: 100%;
  281. height: 100%;
  282. overflow: hidden;
  283. .list {
  284. border-radius: 20rpx;
  285. overflow: hidden;
  286. margin: 0 32rpx 30rpx 32rpx;
  287. background-color: #FFFFFF;
  288. // box-shadow: 0 10rpx 20rpx 0 rgba(0, 0, 0, 0.1);
  289. align-items: flex-start;
  290. .left {
  291. overflow: hidden;
  292. image {
  293. width: 210rpx;
  294. height: 210rpx;
  295. margin: 20rpx;
  296. border-radius: 20rpx;
  297. }
  298. }
  299. .right {
  300. overflow: hidden;
  301. width: 67%;
  302. .title {
  303. margin: 0rpx 20rpx 0rpx 0;
  304. color: #222222;
  305. font-size: 32rpx;
  306. }
  307. .tips {
  308. margin: 16rpx 0;
  309. overflow: hidden;
  310. .u-line-progress {
  311. width: 112rpx;
  312. overflow: hidden;
  313. margin-right: 20rpx;
  314. }
  315. .progress {
  316. color: #777777;
  317. font-size: 24rpx;
  318. }
  319. .bought {
  320. color: #777777;
  321. font-size: 24rpx;
  322. margin-right: 20rpx;
  323. }
  324. }
  325. .price {
  326. overflow: hidden;
  327. color: #FF0000;
  328. button {
  329. width: 150rpx;
  330. height: 63rpx;
  331. background: #fff;
  332. border-radius: 31.5rpx;
  333. font-size: 24rpx;
  334. color: #FF0000;
  335. margin: 0rpx 20rpx 0rpx 20rpx;
  336. border: 1px solid #FF0000;
  337. line-height: 60rpx;
  338. padding: 0;
  339. }
  340. }
  341. }
  342. }
  343. }
  344. </style>