Jacob
昨天 106fc09e267f67bb35a279ed1bf71068a61e73c4
pages/zone/index.vue
....@@ -89,7 +89,8 @@
8989 </view>
9090 </view>
9191 </view>
92
- <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery && info.lotteryBanner">
92
+ <view @click="goLottery" class="lottery_banner"
93
+ v-if="info && info.isLottery && info.lotteryBanner && lotteryBannerReady">
9394 <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix"
9495 :style="{ height: lotteryBannerHeight }">
9596 </image>
....@@ -644,6 +645,7 @@
644645 urlOption: {},
645646 homeTop: '200',
646647 lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应
648
+ lotteryBannerReady: false, //是否已拿到banner尺寸(或已确认拿不到),未就绪前不渲染,避免首帧撑高
647649 hasNewPop: false,
648650 leftCoupon: {},
649651 rightCoupon: {},
....@@ -1486,15 +1488,23 @@
14861488 setLotteryBannerSize(info) {
14871489 let that = this
14881490 that.lotteryBannerHeight = ''
1489
- if (!info || !info.isLottery || !info.lotteryBanner) return
1491
+ that.lotteryBannerReady = false
1492
+ if (!info || !info.isLottery || !info.lotteryBanner) {
1493
+ that.lotteryBannerReady = true
1494
+ return
1495
+ }
14901496 uni.getImageInfo({
14911497 src: info.lotteryBanner,
14921498 success: (img) => {
14931499 if (img.width > 0 && img.height > 0) {
14941500 that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx'
14951501 }
1502
+ that.lotteryBannerReady = true
14961503 },
1497
- fail: () => { }
1504
+ fail: (err) => {
1505
+ console.warn('抽奖banner尺寸预取失败,回退为自适应', err)
1506
+ that.lotteryBannerReady = true
1507
+ }
14981508 })
14991509 },
15001510 getZoneDetail: function () {