Commit 1b650f94de7d35410bc12abbd09f7106e0fc41b0

Authored by 后端研发-苏泰源
1 parent 4056caab

幸运购活动列表封面图高度自适应

packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.js
... ... @@ -10,6 +10,7 @@ Page({
10 10 isLoading: false, // 检测是否已经发送请求,防止重复发送请求
11 11 noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据
12 12 pageNum: 1, // 当前页数
  13 + max_sw_height: 0,
13 14 },
14 15  
15 16 onLoad: function (options) {
... ... @@ -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 1 <wxs module="filters" src="../../../../utils/filter.wxs"></wxs>
2 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 5 <swiper-item wx:for="{{adList}}">
6 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 8 </navigator>
9 9 </swiper-item>
10 10 </swiper>
... ...
packageC/pages/luckyGo/luckyGo_activityList/luckyGo_activityList.wxss
... ... @@ -4,7 +4,7 @@ page {
4 4  
5 5 .ad-container {
6 6 background-color: #f2f2f2;
7   - height: 400rpx;
  7 + /* height: 400rpx; */
8 8 }
9 9  
10 10 .list {
... ...