Jacob
1 天以前 433c5ab2fd2a6fd48fb931b5070b742503a99a6b
pages/zone/index.vue
....@@ -14,16 +14,38 @@
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>
2529 <view class="head_img">
2630 <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>
2749 </view>
2850 <view class="tag-wrap-container" :style="'top:' + (marTop) + 'px;'" v-if="info.zoneType == 7">
2951 <view class="tag-wrap">
....@@ -67,9 +89,10 @@
6789 </view>
6890 </view>
6991 </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">
92
+ <view @click="goLottery" class="lottery_banner"
93
+ v-if="info && info.isLottery && info.lotteryBanner && lotteryBannerReady">
94
+ <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix"
95
+ :style="{ height: lotteryBannerHeight }">
7396 </image>
7497 </view>
7598 <view class="tag-img-container" v-if="info.zoneType == 7">
....@@ -495,7 +518,7 @@
495518
496519 <script>
497520 import {
498
- HTTP_REQUEST_URL
521
+ WEB_ACTIVITY_BASE
499522 } from '@/config/app';
500523 import {
501524 mapGetters
....@@ -586,7 +609,7 @@
586609 showMenu: false,
587610 selectedMenuArr: [],
588611 expireTime: [],
589
- expireTimeUnit: [],
612
+ countdownToken: 0,
590613 isPageShow: false,
591614 loginBackFn: null,
592615 errText: '',
....@@ -596,6 +619,8 @@
596619 isYueyangZone: false,
597620 isOpen: false, // 默认收起,false收起/true展开
598621 currentIndex: -1, // 默认选中第一个【全部】
622
+ videoControls: true, // 专区活动视频是否显示海报+播放按钮
623
+ zoneVideoContext: '', // 活动视频播放上下文
599624 partitionList: [],
600625 partitionProject: {},
601626 tagList: [],
....@@ -619,6 +644,8 @@
619644 stockEmpty: true,
620645 urlOption: {},
621646 homeTop: '200',
647
+ lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应
648
+ lotteryBannerReady: false, //是否已拿到banner尺寸(或已确认拿不到),未就绪前不渲染,避免首帧撑高
622649 hasNewPop: false,
623650 leftCoupon: {},
624651 rightCoupon: {},
....@@ -835,6 +862,17 @@
835862 }
836863 },
837864 methods: {
865
+ /**
866
+ * 专区活动视频:点击海报播放按钮后播放
867
+ */
868
+ bindZoneVideoPlay() {
869
+ if (!this.zoneVideoContext) {
870
+ this.zoneVideoContext = uni.createVideoContext('zoneVideo', this);
871
+ }
872
+ this.$set(this, 'videoControls', false);
873
+ this.zoneVideoContext.play();
874
+ },
875
+ zoneVideoPause() { },
838876 handleCouponRule() {
839877 this.$refs.personalAndShareCouponRuleRef.show(this.info.ruleContentText)
840878 },
....@@ -1195,6 +1233,11 @@
11951233 // that.myCareBean = res2.data.totalCareBeans;
11961234 });
11971235 },
1236
+ goDetail() {
1237
+ uni.navigateTo({
1238
+ url: '/pages/consumption/index?zoneId=' + this.info.id
1239
+ })
1240
+ },
11981241 goLottery() {
11991242 let that = this;
12001243 var data = {
....@@ -1206,11 +1249,7 @@
12061249 this.addTrack('yy_marketPageClick', data);
12071250
12081251 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
- }
1252
+ let webUrl = `${WEB_ACTIVITY_BASE}/acmall_lottery/index.html`
12141253 webUrl += '?token=' +
12151254 that.$store.getters.token + '&unionId=' + that.$store.getters.unionId + '&mdayId=' + that.info
12161255 .mdayId
....@@ -1292,6 +1331,9 @@
12921331 })
12931332 },
12941333 validAlert(data) {
1334
+ // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动
1335
+ this.countdownToken++
1336
+ const token = this.countdownToken
12951337 const {
12961338 startTime,
12971339 expireTime
....@@ -1310,17 +1352,17 @@
13101352 let minutes = startTimetamp.getMinutes()
13111353 minutes = minutes < 10 ? '0' + minutes : minutes;
13121354
1313
- this.countdownTimer(startTime.split('-').join('/'), 'start')
1355
+ this.countdownTimer(startTime.split('-').join('/'), 'start', token)
13141356 this.startOrEnd = "后开启"
13151357 return
1316
- }
1317
- }
1318
- if (expireTime) {
1319
- const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1320
- if (expireTimetamp < nowTimestamp) {
1358
+ }
1359
+ }
1360
+ if (expireTime) {
1361
+ const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1362
+ if (expireTimetamp < nowTimestamp) {
13211363 return
1322
- }
1323
- this.countdownTimer(expireTime.split('-').join('/'), 'end')
1364
+ }
1365
+ this.countdownTimer(expireTime.split('-').join('/'), 'end', token)
13241366 this.startOrEnd = "后结束"
13251367 }
13261368 },
....@@ -1442,6 +1484,29 @@
14421484 this.$refs.popNewuserRef.show()
14431485 }
14441486 },
1487
+ // 预取抽奖banner真实宽高,计算出高度后再渲染,避免加载前被组件默认高度(225px)撑大
1488
+ setLotteryBannerSize(info) {
1489
+ let that = this
1490
+ that.lotteryBannerHeight = ''
1491
+ that.lotteryBannerReady = false
1492
+ if (!info || !info.isLottery || !info.lotteryBanner) {
1493
+ that.lotteryBannerReady = true
1494
+ return
1495
+ }
1496
+ uni.getImageInfo({
1497
+ src: info.lotteryBanner,
1498
+ success: (img) => {
1499
+ if (img.width > 0 && img.height > 0) {
1500
+ that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx'
1501
+ }
1502
+ that.lotteryBannerReady = true
1503
+ },
1504
+ fail: (err) => {
1505
+ console.warn('抽奖banner尺寸预取失败,回退为自适应', err)
1506
+ that.lotteryBannerReady = true
1507
+ }
1508
+ })
1509
+ },
14451510 getZoneDetail: function () {
14461511 let that = this;
14471512 let belong = this.$store.getters.belong;
....@@ -1449,6 +1514,7 @@
14491514 console.log('专区详情入参::', params)
14501515 getZoneDetail(that.id, params).then(res => {
14511516 that.info = res.data;
1517
+ that.setLotteryBannerSize(res.data);
14521518 that.updateZoneShareMenu();
14531519 if (res.data.zoneType == 6) {
14541520 that.setYueyangZone()
....@@ -1458,7 +1524,7 @@
14581524 that.homeTop = that.getHomeTop(0.4)
14591525 }
14601526 that.expireTime = [];
1461
- that.expireTimeUnit = [];
1527
+ that.countdownToken++;
14621528 that.where.page = 1;
14631529 that.getGoodList()
14641530 that.validAlert(res.data)
....@@ -1484,8 +1550,9 @@
14841550 }
14851551 });
14861552 },
1487
- countdownTimer(expireTime, type) {
1553
+ countdownTimer(expireTime, type, token) {
14881554 if (!expireTime) return
1555
+ if (token !== undefined && token !== this.countdownToken) return
14891556 let that = this;
14901557 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳)
14911558 const endTimestamp = new Date(expireTime).getTime();
....@@ -1497,56 +1564,56 @@
14971564 if (type == 'end') {
14981565 if (diff <= 0) {
14991566 this.expireTime = []
1500
- this.expireTimeUnit = []
15011567 return
15021568 } else { }
15031569 } else if (type == 'start') {
15041570 if (diff <= 0) {
15051571 this.expireTime = []
1506
- this.expireTimeUnit = []
15071572 const expireTime2 = that.info.expireTime
15081573 if (expireTime2) {
15091574 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime();
15101575 if (expireTimetamp < nowTimestamp) {
15111576 return
15121577 }
1513
- this.countdownTimer(expireTime2.split('-').join('/'), 'end')
1578
+ this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)
15141579 this.startOrEnd = "后结束"
15151580 }
15161581 return
15171582 }
15181583 }
1584
+ const pad = num => (num < 10 ? '0' + num : String(num))
15191585 const res = []
1520
- const unit = []
15211586 const days = Math.floor(diff / (1000 * 60 * 60 * 24))
15221587 diff %= (1000 * 60 * 60 * 24)
1523
- if (days > 0) {
1524
- res.push(days);
1525
- unit.push('日')
1526
- }
15271588 // 转换为小时、分钟、秒
15281589 const hours = Math.floor(diff / (1000 * 60 * 60));
15291590 diff %= (1000 * 60 * 60); // 剩余毫秒数
1530
- if (hours > 0) {
1531
- res.push(hours < 10 ? '0' + hours : hours);
1532
- unit.push('时')
1533
- }
15341591 const minutes = Math.floor(diff / (1000 * 60));
1535
- if (minutes > 0) {
1536
- res.push(minutes < 10 ? '0' + minutes : minutes);
1537
- unit.push('分')
1538
- }
15391592 diff %= (1000 * 60); // 剩余毫秒数
15401593 const seconds = Math.floor(diff / 1000);
1541
- if (seconds > 0) {
1542
- res.push(seconds < 10 ? '0' + seconds : seconds);
1543
- unit.push('秒')
1594
+ // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定
1595
+ if (days > 0) {
1596
+ res.push({
1597
+ digits: pad(days).split(''),
1598
+ unit: '日'
1599
+ })
15441600 }
1601
+ res.push({
1602
+ digits: pad(hours).split(''),
1603
+ unit: '时'
1604
+ })
1605
+ res.push({
1606
+ digits: pad(minutes).split(''),
1607
+ unit: '分'
1608
+ })
1609
+ res.push({
1610
+ digits: pad(seconds).split(''),
1611
+ unit: '秒'
1612
+ })
15451613 this.expireTime = res
1546
- this.expireTimeUnit = unit
15471614 if (this.isPageShow) {
15481615 setTimeout(() => {
1549
- that.countdownTimer(expireTime, type)
1616
+ that.countdownTimer(expireTime, type, token)
15501617 }, 1000)
15511618 }
15521619 },
....@@ -1633,13 +1700,11 @@
16331700 .lottery_banner {
16341701 margin: 15rpx auto;
16351702 width: 690rpx;
1636
- height: 120rpx;
16371703 text-align: center;
16381704 }
16391705
16401706 .lottery_bannerImg {
16411707 width: 690rpx;
1642
- height: 120rpx;
16431708 }
16441709
16451710 .tag-wrap-container {
....@@ -1840,6 +1905,21 @@
18401905 transform: translate(0, -50%);
18411906 }
18421907
1908
+.detail-btn {
1909
+ border: 2rpx solid #fff;
1910
+ border-top-left-radius: 20rpx;
1911
+ border-bottom-left-radius: 20rpx;
1912
+ padding: 10rpx;
1913
+ background-color: #daf2b2;
1914
+ color: #1e984f;
1915
+ width: 50rpx;
1916
+ position: fixed;
1917
+ top: 200rpx;
1918
+ right: 0rpx;
1919
+ line-height: 1rem;
1920
+ z-index: 99;
1921
+}
1922
+
18431923 .head_img {
18441924 width: 750rpx;
18451925 height: 422rpx;
....@@ -1848,6 +1928,48 @@
18481928 width: 750rpx;
18491929 height: 422rpx;
18501930 }
1931
+}
1932
+
1933
+.rich-content {
1934
+ padding: 24rpx 30rpx;
1935
+ background-color: #fff;
1936
+}
1937
+
1938
+.video-wrap {
1939
+ position: relative;
1940
+ width: 100%;
1941
+ height: 750rpx;
1942
+ background-color: #000;
1943
+}
1944
+
1945
+.video-wrap .video-poster {
1946
+ position: absolute;
1947
+ top: 0;
1948
+ left: 0;
1949
+ width: 100%;
1950
+ height: 750rpx;
1951
+ z-index: 9;
1952
+}
1953
+
1954
+.video-wrap .video-poster .image {
1955
+ width: 100%;
1956
+ height: 100%;
1957
+}
1958
+
1959
+.video-wrap .video-stop {
1960
+ position: absolute;
1961
+ top: 50%;
1962
+ left: 50%;
1963
+ width: 136rpx;
1964
+ height: 136rpx;
1965
+ margin-top: -68rpx;
1966
+ margin-left: -68rpx;
1967
+ z-index: 9;
1968
+}
1969
+
1970
+.video-wrap .video-stop .image {
1971
+ width: 100%;
1972
+ height: 100%;
18511973 }
18521974
18531975 .toolbarList {
....@@ -2066,11 +2188,22 @@
20662188 padding: 15rpx;
20672189 padding-left: 30rpx;
20682190 color: #979797;
2191
+ font-size: 26rpx;
20692192
20702193 .num {
2194
+ display: inline-block;
20712195 color: #000000;
20722196 background: #FFE20E;
2073
- padding: 0 10rpx;
2197
+ padding: 0 6rpx;
2198
+ margin: 0 4rpx;
2199
+ vertical-align: middle;
2200
+ }
2201
+
2202
+ /* 每个数字固定宽度,避免倒计时跳动时宽度忽长忽短 */
2203
+ .digit {
2204
+ display: inline-block;
2205
+ width: 19rpx;
2206
+ text-align: center;
20742207 }
20752208 }
20762209 </style>