pages/zone/index.vue
....@@ -14,11 +14,15 @@
1414 <view :style="{ height: marTop + 'px' }"></view>
1515 <yueyangZone ref=yueyangZoneRef v-if="isYueyangZone" :zoneInfo="info" :careBeanRate="careBeanRate"
1616 style="position: relative;z-index: 2;" @goLottery="goLottery" :relationKey="relationKey"></yueyangZone>
17
+ <view v-if="isYueyangZone" class="detail-btn" @click="goDetail">
18
+ <text>消耗明细</text>
19
+ </view>
1720 <view v-else>
1821 <view class="expireTime" v-if="expireTime && expireTime.length">
1922 <text>专区将在</text>
20
- <text v-for="(val, index) in expireTime" :key="index">
21
- <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 }}
2226 </text>
2327 <text>{{ startOrEnd }}</text>
2428 </view>
....@@ -67,9 +71,8 @@
6771 </view>
6872 </view>
6973 </view>
70
- <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery">
71
- <image class="lottery_bannerImg"
72
- src="https://ossacmall.bluedeer.com.cn/app/static/images/zone_lotteryBanner.gif" mode="widthFix">
74
+ <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery && info.lotteryBanner">
75
+ <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix">
7376 </image>
7477 </view>
7578 <view class="tag-img-container" v-if="info.zoneType == 7">
....@@ -495,7 +498,7 @@
495498
496499 <script>
497500 import {
498
- HTTP_REQUEST_URL
501
+ WEB_ACTIVITY_BASE
499502 } from '@/config/app';
500503 import {
501504 mapGetters
....@@ -586,7 +589,7 @@
586589 showMenu: false,
587590 selectedMenuArr: [],
588591 expireTime: [],
589
- expireTimeUnit: [],
592
+ countdownToken: 0,
590593 isPageShow: false,
591594 loginBackFn: null,
592595 errText: '',
....@@ -1195,6 +1198,11 @@
11951198 // that.myCareBean = res2.data.totalCareBeans;
11961199 });
11971200 },
1201
+ goDetail() {
1202
+ uni.navigateTo({
1203
+ url: '/pages/consumption/index?zoneId=' + this.info.id
1204
+ })
1205
+ },
11981206 goLottery() {
11991207 let that = this;
12001208 var data = {
....@@ -1206,11 +1214,7 @@
12061214 this.addTrack('yy_marketPageClick', data);
12071215
12081216 function go() {
1209
- let webUrl = 'https://ossacmall.bluedeer.com.cn/acmall_lottery/index.html'
1210
- if (HTTP_REQUEST_URL.indexOf('tohours') > 0) {
1211
- webUrl = webUrl.replace('https://ossacmall.bluedeer.com.cn',
1212
- 'https://sit.tohours.com/crmeb_web')
1213
- }
1217
+ let webUrl = `${WEB_ACTIVITY_BASE}/acmall_lottery/index.html`
12141218 webUrl += '?token=' +
12151219 that.$store.getters.token + '&unionId=' + that.$store.getters.unionId + '&mdayId=' + that.info
12161220 .mdayId
....@@ -1292,6 +1296,9 @@
12921296 })
12931297 },
12941298 validAlert(data) {
1299
+ // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动
1300
+ this.countdownToken++
1301
+ const token = this.countdownToken
12951302 const {
12961303 startTime,
12971304 expireTime
....@@ -1310,17 +1317,17 @@
13101317 let minutes = startTimetamp.getMinutes()
13111318 minutes = minutes < 10 ? '0' + minutes : minutes;
13121319
1313
- this.countdownTimer(startTime.split('-').join('/'), 'start')
1320
+ this.countdownTimer(startTime.split('-').join('/'), 'start', token)
13141321 this.startOrEnd = "后开启"
13151322 return
1316
- }
1317
- }
1318
- if (expireTime) {
1319
- const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1320
- if (expireTimetamp < nowTimestamp) {
1323
+ }
1324
+ }
1325
+ if (expireTime) {
1326
+ const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1327
+ if (expireTimetamp < nowTimestamp) {
13211328 return
1322
- }
1323
- this.countdownTimer(expireTime.split('-').join('/'), 'end')
1329
+ }
1330
+ this.countdownTimer(expireTime.split('-').join('/'), 'end', token)
13241331 this.startOrEnd = "后结束"
13251332 }
13261333 },
....@@ -1458,7 +1465,7 @@
14581465 that.homeTop = that.getHomeTop(0.4)
14591466 }
14601467 that.expireTime = [];
1461
- that.expireTimeUnit = [];
1468
+ that.countdownToken++;
14621469 that.where.page = 1;
14631470 that.getGoodList()
14641471 that.validAlert(res.data)
....@@ -1484,8 +1491,9 @@
14841491 }
14851492 });
14861493 },
1487
- countdownTimer(expireTime, type) {
1494
+ countdownTimer(expireTime, type, token) {
14881495 if (!expireTime) return
1496
+ if (token !== undefined && token !== this.countdownToken) return
14891497 let that = this;
14901498 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳)
14911499 const endTimestamp = new Date(expireTime).getTime();
....@@ -1497,56 +1505,56 @@
14971505 if (type == 'end') {
14981506 if (diff <= 0) {
14991507 this.expireTime = []
1500
- this.expireTimeUnit = []
15011508 return
15021509 } else { }
15031510 } else if (type == 'start') {
15041511 if (diff <= 0) {
15051512 this.expireTime = []
1506
- this.expireTimeUnit = []
15071513 const expireTime2 = that.info.expireTime
15081514 if (expireTime2) {
15091515 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime();
15101516 if (expireTimetamp < nowTimestamp) {
15111517 return
15121518 }
1513
- this.countdownTimer(expireTime2.split('-').join('/'), 'end')
1519
+ this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)
15141520 this.startOrEnd = "后结束"
15151521 }
15161522 return
15171523 }
15181524 }
1525
+ const pad = num => (num < 10 ? '0' + num : String(num))
15191526 const res = []
1520
- const unit = []
15211527 const days = Math.floor(diff / (1000 * 60 * 60 * 24))
15221528 diff %= (1000 * 60 * 60 * 24)
1523
- if (days > 0) {
1524
- res.push(days);
1525
- unit.push('日')
1526
- }
15271529 // 转换为小时、分钟、秒
15281530 const hours = Math.floor(diff / (1000 * 60 * 60));
15291531 diff %= (1000 * 60 * 60); // 剩余毫秒数
1530
- if (hours > 0) {
1531
- res.push(hours < 10 ? '0' + hours : hours);
1532
- unit.push('时')
1533
- }
15341532 const minutes = Math.floor(diff / (1000 * 60));
1535
- if (minutes > 0) {
1536
- res.push(minutes < 10 ? '0' + minutes : minutes);
1537
- unit.push('分')
1538
- }
15391533 diff %= (1000 * 60); // 剩余毫秒数
15401534 const seconds = Math.floor(diff / 1000);
1541
- if (seconds > 0) {
1542
- res.push(seconds < 10 ? '0' + seconds : seconds);
1543
- unit.push('秒')
1535
+ // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定
1536
+ if (days > 0) {
1537
+ res.push({
1538
+ digits: pad(days).split(''),
1539
+ unit: '日'
1540
+ })
15441541 }
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
+ })
15451554 this.expireTime = res
1546
- this.expireTimeUnit = unit
15471555 if (this.isPageShow) {
15481556 setTimeout(() => {
1549
- that.countdownTimer(expireTime, type)
1557
+ that.countdownTimer(expireTime, type, token)
15501558 }, 1000)
15511559 }
15521560 },
....@@ -1633,13 +1641,11 @@
16331641 .lottery_banner {
16341642 margin: 15rpx auto;
16351643 width: 690rpx;
1636
- height: 120rpx;
16371644 text-align: center;
16381645 }
16391646
16401647 .lottery_bannerImg {
16411648 width: 690rpx;
1642
- height: 120rpx;
16431649 }
16441650
16451651 .tag-wrap-container {
....@@ -1838,6 +1844,21 @@
18381844 position: absolute;
18391845 top: 50%;
18401846 transform: translate(0, -50%);
1847
+}
1848
+
1849
+.detail-btn {
1850
+ border: 2rpx solid #fff;
1851
+ border-top-left-radius: 20rpx;
1852
+ border-bottom-left-radius: 20rpx;
1853
+ padding: 10rpx;
1854
+ background-color: #daf2b2;
1855
+ color: #1e984f;
1856
+ width: 50rpx;
1857
+ position: fixed;
1858
+ top: 200rpx;
1859
+ right: 0rpx;
1860
+ line-height: 1rem;
1861
+ z-index: 99;
18411862 }
18421863
18431864 .head_img {
....@@ -2066,11 +2087,22 @@
20662087 padding: 15rpx;
20672088 padding-left: 30rpx;
20682089 color: #979797;
2090
+ font-size: 26rpx;
20692091
20702092 .num {
2093
+ display: inline-block;
20712094 color: #000000;
20722095 background: #FFE20E;
2073
- 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;
20742106 }
20752107 }
20762108 </style>