Commit 27016ee0 by 李嘉林

商品列表加载优化

parent c0b464b9
......@@ -16,7 +16,7 @@
<!-- ***这个商品列表组件中需要对数据做缓存,可能有多个地方同时引用此组件
必须在缓存前加个唯一标识不然所有组件全部操作同一个缓存
-->
<goods-list :storageKey="'home'+index" :class="'goodsListItem' + index" :datas="item"></goods-list>
<goods-list :storageKey="'home'+index" :class="['goodsListItem' + index,'goodsListItemIndex0']" :datas="item" :datasIndex="0" :goodsListIndex="0"></goods-list>
</div>
<div v-else-if="item.componentCode == 'area-navigation' && item.componentInfo.visible == 1">
<area-navigation :datas="item" :changeLocation="changeLocation"></area-navigation>
......
......@@ -371,20 +371,26 @@ const componentOptions = {
scrollLoading: true
})
let terminalProductIds = []
console.log(pageNum,'page-----');
let pageNumList = this.getStorageSync('pageNumList')
let pageNum = null
if (flag) {
pageNum = pageNumList[this.data.goodsListIndex]
terminalProductIds = this.getStorageSync('ids')[this.data.goodsListIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize)
pageNum += 1
pageNumList[this.data.goodsListIndex] = pageNum
}else{
pageNum = pageNumList[this.data.datasIndex]
terminalProductIds = this.getStorageSync('ids')[this.data.datasIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize)
pageNum += 1
pageNumList[this.data.datasIndex] = pageNum
// 指定商品&网格布局和横向列表使用加载优化。
let { style } = this.data.datas.componentData;
if (style == 'list' || style == 'rowList') {
if (flag) {
pageNum = pageNumList[this.data.goodsListIndex]
terminalProductIds = this.getStorageSync('ids')[this.data.goodsListIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize)
pageNum += 1
pageNumList[this.data.goodsListIndex] = pageNum
}else{
pageNum = pageNumList[this.data.datasIndex]
terminalProductIds = this.getStorageSync('ids')[this.data.datasIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize)
pageNum += 1
pageNumList[this.data.datasIndex] = pageNum
}
} else {
terminalProductIds = this.getStorageSync('ids')[this.data.goodsListIndex];
}
console.log(pageNum,'page-----');
this.setStorageSync('pageNumList',pageNumList)
let {
vipPrice,
......@@ -407,7 +413,8 @@ const componentOptions = {
goodsApi.queryMoreProductInfo(moreQuery).then(res => {
if (res.data.code == 200) {
goodsList = res.data.data;
this.goodsListVal(goodsList, 1,flag);
let pageGoodsList = this.data.pageGoodsList[this.data.datasIndex] || [];
this.goodsListVal([...pageGoodsList,...goodsList], 1,flag);
}
});
},
......@@ -529,7 +536,7 @@ const componentOptions = {
let { style } = storageDatasList[that.data.datasIndex];
let type = ''
if(style == 'list'){
if(style == 'list' || style == 'rowList'){
type = 'goods-item'
}else{
console.log("不是goods-item");
......@@ -562,7 +569,6 @@ const componentOptions = {
pageGoodsList[that.data.datasIndex][index].loadState = true
}
}
that.setData({
pageGoodsList,
})
......
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