Commit 27016ee0 by 李嘉林

商品列表加载优化

parent c0b464b9
...@@ -16,7 +16,7 @@ ...@@ -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>
<div v-else-if="item.componentCode == 'area-navigation' && item.componentInfo.visible == 1"> <div v-else-if="item.componentCode == 'area-navigation' && item.componentInfo.visible == 1">
<area-navigation :datas="item" :changeLocation="changeLocation"></area-navigation> <area-navigation :datas="item" :changeLocation="changeLocation"></area-navigation>
......
...@@ -371,20 +371,26 @@ const componentOptions = { ...@@ -371,20 +371,26 @@ const componentOptions = {
scrollLoading: true scrollLoading: true
}) })
let terminalProductIds = [] let terminalProductIds = []
console.log(pageNum,'page-----');
let pageNumList = this.getStorageSync('pageNumList') let pageNumList = this.getStorageSync('pageNumList')
let pageNum = null let pageNum = null
if (flag) { // 指定商品&网格布局和横向列表使用加载优化。
pageNum = pageNumList[this.data.goodsListIndex] let { style } = this.data.datas.componentData;
terminalProductIds = this.getStorageSync('ids')[this.data.goodsListIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize) if (style == 'list' || style == 'rowList') {
pageNum += 1 if (flag) {
pageNumList[this.data.goodsListIndex] = pageNum pageNum = pageNumList[this.data.goodsListIndex]
}else{ terminalProductIds = this.getStorageSync('ids')[this.data.goodsListIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize)
pageNum = pageNumList[this.data.datasIndex] pageNum += 1
terminalProductIds = this.getStorageSync('ids')[this.data.datasIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize) pageNumList[this.data.goodsListIndex] = pageNum
pageNum += 1 }else{
pageNumList[this.data.datasIndex] = pageNum 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) this.setStorageSync('pageNumList',pageNumList)
let { let {
vipPrice, vipPrice,
...@@ -407,7 +413,8 @@ const componentOptions = { ...@@ -407,7 +413,8 @@ const componentOptions = {
goodsApi.queryMoreProductInfo(moreQuery).then(res => { goodsApi.queryMoreProductInfo(moreQuery).then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
goodsList = res.data.data; 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 = { ...@@ -529,7 +536,7 @@ const componentOptions = {
let { style } = storageDatasList[that.data.datasIndex]; let { style } = storageDatasList[that.data.datasIndex];
let type = '' let type = ''
if(style == 'list'){ if(style == 'list' || style == 'rowList'){
type = 'goods-item' type = 'goods-item'
}else{ }else{
console.log("不是goods-item"); console.log("不是goods-item");
...@@ -562,7 +569,6 @@ const componentOptions = { ...@@ -562,7 +569,6 @@ const componentOptions = {
pageGoodsList[that.data.datasIndex][index].loadState = true pageGoodsList[that.data.datasIndex][index].loadState = true
} }
} }
that.setData({ that.setData({
pageGoodsList, 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