Jacob
1 天以前 106fc09e267f67bb35a279ed1bf71068a61e73c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
<template>
   <view>
       <view class='my-order'>
           <view class='header bg-color' :style="'padding-top:' + statusBarTop + 'px'">
               <view class='picTxt acea-row row-between-wrapper'>
                   <view class='text'>
                       <view class="return iconfont icon-xiangzuo" @click.stop="goback"></view>
                       <view class='name'>订单信息</view>
                       <view>
                           消费订单:{{ orderData.orderCount || 0 }}<br>总消费:¥{{ toNumber(orderData.sumPrice) }} +
                           {{ toThousands(toNumber(orderData.sumCareBean)) }}悦养豆
                       </view>
                   </view>
               </view>
           </view>
           <view class='nav acea-row row-around'>
               <view class='item' :class='orderStatus == 0 ? "on" : ""' @click="statusClick(0)">
                   <view>待付款</view>
                   <view class='num'>{{ orderData.unPaidCount || 0 }}</view>
               </view>
               <view class='item' :class='orderStatus == 1 ? "on" : ""' @click="statusClick(1)">
                   <view>待发货</view>
                   <view class='num'>{{ orderData.unShippedCount || 0 }}</view>
               </view>
               <view class='item' :class='orderStatus == 2 ? "on" : ""' @click="statusClick(2)">
                   <view>待收货</view>
                   <view class='num '>{{ orderData.receivedCount || 0 }}</view>
               </view>
               <view class='item' :class='orderStatus == 4 ? "on" : ""' @click="statusClick(4)">
                   <view>已完成</view>
                   <view class='num'>{{ orderData.completeCount || 0 }}</view>
               </view>
           </view>
           <view class='list'>
               <view class='item' v-for="(item, index) in orderList" :key="index">
                   <view @click='goOrderDetails(item.orderId)'>
                       <view class='title acea-row row-between-wrapper'>
                           <view class="acea-row row-middle">
                               <text class="sign cart-color acea-row row-center-wrapper"
                                   v-if="item.activityType && item.activityType !== '普通' && item.activityType !== '核销'">{{
                                       item.activityType }}</text>
                               <!-- <text class="sign cart-color acea-row row-center-wrapper" v-if="item.bargainId != 0">砍价</text>
                               <text class="sign cart-color acea-row row-center-wrapper" v-else-if="item.storeOrder.combinationId != 0">拼团</text>
                               <text class="sign cart-color acea-row row-center-wrapper" v-else-if="item.storeOrder.seckillId != 0">秒杀</text> -->
                               <view>{{ item.createTime }}</view>
                           </view>
                           <view class='font-color'>{{ item.orderStatus || '' }}</view>
                           <!-- <view v-if="item.status?item.status.type == 0:0" class='font-color'>待付款</view>
                           <view v-else-if="item.status?item.status.type == 1:0 && item.storeOrder.shippingType==1" class='font-color'>待发货</view>
                           <view v-else-if="item.status?item.status.type == 2:0 && item.storeOrder.shippingType==1" class='font-color'>待收货</view>
                           <view v-else-if="item.status?item.status.type == 3:0 && item.storeOrder.shippingType==1" class='font-color'>待评价</view>
                           <view v-else-if="item.status?item.status.type == 4:0 && item.storeOrder.shippingType==1" class='font-color'>已完成</view>
                           <view v-else-if="item.storeOrder.shippingType==2" class='font-color'>待核销</view> -->
                       </view>
                       <orderListGoods :orderInfoList="item.orderInfoList"
                           :zonePromotionList="item.zonePromotionList || []"></orderListGoods>
                       <view class='totalPrice'>共{{ getTotalNum(item) }}件商品,总金额
                           <text class='money font-color' v-if="getPayWay(item.payPrice, item.payCareBean) == 1">
                               <text class="color-blue">¥{{ toNumber(item.payPrice) }}</text>
                               <text class="color-blue">+{{ toThousands(toNumber(item.payCareBean)) }}悦养豆</text>
                           </text>
                           <text class='money color-blue'
                               v-else-if="getPayWay(item.payPrice, item.payCareBean) == 3">{{
                                   toThousands(toNumber(item.payCareBean)) }}悦养豆</text>
                           <text class='money color-blue' v-else>¥{{ toNumber(item.payPrice) }}</text>
                       </view>
                   </view>
                   <view class='bottom acea-row row-right row-middle'>
                       <view class='bnt gray' v-if="!item.paid" @click='cancelOrder(index, item.id)'>取消订单</view>
                       <view class='bnt blue' v-if="!item.paid" @click='goPay(index)'>立即付款
                       </view>
                       <view class='bnt gray' v-if="item.status == 3" @click='delOrder(item.id, index)'>删除订单
                       </view>
                       <view class='bnt blue'
                           v-if="item.paid && (item.status == 0 || item.status == 1 || item.status == 3)"
                           @click='goOrderDetails(item.orderId)'>查看详情</view>
                   </view>
               </view>
           </view>
           <view class='loadingicon acea-row row-center-wrapper' v-if="orderList.length > 0">
               <text class='loading iconfont icon-jiazai' :hidden='loading == false'></text>{{ loadTitle }}
           </view>
           <view v-if="orderList.length == 0">
               <emptyPage title="暂无订单~"></emptyPage>
           </view>
       </view>
       <!--     <view class='noCart' v-if="orderList.length >0 && page > 1">
           <view class='pictrue'>
               <image src='https://ossacmall.bluedeer.com.cn/app/static/images/noOrder.png'></image>
           </view>
       </view> -->
       <!-- #ifdef MP -->
       <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
       <!-- #endif -->
       <payment :isClicking="isClicking" :payMode='payMode' :pay_close="pay_close" @lockFn='lockFn'
           @onChangeFun='onChangeFun' :order_id="pay_order_id" :totalPrice='totalPrice' :orderInfo="orderInfo">
       </payment>
   </view>
