Commit 303302ae by 侯体倬

轮播优化

parent e176e772
...@@ -223,15 +223,12 @@ const componentOptions = { ...@@ -223,15 +223,12 @@ const componentOptions = {
this.getInterList(2); this.getInterList(2);
} }
} }
// 判断是否为滑动组件
if (this.data.datas.componentData.style === 'swipe') {
this.getSwipeLen(); this.getSwipeLen();
wx.createSelectorQuery().selectAll(`.goodsListItemIndex${this.data.datasIndex}>>>.goods-item`).boundingClientRect(function (rects) { this.getSwipeHeight();
console.log(rects[0], '--rects', _this.data.datasIndex)
if (rects[0] && rects[0].height) {
_this.setData({
swiperHeight: rects[0].height
})
} }
}).exec();
}, },
handleSwipeChange(e) { handleSwipeChange(e) {
this.setData({ currentSwiperIndex: e.detail.current }) this.setData({ currentSwiperIndex: e.detail.current })
...@@ -252,6 +249,17 @@ const componentOptions = { ...@@ -252,6 +249,17 @@ const componentOptions = {
const total = (index + 1) * columnNum; const total = (index + 1) * columnNum;
return total > goodsListLen ? goodsListLen - (index * columnNum) : columnNum return total > goodsListLen ? goodsListLen - (index * columnNum) : columnNum
}, },
getSwipeHeight() {
wx.createSelectorQuery().in(this).selectAll('.goods-item').boundingClientRect((rects) => {
if (rects) {
let maxHeight = 0;
rects.forEach(item => {
if (item.height > maxHeight) maxHeight = item.height;
});
this.setData({ swiperHeight: maxHeight });
}
}).exec();
},
getProductList(code, type) { getProductList(code, type) {
let { goodsSort,attributeValueList } = this.data.datas.componentData; let { goodsSort,attributeValueList } = this.data.datas.componentData;
let goodsList = []; let goodsList = [];
...@@ -553,8 +561,8 @@ const componentOptions = { ...@@ -553,8 +561,8 @@ const componentOptions = {
lazyloading(){ lazyloading(){
var that = this var that = this
let storageDatasList = this.getStorageSync('storageDatasList') || [] let storageDatasList = this.getStorageSync('storageDatasList') || []
const tempItem = storageDatasList[that.data.datasIndex];
let style = storageDatasList[that.data.datasIndex].style || ""; let style = tempItem ? tempItem.style : "";
if (!style) return; if (!style) return;
let type = '' let type = ''
if(style == 'list' || style == 'rowList'){ if(style == 'list' || style == 'rowList'){
......
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