| .. | .. |
|---|
| 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" |
|---|
| 75 | + v-if="info && info.isLottery && info.lotteryBanner && lotteryBannerReady"> |
|---|
| 76 | + <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix" |
|---|
| 77 | + :style="{ height: lotteryBannerHeight }"> |
|---|
| 73 | 78 | </image> |
|---|
| 74 | 79 | </view> |
|---|
| 75 | 80 | <view class="tag-img-container" v-if="info.zoneType == 7"> |
|---|
| .. | .. |
|---|
| 495 | 500 | |
|---|
| 496 | 501 | <script> |
|---|
| 497 | 502 | import { |
|---|
| 498 | | - HTTP_REQUEST_URL |
|---|
| 503 | + WEB_ACTIVITY_BASE |
|---|
| 499 | 504 | } from '@/config/app'; |
|---|
| 500 | 505 | import { |
|---|
| 501 | 506 | mapGetters |
|---|
| .. | .. |
|---|
| 586 | 591 | showMenu: false, |
|---|
| 587 | 592 | selectedMenuArr: [], |
|---|
| 588 | 593 | expireTime: [], |
|---|
| 589 | | - expireTimeUnit: [], |
|---|
| 594 | + countdownToken: 0, |
|---|
| 590 | 595 | isPageShow: false, |
|---|
| 591 | 596 | loginBackFn: null, |
|---|
| 592 | 597 | errText: '', |
|---|
| .. | .. |
|---|
| 619 | 624 | stockEmpty: true, |
|---|
| 620 | 625 | urlOption: {}, |
|---|
| 621 | 626 | homeTop: '200', |
|---|
| 627 | + lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应 |
|---|
| 628 | + lotteryBannerReady: false, //是否已拿到banner尺寸(或已确认拿不到),未就绪前不渲染,避免首帧撑高 |
|---|
| 622 | 629 | hasNewPop: false, |
|---|
| 623 | 630 | leftCoupon: {}, |
|---|
| 624 | 631 | rightCoupon: {}, |
|---|
| .. | .. |
|---|
| 1195 | 1202 | // that.myCareBean = res2.data.totalCareBeans; |
|---|
| 1196 | 1203 | }); |
|---|
| 1197 | 1204 | }, |
|---|
| 1205 | + goDetail() { |
|---|
| 1206 | + uni.navigateTo({ |
|---|
| 1207 | + url: '/pages/consumption/index?zoneId=' + this.info.id |
|---|
| 1208 | + }) |
|---|
| 1209 | + }, |
|---|
| 1198 | 1210 | goLottery() { |
|---|
| 1199 | 1211 | let that = this; |
|---|
| 1200 | 1212 | var data = { |
|---|
| .. | .. |
|---|
| 1206 | 1218 | this.addTrack('yy_marketPageClick', data); |
|---|
| 1207 | 1219 | |
|---|
| 1208 | 1220 | 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 | | - } |
|---|
| 1221 | + let webUrl = `${WEB_ACTIVITY_BASE}/acmall_lottery/index.html` |
|---|
| 1214 | 1222 | webUrl += '?token=' + |
|---|
| 1215 | 1223 | that.$store.getters.token + '&unionId=' + that.$store.getters.unionId + '&mdayId=' + that.info |
|---|
| 1216 | 1224 | .mdayId |
|---|
| .. | .. |
|---|
| 1292 | 1300 | }) |
|---|
| 1293 | 1301 | }, |
|---|
| 1294 | 1302 | validAlert(data) { |
|---|
| 1303 | + // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动 |
|---|
| 1304 | + this.countdownToken++ |
|---|
| 1305 | + const token = this.countdownToken |
|---|
| 1295 | 1306 | const { |
|---|
| 1296 | 1307 | startTime, |
|---|
| 1297 | 1308 | expireTime |
|---|
| .. | .. |
|---|
| 1310 | 1321 | let minutes = startTimetamp.getMinutes() |
|---|
| 1311 | 1322 | minutes = minutes < 10 ? '0' + minutes : minutes; |
|---|
| 1312 | 1323 | |
|---|
| 1313 | | - this.countdownTimer(startTime.split('-').join('/'), 'start') |
|---|
| 1324 | + this.countdownTimer(startTime.split('-').join('/'), 'start', token) |
|---|
| 1314 | 1325 | this.startOrEnd = "后开启" |
|---|
| 1315 | 1326 | return |
|---|
| 1316 | | - } |
|---|
| 1317 | | - } |
|---|
| 1318 | | - if (expireTime) { |
|---|
| 1319 | | - const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime(); |
|---|
| 1320 | | - if (expireTimetamp < nowTimestamp) { |
|---|
| 1327 | + } |
|---|
| 1328 | + } |
|---|
| 1329 | + if (expireTime) { |
|---|
| 1330 | + const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime(); |
|---|
| 1331 | + if (expireTimetamp < nowTimestamp) { |
|---|
| 1321 | 1332 | return |
|---|
| 1322 | | - } |
|---|
| 1323 | | - this.countdownTimer(expireTime.split('-').join('/'), 'end') |
|---|
| 1333 | + } |
|---|
| 1334 | + this.countdownTimer(expireTime.split('-').join('/'), 'end', token) |
|---|
| 1324 | 1335 | this.startOrEnd = "后结束" |
|---|
| 1325 | 1336 | } |
|---|
| 1326 | 1337 | }, |
|---|
| .. | .. |
|---|
| 1442 | 1453 | this.$refs.popNewuserRef.show() |
|---|
| 1443 | 1454 | } |
|---|
| 1444 | 1455 | }, |
|---|
| 1456 | + // 预取抽奖banner真实宽高,计算出高度后再渲染,避免加载前被组件默认高度(225px)撑大 |
|---|
| 1457 | + setLotteryBannerSize(info) { |
|---|
| 1458 | + let that = this |
|---|
| 1459 | + that.lotteryBannerHeight = '' |
|---|
| 1460 | + that.lotteryBannerReady = false |
|---|
| 1461 | + if (!info || !info.isLottery || !info.lotteryBanner) { |
|---|
| 1462 | + that.lotteryBannerReady = true |
|---|
| 1463 | + return |
|---|
| 1464 | + } |
|---|
| 1465 | + uni.getImageInfo({ |
|---|
| 1466 | + src: info.lotteryBanner, |
|---|
| 1467 | + success: (img) => { |
|---|
| 1468 | + if (img.width > 0 && img.height > 0) { |
|---|
| 1469 | + that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx' |
|---|
| 1470 | + } |
|---|
| 1471 | + that.lotteryBannerReady = true |
|---|
| 1472 | + }, |
|---|
| 1473 | + fail: (err) => { |
|---|
| 1474 | + console.warn('抽奖banner尺寸预取失败,回退为自适应', err) |
|---|
| 1475 | + that.lotteryBannerReady = true |
|---|
| 1476 | + } |
|---|
| 1477 | + }) |
|---|
| 1478 | + }, |
|---|
| 1445 | 1479 | getZoneDetail: function () { |
|---|
| 1446 | 1480 | let that = this; |
|---|
| 1447 | 1481 | let belong = this.$store.getters.belong; |
|---|
| .. | .. |
|---|
| 1449 | 1483 | console.log('专区详情入参::', params) |
|---|
| 1450 | 1484 | getZoneDetail(that.id, params).then(res => { |
|---|
| 1451 | 1485 | that.info = res.data; |
|---|
| 1486 | +<<<<<<< Updated upstream |
|---|
| 1487 | +======= |
|---|
| 1488 | + //that.info.zoneType=8; |
|---|
| 1489 | + that.setLotteryBannerSize(res.data); |
|---|
| 1490 | +>>>>>>> Stashed changes |
|---|
| 1452 | 1491 | that.updateZoneShareMenu(); |
|---|
| 1453 | 1492 | if (res.data.zoneType == 6) { |
|---|
| 1454 | 1493 | that.setYueyangZone() |
|---|
| .. | .. |
|---|
| 1458 | 1497 | that.homeTop = that.getHomeTop(0.4) |
|---|
| 1459 | 1498 | } |
|---|
| 1460 | 1499 | that.expireTime = []; |
|---|
| 1461 | | - that.expireTimeUnit = []; |
|---|
| 1500 | + that.countdownToken++; |
|---|
| 1462 | 1501 | that.where.page = 1; |
|---|
| 1463 | 1502 | that.getGoodList() |
|---|
| 1464 | 1503 | that.validAlert(res.data) |
|---|
| .. | .. |
|---|
| 1484 | 1523 | } |
|---|
| 1485 | 1524 | }); |
|---|
| 1486 | 1525 | }, |
|---|
| 1487 | | - countdownTimer(expireTime, type) { |
|---|
| 1526 | + countdownTimer(expireTime, type, token) { |
|---|
| 1488 | 1527 | if (!expireTime) return |
|---|
| 1528 | + if (token !== undefined && token !== this.countdownToken) return |
|---|
| 1489 | 1529 | let that = this; |
|---|
| 1490 | 1530 | // 结束时间的时间戳(需传入一个有效的日期对象或时间戳) |
|---|
| 1491 | 1531 | const endTimestamp = new Date(expireTime).getTime(); |
|---|
| .. | .. |
|---|
| 1497 | 1537 | if (type == 'end') { |
|---|
| 1498 | 1538 | if (diff <= 0) { |
|---|
| 1499 | 1539 | this.expireTime = [] |
|---|
| 1500 | | - this.expireTimeUnit = [] |
|---|
| 1501 | 1540 | return |
|---|
| 1502 | 1541 | } else { } |
|---|
| 1503 | 1542 | } else if (type == 'start') { |
|---|
| 1504 | 1543 | if (diff <= 0) { |
|---|
| 1505 | 1544 | this.expireTime = [] |
|---|
| 1506 | | - this.expireTimeUnit = [] |
|---|
| 1507 | 1545 | const expireTime2 = that.info.expireTime |
|---|
| 1508 | 1546 | if (expireTime2) { |
|---|
| 1509 | 1547 | const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime(); |
|---|
| 1510 | 1548 | if (expireTimetamp < nowTimestamp) { |
|---|
| 1511 | 1549 | return |
|---|
| 1512 | 1550 | } |
|---|
| 1513 | | - this.countdownTimer(expireTime2.split('-').join('/'), 'end') |
|---|
| 1551 | + this.countdownTimer(expireTime2.split('-').join('/'), 'end', token) |
|---|
| 1514 | 1552 | this.startOrEnd = "后结束" |
|---|
| 1515 | 1553 | } |
|---|
| 1516 | 1554 | return |
|---|
| 1517 | 1555 | } |
|---|
| 1518 | 1556 | } |
|---|
| 1557 | + const pad = num => (num < 10 ? '0' + num : String(num)) |
|---|
| 1519 | 1558 | const res = [] |
|---|
| 1520 | | - const unit = [] |
|---|
| 1521 | 1559 | const days = Math.floor(diff / (1000 * 60 * 60 * 24)) |
|---|
| 1522 | 1560 | diff %= (1000 * 60 * 60 * 24) |
|---|
| 1523 | | - if (days > 0) { |
|---|
| 1524 | | - res.push(days); |
|---|
| 1525 | | - unit.push('日') |
|---|
| 1526 | | - } |
|---|
| 1527 | 1561 | // 转换为小时、分钟、秒 |
|---|
| 1528 | 1562 | const hours = Math.floor(diff / (1000 * 60 * 60)); |
|---|
| 1529 | 1563 | diff %= (1000 * 60 * 60); // 剩余毫秒数 |
|---|
| 1530 | | - if (hours > 0) { |
|---|
| 1531 | | - res.push(hours < 10 ? '0' + hours : hours); |
|---|
| 1532 | | - unit.push('时') |
|---|
| 1533 | | - } |
|---|
| 1534 | 1564 | const minutes = Math.floor(diff / (1000 * 60)); |
|---|
| 1535 | | - if (minutes > 0) { |
|---|
| 1536 | | - res.push(minutes < 10 ? '0' + minutes : minutes); |
|---|
| 1537 | | - unit.push('分') |
|---|
| 1538 | | - } |
|---|
| 1539 | 1565 | diff %= (1000 * 60); // 剩余毫秒数 |
|---|
| 1540 | 1566 | const seconds = Math.floor(diff / 1000); |
|---|
| 1541 | | - if (seconds > 0) { |
|---|
| 1542 | | - res.push(seconds < 10 ? '0' + seconds : seconds); |
|---|
| 1543 | | - unit.push('秒') |
|---|
| 1567 | + // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定 |
|---|
| 1568 | + if (days > 0) { |
|---|
| 1569 | + res.push({ |
|---|
| 1570 | + digits: pad(days).split(''), |
|---|
| 1571 | + unit: '日' |
|---|
| 1572 | + }) |
|---|
| 1544 | 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 | + }) |
|---|
| 1545 | 1586 | this.expireTime = res |
|---|
| 1546 | | - this.expireTimeUnit = unit |
|---|
| 1547 | 1587 | if (this.isPageShow) { |
|---|
| 1548 | 1588 | setTimeout(() => { |
|---|
| 1549 | | - that.countdownTimer(expireTime, type) |
|---|
| 1589 | + that.countdownTimer(expireTime, type, token) |
|---|
| 1550 | 1590 | }, 1000) |
|---|
| 1551 | 1591 | } |
|---|
| 1552 | 1592 | }, |
|---|
| .. | .. |
|---|
| 1633 | 1673 | .lottery_banner { |
|---|
| 1634 | 1674 | margin: 15rpx auto; |
|---|
| 1635 | 1675 | width: 690rpx; |
|---|
| 1636 | | - height: 120rpx; |
|---|
| 1637 | 1676 | text-align: center; |
|---|
| 1638 | 1677 | } |
|---|
| 1639 | 1678 | |
|---|
| 1640 | 1679 | .lottery_bannerImg { |
|---|
| 1641 | 1680 | width: 690rpx; |
|---|
| 1642 | | - height: 120rpx; |
|---|
| 1643 | 1681 | } |
|---|
| 1644 | 1682 | |
|---|
| 1645 | 1683 | .tag-wrap-container { |
|---|
| .. | .. |
|---|
| 1838 | 1876 | position: absolute; |
|---|
| 1839 | 1877 | top: 50%; |
|---|
| 1840 | 1878 | transform: translate(0, -50%); |
|---|
| 1879 | +} |
|---|
| 1880 | + |
|---|
| 1881 | +.detail-btn { |
|---|
| 1882 | + border: 2rpx solid #fff; |
|---|
| 1883 | + border-top-left-radius: 20rpx; |
|---|
| 1884 | + border-bottom-left-radius: 20rpx; |
|---|
| 1885 | + padding: 10rpx; |
|---|
| 1886 | + background-color: #daf2b2; |
|---|
| 1887 | + color: #1e984f; |
|---|
| 1888 | + width: 50rpx; |
|---|
| 1889 | + position: fixed; |
|---|
| 1890 | + top: 200rpx; |
|---|
| 1891 | + right: 0rpx; |
|---|
| 1892 | + line-height: 1rem; |
|---|
| 1893 | + z-index: 99; |
|---|
| 1841 | 1894 | } |
|---|
| 1842 | 1895 | |
|---|
| 1843 | 1896 | .head_img { |
|---|
| .. | .. |
|---|
| 2066 | 2119 | padding: 15rpx; |
|---|
| 2067 | 2120 | padding-left: 30rpx; |
|---|
| 2068 | 2121 | color: #979797; |
|---|
| 2122 | + font-size: 26rpx; |
|---|
| 2069 | 2123 | |
|---|
| 2070 | 2124 | .num { |
|---|
| 2125 | + display: inline-block; |
|---|
| 2071 | 2126 | color: #000000; |
|---|
| 2072 | 2127 | background: #FFE20E; |
|---|
| 2073 | | - padding: 0 10rpx; |
|---|
| 2128 | + padding: 0 6rpx; |
|---|
| 2129 | + margin: 0 4rpx; |
|---|
| 2130 | + vertical-align: middle; |
|---|
| 2131 | + } |
|---|
| 2132 | + |
|---|
| 2133 | + /* 每个数字固定宽度,避免倒计时跳动时宽度忽长忽短 */ |
|---|
| 2134 | + .digit { |
|---|
| 2135 | + display: inline-block; |
|---|
| 2136 | + width: 19rpx; |
|---|
| 2137 | + text-align: center; |
|---|
| 2074 | 2138 | } |
|---|
| 2075 | 2139 | } |
|---|
| 2076 | 2140 | </style> |
|---|