order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view class="content">
  3. <view class="tab-menu">
  4. <view :class="orderState==0?'tab-item active':'tab-item'" @click="orderStatus(0)">全部</view>
  5. <view :class="orderState==2?'tab-item active':'tab-item'" @click="orderStatus(2)">待使用</view>
  6. <view :class="orderState==3?'tab-item active':'tab-item'" @click="orderStatus(3)">已完成</view>
  7. <view :class="orderState==4?'tab-item active':'tab-item'" @click="orderStatus(4)">已退款</view>
  8. <view :class="orderState==8?'tab-item active':'tab-item'" @click="orderStatus(8)">履约中</view>
  9. </view>
  10. <scroll-view class="order-body" scroll-y scroll-with-animation @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower" upper-threshold="80">
  11. <view class="order-list" v-if="orderList.length == 0 && orderData.loading">
  12. <view class="order-item" v-for="(item,indx) in 3" :key="indx">
  13. <view class="item-header">
  14. <view class="item-store" style="flex: 1;"><view class="skeleton-line animate"></view></view>
  15. </view>
  16. <view class="item-goods">
  17. <view class="image">
  18. <view class="skeleton-line animate"></view>
  19. </view>
  20. <view class="info">
  21. <view class="title">
  22. <view class="skeleton-line animate"></view>
  23. </view>
  24. <view class="tags">
  25. <view class="skeleton-line animate"></view>
  26. </view>
  27. <view class="tags">
  28. <view class="skeleton-line animate"></view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="mt15">
  33. <view class="skeleton-line animate"></view>
  34. </view>
  35. <view class="item-footer mt15">
  36. <view class="footer-left" style="width: 30%;">
  37. <view class="skeleton-line animate"></view>
  38. </view>
  39. <view class="footer-group-btn" style="width: 30%;">
  40. <view class="skeleton-line animate"></view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="order-list" v-else>
  46. <view class="empty-body" v-if="orderList.length == 0">
  47. <view class="imgs">
  48. <image src="/static/image/empty.png" mode="widthFix"></image>
  49. <view class="tip">没有更多数据啦~</view>
  50. <view class="re-btn" @click="toLogin" v-if="!isLogin">立即登录</view>
  51. </view>
  52. </view>
  53. <view class="order-item" v-for="(item,indx) in orderList" :key="item.id" v-else>
  54. <view class="item-header" @click="toDetail(item.out_order_no)">
  55. <view class="item-store">
  56. <image src="/static/image/store.svg"></image>
  57. <text>{{item.poi.poi_name}}</text>
  58. </view>
  59. <view class="item-status danger" v-if="item.status == 1">待使用</view>
  60. <view class="item-status success" v-if="item.status == 2">已完成</view>
  61. <view class="item-status fail" v-if="item.status == 3">已退款</view>
  62. <view class="item-status warn" v-if="item.status == 4">退款中</view>
  63. <view class="item-status fail" v-if="item.status == 5">已关闭</view>
  64. <view class="item-status warn" v-if="item.status == 6">部分退款</view>
  65. <view class="item-status success" v-if="item.status == 7">履约中</view>
  66. <view class="item-status warn" v-if="item.status == 8">退款审核中</view>
  67. </view>
  68. <view class="item-goods" @click="toDetail(item.out_order_no)">
  69. <view class="image">
  70. <image :src="item.img"></image>
  71. </view>
  72. <view class="info">
  73. <view class="title">
  74. <view class="name" v-if="item.product.is_new == 1">{{item.product.price}}元代{{item.product.line_price}}元商场权益券{{ item.product.product_name }}</view>
  75. <view class="name" v-else>{{ item.product.product_name }}</view>
  76. <view class="num">x{{ item.number }}</view>
  77. </view>
  78. <view class="tags">
  79. {{item.sku_name?item.sku_name:'默认'}}
  80. <view class="price">{{ $dialog.formatMoney(item.price,true) }}</view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="item-time">
  85. <view class="time-list">订单编号:{{ item.order_sn }}</view>
  86. <view class="time-list">下单时间:{{item.create_at}}</view>
  87. </view>
  88. <view class="item-footer" @click="toDetail(item.out_order_no)">
  89. <view class="footer-left">实付 <text>{{ $dialog.formatMoney(item.pay_money,true) }}</text></view>
  90. <view class="footer-group-btn">
  91. <view v-if="item.status == 0" class="button warn">继续支付</view>
  92. <view v-if="item.status == 1" class="button border">立即预约</view>
  93. <view v-if="item.status == 1" class="button border">申请退款</view>
  94. <view v-if="item.status == 2" class="button warn">再来一单</view>
  95. <view v-if="item.status == 7" class="button warn">申请退款</view>
  96. <view v-if="item.status == 4||item.status == 3" class="button border">再次购买</view>
  97. <view v-if="item.status == 5||item.status == 6||item.status == 7||item.status == 8" class="button warn">查看详情</view>
  98. </view>
  99. </view>
  100. </view>
  101. <uni-load-more status="loading" v-if="orderData.loading"></uni-load-more>
  102. <uni-load-more status="noMore" v-if="orderList.length > 0 && orderData.isDone"></uni-load-more>
  103. </view>
  104. <view class="line-height"></view>
  105. </scroll-view>
  106. <halfLogin ref="loginCom" @success="loginSuccess"></halfLogin>
  107. </view>
  108. </template>
  109. <script>
  110. var app;
  111. const pageSize = 10;
  112. export default {
  113. data() {
  114. return {
  115. orderState:0,
  116. orderData:{
  117. size:pageSize,
  118. page:1,
  119. loading:false,
  120. isDone:false
  121. },
  122. orderList:[],
  123. isLogin:true
  124. }
  125. },
  126. onLoad() {
  127. app = this;
  128. app.getOrder()
  129. },
  130. methods: {
  131. scrolltoupper(){},
  132. scrolltolower(e){
  133. if (app.orderData.isDone || app.orderList.length == 0) return ;
  134. app.getOrder()
  135. },
  136. toDetail(order){
  137. uni.navigateTo({
  138. url:"/pages/order/detail?order="+order
  139. })
  140. },
  141. loginSuccess(){
  142. app.getOrder()
  143. },
  144. toLogin(){
  145. app.$refs.loginCom.open();
  146. },
  147. orderStatus(state) {
  148. app.orderState = state
  149. app.orderList = [];
  150. app.orderData = {
  151. size:pageSize,
  152. page:1,
  153. loading:false,
  154. isDone:false
  155. };
  156. app.getOrder()
  157. },
  158. async getOrder(){
  159. app.orderData.loading = true;
  160. var formData = {};
  161. const tokenPoi = uni.getStorageSync("contact");
  162. formData.poi = tokenPoi.poi_id;
  163. formData.page = app.orderData.page;
  164. formData.size = app.orderData.size;
  165. formData.status = app.orderState;
  166. var resp = await app.$api.order.list.get(formData)
  167. app.orderData.loading = false;
  168. if (resp.code == 401) {
  169. app.isLogin = false;
  170. return ;
  171. }
  172. if (resp.code == 0) {
  173. return app.$dialog.showSuccess(resp.msg)
  174. }
  175. app.isLogin = true;
  176. if (resp.data.rows.length > 0) {
  177. app.orderData.page ++;
  178. app.orderList = [...app.orderList,...resp.data.rows];
  179. } else {
  180. app.orderData.isDone = true;
  181. }
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .content{
  188. position: fixed;
  189. z-index: 1;
  190. top: 0;
  191. left: 0;
  192. bottom: 0;
  193. right: 0;
  194. background-color: #ededed;
  195. display: flex;
  196. flex-direction: column;
  197. .line-height{
  198. height: 40rpx;
  199. width: 100%;
  200. }
  201. }
  202. .empty-body{
  203. display: flex;align-items: center;justify-content: center;flex-direction: column;height: calc(100vh - 100upx);
  204. .imgs{
  205. text-align: center;font-size: 28upx;color: #666;
  206. image{height: 160upx;width: 160upx;}
  207. .tip{margin-top: 20upx;}
  208. }
  209. .re-btn{
  210. width: 180upx;
  211. height: 80upx;
  212. line-height: 80upx;
  213. text-align: center;
  214. font-size: 28upx;
  215. color: #fff;
  216. background-color: $main-color;
  217. border-radius: 10upx;
  218. margin-top: 60upx;
  219. }
  220. }
  221. .tab-menu{
  222. height: 80rpx;
  223. line-height: 80rpx;
  224. background-color: #fff;
  225. display: flex;
  226. align-items: center;
  227. font-size: 28rpx;
  228. color: #666;
  229. justify-content: space-around;
  230. .tab-item{
  231. position: relative;
  232. color: $main-text-color;
  233. &.active{
  234. color: $main-color;
  235. font-weight: 700;
  236. &::after{
  237. position: absolute;
  238. content: "";
  239. width: 30%;
  240. left: 35%;
  241. height: 4rpx;
  242. bottom: 0;
  243. background-color: $main-color;
  244. }
  245. }
  246. }
  247. }
  248. .order-body{
  249. height: 0;
  250. flex: 1;
  251. .order-list{
  252. .order-item{
  253. width: 95%;
  254. margin: 0 auto;
  255. background-color: #fff;
  256. padding: 20rpx;
  257. margin-top: 20rpx;
  258. border-radius: 10rpx;
  259. .item-footer{
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. color: $main-text-color;
  264. font-size: 28rpx;
  265. .footer-left{
  266. text {
  267. font-size: 30rpx;
  268. font-weight: bold;
  269. color: $main-color;
  270. }
  271. }
  272. .footer-group-btn{
  273. display: flex;
  274. align-items: center;
  275. gap: 20rpx;
  276. .button{
  277. font-size: 24rpx;
  278. padding: 10rpx 20rpx;
  279. border-radius: 40rpx;
  280. display: flex;
  281. align-items: center;
  282. &.border{
  283. background-color: #fff;
  284. border: 2rpx solid #fed7aa;
  285. color: #f26428;
  286. }
  287. &.success{
  288. background-color: #d1fae5;
  289. color: #059669;
  290. }
  291. &.fail{
  292. background-color: #f1f5f9;
  293. color: #64748b;
  294. }
  295. &.danger{
  296. background-color: #fef3c7;
  297. color: #b45309;
  298. }
  299. &.warn{
  300. background-color: #fef3c7;
  301. color: #b45309;
  302. }
  303. }
  304. }
  305. }
  306. .item-time{
  307. background-color: #fff8f1;
  308. border-radius: 10rpx;
  309. margin: 20rpx 0;
  310. padding: 20rpx;
  311. .time-list{
  312. line-height: 48rpx;
  313. font-size: 24rpx;
  314. color: #64748b;
  315. }
  316. }
  317. .item-goods{
  318. display: flex;
  319. align-items: center;
  320. gap: 20rpx;
  321. background-color: #fff;
  322. margin-top: 20rpx;
  323. border-radius: 20rpx;
  324. .stock{
  325. text-align: right;
  326. }
  327. .image {
  328. height: 180rpx;
  329. overflow: hidden;display: flex;align-items: center;min-width: 180rpx;
  330. position: relative;
  331. image {
  332. width: 180rpx;
  333. border-radius: 10upx;
  334. height: 100%;
  335. }
  336. }
  337. .info{
  338. flex: 1 1 0%;
  339. overflow: hidden;
  340. .title{
  341. display: flex;
  342. align-items: center;
  343. justify-content: space-between;
  344. .name {
  345. overflow: hidden;
  346. text-overflow: ellipsis;
  347. font-size: 32rpx;
  348. display: -webkit-box;
  349. -webkit-line-clamp: 2;
  350. -webkit-box-orient: vertical;
  351. color: #333;
  352. font-weight: 900;
  353. }
  354. }
  355. .tags {
  356. color: #94a3b8;
  357. font-size: 24rpx;
  358. margin: 10rpx 0;
  359. display: flex;
  360. align-items: center;
  361. justify-content: space-between;
  362. .price {
  363. font-size: 28rpx;
  364. color: $main-text-color;
  365. font-weight: 600;
  366. }
  367. }
  368. }
  369. }
  370. .item-header{
  371. display: flex;
  372. align-items: center;
  373. justify-content: space-between;
  374. border-bottom: 2rpx solid #fff7ed;
  375. padding-bottom: 10rpx;
  376. .item-status{
  377. font-size: 24rpx;
  378. padding: 10rpx 20rpx;
  379. border-radius: 30rpx;
  380. &.success{
  381. background-color: #d1fae5;
  382. color: #059669;
  383. }
  384. &.fail{
  385. background-color: #f1f5f9;
  386. color: #64748b;
  387. }
  388. &.danger{
  389. background-color: #fef3c7;
  390. color: #b45309;
  391. }
  392. &.warn{
  393. background-color: #ffedd5;
  394. color: #e95b22;
  395. }
  396. }
  397. .item-store{
  398. display: flex;
  399. align-items: center;
  400. gap: 15rpx;
  401. image {
  402. width: 40rpx;
  403. height: 40rpx;
  404. }
  405. }
  406. }
  407. }
  408. }
  409. }
  410. </style>