| components/orderListGoods/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| main.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| pages/users/order_list/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| pages/zone/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
components/orderListGoods/index.vue
.. .. @@ -9,8 +9,8 @@ 9 9 </view> 10 10 <view class='text acea-row row-between'> 11 11 <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>14 14 </view> 15 15 <view class='info'></view> 16 16 <view class='money'> .. .. @@ -34,8 +34,8 @@ 34 34 <view class="gift-tag">赠品</view> 35 35 </view> 36 36 <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>39 39 </view> 40 40 </view> 41 41 </view> main.js
.. .. @@ -228,16 +228,21 @@ 228 228 Vue.mixin(pageLog); 229 229 import BigNumber from 'bignumber.js'; 230 230 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、NaN232 + if (number === null || number === undefined || number === '' || isNaN(number)) {233 + return 0;235 234 } 235 + const result = BigNumber(number).toNumber();236 + return isNaN(result) ? 0 : result;236 237 } 237 238 238 239 Vue.prototype.toThousands = function(num) { 239 - if (num < 1000) return num;240 - if (Number.isInteger(num)) {240 + // null / undefined / 空值 / 非数字统一返回 0,避免页面显示 null、undefined、NaN241 + 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))) {241 246 return String(num).replace(/(?!^)(?=(\d{3})+$)/g, ',') 242 247 } else { 243 248 return String(num).replace(/(?!^)(?=(\d{3})+\.)/g, ',') pages/users/order_list/index.vue
.. .. @@ -37,14 +37,14 @@ 37 37 <view class='title acea-row row-between-wrapper'> 38 38 <view class="acea-row row-middle"> 39 39 <text class="sign cart-color acea-row row-center-wrapper" 40 - v-if="item.activityType !== '普通' && item.activityType !== '核销'">{{ item.activityType41 - }}</text>40 + v-if="item.activityType && item.activityType !== '普通' && item.activityType !== '核销'">{{41 + item.activityType }}</text>42 42 <!-- <text class="sign cart-color acea-row row-center-wrapper" v-if="item.bargainId != 0">砍价</text> 43 43 <text class="sign cart-color acea-row row-center-wrapper" v-else-if="item.storeOrder.combinationId != 0">拼团</text> 44 44 <text class="sign cart-color acea-row row-center-wrapper" v-else-if="item.storeOrder.seckillId != 0">秒杀</text> --> 45 45 <view>{{ item.createTime }}</view> 46 46 </view> 47 - <view class='font-color'>{{ item.orderStatus }}</view>47 + <view class='font-color'>{{ item.orderStatus || '' }}</view>48 48 <!-- <view v-if="item.status?item.status.type == 0:0" class='font-color'>待付款</view> 49 49 <view v-else-if="item.status?item.status.type == 1:0 && item.storeOrder.shippingType==1" class='font-color'>待发货</view> 50 50 <view v-else-if="item.status?item.status.type == 2:0 && item.storeOrder.shippingType==1" class='font-color'>待收货</view> .. .. @@ -54,8 +54,7 @@ 54 54 </view> 55 55 <orderListGoods :orderInfoList="item.orderInfoList" 56 56 :zonePromotionList="item.zonePromotionList || []"></orderListGoods> 57 - <view class='totalPrice'>共{{ item.totalNum + getGiftCount(item.zonePromotionList || [])58 - }}件商品,总金额57 + <view class='totalPrice'>共{{ getTotalNum(item) }}件商品,总金额59 58 <text class='money font-color' v-if="getPayWay(item.payPrice, item.payCareBean) == 1"> 60 59 <text class="color-blue">¥{{ toNumber(item.payPrice) }}</text> 61 60 <text class="color-blue">+{{ toThousands(toNumber(item.payCareBean)) }}悦养豆</text> .. .. @@ -254,6 +253,9 @@ 254 253 }); 255 254 return count; 256 255 }, 256 + getTotalNum(item) {257 + return (Number(item.totalNum) || 0) + this.getGiftCount(item.zonePromotionList || []);258 + },257 259 getPayWay(price, payCareBean) { 258 260 console.log('阿斯顿发送到发送地方', Number(price) > 0 && Number(payCareBean) > 0); 259 261 if (Number(price) > 0 && Number(payCareBean) > 0) { .. .. @@ -312,7 +314,9 @@ 312 314 getOrderData: function () { 313 315 let that = this; 314 316 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', {});316 320 }) 317 321 }, 318 322 /** .. .. @@ -447,7 +451,7 @@ 447 451 page: that.page, 448 452 limit: that.limit, 449 453 }).then(res => { 450 - let list = res.data.list || [];454 + let list = (res && res.data && res.data.list) || [];451 455 let loadend = list.length < that.limit; 452 456 that.orderList = that.$util.SplitArray(list, that.orderList); 453 457 that.$set(that, 'orderList', that.orderList); pages/zone/index.vue
.. .. @@ -20,8 +20,9 @@ 20 20 <view v-else> 21 21 <view class="expireTime" v-if="expireTime && expireTime.length"> 22 22 <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 }}25 26 </text> 26 27 <text>{{ startOrEnd }}</text> 27 28 </view> .. .. @@ -606,7 +607,7 @@ 606 607 showMenu: false, 607 608 selectedMenuArr: [], 608 609 expireTime: [], 609 - expireTimeUnit: [],610 + countdownToken: 0,610 611 isPageShow: false, 611 612 loginBackFn: null, 612 613 errText: '', .. .. @@ -1326,6 +1327,9 @@ 1326 1327 }) 1327 1328 }, 1328 1329 validAlert(data) { 1330 + // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动1331 + this.countdownToken++1332 + const token = this.countdownToken1329 1333 const { 1330 1334 startTime, 1331 1335 expireTime .. .. @@ -1344,17 +1348,17 @@ 1344 1348 let minutes = startTimetamp.getMinutes() 1345 1349 minutes = minutes < 10 ? '0' + minutes : minutes; 1346 1350 1347 - this.countdownTimer(startTime.split('-').join('/'), 'start')1351 + this.countdownTimer(startTime.split('-').join('/'), 'start', token)1348 1352 this.startOrEnd = "后开启" 1349 1353 return 1350 - }1351 - }1352 - if (expireTime) {1353 - const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();1354 - if (expireTimetamp < nowTimestamp) {1354 + }1355 + }1356 + if (expireTime) {1357 + const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();1358 + if (expireTimetamp < nowTimestamp) {1355 1359 return 1356 - }1357 - this.countdownTimer(expireTime.split('-').join('/'), 'end')1360 + }1361 + this.countdownTimer(expireTime.split('-').join('/'), 'end', token)1358 1362 this.startOrEnd = "后结束" 1359 1363 } 1360 1364 }, .. .. @@ -1493,7 +1497,7 @@ 1493 1497 that.homeTop = that.getHomeTop(0.4) 1494 1498 } 1495 1499 that.expireTime = []; 1496 - that.expireTimeUnit = [];1500 + that.countdownToken++;1497 1501 that.where.page = 1; 1498 1502 that.getGoodList() 1499 1503 that.validAlert(res.data) .. .. @@ -1519,8 +1523,9 @@ 1519 1523 } 1520 1524 }); 1521 1525 }, 1522 - countdownTimer(expireTime, type) {1526 + countdownTimer(expireTime, type, token) {1523 1527 if (!expireTime) return 1528 + if (token !== undefined && token !== this.countdownToken) return1524 1529 let that = this; 1525 1530 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳) 1526 1531 const endTimestamp = new Date(expireTime).getTime(); .. .. @@ -1532,56 +1537,56 @@ 1532 1537 if (type == 'end') { 1533 1538 if (diff <= 0) { 1534 1539 this.expireTime = [] 1535 - this.expireTimeUnit = []1536 1540 return 1537 1541 } else { } 1538 1542 } else if (type == 'start') { 1539 1543 if (diff <= 0) { 1540 1544 this.expireTime = [] 1541 - this.expireTimeUnit = []1542 1545 const expireTime2 = that.info.expireTime 1543 1546 if (expireTime2) { 1544 1547 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime(); 1545 1548 if (expireTimetamp < nowTimestamp) { 1546 1549 return 1547 1550 } 1548 - this.countdownTimer(expireTime2.split('-').join('/'), 'end')1551 + this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)1549 1552 this.startOrEnd = "后结束" 1550 1553 } 1551 1554 return 1552 1555 } 1553 1556 } 1557 + const pad = num => (num < 10 ? '0' + num : String(num))1554 1558 const res = [] 1555 - const unit = []1556 1559 const days = Math.floor(diff / (1000 * 60 * 60 * 24)) 1557 1560 diff %= (1000 * 60 * 60 * 24) 1558 - if (days > 0) {1559 - res.push(days);1560 - unit.push('日')1561 - }1562 1561 // 转换为小时、分钟、秒 1563 1562 const hours = Math.floor(diff / (1000 * 60 * 60)); 1564 1563 diff %= (1000 * 60 * 60); // 剩余毫秒数 1565 - if (hours > 0) {1566 - res.push(hours < 10 ? '0' + hours : hours);1567 - unit.push('时')1568 - }1569 1564 const minutes = Math.floor(diff / (1000 * 60)); 1570 - if (minutes > 0) {1571 - res.push(minutes < 10 ? '0' + minutes : minutes);1572 - unit.push('分')1573 - }1574 1565 diff %= (1000 * 60); // 剩余毫秒数 1575 1566 const seconds = Math.floor(diff / 1000); 1576 - if (seconds > 0) {1577 - res.push(seconds < 10 ? '0' + seconds : seconds);1578 - unit.push('秒')1567 + // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定1568 + if (days > 0) {1569 + res.push({1570 + digits: pad(days).split(''),1571 + unit: '日'1572 + })1579 1573 } 1574 + res.push({1575 + digits: pad(hours).split(''),1576 + unit: '时'1577 + })1578 + res.push({1579 + digits: pad(minutes).split(''),1580 + unit: '分'1581 + })1582 + res.push({1583 + digits: pad(seconds).split(''),1584 + unit: '秒'1585 + })1580 1586 this.expireTime = res 1581 - this.expireTimeUnit = unit1582 1587 if (this.isPageShow) { 1583 1588 setTimeout(() => { 1584 - that.countdownTimer(expireTime, type)1589 + that.countdownTimer(expireTime, type, token)1585 1590 }, 1000) 1586 1591 } 1587 1592 }, .. .. @@ -2156,11 +2161,22 @@ 2156 2161 padding: 15rpx; 2157 2162 padding-left: 30rpx; 2158 2163 color: #979797; 2164 + font-size: 26rpx;2159 2165 2160 2166 .num { 2167 + display: inline-block;2161 2168 color: #000000; 2162 2169 background: #FFE20E; 2163 - padding: 0 10rpx;2170 + padding: 0 6rpx;2171 + margin: 0 4rpx;2172 + vertical-align: middle;2173 + }2174 +2175 + /* 每个数字固定宽度,避免倒计时跳动时宽度忽长忽短 */2176 + .digit {2177 + display: inline-block;2178 + width: 19rpx;2179 + text-align: center;2164 2180 } 2165 2181 } 2166 2182 </style>