Commit d0b9a922 by 李嘉林

商品列表轮播改参数

parent c3ce6cdf
...@@ -223,18 +223,12 @@ const componentOptions = { ...@@ -223,18 +223,12 @@ const componentOptions = {
this.getInterList(2); this.getInterList(2);
} }
} }
// 判断是否为滑动组件
if (this.data.datas.componentData.style === 'swipe') {
this.getSwipeLen();
this.getSwipeHeight();
}
}, },
handleSwipeChange(e) { handleSwipeChange(e) {
this.setData({ currentSwiperIndex: e.detail.current }) this.setData({ currentSwiperIndex: e.detail.current })
}, },
getSwipeLen() { getSwipeLen() {
const goodsListLen = this.data.datas.componentData.goodsList.length || 0; const goodsListLen = this.data.pageGoodsList[this.data.datasIndex].length || 0;
const len = Math.ceil((goodsListLen / this.data.datas.componentData.columnNum)); const len = Math.ceil((goodsListLen / this.data.datas.componentData.columnNum));
const result = []; const result = [];
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
...@@ -244,7 +238,7 @@ const componentOptions = { ...@@ -244,7 +238,7 @@ const componentOptions = {
this.setData({ swipeInfo: result }); this.setData({ swipeInfo: result });
}, },
getSwipeItemLen(index) { getSwipeItemLen(index) {
const goodsListLen = this.data.datas.componentData.goodsList.length || 0; const goodsListLen = this.data.pageGoodsList[this.data.datasIndex].length || 0;
const columnNum = this.data.datas.componentData.columnNum; const columnNum = this.data.datas.componentData.columnNum;
const total = (index + 1) * columnNum; const total = (index + 1) * columnNum;
return total > goodsListLen ? goodsListLen - (index * columnNum) : columnNum return total > goodsListLen ? goodsListLen - (index * columnNum) : columnNum
...@@ -507,7 +501,12 @@ const componentOptions = { ...@@ -507,7 +501,12 @@ const componentOptions = {
this.selectComponent("#waterfallFlow").reLoadPro(list); this.selectComponent("#waterfallFlow").reLoadPro(list);
} }
} }
}) });
// 判断是否为滑动组件
if (this.data.datas.componentData.style === 'swipe') {
this.getSwipeLen();
this.getSwipeHeight();
}
}); });
}, },
......
...@@ -154,13 +154,13 @@ ...@@ -154,13 +154,13 @@
<!-- 轮播滑动 --> <!-- 轮播滑动 -->
<view wx:if="{{datas.componentData.style === 'swipe' && datas.componentData.goodsList.length > 0}}" style="position:relative;"> <view wx:if="{{datas.componentData.style === 'swipe' && datas.componentData.goodsList.length > 0}}" style="position:relative;">
<swiper bindchange="handleSwipeChange" style="height: {{swiperHeight}}px"> <swiper bindchange="handleSwipeChange" style="height: {{swiperHeight}}px">
<block wx:for="{{swipeInfo}}"> <block wx:for="{{swipeInfo}}" wx:key="index">
<swiper-item> <swiper-item>
<view class="goods-item" style="display: grid;gap:{{datas.componentData.proGap*2}}rpx;grid-template-columns:repeat({{datas.componentData.columnNum}}, 1fr)"> <view class="goods-item" style="display: grid;gap:{{datas.componentData.proGap*2}}rpx;grid-template-columns:repeat({{datas.componentData.columnNum}}, 1fr)">
<view wx:for="{{item}}" wx:for-index="indey" style="display:flex;"> <view wx:for="{{item}}" wx:key="indey" wx:for-index="indey" style="display:flex;">
<goods-item <goods-item
datas="{{datas}}" datas="{{datas}}"
items="{{datas.componentData.goodsList[index * datas.componentData.columnNum + indey]}}" items="{{pageGoodsList[datasIndex][index * datas.componentData.columnNum + indey]}}"
indexs="{{index}}" indexs="{{index}}"
></goods-item> ></goods-item>
</view> </view>
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
</block> </block>
</swiper> </swiper>
<view class="flex custom-indicator" wx:if="{{swiperHeight > 0}}"> <view class="flex custom-indicator" wx:if="{{swiperHeight > 0}}">
<block wx:for="{{swipeInfo}}"> <block wx:for="{{swipeInfo}}" wx:key="index">
<view class="custom-indicator__item {{currentSwiperIndex === index && 'custom-indicator__active'}}"></view> <view class="custom-indicator__item {{currentSwiperIndex === index && 'custom-indicator__active'}}"></view>
</block> </block>
</view> </view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment