| .. | .. |
|---|
| 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> |
|---|
| 28 | 29 | <view class="head_img"> |
|---|
| 29 | 30 | <image :src="info.image"></image> |
|---|
| 31 | + </view> |
|---|
| 32 | + <view v-if="info.zoneType == 8 && info.info" class="rich-content"> |
|---|
| 33 | + <rich-text :nodes="info.info"></rich-text> |
|---|
| 34 | + </view> |
|---|
| 35 | + <view v-if="info.zoneType == 8 && info.uploadVideo" class="video-wrap"> |
|---|
| 36 | + <view v-show="!videoControls" style="width:100%;height:750rpx"> |
|---|
| 37 | + <video id="zoneVideo" :src='info.uploadVideo' objectFit="contain" controls |
|---|
| 38 | + style="width:100%;height:100%" show-center-play-btn="true" show-mute-btn="true" muted="true" |
|---|
| 39 | + show-fullscreen-btn="true" auto-pause-if-navigate :custom-cache="false" |
|---|
| 40 | + :enable-progress-gesture="true" show-progress="false" |
|---|
| 41 | + :poster="info.uploadVideoImg || info.image" @pause="zoneVideoPause"></video> |
|---|
| 42 | + </view> |
|---|
| 43 | + <view class="video-poster" v-show="videoControls"> |
|---|
| 44 | + <image class="image" :src="info.uploadVideoImg || info.image"></image> |
|---|
| 45 | + </view> |
|---|
| 46 | + <view class="video-stop" v-show="videoControls" @tap="bindZoneVideoPlay"> |
|---|
| 47 | + <image class="image" src="https://ossacmall.bluedeer.com.cn/app/static/images/stop.png"></image> |
|---|
| 48 | + </view> |
|---|
| 30 | 49 | </view> |
|---|
| 31 | 50 | <view class="tag-wrap-container" :style="'top:' + (marTop) + 'px;'" v-if="info.zoneType == 7"> |
|---|
| 32 | 51 | <view class="tag-wrap"> |
|---|
| .. | .. |
|---|
| 70 | 89 | </view> |
|---|
| 71 | 90 | </view> |
|---|
| 72 | 91 | </view> |
|---|
| 73 | | - <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery"> |
|---|
| 74 | | - <image class="lottery_bannerImg" |
|---|
| 75 | | - src="https://ossacmall.bluedeer.com.cn/app/static/images/zone_lotteryBanner.gif" mode="widthFix"> |
|---|
| 92 | + <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery && info.lotteryBanner"> |
|---|
| 93 | + <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix" |
|---|
| 94 | + :style="{ height: lotteryBannerHeight }"> |
|---|
| 76 | 95 | </image> |
|---|
| 77 | 96 | </view> |
|---|
| 78 | 97 | <view class="tag-img-container" v-if="info.zoneType == 7"> |
|---|
| .. | .. |
|---|
| 589 | 608 | showMenu: false, |
|---|
| 590 | 609 | selectedMenuArr: [], |
|---|
| 591 | 610 | expireTime: [], |
|---|
| 592 | | - expireTimeUnit: [], |
|---|
| 611 | + countdownToken: 0, |
|---|
| 593 | 612 | isPageShow: false, |
|---|
| 594 | 613 | loginBackFn: null, |
|---|
| 595 | 614 | errText: '', |
|---|
| .. | .. |
|---|
| 599 | 618 | isYueyangZone: false, |
|---|
| 600 | 619 | isOpen: false, // 默认收起,false收起/true展开 |
|---|
| 601 | 620 | currentIndex: -1, // 默认选中第一个【全部】 |
|---|
| 621 | + videoControls: true, // 专区活动视频是否显示海报+播放按钮 |
|---|
| 622 | + zoneVideoContext: '', // 活动视频播放上下文 |
|---|
| 602 | 623 | partitionList: [], |
|---|
| 603 | 624 | partitionProject: {}, |
|---|
| 604 | 625 | tagList: [], |
|---|
| .. | .. |
|---|
| 622 | 643 | stockEmpty: true, |
|---|
| 623 | 644 | urlOption: {}, |
|---|
| 624 | 645 | homeTop: '200', |
|---|
| 646 | + lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应 |
|---|
| 625 | 647 | hasNewPop: false, |
|---|
| 626 | 648 | leftCoupon: {}, |
|---|
| 627 | 649 | rightCoupon: {}, |
|---|
| .. | .. |
|---|
| 838 | 860 | } |
|---|
| 839 | 861 | }, |
|---|
| 840 | 862 | methods: { |
|---|
| 863 | + /** |
|---|
| 864 | + * 专区活动视频:点击海报播放按钮后播放 |
|---|
| 865 | + */ |
|---|
| 866 | + bindZoneVideoPlay() { |
|---|
| 867 | + if (!this.zoneVideoContext) { |
|---|
| 868 | + this.zoneVideoContext = uni.createVideoContext('zoneVideo', this); |
|---|
| 869 | + } |
|---|
| 870 | + this.$set(this, 'videoControls', false); |
|---|
| 871 | + this.zoneVideoContext.play(); |
|---|
| 872 | + }, |
|---|
| 873 | + zoneVideoPause() { }, |
|---|
| 841 | 874 | handleCouponRule() { |
|---|
| 842 | 875 | this.$refs.personalAndShareCouponRuleRef.show(this.info.ruleContentText) |
|---|
| 843 | 876 | }, |
|---|
| .. | .. |
|---|
| 1296 | 1329 | }) |
|---|
| 1297 | 1330 | }, |
|---|
| 1298 | 1331 | validAlert(data) { |
|---|
| 1332 | + // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动 |
|---|
| 1333 | + this.countdownToken++ |
|---|
| 1334 | + const token = this.countdownToken |
|---|
| 1299 | 1335 | const { |
|---|
| 1300 | 1336 | startTime, |
|---|
| 1301 | 1337 | expireTime |
|---|
| .. | .. |
|---|
| 1314 | 1350 | let minutes = startTimetamp.getMinutes() |
|---|
| 1315 | 1351 | minutes = minutes < 10 ? '0' + minutes : minutes; |
|---|
| 1316 | 1352 | |
|---|
| 1317 | | - this.countdownTimer(startTime.split('-').join('/'), 'start') |
|---|
| 1353 | + this.countdownTimer(startTime.split('-').join('/'), 'start', token) |
|---|
| 1318 | 1354 | this.startOrEnd = "后开启" |
|---|
| 1319 | 1355 | return |
|---|
| 1320 | | - } |
|---|
| 1321 | | - } |
|---|
| 1322 | | - if (expireTime) { |
|---|
| 1323 | | - const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime(); |
|---|
| 1324 | | - if (expireTimetamp < nowTimestamp) { |
|---|
| 1356 | + } |
|---|
| 1357 | + } |
|---|
| 1358 | + if (expireTime) { |
|---|
| 1359 | + const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime(); |
|---|
| 1360 | + if (expireTimetamp < nowTimestamp) { |
|---|
| 1325 | 1361 | return |
|---|
| 1326 | | - } |
|---|
| 1327 | | - this.countdownTimer(expireTime.split('-').join('/'), 'end') |
|---|
| 1362 | + } |
|---|
| 1363 | + this.countdownTimer(expireTime.split('-').join('/'), 'end', token) |
|---|
| 1328 | 1364 | this.startOrEnd = "后结束" |
|---|
| 1329 | 1365 | } |
|---|
| 1330 | 1366 | }, |
|---|
| .. | .. |
|---|
| 1446 | 1482 | this.$refs.popNewuserRef.show() |
|---|
| 1447 | 1483 | } |
|---|
| 1448 | 1484 | }, |
|---|
| 1485 | + // 预取抽奖banner真实宽高,计算出高度后再渲染,避免加载前被组件默认高度(225px)撑大 |
|---|
| 1486 | + setLotteryBannerSize(info) { |
|---|
| 1487 | + let that = this |
|---|
| 1488 | + that.lotteryBannerHeight = '' |
|---|
| 1489 | + if (!info || !info.isLottery || !info.lotteryBanner) return |
|---|
| 1490 | + uni.getImageInfo({ |
|---|
| 1491 | + src: info.lotteryBanner, |
|---|
| 1492 | + success: (img) => { |
|---|
| 1493 | + if (img.width > 0 && img.height > 0) { |
|---|
| 1494 | + that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx' |
|---|
| 1495 | + } |
|---|
| 1496 | + }, |
|---|
| 1497 | + fail: () => { } |
|---|
| 1498 | + }) |
|---|
| 1499 | + }, |
|---|
| 1449 | 1500 | getZoneDetail: function () { |
|---|
| 1450 | 1501 | let that = this; |
|---|
| 1451 | 1502 | let belong = this.$store.getters.belong; |
|---|
| .. | .. |
|---|
| 1453 | 1504 | console.log('专区详情入参::', params) |
|---|
| 1454 | 1505 | getZoneDetail(that.id, params).then(res => { |
|---|
| 1455 | 1506 | that.info = res.data; |
|---|
| 1507 | + that.setLotteryBannerSize(res.data); |
|---|
| 1456 | 1508 | that.updateZoneShareMenu(); |
|---|
| 1457 | 1509 | if (res.data.zoneType == 6) { |
|---|
| 1458 | 1510 | that.setYueyangZone() |
|---|
| .. | .. |
|---|
| 1462 | 1514 | that.homeTop = that.getHomeTop(0.4) |
|---|
| 1463 | 1515 | } |
|---|
| 1464 | 1516 | that.expireTime = []; |
|---|
| 1465 | | - that.expireTimeUnit = []; |
|---|
| 1517 | + that.countdownToken++; |
|---|
| 1466 | 1518 | that.where.page = 1; |
|---|
| 1467 | 1519 | that.getGoodList() |
|---|
| 1468 | 1520 | that.validAlert(res.data) |
|---|
| .. | .. |
|---|
| 1488 | 1540 | } |
|---|
| 1489 | 1541 | }); |
|---|
| 1490 | 1542 | }, |
|---|
| 1491 | | - countdownTimer(expireTime, type) { |
|---|
| 1543 | + countdownTimer(expireTime, type, token) { |
|---|
| 1492 | 1544 | if (!expireTime) return |
|---|
| 1545 | + if (token !== undefined && token !== this.countdownToken) return |
|---|
| 1493 | 1546 | let that = this; |
|---|
| 1494 | 1547 | // 结束时间的时间戳(需传入一个有效的日期对象或时间戳) |
|---|
| 1495 | 1548 | const endTimestamp = new Date(expireTime).getTime(); |
|---|
| .. | .. |
|---|
| 1501 | 1554 | if (type == 'end') { |
|---|
| 1502 | 1555 | if (diff <= 0) { |
|---|
| 1503 | 1556 | this.expireTime = [] |
|---|
| 1504 | | - this.expireTimeUnit = [] |
|---|
| 1505 | 1557 | return |
|---|
| 1506 | 1558 | } else { } |
|---|
| 1507 | 1559 | } else if (type == 'start') { |
|---|
| 1508 | 1560 | if (diff <= 0) { |
|---|
| 1509 | 1561 | this.expireTime = [] |
|---|
| 1510 | | - this.expireTimeUnit = [] |
|---|
| 1511 | 1562 | const expireTime2 = that.info.expireTime |
|---|
| 1512 | 1563 | if (expireTime2) { |
|---|
| 1513 | 1564 | const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime(); |
|---|
| 1514 | 1565 | if (expireTimetamp < nowTimestamp) { |
|---|
| 1515 | 1566 | return |
|---|
| 1516 | 1567 | } |
|---|
| 1517 | | - this.countdownTimer(expireTime2.split('-').join('/'), 'end') |
|---|
| 1568 | + this.countdownTimer(expireTime2.split('-').join('/'), 'end', token) |
|---|
| 1518 | 1569 | this.startOrEnd = "后结束" |
|---|
| 1519 | 1570 | } |
|---|
| 1520 | 1571 | return |
|---|
| 1521 | 1572 | } |
|---|
| 1522 | 1573 | } |
|---|
| 1574 | + const pad = num => (num < 10 ? '0' + num : String(num)) |
|---|
| 1523 | 1575 | const res = [] |
|---|
| 1524 | | - const unit = [] |
|---|
| 1525 | 1576 | const days = Math.floor(diff / (1000 * 60 * 60 * 24)) |
|---|
| 1526 | 1577 | diff %= (1000 * 60 * 60 * 24) |
|---|
| 1527 | | - if (days > 0) { |
|---|
| 1528 | | - res.push(days); |
|---|
| 1529 | | - unit.push('日') |
|---|
| 1530 | | - } |
|---|
| 1531 | 1578 | // 转换为小时、分钟、秒 |
|---|
| 1532 | 1579 | const hours = Math.floor(diff / (1000 * 60 * 60)); |
|---|
| 1533 | 1580 | diff %= (1000 * 60 * 60); // 剩余毫秒数 |
|---|
| 1534 | | - if (hours > 0) { |
|---|
| 1535 | | - res.push(hours < 10 ? '0' + hours : hours); |
|---|
| 1536 | | - unit.push('时') |
|---|
| 1537 | | - } |
|---|
| 1538 | 1581 | const minutes = Math.floor(diff / (1000 * 60)); |
|---|
| 1539 | | - if (minutes > 0) { |
|---|
| 1540 | | - res.push(minutes < 10 ? '0' + minutes : minutes); |
|---|
| 1541 | | - unit.push('分') |
|---|
| 1542 | | - } |
|---|
| 1543 | 1582 | diff %= (1000 * 60); // 剩余毫秒数 |
|---|
| 1544 | 1583 | const seconds = Math.floor(diff / 1000); |
|---|
| 1545 | | - if (seconds > 0) { |
|---|
| 1546 | | - res.push(seconds < 10 ? '0' + seconds : seconds); |
|---|
| 1547 | | - unit.push('秒') |
|---|
| 1584 | + // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定 |
|---|
| 1585 | + if (days > 0) { |
|---|
| 1586 | + res.push({ |
|---|
| 1587 | + digits: pad(days).split(''), |
|---|
| 1588 | + unit: '日' |
|---|
| 1589 | + }) |
|---|
| 1548 | 1590 | } |
|---|
| 1591 | + res.push({ |
|---|
| 1592 | + digits: pad(hours).split(''), |
|---|
| 1593 | + unit: '时' |
|---|
| 1594 | + }) |
|---|
| 1595 | + res.push({ |
|---|
| 1596 | + digits: pad(minutes).split(''), |
|---|
| 1597 | + unit: '分' |
|---|
| 1598 | + }) |
|---|
| 1599 | + res.push({ |
|---|
| 1600 | + digits: pad(seconds).split(''), |
|---|
| 1601 | + unit: '秒' |
|---|
| 1602 | + }) |
|---|
| 1549 | 1603 | this.expireTime = res |
|---|
| 1550 | | - this.expireTimeUnit = unit |
|---|
| 1551 | 1604 | if (this.isPageShow) { |
|---|
| 1552 | 1605 | setTimeout(() => { |
|---|
| 1553 | | - that.countdownTimer(expireTime, type) |
|---|
| 1606 | + that.countdownTimer(expireTime, type, token) |
|---|
| 1554 | 1607 | }, 1000) |
|---|
| 1555 | 1608 | } |
|---|
| 1556 | 1609 | }, |
|---|
| .. | .. |
|---|
| 1637 | 1690 | .lottery_banner { |
|---|
| 1638 | 1691 | margin: 15rpx auto; |
|---|
| 1639 | 1692 | width: 690rpx; |
|---|
| 1640 | | - height: 120rpx; |
|---|
| 1641 | 1693 | text-align: center; |
|---|
| 1642 | 1694 | } |
|---|
| 1643 | 1695 | |
|---|
| 1644 | 1696 | .lottery_bannerImg { |
|---|
| 1645 | 1697 | width: 690rpx; |
|---|
| 1646 | | - height: 120rpx; |
|---|
| 1647 | 1698 | } |
|---|
| 1648 | 1699 | |
|---|
| 1649 | 1700 | .tag-wrap-container { |
|---|
| .. | .. |
|---|
| 1869 | 1920 | } |
|---|
| 1870 | 1921 | } |
|---|
| 1871 | 1922 | |
|---|
| 1923 | +.rich-content { |
|---|
| 1924 | + padding: 24rpx 30rpx; |
|---|
| 1925 | + background-color: #fff; |
|---|
| 1926 | +} |
|---|
| 1927 | + |
|---|
| 1928 | +.video-wrap { |
|---|
| 1929 | + position: relative; |
|---|
| 1930 | + width: 100%; |
|---|
| 1931 | + height: 750rpx; |
|---|
| 1932 | + background-color: #000; |
|---|
| 1933 | +} |
|---|
| 1934 | + |
|---|
| 1935 | +.video-wrap .video-poster { |
|---|
| 1936 | + position: absolute; |
|---|
| 1937 | + top: 0; |
|---|
| 1938 | + left: 0; |
|---|
| 1939 | + width: 100%; |
|---|
| 1940 | + height: 750rpx; |
|---|
| 1941 | + z-index: 9; |
|---|
| 1942 | +} |
|---|
| 1943 | + |
|---|
| 1944 | +.video-wrap .video-poster .image { |
|---|
| 1945 | + width: 100%; |
|---|
| 1946 | + height: 100%; |
|---|
| 1947 | +} |
|---|
| 1948 | + |
|---|
| 1949 | +.video-wrap .video-stop { |
|---|
| 1950 | + position: absolute; |
|---|
| 1951 | + top: 50%; |
|---|
| 1952 | + left: 50%; |
|---|
| 1953 | + width: 136rpx; |
|---|
| 1954 | + height: 136rpx; |
|---|
| 1955 | + margin-top: -68rpx; |
|---|
| 1956 | + margin-left: -68rpx; |
|---|
| 1957 | + z-index: 9; |
|---|
| 1958 | +} |
|---|
| 1959 | + |
|---|
| 1960 | +.video-wrap .video-stop .image { |
|---|
| 1961 | + width: 100%; |
|---|
| 1962 | + height: 100%; |
|---|
| 1963 | +} |
|---|
| 1964 | + |
|---|
| 1872 | 1965 | .toolbarList { |
|---|
| 1873 | 1966 | width: 750rpx; |
|---|
| 1874 | 1967 | position: -webkit-sticky; |
|---|
| .. | .. |
|---|
| 2085 | 2178 | padding: 15rpx; |
|---|
| 2086 | 2179 | padding-left: 30rpx; |
|---|
| 2087 | 2180 | color: #979797; |
|---|
| 2181 | + font-size: 26rpx; |
|---|
| 2088 | 2182 | |
|---|
| 2089 | 2183 | .num { |
|---|
| 2184 | + display: inline-block; |
|---|
| 2090 | 2185 | color: #000000; |
|---|
| 2091 | 2186 | background: #FFE20E; |
|---|
| 2092 | | - padding: 0 10rpx; |
|---|
| 2187 | + padding: 0 6rpx; |
|---|
| 2188 | + margin: 0 4rpx; |
|---|
| 2189 | + vertical-align: middle; |
|---|
| 2190 | + } |
|---|
| 2191 | + |
|---|
| 2192 | + /* 每个数字固定宽度,避免倒计时跳动时宽度忽长忽短 */ |
|---|
| 2193 | + .digit { |
|---|
| 2194 | + display: inline-block; |
|---|
| 2195 | + width: 19rpx; |
|---|
| 2196 | + text-align: center; |
|---|
| 2093 | 2197 | } |
|---|
| 2094 | 2198 | } |
|---|
| 2095 | 2199 | </style> |
|---|