Jacob
1 天以前 24b8f2afa92ce7bbe490185ecbab869c460b798b
pages/zone/index.vue
....@@ -90,7 +90,8 @@
9090 </view>
9191 </view>
9292 <view @click="goLottery" class="lottery_banner" v-if="info && info.isLottery && info.lotteryBanner">
93
- <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix">
93
+ <image class="lottery_bannerImg" :src="info.lotteryBanner" mode="widthFix"
94
+ :style="{ height: lotteryBannerHeight }">
9495 </image>
9596 </view>
9697 <view class="tag-img-container" v-if="info.zoneType == 7">
....@@ -642,6 +643,7 @@
642643 stockEmpty: true,
643644 urlOption: {},
644645 homeTop: '200',
646
+ lotteryBannerHeight: '', //抽奖banner预计算高度(rpx),空字符串表示未取到,按原逻辑自适应
645647 hasNewPop: false,
646648 leftCoupon: {},
647649 rightCoupon: {},
....@@ -1480,6 +1482,21 @@
14801482 this.$refs.popNewuserRef.show()
14811483 }
14821484 },
1485
+ // 预取抽奖banner真实宽高,计算出高度后再渲染,避免加载前被组件默认高度(225px)撑大
1486
+ setLotteryBannerSize(info) {
1487
+ let that = this
1488
+ that.lotteryBannerHeight = ''
1489
+ if (!info || !info.isLottery || !info.lotteryBanner) return
1490
+ uni.getImageInfo({
1491
+ src: info.lotteryBanner,
1492
+ success: (img) => {
1493
+ if (img.width > 0 && img.height > 0) {
1494
+ that.lotteryBannerHeight = (690 * img.height / img.width).toFixed(2) + 'rpx'
1495
+ }
1496
+ },
1497
+ fail: () => { }
1498
+ })
1499
+ },
14831500 getZoneDetail: function () {
14841501 let that = this;
14851502 let belong = this.$store.getters.belong;
....@@ -1487,7 +1504,7 @@
14871504 console.log('专区详情入参::', params)
14881505 getZoneDetail(that.id, params).then(res => {
14891506 that.info = res.data;
1490
- //that.info.zoneType=8;
1507
+ that.setLotteryBannerSize(res.data);
14911508 that.updateZoneShareMenu();
14921509 if (res.data.zoneType == 6) {
14931510 that.setYueyangZone()