Jacob
1 天以前 f7034f535b85264e0c5b18e82fc295dab2052304
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 () {
....@@ -1473,11 +1483,8 @@
14731483 console.log('专区详情入参::', params)
14741484 getZoneDetail(that.id, params).then(res => {
14751485 that.info = res.data;
1476
-<<<<<<< Updated upstream
1477
-=======
14781486 //that.info.zoneType=8;
14791487 that.setLotteryBannerSize(res.data);
1480
->>>>>>> Stashed changes
14811488 that.updateZoneShareMenu();
14821489 if (res.data.zoneType == 6) {
14831490 that.setYueyangZone()