Jacob
1 天以前 76005787a10f1cf2e26f1b0c1672836b7d633ed2
pages/zone/index.vue
....@@ -71,7 +71,8 @@
7171 </view>
7272 </view>
7373 </view>
74
- <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery && info.lotteryBanner">
74
+ <view @click="goLottery" class="lottery_banner"
75
+ v-if="info && info.isLottery && info.lotteryBanner && lotteryBannerReady">
7576 <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix"
7677 :style="{ height: lotteryBannerHeight }">
7778 </image>
....@@ -624,6 +625,7 @@
624625 urlOption: {},
625626 homeTop: '200',
626627 lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应
628
+ lotteryBannerReady: false, //是否已拿到banner尺寸(或已确认拿不到),未就绪前不渲染,避免首帧撑高
627629 hasNewPop: false,
628630 leftCoupon: {},
629631 rightCoupon: {},
....@@ -1455,15 +1457,23 @@
14551457 setLotteryBannerSize(info) {
14561458 let that = this
14571459 that.lotteryBannerHeight = ''
1458
- if (!info || !info.isLottery || !info.lotteryBanner) return
1460
+ that.lotteryBannerReady = false
1461
+ if (!info || !info.isLottery || !info.lotteryBanner) {
1462
+ that.lotteryBannerReady = true
1463
+ return
1464
+ }
14591465 uni.getImageInfo({
14601466 src: info.lotteryBanner,
14611467 success: (img) => {
14621468 if (img.width > 0 && img.height > 0) {
14631469 that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx'
14641470 }
1471
+ that.lotteryBannerReady = true
14651472 },
1466
- fail: () => { }
1473
+ fail: (err) => {
1474
+ console.warn('抽奖banner尺寸预取失败,回退为自适应', err)
1475
+ that.lotteryBannerReady = true
1476
+ }
14671477 })
14681478 },
14691479 getZoneDetail: function () {