Jacob
1 天以前 24b8f2afa92ce7bbe490185ecbab869c460b798b
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,9 @@
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" v-if="info && info.isLottery && info.lotteryBanner">
93
+ <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix"
94
+ :style="{ height: lotteryBannerHeight }">
7395 </image>
7496 </view>
7597 <view class="tag-img-container" v-if="info.zoneType == 7">
....@@ -586,7 +608,7 @@
586608 showMenu: false,
587609 selectedMenuArr: [],
588610 expireTime: [],
589
- expireTimeUnit: [],
611
+ countdownToken: 0,
590612 isPageShow: false,
591613 loginBackFn: null,
592614 errText: '',
....@@ -596,6 +618,8 @@
596618 isYueyangZone: false,
597619 isOpen: false, // 默认收起,false收起/true展开
598620 currentIndex: -1, // 默认选中第一个【全部】
621
+ videoControls: true, // 专区活动视频是否显示海报+播放按钮
622
+ zoneVideoContext: '', // 活动视频播放上下文
599623 partitionList: [],
600624 partitionProject: {},
601625 tagList: [],
....@@ -619,6 +643,7 @@
619643 stockEmpty: true,
620644 urlOption: {},
621645 homeTop: '200',
646
+ lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应
622647 hasNewPop: false,
623648 leftCoupon: {},
624649 rightCoupon: {},
....@@ -835,6 +860,17 @@
835860 }
836861 },
837862 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() { },
838874 handleCouponRule() {
839875 this.$refs.personalAndShareCouponRuleRef.show(this.info.ruleContentText)
840876 },
....@@ -1195,6 +1231,11 @@
11951231 // that.myCareBean = res2.data.totalCareBeans;
11961232 });
11971233 },
1234
+ goDetail() {
1235
+ uni.navigateTo({
1236
+ url: '/pages/consumption/index?zoneId=' + this.info.id
1237
+ })
1238
+ },
11981239 goLottery() {
11991240 let that = this;
12001241 var data = {
....@@ -1288,6 +1329,9 @@
12881329 })
12891330 },
12901331 validAlert(data) {
1332
+ // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动
1333
+ this.countdownToken++
1334
+ const token = this.countdownToken
12911335 const {
12921336 startTime,
12931337 expireTime
....@@ -1306,17 +1350,17 @@
13061350 let minutes = startTimetamp.getMinutes()
13071351 minutes = minutes < 10 ? '0' + minutes : minutes;
13081352
1309
- this.countdownTimer(startTime.split('-').join('/'), 'start')
1353
+ this.countdownTimer(startTime.split('-').join('/'), 'start', token)
13101354 this.startOrEnd = "后开启"
13111355 return
1312
- }
1313
- }
1314
- if (expireTime) {
1315
- const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1316
- if (expireTimetamp < nowTimestamp) {
1356
+ }
1357
+ }
1358
+ if (expireTime) {
1359
+ const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1360
+ if (expireTimetamp < nowTimestamp) {
13171361 return
1318
- }
1319
- this.countdownTimer(expireTime.split('-').join('/'), 'end')
1362
+ }
1363
+ this.countdownTimer(expireTime.split('-').join('/'), 'end', token)
13201364 this.startOrEnd = "后结束"
13211365 }
13221366 },
....@@ -1438,6 +1482,21 @@
14381482 this.$refs.popNewuserRef.show()
14391483 }
14401484 },
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
+ },
14411500 getZoneDetail: function () {
14421501 let that = this;
14431502 let belong = this.$store.getters.belong;
....@@ -1445,6 +1504,7 @@
14451504 console.log('专区详情入参::', params)
14461505 getZoneDetail(that.id, params).then(res => {
14471506 that.info = res.data;
1507
+ that.setLotteryBannerSize(res.data);
14481508 that.updateZoneShareMenu();
14491509 if (res.data.zoneType == 6) {
14501510 that.setYueyangZone()
....@@ -1454,7 +1514,7 @@
14541514 that.homeTop = that.getHomeTop(0.4)
14551515 }
14561516 that.expireTime = [];
1457
- that.expireTimeUnit = [];
1517
+ that.countdownToken++;
14581518 that.where.page = 1;
14591519 that.getGoodList()
14601520 that.validAlert(res.data)
....@@ -1480,8 +1540,9 @@
14801540 }
14811541 });
14821542 },
1483
- countdownTimer(expireTime, type) {
1543
+ countdownTimer(expireTime, type, token) {
14841544 if (!expireTime) return
1545
+ if (token !== undefined && token !== this.countdownToken) return
14851546 let that = this;
14861547 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳)
14871548 const endTimestamp = new Date(expireTime).getTime();
....@@ -1493,56 +1554,56 @@
14931554 if (type == 'end') {
14941555 if (diff <= 0) {
14951556 this.expireTime = []
1496
- this.expireTimeUnit = []
14971557 return
14981558 } else { }
14991559 } else if (type == 'start') {
15001560 if (diff <= 0) {
15011561 this.expireTime = []
1502
- this.expireTimeUnit = []
15031562 const expireTime2 = that.info.expireTime
15041563 if (expireTime2) {
15051564 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime();
15061565 if (expireTimetamp < nowTimestamp) {
15071566 return
15081567 }
1509
- this.countdownTimer(expireTime2.split('-').join('/'), 'end')
1568
+ this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)
15101569 this.startOrEnd = "后结束"
15111570 }
15121571 return
15131572 }
15141573 }
1574
+ const pad = num => (num < 10 ? '0' + num : String(num))
15151575 const res = []
1516
- const unit = []
15171576 const days = Math.floor(diff / (1000 * 60 * 60 * 24))
15181577 diff %= (1000 * 60 * 60 * 24)
1519
- if (days > 0) {
1520
- res.push(days);
1521
- unit.push('日')
1522
- }
15231578 // 转换为小时、分钟、秒
15241579 const hours = Math.floor(diff / (1000 * 60 * 60));
15251580 diff %= (1000 * 60 * 60); // 剩余毫秒数
1526
- if (hours > 0) {
1527
- res.push(hours < 10 ? '0' + hours : hours);
1528
- unit.push('时')
1529
- }
15301581 const minutes = Math.floor(diff / (1000 * 60));
1531
- if (minutes > 0) {
1532
- res.push(minutes < 10 ? '0' + minutes : minutes);
1533
- unit.push('分')
1534
- }
15351582 diff %= (1000 * 60); // 剩余毫秒数
15361583 const seconds = Math.floor(diff / 1000);
1537
- if (seconds > 0) {
1538
- res.push(seconds < 10 ? '0' + seconds : seconds);
1539
- unit.push('秒')
1584
+ // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定
1585
+ if (days > 0) {
1586
+ res.push({
1587
+ digits: pad(days).split(''),
1588
+ unit: '日'
1589
+ })
15401590 }
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
+ })
15411603 this.expireTime = res
1542
- this.expireTimeUnit = unit
15431604 if (this.isPageShow) {
15441605 setTimeout(() => {
1545
- that.countdownTimer(expireTime, type)
1606
+ that.countdownTimer(expireTime, type, token)
15461607 }, 1000)
15471608 }
15481609 },
....@@ -1629,13 +1690,11 @@
16291690 .lottery_banner {
16301691 margin: 15rpx auto;
16311692 width: 690rpx;
1632
- height: 120rpx;
16331693 text-align: center;
16341694 }
16351695
16361696 .lottery_bannerImg {
16371697 width: 690rpx;
1638
- height: 120rpx;
16391698 }
16401699
16411700 .tag-wrap-container {
....@@ -1836,6 +1895,21 @@
18361895 transform: translate(0, -50%);
18371896 }
18381897
1898
+.detail-btn {
1899
+ border: 2rpx solid #fff;
1900
+ border-top-left-radius: 20rpx;
1901
+ border-bottom-left-radius: 20rpx;
1902
+ padding: 10rpx;
1903
+ background-color: #daf2b2;
1904
+ color: #1e984f;
1905
+ width: 50rpx;
1906
+ position: fixed;
1907
+ top: 200rpx;
1908
+ right: 0rpx;
1909
+ line-height: 1rem;
1910
+ z-index: 99;
1911
+}
1912
+
18391913 .head_img {
18401914 width: 750rpx;
18411915 height: 422rpx;
....@@ -1844,6 +1918,48 @@
18441918 width: 750rpx;
18451919 height: 422rpx;
18461920 }
1921
+}
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%;
18471963 }
18481964
18491965 .toolbarList {
....@@ -2062,11 +2178,22 @@
20622178 padding: 15rpx;
20632179 padding-left: 30rpx;
20642180 color: #979797;
2181
+ font-size: 26rpx;
20652182
20662183 .num {
2184
+ display: inline-block;
20672185 color: #000000;
20682186 background: #FFE20E;
2069
- 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;
20702197 }
20712198 }
20722199 </style>