Jacob
1 天以前 6a0a2c52a4ea8049909b8d7a40d0c2d098b5e74c
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>
....@@ -67,9 +71,9 @@
6771 </view>
6872 </view>
6973 </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">
74
+ <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery && info.lotteryBanner">
75
+ <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix"
76
+ :style="{ height: lotteryBannerHeight }">
7377 </image>
7478 </view>
7579 <view class="tag-img-container" v-if="info.zoneType == 7">
....@@ -495,7 +499,7 @@
495499
496500 <script>
497501 import {
498
- HTTP_REQUEST_URL
502
+ WEB_ACTIVITY_BASE
499503 } from '@/config/app';
500504 import {
501505 mapGetters
....@@ -586,7 +590,7 @@
586590 showMenu: false,
587591 selectedMenuArr: [],
588592 expireTime: [],
589
- expireTimeUnit: [],
593
+ countdownToken: 0,
590594 isPageShow: false,
591595 loginBackFn: null,
592596 errText: '',
....@@ -619,6 +623,7 @@
619623 stockEmpty: true,
620624 urlOption: {},
621625 homeTop: '200',
626
+ lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应
622627 hasNewPop: false,
623628 leftCoupon: {},
624629 rightCoupon: {},
....@@ -1195,6 +1200,11 @@
11951200 // that.myCareBean = res2.data.totalCareBeans;
11961201 });
11971202 },
1203
+ goDetail() {
1204
+ uni.navigateTo({
1205
+ url: '/pages/consumption/index?zoneId=' + this.info.id
1206
+ })
1207
+ },
11981208 goLottery() {
11991209 let that = this;
12001210 var data = {
....@@ -1206,11 +1216,7 @@
12061216 this.addTrack('yy_marketPageClick', data);
12071217
12081218 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
- }
1219
+ let webUrl = `${WEB_ACTIVITY_BASE}/acmall_lottery/index.html`
12141220 webUrl += '?token=' +
12151221 that.$store.getters.token + '&unionId=' + that.$store.getters.unionId + '&mdayId=' + that.info
12161222 .mdayId
....@@ -1292,6 +1298,9 @@
12921298 })
12931299 },
12941300 validAlert(data) {
1301
+ // 每次重新计算前作废旧的倒计时链,避免多条定时器同时刷新导致数字跳动
1302
+ this.countdownToken++
1303
+ const token = this.countdownToken
12951304 const {
12961305 startTime,
12971306 expireTime
....@@ -1310,17 +1319,17 @@
13101319 let minutes = startTimetamp.getMinutes()
13111320 minutes = minutes < 10 ? '0' + minutes : minutes;
13121321
1313
- this.countdownTimer(startTime.split('-').join('/'), 'start')
1322
+ this.countdownTimer(startTime.split('-').join('/'), 'start', token)
13141323 this.startOrEnd = "后开启"
13151324 return
1316
- }
1317
- }
1318
- if (expireTime) {
1319
- const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1320
- if (expireTimetamp < nowTimestamp) {
1325
+ }
1326
+ }
1327
+ if (expireTime) {
1328
+ const expireTimetamp = new Date(expireTime.split('-').join('/')).getTime();
1329
+ if (expireTimetamp < nowTimestamp) {
13211330 return
1322
- }
1323
- this.countdownTimer(expireTime.split('-').join('/'), 'end')
1331
+ }
1332
+ this.countdownTimer(expireTime.split('-').join('/'), 'end', token)
13241333 this.startOrEnd = "后结束"
13251334 }
13261335 },
....@@ -1442,6 +1451,21 @@
14421451 this.$refs.popNewuserRef.show()
14431452 }
14441453 },
1454
+ // 预取抽奖banner真实宽高,计算出高度后再渲染,避免加载前被组件默认高度(225px)撑大
1455
+ setLotteryBannerSize(info) {
1456
+ let that = this
1457
+ that.lotteryBannerHeight = ''
1458
+ if (!info || !info.isLottery || !info.lotteryBanner) return
1459
+ uni.getImageInfo({
1460
+ src: info.lotteryBanner,
1461
+ success: (img) => {
1462
+ if (img.width > 0 && img.height > 0) {
1463
+ that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx'
1464
+ }
1465
+ },
1466
+ fail: () => { }
1467
+ })
1468
+ },
14451469 getZoneDetail: function () {
14461470 let that = this;
14471471 let belong = this.$store.getters.belong;
....@@ -1449,6 +1473,11 @@
14491473 console.log('专区详情入参::', params)
14501474 getZoneDetail(that.id, params).then(res => {
14511475 that.info = res.data;
1476
+<<<<<<< Updated upstream
1477
+=======
1478
+ //that.info.zoneType=8;
1479
+ that.setLotteryBannerSize(res.data);
1480
+>>>>>>> Stashed changes
14521481 that.updateZoneShareMenu();
14531482 if (res.data.zoneType == 6) {
14541483 that.setYueyangZone()
....@@ -1458,7 +1487,7 @@
14581487 that.homeTop = that.getHomeTop(0.4)
14591488 }
14601489 that.expireTime = [];
1461
- that.expireTimeUnit = [];
1490
+ that.countdownToken++;
14621491 that.where.page = 1;
14631492 that.getGoodList()
14641493 that.validAlert(res.data)
....@@ -1484,8 +1513,9 @@
14841513 }
14851514 });
14861515 },
1487
- countdownTimer(expireTime, type) {
1516
+ countdownTimer(expireTime, type, token) {
14881517 if (!expireTime) return
1518
+ if (token !== undefined && token !== this.countdownToken) return
14891519 let that = this;
14901520 // 结束时间的时间戳(需传入一个有效的日期对象或时间戳)
14911521 const endTimestamp = new Date(expireTime).getTime();
....@@ -1497,56 +1527,56 @@
14971527 if (type == 'end') {
14981528 if (diff <= 0) {
14991529 this.expireTime = []
1500
- this.expireTimeUnit = []
15011530 return
15021531 } else { }
15031532 } else if (type == 'start') {
15041533 if (diff <= 0) {
15051534 this.expireTime = []
1506
- this.expireTimeUnit = []
15071535 const expireTime2 = that.info.expireTime
15081536 if (expireTime2) {
15091537 const expireTimetamp = new Date(expireTime2.split('-').join('/')).getTime();
15101538 if (expireTimetamp < nowTimestamp) {
15111539 return
15121540 }
1513
- this.countdownTimer(expireTime2.split('-').join('/'), 'end')
1541
+ this.countdownTimer(expireTime2.split('-').join('/'), 'end', token)
15141542 this.startOrEnd = "后结束"
15151543 }
15161544 return
15171545 }
15181546 }
1547
+ const pad = num => (num < 10 ? '0' + num : String(num))
15191548 const res = []
1520
- const unit = []
15211549 const days = Math.floor(diff / (1000 * 60 * 60 * 24))
15221550 diff %= (1000 * 60 * 60 * 24)
1523
- if (days > 0) {
1524
- res.push(days);
1525
- unit.push('日')
1526
- }
15271551 // 转换为小时、分钟、秒
15281552 const hours = Math.floor(diff / (1000 * 60 * 60));
15291553 diff %= (1000 * 60 * 60); // 剩余毫秒数
1530
- if (hours > 0) {
1531
- res.push(hours < 10 ? '0' + hours : hours);
1532
- unit.push('时')
1533
- }
15341554 const minutes = Math.floor(diff / (1000 * 60));
1535
- if (minutes > 0) {
1536
- res.push(minutes < 10 ? '0' + minutes : minutes);
1537
- unit.push('分')
1538
- }
15391555 diff %= (1000 * 60); // 剩余毫秒数
15401556 const seconds = Math.floor(diff / 1000);
1541
- if (seconds > 0) {
1542
- res.push(seconds < 10 ? '0' + seconds : seconds);
1543
- unit.push('秒')
1557
+ // 天数为 0 时不展示,时/分/秒始终展示(补 0),保证倒计时长度稳定
1558
+ if (days > 0) {
1559
+ res.push({
1560
+ digits: pad(days).split(''),
1561
+ unit: '日'
1562
+ })
15441563 }
1564
+ res.push({
1565
+ digits: pad(hours).split(''),
1566
+ unit: '时'
1567
+ })
1568
+ res.push({
1569
+ digits: pad(minutes).split(''),
1570
+ unit: '分'
1571
+ })
1572
+ res.push({
1573
+ digits: pad(seconds).split(''),
1574
+ unit: '秒'
1575
+ })
15451576 this.expireTime = res
1546
- this.expireTimeUnit = unit
15471577 if (this.isPageShow) {
15481578 setTimeout(() => {
1549
- that.countdownTimer(expireTime, type)
1579
+ that.countdownTimer(expireTime, type, token)
15501580 }, 1000)
15511581 }
15521582 },
....@@ -1633,13 +1663,11 @@
16331663 .lottery_banner {
16341664 margin: 15rpx auto;
16351665 width: 690rpx;
1636
- height: 120rpx;
16371666 text-align: center;
16381667 }
16391668
16401669 .lottery_bannerImg {
16411670 width: 690rpx;
1642
- height: 120rpx;
16431671 }
16441672
16451673 .tag-wrap-container {
....@@ -1838,6 +1866,21 @@
18381866 position: absolute;
18391867 top: 50%;
18401868 transform: translate(0, -50%);
1869
+}
1870
+
1871
+.detail-btn {
1872
+ border: 2rpx solid #fff;
1873
+ border-top-left-radius: 20rpx;
1874
+ border-bottom-left-radius: 20rpx;
1875
+ padding: 10rpx;
1876
+ background-color: #daf2b2;
1877
+ color: #1e984f;
1878
+ width: 50rpx;
1879
+ position: fixed;
1880
+ top: 200rpx;
1881
+ right: 0rpx;
1882
+ line-height: 1rem;
1883
+ z-index: 99;
18411884 }
18421885
18431886 .head_img {
....@@ -2066,11 +2109,22 @@
20662109 padding: 15rpx;
20672110 padding-left: 30rpx;
20682111 color: #979797;
2112
+ font-size: 26rpx;
20692113
20702114 .num {
2115
+ display: inline-block;
20712116 color: #000000;
20722117 background: #FFE20E;
2073
- padding: 0 10rpx;
2118
+ padding: 0 6rpx;
2119
+ margin: 0 4rpx;
2120
+ vertical-align: middle;
2121
+ }
2122
+
2123
+ /* 每个数字固定宽度,避免倒计时跳动时宽度忽长忽短 */
2124
+ .digit {
2125
+ display: inline-block;
2126
+ width: 19rpx;
2127
+ text-align: center;
20742128 }
20752129 }
20762130 </style>