Jacob
1 天以前 24b8f2afa92ce7bbe490185ecbab869c460b798b
pages/zone/index.vue
....@@ -14,11 +14,15 @@
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>
....@@ -85,9 +89,9 @@
8589 </view>
8690 </view>
8791 </view>
88
- <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery">
89
- <image class="lottery_bannerImg"
90
- 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 }">
9195 </image>
9296 </view>
9397 <view class="tag-img-container" v-if="info.zoneType == 7">
....@@ -513,7 +517,7 @@
513517
514518 <script>
515519 import {
516
- HTTP_REQUEST_URL
520
+ WEB_ACTIVITY_BASE
517521 } from '@/config/app';
518522 import {
519523 mapGetters
....@@ -604,7 +608,7 @@
604608 showMenu: false,
605609 selectedMenuArr: [],
606610 expireTime: [],
607
- expireTimeUnit: [],
611
+ countdownToken: 0,
608612 isPageShow: false,
609613 loginBackFn: null,
610614 errText: '',
....@@ -639,6 +643,7 @@
639643 stockEmpty: true,
640644 urlOption: {},
641645 homeTop: '200',
646
+ lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应
642647 hasNewPop: false,
643648 leftCoupon: {},
644649 rightCoupon: {},
....@@ -1226,6 +1231,11 @@
12261231 // that.myCareBean = res2.data.totalCareBeans;
12271232 });
12281233 },
1234
+ goDetail() {
1235
+ uni.navigateTo({
1236
+ url: '/pages/consumption/index?zoneId=' + this.info.id
1237
+ })
1238
+ },
12291239 goLottery() {
12301240 let that = this;
12311241 var data = {
....@@ -1237,11 +1247,7 @@
12371247 this.addTrack('yy_marketPageClick', data);
12381248
12391249 function go() {
1240
- let webUrl = 'https://ossacmall.bluedeer.com.cn/acmall_lottery/index.html'
1241
- if (HTTP_REQUEST_URL.indexOf('tohours') > 0) {
1242
- webUrl = webUrl.replace('https://ossacmall.bluedeer.com.cn',
1243
- 'https://sit.tohours.com/crmeb_web')
1244
- }
1250
+ let webUrl = `${WEB_ACTIVITY_BASE}/acmall_lottery/index.html`
12451251 webUrl += '?token=' +
12461252 that.$store.getters.token + '&unionId=' + that.$store.getters.unionId + '&mdayId=' + that.info
12471253 .mdayId
....@@ -1323,6 +1329,9 @@
13231329 })
13241330 },
13251331 validAlert(data) {
1332
+ // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动
1333
+ this.countdownToken++
1334
+ const token = this.countdownToken
13261335 const {
13271336 startTime,
13281337 expireTime
....@@ -1341,17 +1350,17 @@
13411350 let minutes = startTimetamp.getMinutes()
13421351 minutes = minutes < 10 ? '0' + minutes : minutes;
13431352
1344
- this.countdownTimer(startTime.split('-').join('/'), 'start')
1353
+ this.countdownTimer(startTime.split('-').join('/'), 'start', token)
13451354 this.startOrEnd = "后开启"
13461355 return
1347
- }
1348
- }
1349
- if (expireTime) {
1350
- const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1351
- if (expireTimetamp < nowTimestamp) {
1356
+ }
1357
+ }
1358
+ if (expireTime) {
1359
+ const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1360
+ if (expireTimetamp < nowTimestamp) {
13521361 return
1353
- }
1354
- this.countdownTimer(expireTime.split('-').join('/'), 'end')
1362
+ }
1363
+ this.countdownTimer(expireTime.split('-').join('/'), 'end', token)
13551364 this.startOrEnd = "后结束"
13561365 }
13571366 },
....@@ -1473,6 +1482,21 @@
14731482 this.$refs.popNewuserRef.show()
14741483 }
14751484 },
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
+ },
14761500 getZoneDetail: function () {
14771501 let that = this;
14781502 let belong = this.$store.getters.belong;
....@@ -1480,7 +1504,7 @@
14801504 console.log('专区详情入参::', params)
14811505 getZoneDetail(that.id, params).then(res => {
14821506 that.info = res.data;
1483
- //that.info.zoneType=8;
1507
+ that.setLotteryBannerSize(res.data);
14841508 that.updateZoneShareMenu();
14851509 if (res.data.zoneType == 6) {
14861510 that.setYueyangZone()
....@@ -1490,7 +1514,7 @@
14901514 that.homeTop = that.getHomeTop(0.4)
14911515 }
14921516 that.expireTime = [];
1493
- that.expireTimeUnit = [];
1517
+ that.countdownToken++;
14941518 that.where.page = 1;
14951519 that.getGoodList()
14961520 that.validAlert(res.data)
....@@ -1516,8 +1540,9 @@
15161540 }
15171541 });
15181542 },
1519
- countdownTimer(expireTime, type) {
1543
+ countdownTimer(expireTime, type, token) {
15201544 if (!expireTime) return
1545
+ if (token !== undefined && token !== this.countdownToken) return
15211546 let that = this;
15221547 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳)
15231548 const endTimestamp = new Date(expireTime).getTime();
....@@ -1529,56 +1554,56 @@
15291554 if (type == 'end') {
15301555 if (diff <= 0) {
15311556 this.expireTime = []
1532
- this.expireTimeUnit = []
15331557 return
15341558 } else { }
15351559 } else if (type == 'start') {
15361560 if (diff <= 0) {
15371561 this.expireTime = []
1538
- this.expireTimeUnit = []
15391562 const expireTime2 = that.info.expireTime
15401563 if (expireTime2) {
15411564 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime();
15421565 if (expireTimetamp < nowTimestamp) {
15431566 return
15441567 }
1545
- this.countdownTimer(expireTime2.split('-').join('/'), 'end')
1568
+ this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)
15461569 this.startOrEnd = "后结束"
15471570 }
15481571 return
15491572 }
15501573 }
1574
+ const pad = num => (num < 10 ? '0' + num : String(num))
15511575 const res = []
1552
- const unit = []
15531576 const days = Math.floor(diff / (1000 * 60 * 60 * 24))
15541577 diff %= (1000 * 60 * 60 * 24)
1555
- if (days > 0) {
1556
- res.push(days);
1557
- unit.push('日')
1558
- }
15591578 // 转换为小时、分钟、秒
15601579 const hours = Math.floor(diff / (1000 * 60 * 60));
15611580 diff %= (1000 * 60 * 60); // 剩余毫秒数
1562
- if (hours > 0) {
1563
- res.push(hours < 10 ? '0' + hours : hours);
1564
- unit.push('时')
1565
- }
15661581 const minutes = Math.floor(diff / (1000 * 60));
1567
- if (minutes > 0) {
1568
- res.push(minutes < 10 ? '0' + minutes : minutes);
1569
- unit.push('分')
1570
- }
15711582 diff %= (1000 * 60); // 剩余毫秒数
15721583 const seconds = Math.floor(diff / 1000);
1573
- if (seconds > 0) {
1574
- res.push(seconds < 10 ? '0' + seconds : seconds);
1575
- unit.push('秒')
1584
+ // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定
1585
+ if (days > 0) {
1586
+ res.push({
1587
+ digits: pad(days).split(''),
1588
+ unit: '日'
1589
+ })
15761590 }
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
+ })
15771603 this.expireTime = res
1578
- this.expireTimeUnit = unit
15791604 if (this.isPageShow) {
15801605 setTimeout(() => {
1581
- that.countdownTimer(expireTime, type)
1606
+ that.countdownTimer(expireTime, type, token)
15821607 }, 1000)
15831608 }
15841609 },
....@@ -1665,13 +1690,11 @@
16651690 .lottery_banner {
16661691 margin: 15rpx auto;
16671692 width: 690rpx;
1668
- height: 120rpx;
16691693 text-align: center;
16701694 }
16711695
16721696 .lottery_bannerImg {
16731697 width: 690rpx;
1674
- height: 120rpx;
16751698 }
16761699
16771700 .tag-wrap-container {
....@@ -1870,6 +1893,21 @@
18701893 position: absolute;
18711894 top: 50%;
18721895 transform: translate(0, -50%);
1896
+}
1897
+
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;
18731911 }
18741912
18751913 .head_img {
....@@ -2140,11 +2178,22 @@
21402178 padding: 15rpx;
21412179 padding-left: 30rpx;
21422180 color: #979797;
2181
+ font-size: 26rpx;
21432182
21442183 .num {
2184
+ display: inline-block;
21452185 color: #000000;
21462186 background: #FFE20E;
2147
- 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;
21482197 }
21492198 }
21502199 </style>