</template>
 
<script>
import {
   getOrderList,
   orderData,
   orderCancel,
   orderDel
} from '@/api/order.js';
import {
   openOrderSubscribe
} from '@/utils/SubscribeMessage.js';
import home from '@/components/home';
import payment from '@/components/payment';
import {
   toLogin
} from '@/libs/login.js';
import {
   mapGetters
} from "vuex";
import emptyPage from '@/components/emptyPage.vue';
import orderListGoods from '@/components/orderListGoods';
export default {
   components: {
       payment,
       home,
       emptyPage,
       orderListGoods
   },
   data() {
       return {
           loading: false, //是否加载中
           loadend: false, //是否加载完毕
           loadTitle: '加载更多', //提示语
           orderList: [], //订单数组
           orderData: {}, //订单详细统计
           orderStatus: 0, //订单状态
           page: 1,
           limit: 20,
           payMode: [{
               name: "微信支付",
               icon: "icon-weixinzhifu",
               value: 'weixin',
               title: '微信快捷支付'
           }],
           pay_close: false,
           pay_order_id: '',
           totalPrice: '0',
           orderInfo: {},
           isAuto: false, //没有授权的不会自动授权
           isShowAuth: false, //是否隐藏授权
           statusBarTop: 0,
           clicking: false,
           isPageShow: false,
           loginBackFn: null,
           isClicking: false,
       };
   },
   computed: mapGetters(['isLogin', 'userInfo']),
   onShow() {
       let that = this;
       that.isPageShow = true;
       let pages = getCurrentPages(),
           currPage = pages[pages.length - 1];
       if (that.$store.getters.isSystemHide) {
           console.log('系统事件触发了onshow事件');
           that.$store.getters.isSystemHide = false;
       }
       console.log('------------------page onShow start-----------------');
       console.log('route', currPage.route);
       console.log('options', currPage.options);
       console.log('------------------page onShow end-----------------');
 
       if (that.$store.getters.isBelong) {
           that.belongInfoReadyFn({
               isRegister: false
           })
       } else {
           uni.$once('BELONG_READY', that.belongInfoReadyFn);
       }
   },
   onHide: function () {
       let that = this;
       that.isPageShow = false;
       uni.$off('loginFlSuccess', that.registerFn);
       uni.$off('BELONG_READY', that.belongInfoReadyFn);
   },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
       let that = this;
       let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
       that.statusBarTop = menuButtonInfo.top;
       if (options.status) this.orderStatus = options.status;
   },
   methods: {
       belongInfoReadyFn(data) {
           let that = this;
           if (!data.isRegister) {
               that.checkLoginFn()
           } else {
               that.loadFn();
           }
       },
       checkLoginFn() {
           let that = this;
           that.isPageShow = true;
           let pages = getCurrentPages(),
               currPage = pages[pages.length - 1];
           that.addTrack('yy_pageView', {
               pageTitle_var: '订单中心',
               pagePath_var: currPage.$page.fullPath,
               pageType_var: '订单'
           });
 
           if (that.$store.getters.isLogin) {
               that.loadFn();
           } else {
               toLogin(that);
           }
           that.loginBackFn = function () {
               that.loginFn();
           }
           uni.$once('loginFlSuccess', that.registerFn);
       },
       registerFn() {
           console.log('registerFn');
           let that = this;
           if (that.loginBackFn) {
               that.loginBackFn();
           }
           that.loginBackFn = null;
       },
       loadFn() {
           let that = this;
           that.loadend = false;
           that.page = 1;
           that.$set(that, 'orderList', []);
           that.getOrderData();
           that.getOrderList();
       },
       getGiftCount(zonePromotionList) {
           let count = 0;
           if (!zonePromotionList || !Array.isArray(zonePromotionList)) return 0;
           zonePromotionList.forEach(promotion => {
               if (promotion.giftList) {
                   promotion.giftList.forEach(gift => {
                       console.log('giftNum--------------------', gift.giftNum);
                       if (gift.giftType === 1) {
                           count += gift.giftNum || 0;
                       }
                   });
               }
           });
           return count;
       },
       getTotalNum(item) {
           return (Number(item.totalNum) || 0) + this.getGiftCount(item.zonePromotionList || []);
       },
       getPayWay(price, payCareBean) {
           console.log('阿斯顿发送到发送地方', Number(price) > 0 && Number(payCareBean) > 0);
           if (Number(price) > 0 && Number(payCareBean) > 0) {
               return 1;
           } else if (Number(payCareBean) > 0) {
               return 3;
           } else {
               return 2;
           }
       },
       goback() {
           // #ifdef H5
           return history.back();
           // #endif
           // #ifndef H5
           return uni.navigateBack({
               delta: 1,
           })
           // #endif
       },
       onLoadFun() {
           this.getOrderData();
           this.getOrderList();
       },
       // 授权关闭
       authColse: function (e) {
           this.isShowAuth = e
       },
       /**
        * 事件回调
        *
        */
       onChangeFun: function (e) {
           let opt = e;
           let action = opt.action || null;
           let value = opt.value != undefined ? opt.value : null;
           (action && this[action]) && this[action](value);
           this.isClicking = false;
           console.log(this.isClicking);
           this.getOrderData();
       },
       lockFn: function () {
           this.isClicking = true;
       },
       /**
        * 关闭支付组件
        *
        */
       payClose: function () {
           this.pay_close = false;
       },
       /**
        * 获取订单统计数据
        *
        */
       getOrderData: function () {
           let that = this;
           orderData().then(res => {
               that.$set(that, 'orderData', (res && res.data) || {});
           }).catch(() => {
               that.$set(that, 'orderData', {});
           })
       },
       /**
        * 取消订单
        *
        */
       cancelOrder: function (index, order_id) {
           let that = this;
           if (!order_id) return that.$util.Tips({
               title: '缺少订单号无法取消订单'
           });
           that.$refs.showConfirm.show({
               title: '提示',
               content: '您确定要取消订单吗?<br>取消后订单将无法恢复哦~',
               center: true,
               success: function (res) {
                   if (res.confirm) {
                       uni.showLoading({
                           title: '正在取消中'
                       });
                       orderCancel(order_id).then(res => {
                           uni.hideLoading();
                           return that.$util.Tips({
                               title: '取消成功',
                               icon: 'success'
                           }, function () {
                               that.orderList.splice(index, 1);
                               that.$set(that, 'orderList', that.orderList);
                               that.$set(that.orderData, 'unpaid_count', that
                                   .orderData.unpaid_count - 1);
                               that.getOrderData();
                           });
                       }).catch(err => {
                           return that.$util.Tips({
                               title: (err && err.message) ? err.message : err
                           });
                       });
                   } else {
 
                   }
               },
           });
 
       },
       /**
        * 打开支付组件
        *
        */
       goPay(index) {
           this.$set(this, 'orderInfo', this.orderList[index]);
           this.$set(this, 'pay_close', true);
           // this.$set(this.orderInfo,item);
           // this.$set(this, 'pay_order_id', item.orderId);
           // this.$set(this, 'totalPrice', item.payPrice);
       },
       /**
        * 支付成功回调
        *
        */
       pay_complete: function () {
           this.loadend = false;
           this.page = 1;
           this.$set(this, 'orderList', []);
           this.$set(this, 'pay_close', false);
           this.getOrderData();
           this.getOrderList();
       },
       /**
        * 支付失败回调
        *
        */
       pay_fail: function () {
           this.pay_close = false;
       },
       /**
        * 去订单详情
        */
       goOrderDetails: function (order_id) {
           let that = this;
           if (that.clicking) return false;
           that.clicking = true;
 
           if (!order_id) return that.$util.Tips({
               title: '缺少订单号无法查看订单详情'
           });
           // #ifdef MP
           uni.showLoading({
               title: '正在加载',
           })
           openOrderSubscribe().then(() => {
               uni.hideLoading();
               uni.navigateTo({
                   url: '/pages/order_details/index?order_id=' + order_id
               })
               setTimeout(() => {
                   that.clicking = false;
               }, 500)
           }).catch(() => {
               that.clicking = false;
               uni.hideLoading();
           })
           // #endif
           // #ifndef MP
           uni.navigateTo({
               url: '/pages/order_details/index?order_id=' + order_id
           })
           // #endif
       },
       /**
        * 切换类型
        */
       statusClick: function (status) {
           if (status == this.orderStatus) return;
           this.orderStatus = status;
           this.loadend = false;
           this.page = 1;
           this.$set(this, 'orderList', []);
           this.getOrderData();
           this.getOrderList();
       },
       /**
        * 获取订单列表
        */
       getOrderList: function () {
           let that = this;
           if (that.loadend) return;
           if (that.loading) return;
           that.loading = true;
           that.loadTitle = "加载更多";
           getOrderList({
               type: that.orderStatus,
               page: that.page,
               limit: that.limit,
           }).then(res => {
               let list = (res && res.data && res.data.list) || [];
               let loadend = list.length < that.limit;
               that.orderList = that.$util.SplitArray(list, that.orderList);
               that.$set(that, 'orderList', that.orderList);
               that.loadend = loadend;
               that.loading = false;
               that.loadTitle = loadend ? "我也是有底线的" : '加载更多';
               that.page = that.page + 1;
           }).catch(err => {
               that.loading = false;
               that.loadTitle = "加载更多";
           })
       },
 
       /**
        * 删除订单
        */
       delOrder: function (order_id, index) {
           let that = this;
           that.$refs.showConfirm.show({
               title: '提示',
               content: '您确定要删除订单吗?<br>删除后订单将无法恢复哦~',
               center: true,
               success: function (res) {
                   if (res.confirm) {
                       orderDel(order_id).then(res => {
                           that.orderList.splice(index, 1);
                           that.$set(that, 'orderList', that.orderList);
                           that.$set(that.orderData, 'unpaid_count', that.orderData
                               .unpaid_count - 1);
                           that.getOrderData();
                           return that.$util.Tips({
                               title: '删除成功',
                               icon: 'success'
                           });
                       }).catch(err => {
                           return that.$util.Tips({
                               title: (err && err.message) ? err.message : err
                           });
                       })
                   } else {
 
                   }
               },
           });
       },
   },
   onReachBottom: function () {
       this.getOrderList();
   }
}
</script>
 
