4个文件已修改
129 ■■■■■ 已修改文件
components/orderListGoods/index.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.js 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/users/order_list/index.vue 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/zone/index.vue 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/orderListGoods/index.vue
....@@ -9,8 +9,8 @@
99 </view>
1010 <view class='text acea-row row-between'>
1111 <view class="acea-row row-between-wrapper name_box">
12
- <view class='name line2'>{{ items.storeName }}</view>
13
- <view class="num">{{ items.sku }} x{{ items.cartNum }}</view>
12
+ <view class='name line2'>{{ items.storeName || '' }}</view>
13
+ <view class="num">{{ items.sku || '' }} x{{ toNumber(items.cartNum) }}</view>
1414 </view>
1515 <view class='info'></view>
1616 <view class='money'>
....@@ -34,8 +34,8 @@
3434 <view class="gift-tag">赠品</view>
3535 </view>
3636 <view class='text' style="margin-left: 20rpx;">
37
- <view class='line1'>{{ gift.giftName }}</view>
38
- <view class='infor'>x{{ gift.giftNum }}</view>
37
+ <view class='line1'>{{ gift.giftName || '' }}</view>
38
+ <view class='infor'>x{{ toNumber(gift.giftNum) }}</view>
3939 </view>
4040 </view>
4141 </view>
main.js
....@@ -228,16 +228,21 @@
228228 Vue.mixin(pageLog);
229229 import BigNumber from 'bignumber.js';
230230 Vue.prototype.toNumber = function(number) {
231
- if (isNaN(number)) {
232
- return number;
233
- } else {
234
- return BigNumber(number).toNumber();
231
+ // null / undefined / 空值 / 非数字统一返回 0,避免页面显示 null、undefined、NaN
232
+ if (number === null || number === undefined || number === '' || isNaN(number)) {
233
+ return 0;
235234 }
235
+ const result = BigNumber(number).toNumber();
236
+ return isNaN(result) ? 0 : result;
236237 }
237238
238239 Vue.prototype.toThousands = function(num) {
239
- if (num < 1000) return num;
240
- if (Number.isInteger(num)) {
240
+ // null / undefined / 空值 / 非数字统一返回 0,避免页面显示 null、undefined、NaN
241
+ if (num === null || num === undefined || num === '' || isNaN(num)) {
242
+ return 0;
243
+ }
244
+ if (Number(num) < 1000) return num;
245
+ if (Number.isInteger(Number(num))) {
241246 return String(num).replace(/(?!^)(?=(\d{3})+$)/g, ',')
242247 } else {
243248 return String(num).replace(/(?!^)(?=(\d{3})+\.)/g, ',')
pages/users/order_list/index.vue
....@@ -37,14 +37,14 @@
3737 <view class='title acea-row row-between-wrapper'>
3838 <view class="acea-row row-middle">
3939 <text class="sign cart-color acea-row row-center-wrapper"
40
- v-if="item.activityType !== '普通' && item.activityType !== '核销'">{{ item.activityType
41
- }}</text>
40
+ v-if="item.activityType && item.activityType !== '普通' && item.activityType !== '核销'">{{
41
+ item.activityType }}</text>
4242 <!-- <text class="sign cart-color acea-row row-center-wrapper" v-if="item.bargainId != 0">砍价</text>
4343 <text class="sign cart-color acea-row row-center-wrapper" v-else-if="item.storeOrder.combinationId != 0">拼团</text>
4444 <text class="sign cart-color acea-row row-center-wrapper" v-else-if="item.storeOrder.seckillId != 0">秒杀</text> -->
4545 <view>{{ item.createTime }}</view>
4646 </view>
47
- <view class='font-color'>{{ item.orderStatus }}</view>
47
+ <view class='font-color'>{{ item.orderStatus || '' }}</view>
4848 <!-- <view v-if="item.status?item.status.type == 0:0" class='font-color'>待付款</view>
4949 <view v-else-if="item.status?item.status.type == 1:0 && item.storeOrder.shippingType==1" class='font-color'>待发货</view>
5050 <view v-else-if="item.status?item.status.type == 2:0 && item.storeOrder.shippingType==1" class='font-color'>待收货</view>
....@@ -54,8 +54,7 @@
5454 </view>
5555 <orderListGoods :orderInfoList="item.orderInfoList"
5656 :zonePromotionList="item.zonePromotionList || []"></orderListGoods>
57
- <view class='totalPrice'>共{{ item.totalNum + getGiftCount(item.zonePromotionList || [])
58
- }}件商品,总金额
57
+ <view class='totalPrice'>共{{ getTotalNum(item) }}件商品,总金额
5958 <text class='money font-color' v-if="getPayWay(item.payPrice, item.payCareBean) == 1">
6059 <text class="color-blue">¥{{ toNumber(item.payPrice) }}</text>
6160 <text class="color-blue">+{{ toThousands(toNumber(item.payCareBean)) }}悦养豆</text>
....@@ -254,6 +253,9 @@
254253 });
255254 return count;
256255 },
256
+ getTotalNum(item) {
257
+ return (Number(item.totalNum) || 0) + this.getGiftCount(item.zonePromotionList || []);
258
+ },
257259 getPayWay(price, payCareBean) {
258260 console.log('阿斯顿发送到发送地方', Number(price) > 0 && Number(payCareBean) > 0);
259261 if (Number(price) > 0 && Number(payCareBean) > 0) {
....@@ -312,7 +314,9 @@
312314 getOrderData: function () {
313315 let that = this;
314316 orderData().then(res => {
315
- that.$set(that, 'orderData', res.data);
317
+ that.$set(that, 'orderData', (res && res.data) || {});
318
+ }).catch(() => {
319
+ that.$set(that, 'orderData', {});
316320 })
317321 },
318322 /**
....@@ -447,7 +451,7 @@
447451 page: that.page,
448452 limit: that.limit,
449453 }).then(res => {
450
- let list = res.data.list || [];
454
+ let list = (res && res.data && res.data.list) || [];
451455 let loadend = list.length < that.limit;
452456 that.orderList = that.$util.SplitArray(list, that.orderList);
453457 that.$set(that, 'orderList', that.orderList);
pages/zone/index.vue
....@@ -20,8 +20,9 @@
2020 <view v-else>
2121 <view class="expireTime" v-if="expireTime && expireTime.length">
2222 <text>专区将在</text>
23
- <text v-for="(val, index) in expireTime" :key="index">
24
- <text class="num">{{ val }}</text>{{ expireTimeUnit[index] }}
23
+ <text v-for="(item, index) in expireTime" :key="index">
24
+ <text class="num"><text v-for="(char, ci) in item.digits" :key="ci"
25
+ class="digit">{{ char }}</text></text>{{ item.unit }}
2526 </text>
2627 <text>{{ startOrEnd }}</text>
2728 </view>
....@@ -588,7 +589,7 @@
588589 showMenu: false,
589590 selectedMenuArr: [],
590591 expireTime: [],
591
- expireTimeUnit: [],
592
+ countdownToken: 0,
592593 isPageShow: false,
593594 loginBackFn: null,
594595 errText: '',
....@@ -1295,6 +1296,9 @@
12951296 })
12961297 },
12971298 validAlert(data) {
1299
+ // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动
1300
+ this.countdownToken++
1301
+ const token = this.countdownToken
12981302 const {
12991303 startTime,
13001304 expireTime
....@@ -1313,17 +1317,17 @@
13131317 let minutes = startTimetamp.getMinutes()
13141318 minutes = minutes < 10 ? '0' + minutes : minutes;
13151319
1316
- this.countdownTimer(startTime.split('-').join('/'), 'start')
1320
+ this.countdownTimer(startTime.split('-').join('/'), 'start', token)
13171321 this.startOrEnd = "后开启"
13181322 return
1319
- }
1320
- }
1321
- if (expireTime) {
1322
- const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1323
- if (expireTimetamp < nowTimestamp) {
1323
+ }
1324
+ }
1325
+ if (expireTime) {
1326
+ const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1327
+ if (expireTimetamp < nowTimestamp) {
13241328 return
1325
- }
1326
- this.countdownTimer(expireTime.split('-').join('/'), 'end')
1329
+ }
1330
+ this.countdownTimer(expireTime.split('-').join('/'), 'end', token)
13271331 this.startOrEnd = "后结束"
13281332 }
13291333 },
....@@ -1461,7 +1465,7 @@
14611465 that.homeTop = that.getHomeTop(0.4)
14621466 }
14631467 that.expireTime = [];
1464
- that.expireTimeUnit = [];
1468
+ that.countdownToken++;
14651469 that.where.page = 1;
14661470 that.getGoodList()
14671471 that.validAlert(res.data)
....@@ -1487,8 +1491,9 @@
14871491 }
14881492 });
14891493 },
1490
- countdownTimer(expireTime, type) {
1494
+ countdownTimer(expireTime, type, token) {
14911495 if (!expireTime) return
1496
+ if (token !== undefined && token !== this.countdownToken) return
14921497 let that = this;
14931498 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳)
14941499 const endTimestamp = new Date(expireTime).getTime();
....@@ -1500,56 +1505,56 @@
15001505 if (type == 'end') {
15011506 if (diff <= 0) {
15021507 this.expireTime = []
1503
- this.expireTimeUnit = []
15041508 return
15051509 } else { }
15061510 } else if (type == 'start') {
15071511 if (diff <= 0) {
15081512 this.expireTime = []
1509
- this.expireTimeUnit = []
15101513 const expireTime2 = that.info.expireTime
15111514 if (expireTime2) {
15121515 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime();
15131516 if (expireTimetamp < nowTimestamp) {
15141517 return
15151518 }
1516
- this.countdownTimer(expireTime2.split('-').join('/'), 'end')
1519
+ this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)
15171520 this.startOrEnd = "后结束"
15181521 }
15191522 return
15201523 }
15211524 }
1525
+ const pad = num => (num < 10 ? '0' + num : String(num))
15221526 const res = []
1523
- const unit = []
15241527 const days = Math.floor(diff / (1000 * 60 * 60 * 24))
15251528 diff %= (1000 * 60 * 60 * 24)
1526
- if (days > 0) {
1527
- res.push(days);
1528
- unit.push('日')
1529
- }
15301529 // 转换为小时、分钟、秒
15311530 const hours = Math.floor(diff / (1000 * 60 * 60));
15321531 diff %= (1000 * 60 * 60); // 剩余毫秒数
1533
- if (hours > 0) {
1534
- res.push(hours < 10 ? '0' + hours : hours);
1535
- unit.push('时')
1536
- }
15371532 const minutes = Math.floor(diff / (1000 * 60));
1538
- if (minutes > 0) {
1539
- res.push(minutes < 10 ? '0' + minutes : minutes);
1540
- unit.push('分')
1541
- }
15421533 diff %= (1000 * 60); // 剩余毫秒数
15431534 const seconds = Math.floor(diff / 1000);
1544
- if (seconds > 0) {
1545
- res.push(seconds < 10 ? '0' + seconds : seconds);
1546
- unit.push('秒')
1535
+ // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定
1536
+ if (days > 0) {
1537
+ res.push({
1538
+ digits: pad(days).split(''),
1539
+ unit: '日'
1540
+ })
15471541 }
1542
+ res.push({
1543
+ digits: pad(hours).split(''),
1544
+ unit: '时'
1545
+ })
1546
+ res.push({
1547
+ digits: pad(minutes).split(''),
1548
+ unit: '分'
1549
+ })
1550
+ res.push({
1551
+ digits: pad(seconds).split(''),
1552
+ unit: '秒'
1553
+ })
15481554 this.expireTime = res
1549
- this.expireTimeUnit = unit
15501555 if (this.isPageShow) {
15511556 setTimeout(() => {
1552
- that.countdownTimer(expireTime, type)
1557
+ that.countdownTimer(expireTime, type, token)
15531558 }, 1000)
15541559 }
15551560 },
....@@ -2082,11 +2087,22 @@
20822087 padding: 15rpx;
20832088 padding-left: 30rpx;
20842089 color: #979797;
2090
+ font-size: 26rpx;
20852091
20862092 .num {
2093
+ display: inline-block;
20872094 color: #000000;
20882095 background: #FFE20E;
2089
- padding: 0 10rpx;
2096
+ padding: 0 6rpx;
2097
+ margin: 0 4rpx;
2098
+ vertical-align: middle;
2099
+ }
2100
+
2101
+ /* 每个数字固定宽度,避免倒计时跳动时宽度忽长忽短 */
2102
+ .digit {
2103
+ display: inline-block;
2104
+ width: 19rpx;
2105
+ text-align: center;
20902106 }
20912107 }
20922108 </style>