Commit 1b650f94de7d35410bc12abbd09f7106e0fc41b0
1 parent
4056caab
幸运购活动列表封面图高度自适应
Showing
3 changed files
with
16 additions
and
3 deletions
packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.js
@@ -10,6 +10,7 @@ Page({ | @@ -10,6 +10,7 @@ Page({ | ||
10 | isLoading: false, // 检测是否已经发送请求,防止重复发送请求 | 10 | isLoading: false, // 检测是否已经发送请求,防止重复发送请求 |
11 | noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 | 11 | noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 |
12 | pageNum: 1, // 当前页数 | 12 | pageNum: 1, // 当前页数 |
13 | + max_sw_height: 0, | ||
13 | }, | 14 | }, |
14 | 15 | ||
15 | onLoad: function (options) { | 16 | onLoad: function (options) { |
@@ -222,5 +223,17 @@ Page({ | @@ -222,5 +223,17 @@ Page({ | ||
222 | // } | 223 | // } |
223 | // }, | 224 | // }, |
224 | 225 | ||
226 | + imageLoad: function (e) { | ||
227 | + var imgwidth = e.detail.width; | ||
228 | + var imgheight = e.detail.height; | ||
229 | + //宽高比 | ||
230 | + var ratio = imgwidth / imgheight; | ||
231 | + //计算的高度值 | ||
232 | + var viewHeight = 715 / ratio; | ||
233 | + if (this.data.max_sw_height < viewHeight) this.setData({ | ||
234 | + max_sw_height: viewHeight | ||
235 | + }); | ||
236 | + }, | ||
237 | + | ||
225 | }) | 238 | }) |
226 | 239 |
packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.wxml
1 | <wxs module="filters" src="../../../../utils/filter.wxs"></wxs> | 1 | <wxs module="filters" src="../../../../utils/filter.wxs"></wxs> |
2 | <view> | 2 | <view> |
3 | <!-- 广告图 --> | 3 | <!-- 广告图 --> |
4 | - <swiper class="ad-container" circular="true" autoplay="true" indicator-dots="true" interval="2500" indicator-active-color="rgba(255,255,255,.5)" wx:if="{{adList && adList.length != 0}}"> | 4 | + <swiper class="ad-container" circular="true" autoplay="true" indicator-dots="true" interval="2500" indicator-active-color="rgba(255,255,255,.5)" wx:if="{{adList && adList.length != 0}}" style="height:{{max_sw_height}}rpx"> |
5 | <swiper-item wx:for="{{adList}}"> | 5 | <swiper-item wx:for="{{adList}}"> |
6 | <navigator url="{{item.ad_weapplink}}" style="height: 100%;" hover-class="none" open-type="reLaunch"> | 6 | <navigator url="{{item.ad_weapplink}}" style="height: 100%;" hover-class="none" open-type="reLaunch"> |
7 | - <image src="{{imghost + item.ad_code}}" class="img-block" bindload="imageLoad" data-index="{{index}}" mode="scaleToFill" lazy-load="true"/> | 7 | + <image src="{{imghost + item.ad_code}}" class="img-block" bindload="imageLoad" data-index="{{index}}" lazy-load="true" mode="widthFix"/> |
8 | </navigator> | 8 | </navigator> |
9 | </swiper-item> | 9 | </swiper-item> |
10 | </swiper> | 10 | </swiper> |
packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.wxss