<style scoped lang="scss">
.my-order .header {
   padding: 50rpx 30rpx 100rpx 30rpx;
}
 
.my-order .header .picTxt .text {
   color: rgba(255, 255, 255, 0.8);
   color: #000000;
   font-size: 26rpx;
   font-family: 'Guildford Pro';
   padding-left: 60rpx;
   position: relative;
 
   .return {
       position: absolute;
       left: 0;
       top: 10rpx;
   }
}
 
.my-order .header .picTxt .text .name {
   font-weight: bold;
   color: #000000;
   margin-bottom: 7rpx;
   padding-top: 6rpx;
}
 
.my-order .header .picTxt .pictrue {
   width: 122rpx;
   height: 109rpx;
}
 
.my-order .header .picTxt .pictrue image {
   width: 100%;
   height: 100%;
}
 
.my-order .nav {
   background-color: #fff;
   width: 690rpx;
   height: 140rpx;
   border-radius: 14rpx;
   margin: -60rpx auto 0 auto;
}
 
.my-order .nav .item {
   text-align: center;
   font-size: 26rpx;
   color: #282828;
   padding: 26rpx 0;
}
 
.my-order .nav .item.on {
   // font-weight: bold;
   // border-bottom: 5rpx solid #e93323;
   /* #ifdef H5 || MP */
   font-weight: bold;
   /* #endif */
   border-bottom: 5rpx solid #04C763;
}
 
