Jacob
4 天以前 f564a64d3c99b4d300e54e038446227a440bba48
pages/zone/index.vue
....@@ -20,13 +20,32 @@
2020 <view v-else>
2121 <view class="expireTime" v-if="expireTime && expireTime.length">
2222 <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 }}
2526 </text>
2627 <text>{{ startOrEnd }}</text>
2728 </view>
2829 <view class="head_img">
2930 <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>
3049 </view>
3150 <view class="tag-wrap-container" :style="'top:' + (marTop) + 'px;'" v-if="info.zoneType == 7">
3251 <view class="tag-wrap">
....@@ -70,9 +89,8 @@
7089 </view>
7190 </view>
7291 </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">
7694 </image>
7795 </view>
7896 <view class="tag-img-container" v-if="info.zoneType == 7">
....@@ -589,7 +607,7 @@
589607 showMenu: false,
590608 selectedMenuArr: [],
591609 expireTime: [],
592
- expireTimeUnit: [],
610
+ countdownToken: 0,
593611 isPageShow: false,
594612 loginBackFn: null,
595613 errText: '',
....@@ -599,6 +617,8 @@
599617 isYueyangZone: false,
600618 isOpen: false, // 默认收起,false收起/true展开
601619 currentIndex: -1, // 默认选中第一个【全部】
620
+ videoControls: true, // 专区活动视频是否显示海报+播放按钮
621
+ zoneVideoContext: '', // 活动视频播放上下文
602622 partitionList: [],
603623 partitionProject: {},
604624 tagList: [],
....@@ -838,6 +858,17 @@
838858 }
839859 },
840860 methods: {
861
+ /**
862
+ * 专区活动视频:点击海报播放按钮后播放
863
+ */
864
+ bindZoneVideoPlay() {
865
+ if (!this.zoneVideoContext) {
866
+ this.zoneVideoContext = uni.createVideoContext('zoneVideo', this);
867
+ }
868
+ this.$set(this, 'videoControls', false);
869
+ this.zoneVideoContext.play();
870
+ },
871
+ zoneVideoPause() { },
841872 handleCouponRule() {
842873 this.$refs.personalAndShareCouponRuleRef.show(this.info.ruleContentText)
843874 },
....@@ -1296,6 +1327,9 @@
12961327 })
12971328 },
12981329 validAlert(data) {
1330
+ // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动
1331
+ this.countdownToken++
1332
+ const token = this.countdownToken
12991333 const {
13001334 startTime,
13011335 expireTime
....@@ -1314,17 +1348,17 @@
13141348 let minutes = startTimetamp.getMinutes()
13151349 minutes = minutes < 10 ? '0' + minutes : minutes;
13161350
1317
- this.countdownTimer(startTime.split('-').join('/'), 'start')
1351
+ this.countdownTimer(startTime.split('-').join('/'), 'start', token)
13181352 this.startOrEnd = "后开启"
13191353 return
1320
- }
1321
- }
1322
- if (expireTime) {
1323
- const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1324
- if (expireTimetamp < nowTimestamp) {
1354
+ }
1355
+ }
1356
+ if (expireTime) {
1357
+ const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1358
+ if (expireTimetamp < nowTimestamp) {
13251359 return
1326
- }
1327
- this.countdownTimer(expireTime.split('-').join('/'), 'end')
1360
+ }
1361
+ this.countdownTimer(expireTime.split('-').join('/'), 'end', token)
13281362 this.startOrEnd = "后结束"
13291363 }
13301364 },
....@@ -1453,6 +1487,7 @@
14531487 console.log('专区详情入参::', params)
14541488 getZoneDetail(that.id, params).then(res => {
14551489 that.info = res.data;
1490
+ //that.info.zoneType=8;
14561491 that.updateZoneShareMenu();
14571492 if (res.data.zoneType == 6) {
14581493 that.setYueyangZone()
....@@ -1462,7 +1497,7 @@
14621497 that.homeTop = that.getHomeTop(0.4)
14631498 }
14641499 that.expireTime = [];
1465
- that.expireTimeUnit = [];
1500
+ that.countdownToken++;
14661501 that.where.page = 1;
14671502 that.getGoodList()
14681503 that.validAlert(res.data)
....@@ -1488,8 +1523,9 @@
14881523 }
14891524 });
14901525 },
1491
- countdownTimer(expireTime, type) {
1526
+ countdownTimer(expireTime, type, token) {
14921527 if (!expireTime) return
1528
+ if (token !== undefined && token !== this.countdownToken) return
14931529 let that = this;
14941530 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳)
14951531 const endTimestamp = new Date(expireTime).getTime();
....@@ -1501,56 +1537,56 @@
15011537 if (type == 'end') {
15021538 if (diff <= 0) {
15031539 this.expireTime = []
1504
- this.expireTimeUnit = []
15051540 return
15061541 } else { }
15071542 } else if (type == 'start') {
15081543 if (diff <= 0) {
15091544 this.expireTime = []
1510
- this.expireTimeUnit = []
15111545 const expireTime2 = that.info.expireTime
15121546 if (expireTime2) {
15131547 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime();
15141548 if (expireTimetamp < nowTimestamp) {
15151549 return
15161550 }
1517
- this.countdownTimer(expireTime2.split('-').join('/'), 'end')
1551
+ this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)
15181552 this.startOrEnd = "后结束"
15191553 }
15201554 return
15211555 }
15221556 }
1557
+ const pad = num => (num < 10 ? '0' + num : String(num))
15231558 const res = []
1524
- const unit = []
15251559 const days = Math.floor(diff / (1000 * 60 * 60 * 24))
15261560 diff %= (1000 * 60 * 60 * 24)
1527
- if (days > 0) {
1528
- res.push(days);
1529
- unit.push('日')
1530
- }
15311561 // 转换为小时、分钟、秒
15321562 const hours = Math.floor(diff / (1000 * 60 * 60));
15331563 diff %= (1000 * 60 * 60); // 剩余毫秒数
1534
- if (hours > 0) {
1535
- res.push(hours < 10 ? '0' + hours : hours);
1536
- unit.push('时')
1537
- }
15381564 const minutes = Math.floor(diff / (1000 * 60));
1539
- if (minutes > 0) {
1540
- res.push(minutes < 10 ? '0' + minutes : minutes);
1541
- unit.push('分')
1542
- }
15431565 diff %= (1000 * 60); // 剩余毫秒数
15441566 const seconds = Math.floor(diff / 1000);
1545
- if (seconds > 0) {
1546
- res.push(seconds < 10 ? '0' + seconds : seconds);
1547
- unit.push('秒')
1567
+ // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定
1568
+ if (days > 0) {
1569
+ res.push({
1570
+ digits: pad(days).split(''),
1571
+ unit: '日'
1572
+ })
15481573 }
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
+ })
15491586 this.expireTime = res
1550
- this.expireTimeUnit = unit
15511587 if (this.isPageShow) {
15521588 setTimeout(() => {
1553
- that.countdownTimer(expireTime, type)
1589
+ that.countdownTimer(expireTime, type, token)
15541590 }, 1000)
15551591 }
15561592 },
....@@ -1637,13 +1673,11 @@
16371673 .lottery_banner {
16381674 margin: 15rpx auto;
16391675 width: 690rpx;
1640
- height: 120rpx;
16411676 text-align: center;
16421677 }
16431678
16441679 .lottery_bannerImg {
16451680 width: 690rpx;
1646
- height: 120rpx;
16471681 }
16481682
16491683 .tag-wrap-container {
....@@ -1869,6 +1903,48 @@
18691903 }
18701904 }
18711905
1906
+.rich-content {
1907
+ padding: 24rpx 30rpx;
1908
+ background-color: #fff;
1909
+}
1910
+
1911
+.video-wrap {
1912
+ position: relative;
1913
+ width: 100%;
1914
+ height: 750rpx;
1915
+ background-color: #000;
1916
+}
1917
+
1918
+.video-wrap .video-poster {
1919
+ position: absolute;
1920
+ top: 0;
1921
+ left: 0;
1922
+ width: 100%;
1923
+ height: 750rpx;
1924
+ z-index: 9;
1925
+}
1926
+
1927
+.video-wrap .video-poster .image {
1928
+ width: 100%;
1929
+ height: 100%;
1930
+}
1931
+
1932
+.video-wrap .video-stop {
1933
+ position: absolute;
1934
+ top: 50%;
1935
+ left: 50%;
1936
+ width: 136rpx;
1937
+ height: 136rpx;
1938
+ margin-top: -68rpx;
1939
+ margin-left: -68rpx;
1940
+ z-index: 9;
1941
+}
1942
+
1943
+.video-wrap .video-stop .image {
1944
+ width: 100%;
1945
+ height: 100%;
1946
+}
1947
+
18721948 .toolbarList {
18731949 width: 750rpx;
18741950 position: -webkit-sticky;
....@@ -2085,11 +2161,22 @@
20852161 padding: 15rpx;
20862162 padding-left: 30rpx;
20872163 color: #979797;
2164
+ font-size: 26rpx;
20882165
20892166 .num {
2167
+ display: inline-block;
20902168 color: #000000;
20912169 background: #FFE20E;
2092
- padding: 0 10rpx;
2170
+ padding: 0 6rpx;
2171
+ margin: 0 4rpx;
2172
+ vertical-align: middle;
2173
+ }
2174
+
2175
+ /* 每个数字固定宽度,避免倒计时跳动时宽度忽长忽短 */
2176
+ .digit {
2177
+ display: inline-block;
2178
+ width: 19rpx;
2179
+ text-align: center;
20932180 }
20942181 }
20952182 </style>