| .. | .. |
|---|
| 89 | 89 | </view> |
|---|
| 90 | 90 | </view> |
|---|
| 91 | 91 | </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"> |
|---|
| 93 | 94 | <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix" |
|---|
| 94 | 95 | :style="{ height: lotteryBannerHeight }"> |
|---|
| 95 | 96 | </image> |
|---|
| .. | .. |
|---|
| 644 | 645 | urlOption: {}, |
|---|
| 645 | 646 | homeTop: '200', |
|---|
| 646 | 647 | lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应 |
|---|
| 648 | + lotteryBannerReady: false, //是否已拿到banner尺寸(或已确认拿不到),未就绪前不渲染,避免首帧撑高 |
|---|
| 647 | 649 | hasNewPop: false, |
|---|
| 648 | 650 | leftCoupon: {}, |
|---|
| 649 | 651 | rightCoupon: {}, |
|---|
| .. | .. |
|---|
| 1486 | 1488 | setLotteryBannerSize(info) { |
|---|
| 1487 | 1489 | let that = this |
|---|
| 1488 | 1490 | 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 | + } |
|---|
| 1490 | 1496 | uni.getImageInfo({ |
|---|
| 1491 | 1497 | src: info.lotteryBanner, |
|---|
| 1492 | 1498 | success: (img) => { |
|---|
| 1493 | 1499 | if (img.width > 0 && img.height > 0) { |
|---|
| 1494 | 1500 | that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx' |
|---|
| 1495 | 1501 | } |
|---|
| 1502 | + that.lotteryBannerReady = true |
|---|
| 1496 | 1503 | }, |
|---|
| 1497 | | - fail: () => { } |
|---|
| 1504 | + fail: (err) => { |
|---|
| 1505 | + console.warn('抽奖banner尺寸预取失败,回退为自适应', err) |
|---|
| 1506 | + that.lotteryBannerReady = true |
|---|
| 1507 | + } |
|---|
| 1498 | 1508 | }) |
|---|
| 1499 | 1509 | }, |
|---|
| 1500 | 1510 | getZoneDetail: function () { |
|---|