.my-order .nav .item .num {
   margin-top: 18rpx;
}
 
.my-order .list {
   width: 690rpx;
   margin: 14rpx auto 0 auto;
}
 
.my-order .list .item {
   background-color: #fff;
   border-radius: 14rpx;
   margin-bottom: 14rpx;
}
 
.my-order .list .item .title {
   height: 84rpx;
   padding: 0 24rpx;
   border-bottom: 1rpx solid #eee;
   font-size: 28rpx;
   color: #282828;
}
 
.my-order .list .item .title .sign {
   font-size: 24rpx;
   padding: 0 13rpx;
   height: 36rpx;
   margin-right: 15rpx;
   border-radius: 18rpx;
}
 
.my-order .list .item .item-info {
   padding: 0 24rpx;
   margin-top: 22rpx;
}
 
.my-order .list .item .item-info .pictrue {
   width: 120rpx;
   height: 120rpx;
}
 
.my-order .list .item .item-info .pictrue image {
   width: 100%;
   height: 100%;
   border-radius: 14rpx;
}
 
.my-order .list .item .item-info .text {
   width: 500rpx;
   font-size: 28rpx;
   color: #999;
}
 
.my-order .list .item .item-info .text .name_box {
   width: 100%;
}
 
.my-order .list .item .item-info .text .name {
   color: #282828;
}
 
 
.my-order .list .item .item-info .text .money {
   // text-align: left;
   // display: flex;
   // justify-content: space-between;
   color: #FF780D;
 
   .num {
       color: #868686;
   }
}
 
