| .. | .. |
|---|
| 14 | 14 | <view :style="{ height: marTop + 'px' }"></view> |
|---|
| 15 | 15 | <yueyangZone ref=yueyangZoneRef v-if="isYueyangZone" :zoneInfo="info" :careBeanRate="careBeanRate" |
|---|
| 16 | 16 | 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> |
|---|
| 17 | 20 | <view v-else> |
|---|
| 18 | 21 | <view class="expireTime" v-if="expireTime && expireTime.length"> |
|---|
| 19 | 22 | <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 }} |
|---|
| 22 | 26 | </text> |
|---|
| 23 | 27 | <text>{{ startOrEnd }}</text> |
|---|
| 24 | 28 | </view> |
|---|
| .. | .. |
|---|
| 67 | 71 | </view> |
|---|
| 68 | 72 | </view> |
|---|
| 69 | 73 | </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"> |
|---|
| 73 | 76 | </image> |
|---|
| 74 | 77 | </view> |
|---|
| 75 | 78 | <view class="tag-img-container" v-if="info.zoneType == 7"> |
|---|
| .. | .. |
|---|
| 495 | 498 | |
|---|
| 496 | 499 | <script> |
|---|
| 497 | 500 | import { |
|---|
| 498 | | - HTTP_REQUEST_URL |
|---|
| 501 | + WEB_ACTIVITY_BASE |
|---|
| 499 | 502 | } from '@/config/app'; |
|---|
| 500 | 503 | import { |
|---|
| 501 | 504 | mapGetters |
|---|
| .. | .. |
|---|
| 586 | 589 | showMenu: false, |
|---|
| 587 | 590 | selectedMenuArr: [], |
|---|
| 588 | 591 | expireTime: [], |
|---|
| 589 | | - expireTimeUnit: [], |
|---|
| 592 | + countdownToken: 0, |
|---|
| 590 | 593 | isPageShow: false, |
|---|
| 591 | 594 | loginBackFn: null, |
|---|
| 592 | 595 | errText: '', |
|---|
| .. | .. |
|---|
| 1195 | 1198 | // that.myCareBean = res2.data.totalCareBeans; |
|---|
| 1196 | 1199 | }); |
|---|
| 1197 | 1200 | }, |
|---|
| 1201 | + goDetail() { |
|---|
| 1202 | + uni.navigateTo({ |
|---|
| 1203 | + url: '/pages/consumption/index?zoneId=' + this.info.id |
|---|
| 1204 | + }) |
|---|
| 1205 | + }, |
|---|
| 1198 | 1206 | goLottery() { |
|---|
| 1199 | 1207 | let that = this; |
|---|
| 1200 | 1208 | var data = { |
|---|
| .. | .. |
|---|
| 1206 | 1214 | this.addTrack('yy_marketPageClick', data); |
|---|
| 1207 | 1215 | |
|---|
| 1208 | 1216 | 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` |
|---|
| 1214 | 1218 | webUrl += '?token=' + |
|---|
| 1215 | 1219 | that.$store.getters.token + '&unionId=' + that.$store.getters.unionId + '&mdayId=' + that.info |
|---|
| 1216 | 1220 | .mdayId |
|---|
| .. | .. |
|---|
| 1292 | 1296 | }) |
|---|
| 1293 | 1297 | }, |
|---|
| 1294 | 1298 | validAlert(data) { |
|---|
| 1299 | + // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动 |
|---|
| 1300 | + this.countdownToken++ |
|---|
| 1301 | + const token = this.countdownToken |
|---|
| 1295 | 1302 | const { |
|---|
| 1296 | 1303 | startTime, |
|---|
| 1297 | 1304 | expireTime |
|---|
| .. | .. |
|---|
| 1310 | 1317 | let minutes = startTimetamp.getMinutes() |
|---|
| 1311 | 1318 | minutes = minutes < 10 ? '0' + minutes : minutes; |
|---|
| 1312 | 1319 | |
|---|
| 1313 | | - this.countdownTimer(startTime.split('-').join('/'), 'start') |
|---|
| 1320 | + this.countdownTimer(startTime.split('-').join('/'), 'start', token) |
|---|
| 1314 | 1321 | this.startOrEnd = "后开启" |
|---|
| 1315 | 1322 | 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) { |
|---|
| 1321 | 1328 | return |
|---|
| 1322 | | - } |
|---|
| 1323 | | - this.countdownTimer(expireTime.split('-').join('/'), 'end') |
|---|
| 1329 | + } |
|---|
| 1330 | + this.countdownTimer(expireTime.split('-').join('/'), 'end', token) |
|---|
| 1324 | 1331 | this.startOrEnd = "后结束" |
|---|
| 1325 | 1332 | } |
|---|
| 1326 | 1333 | }, |
|---|
| .. | .. |
|---|
| 1458 | 1465 | that.homeTop = that.getHomeTop(0.4) |
|---|
| 1459 | 1466 | } |
|---|
| 1460 | 1467 | that.expireTime = []; |
|---|
| 1461 | | - that.expireTimeUnit = []; |
|---|
| 1468 | + that.countdownToken++; |
|---|
| 1462 | 1469 | that.where.page = 1; |
|---|
| 1463 | 1470 | that.getGoodList() |
|---|
| 1464 | 1471 | that.validAlert(res.data) |
|---|
| .. | .. |
|---|
| 1484 | 1491 | } |
|---|
| 1485 | 1492 | }); |
|---|
| 1486 | 1493 | }, |
|---|
| 1487 | | - countdownTimer(expireTime, type) { |
|---|
| 1494 | + countdownTimer(expireTime, type, token) { |
|---|
| 1488 | 1495 | if (!expireTime) return |
|---|
| 1496 | + if (token !== undefined && token !== this.countdownToken) return |
|---|
| 1489 | 1497 | let that = this; |
|---|
| 1490 | 1498 | // 结束时间的时间戳(需传入一个有效的日期对象或时间戳) |
|---|
| 1491 | 1499 | const endTimestamp = new Date(expireTime).getTime(); |
|---|
| .. | .. |
|---|
| 1497 | 1505 | if (type == 'end') { |
|---|
| 1498 | 1506 | if (diff <= 0) { |
|---|
| 1499 | 1507 | this.expireTime = [] |
|---|
| 1500 | | - this.expireTimeUnit = [] |
|---|
| 1501 | 1508 | return |
|---|
| 1502 | 1509 | } else { } |
|---|
| 1503 | 1510 | } else if (type == 'start') { |
|---|
| 1504 | 1511 | if (diff <= 0) { |
|---|
| 1505 | 1512 | this.expireTime = [] |
|---|
| 1506 | | - this.expireTimeUnit = [] |
|---|
| 1507 | 1513 | const expireTime2 = that.info.expireTime |
|---|
| 1508 | 1514 | if (expireTime2) { |
|---|
| 1509 | 1515 | const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime(); |
|---|
| 1510 | 1516 | if (expireTimetamp < nowTimestamp) { |
|---|
| 1511 | 1517 | return |
|---|
| 1512 | 1518 | } |
|---|
| 1513 | | - this.countdownTimer(expireTime2.split('-').join('/'), 'end') |
|---|
| 1519 | + this.countdownTimer(expireTime2.split('-').join('/'), 'end', token) |
|---|
| 1514 | 1520 | this.startOrEnd = "后结束" |
|---|
| 1515 | 1521 | } |
|---|
| 1516 | 1522 | return |
|---|
| 1517 | 1523 | } |
|---|
| 1518 | 1524 | } |
|---|
| 1525 | + const pad = num => (num < 10 ? '0' + num : String(num)) |
|---|
| 1519 | 1526 | const res = [] |
|---|
| 1520 | | - const unit = [] |
|---|
| 1521 | 1527 | const days = Math.floor(diff / (1000 * 60 * 60 * 24)) |
|---|
| 1522 | 1528 | diff %= (1000 * 60 * 60 * 24) |
|---|
| 1523 | | - if (days > 0) { |
|---|
| 1524 | | - res.push(days); |
|---|
| 1525 | | - unit.push('日') |
|---|
| 1526 | | - } |
|---|
| 1527 | 1529 | // 转换为小时、分钟、秒 |
|---|
| 1528 | 1530 | const hours = Math.floor(diff / (1000 * 60 * 60)); |
|---|
| 1529 | 1531 | diff %= (1000 * 60 * 60); // 剩余毫秒数 |
|---|
| 1530 | | - if (hours > 0) { |
|---|
| 1531 | | - res.push(hours < 10 ? '0' + hours : hours); |
|---|
| 1532 | | - unit.push('时') |
|---|
| 1533 | | - } |
|---|
| 1534 | 1532 | const minutes = Math.floor(diff / (1000 * 60)); |
|---|
| 1535 | | - if (minutes > 0) { |
|---|
| 1536 | | - res.push(minutes < 10 ? '0' + minutes : minutes); |
|---|
| 1537 | | - unit.push('分') |
|---|
| 1538 | | - } |
|---|
| 1539 | 1533 | diff %= (1000 * 60); // 剩余毫秒数 |
|---|
| 1540 | 1534 | 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 | + }) |
|---|
| 1544 | 1541 | } |
|---|
| 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 | + }) |
|---|
| 1545 | 1554 | this.expireTime = res |
|---|
| 1546 | | - this.expireTimeUnit = unit |
|---|
| 1547 | 1555 | if (this.isPageShow) { |
|---|
| 1548 | 1556 | setTimeout(() => { |
|---|
| 1549 | | - that.countdownTimer(expireTime, type) |
|---|
| 1557 | + that.countdownTimer(expireTime, type, token) |
|---|
| 1550 | 1558 | }, 1000) |
|---|
| 1551 | 1559 | } |
|---|
| 1552 | 1560 | }, |
|---|
| .. | .. |
|---|
| 1633 | 1641 | .lottery_banner { |
|---|
| 1634 | 1642 | margin: 15rpx auto; |
|---|
| 1635 | 1643 | width: 690rpx; |
|---|
| 1636 | | - height: 120rpx; |
|---|
| 1637 | 1644 | text-align: center; |
|---|
| 1638 | 1645 | } |
|---|
| 1639 | 1646 | |
|---|
| 1640 | 1647 | .lottery_bannerImg { |
|---|
| 1641 | 1648 | width: 690rpx; |
|---|
| 1642 | | - height: 120rpx; |
|---|
| 1643 | 1649 | } |
|---|
| 1644 | 1650 | |
|---|
| 1645 | 1651 | .tag-wrap-container { |
|---|
| .. | .. |
|---|
| 1838 | 1844 | position: absolute; |
|---|
| 1839 | 1845 | top: 50%; |
|---|
| 1840 | 1846 | 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; |
|---|
| 1841 | 1862 | } |
|---|
| 1842 | 1863 | |
|---|
| 1843 | 1864 | .head_img { |
|---|
| .. | .. |
|---|
| 2066 | 2087 | padding: 15rpx; |
|---|
| 2067 | 2088 | padding-left: 30rpx; |
|---|
| 2068 | 2089 | color: #979797; |
|---|
| 2090 | + font-size: 26rpx; |
|---|
| 2069 | 2091 | |
|---|
| 2070 | 2092 | .num { |
|---|
| 2093 | + display: inline-block; |
|---|
| 2071 | 2094 | color: #000000; |
|---|
| 2072 | 2095 | 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; |
|---|
| 2074 | 2106 | } |
|---|
| 2075 | 2107 | } |
|---|
| 2076 | 2108 | </style> |
|---|