.my-order .list .item .totalPrice {
   font-size: 26rpx;
   color: #282828;
   text-align: right;
   margin: 27rpx 0 0 30rpx;
   padding: 0 30rpx 30rpx 0;
   border-bottom: 1rpx solid #eee;
}
 
.my-order .list .item .totalPrice .money {
   font-size: 28rpx;
   font-weight: bold;
}
 
.my-order .list .item .bottom {
   height: 107rpx;
   padding: 0 30rpx;
}
 
.my-order .list .item .bottom .bnt {
   width: 176rpx;
   height: 60rpx;
   line-height: 60rpx;
   text-align: center;
   border-radius: 11rpx;
   color: #fff;
   font-size: 27rpx;
}
 
.my-order .list .item .bottom .bnt.gray {
   color: #000000;
   background-color: #DDDDDD;
}
 
.my-order .list .item .bottom .bnt.yellow {
   color: #000000;
   background-color: #FFE20E
}
 
.my-order .list .item .bottom .bnt.blue {
   color: #ffffff;
   background-color: #016DCC
}
 
.my-order .list .item .bottom .bnt~.bnt {
   margin-left: 17rpx;
}
 
.noCart {
   margin-top: 171rpx;
   padding-top: 0.1rpx;
}
 
.noCart .pictrue {
   width: 414rpx;
   height: 336rpx;
   margin: 78rpx auto 56rpx auto;
}
 
.noCart .pictrue image {
   width: 100%;
   height: 100%;
}
 
.font-color {
   color: #FF780D !important;
}
 
.bg-color {
   color: #000000 !important;
   background-color: #FFE20E !important;
}
</style>