Commit 0cc72546 by 李嘉林

横向标签加载修改

parent 751531f7
......@@ -72,7 +72,7 @@
<!-- <goods-list class="goodsListItem" :datas="item1"></goods-list> -->
{{index}}------
<goods-list :class="['goodsListItem','goodsListItemIndex'+index]" :datas="item1" :datasIndex="active" :goodsListIndex="index"></goods-list>
<goods-list :class="['goodsListItemIndex'+index,'transverse-label-goodsListItem']" :datas="item1" :datasIndex="active" :goodsListIndex="index"></goods-list>
</div>
<div v-else-if="item1.componentCode == 'area-navigation' && item1.componentInfo.visible == 1">
......@@ -447,11 +447,11 @@ export default {
item.getScroll()
})
}
if(this.$parent.$mp.page.selectAllComponents('.goodsListItem')){
// this.$parent.$mp.page.selectAllComponents('.goodsListItem').forEach(v=>{
if(this.$parent.$mp.page.selectAllComponents('.transverse-label-goodsListItem')){
// this.$parent.$mp.page.selectAllComponents('.transverse-label-goodsListItem').forEach(v=>{
// v.wheatherLazyloading == true
// })
// console.log(this.$parent.$mp.page.selectAllComponents('.goodsListItem')[res.target.index].setPageDatas(res.target.index));
// console.log(this.$parent.$mp.page.selectAllComponents('.transverse-label-goodsListItem')[res.target.index].setPageDatas(res.target.index));
// console.log('setDatas');
}
this.active=res.target.index;
......
......@@ -698,8 +698,15 @@ export default {
this.$mp.page.selectComponent(".getIndexHomePage").getScroll(el);
}
if(this.$mp.page && this.$mp.page.selectComponent(".goodsListItem")){
console.log(this.$mp.page.selectAllComponents(".transverse-label-goodsListItem"),'-this.$mp.page.selectComponent(".goodsListItem")')
this.$mp.page.selectComponent(".goodsListItem").getScroll(el);
}
if(this.$mp.page && this.$mp.page.selectAllComponents(".transverse-label-goodsListItem")){
this.$mp.page.selectAllComponents(".transverse-label-goodsListItem").forEach(item=>{
console.log(item,'-this.$mp.page.selectComponent(".goodsListItem")')
item.getScroll(el)
})
}
},
setFooterShow(el){
// return
......
......@@ -10,10 +10,10 @@ const componentOptions = {
datas: {
type: Object
},
datasIndex:{
datasIndex: {
type: Number
},
goodsListIndex:{
goodsListIndex: {
type: Number
}
},
......@@ -26,13 +26,14 @@ const componentOptions = {
queryProductInfoLoading: false,
loading: false,
finished: false,
goodsList:[],
storageGoodsList:[],
storageDatasList:[],
pageSize:10,
pageNum:1,
pageGoodsList:[],
loadingFlag:[],
goodsList: [],
storageGoodsList: [],
storageDatasList: [],
pageSize: 10,
pageNum: 1,
pageGoodsList: [],
loadingFlag: [],
testFlag: 0
},
// 数据监听器
observers: {},
......@@ -85,7 +86,7 @@ const componentOptions = {
angleSignImg,
titleIcon
} = this.data.datas.componentData;
angleSignImg = DFSImg(angleSignImg,150,150,1);
angleSignImg = DFSImg(angleSignImg, 150, 150, 1);
if (titleIcon) {
titleIcon = DFSImg(titleIcon);
}
......@@ -201,13 +202,15 @@ const componentOptions = {
return element.terminalProductId;
});
let storageIds = wx.getStorageSync('ids')
storageIds[this.data.goodsListIndex] = ids
wx.setStorageSync('ids',storageIds)
let storageIds = wx.getStorageSync("ids");
storageIds[this.data.goodsListIndex] = ids;
wx.setStorageSync("ids", storageIds);
let storageDatasList = wx.getStorageSync('storageDatasList')
storageDatasList[this.data.goodsListIndex] = this.data.datas.componentData
wx.setStorageSync('storageDatasList',storageDatasList)
let storageDatasList = wx.getStorageSync("storageDatasList");
storageDatasList[
this.data.goodsListIndex
] = this.data.datas.componentData;
wx.setStorageSync("storageDatasList", storageDatasList);
this.moreProduct(true);
}
......@@ -216,23 +219,38 @@ const componentOptions = {
async moreProduct(flag) {
// 没有数据了就不再请求了,直接return
if (this.data.pageGoodsList.length != 0 && this.data.pageGoodsList[this.data.datasIndex].length == wx.getStorageSync('ids')[this.data.datasIndex].length) return
let terminalProductIds = []
console.log(pageNum,'page-----');
let pageNumList = wx.getStorageSync('pageNumList')
let pageNum = null
if (
this.data.pageGoodsList.length != 0 &&
this.data.pageGoodsList[this.data.datasIndex].length ==
wx.getStorageSync("ids")[this.data.datasIndex].length
)
return;
let terminalProductIds = [];
console.log(pageNum, "page-----");
let pageNumList = wx.getStorageSync("pageNumList");
let pageNum = null;
if (flag) {
pageNum = pageNumList[this.data.goodsListIndex]
terminalProductIds = wx.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 = wx.getStorageSync('ids')[this.data.datasIndex].slice((pageNum - 1) * this.data.pageSize,pageNum * this.data.pageSize)
pageNum += 1
pageNumList[this.data.datasIndex] = pageNum
}
wx.setStorageSync('pageNumList',pageNumList)
pageNum = pageNumList[this.data.goodsListIndex];
terminalProductIds = wx
.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 = wx
.getStorageSync("ids")
[this.data.datasIndex].slice(
(pageNum - 1) * this.data.pageSize,
pageNum * this.data.pageSize
);
pageNum += 1;
pageNumList[this.data.datasIndex] = pageNum;
}
wx.setStorageSync("pageNumList", pageNumList);
let {
vipPrice,
marketingTag,
......@@ -252,11 +270,12 @@ const componentOptions = {
goodsApi.queryMoreProductInfo(moreQuery).then(res => {
if (res.data.code == 200) {
goodsList = res.data.data;
this.goodsListVal(goodsList, 1,flag);
this.goodsListVal(goodsList, 1, flag);
}
});
},
goodsListVal(goodsList, type,flag) {
goodsListVal(goodsList, type, flag) {
console.log(this, "----------------------280");
console.log(goodsList, "------------goodsListVal");
goodsList.forEach((item, index) => {
item.marketingTag = item.defaultTags
......@@ -266,7 +285,7 @@ const componentOptions = {
)
: [];
item.shopLogoUrl = DFSImg(item.shopLogoUrl);
item.loadState = false
item.loadState = false;
item.coverImage = DFSImg(item.coverImage, 400, 400, 1);
item.productImgUrl = DFSImg(item.productImgUrl, 400, 400, 1);
item.minPrice = Number(item.minPrice).toFixed(2);
......@@ -289,32 +308,35 @@ const componentOptions = {
item.getSaleTime = this.getSaleTime(item.saleTime);
}
});
var that = this
let pageGoodsList = wx.getStorageSync('pageGoodsList') || []
let pageGoodsList = wx.getStorageSync("pageGoodsList") || [];
if (flag) {
pageGoodsList[that.data.goodsListIndex].push(...goodsList)
}else{
pageGoodsList[that.data.datasIndex].push(...goodsList)
console.log(pageGoodsList[that.data.datasIndex],'--pageGoodsList[that.data.datasIndex]')
pageGoodsList[this.data.goodsListIndex].push(...goodsList);
} else {
pageGoodsList[this.data.datasIndex].push(...goodsList);
console.log(
pageGoodsList[this.data.datasIndex],
"--pageGoodsList[this.data.datasIndex]"
);
}
wx.setStorageSync('pageGoodsList', pageGoodsList);
wx.setStorageSync("pageGoodsList", pageGoodsList);
// 获取是否要开启请求拦截
let loadingFlag = wx.getStorageSync('loadingFlag')
loadingFlag[that.data.datasIndex] = false
wx.setStorageSync('loadingFlag', loadingFlag);
that.setData({
pageGoodsList,
})
let loadingFlag = wx.getStorageSync("loadingFlag");
loadingFlag[this.data.datasIndex] = false;
wx.setStorageSync("loadingFlag", loadingFlag);
this.setData({
pageGoodsList,
testFlag: 999
});
this.setData(
{
"datas.componentData.goodsList": goodsList,
// goodsList
loadingFlag
},function () {
// that.lazyloading();
},
function() {
// this.lazyloading();
// 节点布局方案在组件嵌套层级过深测试无效
// let goodsList = this.data.goodsList // 获取原数据
// goodsList.forEach((item,index)=>{
......@@ -328,7 +350,8 @@ const componentOptions = {
// console.log('1111');
// })
// })
})
}
);
if (type == 1) {
// 初始化
......@@ -344,53 +367,85 @@ const componentOptions = {
},
// 触发图片加载
lazyloading(){
var that = this
console.log(that.data.datasIndex,that.data.goodsListIndex,'datasIndex');
console.log(that.data.pageGoodsList[that.data.datasIndex]);
let storageDatasList = wx.getStorageSync('storageDatasList') || []
lazyloading() {
console.log(this, "-------------------------this");
console.log(this.data.datasIndex, this.data.goodsListIndex, "datasIndex");
console.log(this.data.pageGoodsList[this.data.datasIndex]);
let storageDatasList = wx.getStorageSync("storageDatasList") || [];
let { style } = storageDatasList[that.data.datasIndex];
let type = ''
if(style == 'list'){
type = 'goods-item'
}else{
let { style } = storageDatasList[this.data.datasIndex];
let type = "";
if (style == "list") {
type = "goods-item";
} else {
console.log("不是goods-item");
return
return;
}
let windowHeight = wx.getSystemInfoSync().windowHeight
let pageGoodsList = wx.getStorageSync('pageGoodsList') || []
console.log(that.data.pageGoodsList,pageGoodsList,that.data.datasIndex,'pageGoodsList--loading');
let windowHeight = wx.getSystemInfoSync().windowHeight;
let pageGoodsList = wx.getStorageSync("pageGoodsList") || [];
console.log(
this.data.pageGoodsList,
pageGoodsList,
this.data.datasIndex,
"pageGoodsList--loading"
);
let loadingFlag = wx.getStorageSync('loadingFlag')
let loadingFlag = wx.getStorageSync("loadingFlag");
// 如果所有的商品都加载完成直接return
if (loadingFlag[that.data.datasIndex]) {
if (loadingFlag[this.data.datasIndex]) {
console.log("如果所有的商品都加载完成直接return");
return
return;
}
wx.createSelectorQuery().selectAll(`.goodsListItemIndex${that.data.datasIndex}>>>.${type}`).boundingClientRect(function(rects){
let that = this;
console.log(this, "--------------this.data--1");
wx
.createSelectorQuery()
.selectAll(`.goodsListItemIndex${this.data.datasIndex}>>>.${type}`)
.boundingClientRect(function(rects) {
for (let index = 0; index < rects.length; index++) {
if (rects[index].top == 0 && rects[index].bottom == 0 && rects[index].left == 0 && rects[index].right == 0) {
break
if (
rects[index].top == 0 &&
rects[index].bottom == 0 &&
rects[index].left == 0 &&
rects[index].right == 0
) {
break;
}
console.log(rects[index].top,windowHeight,'判断判断');
console.log(
rects[index].top,
windowHeight,
that.data.datasIndex,
"判断判断"
);
if (rects[index].top < windowHeight) {
// that.$set(pageGoodsList[that.data.datasIndex][index],'loadState',true)
pageGoodsList[that.data.datasIndex][index].loadState = true
pageGoodsList[that.data.datasIndex][index].loadState = true;
// var newArr = JSON.parse(JSON.stringify(pageGoodsList))
// pageGoodsList[that.data.datasIndex] = []
}
console.log(
pageGoodsList[that.data.datasIndex][0].productName,
that.data.testFlag,
"----------------pageGoodsList"
);
}
that.setData({
pageGoodsList,
})
testFlag: 2
});
console.log(that, "--------------that.data--2");
// that.pageGoodsList = pageGoodsList
console.log(rects,pageGoodsList[that.data.goodsListIndex], pageGoodsList[that.data.datasIndex],'fff');
wx.setStorageSync('pageGoodsList',pageGoodsList)
console.log(
rects,
pageGoodsList[that.data.goodsListIndex],
pageGoodsList[that.data.datasIndex],
"fff"
);
wx.setStorageSync("pageGoodsList", pageGoodsList);
// loadingFlag[that.data.datasIndex] = true
// that.setData({
......@@ -401,20 +456,23 @@ const componentOptions = {
// console.log('load--ok');
// 如果当前分页最后一张加载完成直接 打开loadingFlag开关并加载下一页数据
if (that.data.pageGoodsList[that.data.datasIndex][that.data.pageGoodsList[that.data.datasIndex].length -1].loadState == true) {
loadingFlag[that.data.datasIndex] = true
if (
that.data.pageGoodsList[that.data.datasIndex][
that.data.pageGoodsList[that.data.datasIndex].length - 1
].loadState == true
) {
loadingFlag[that.data.datasIndex] = true;
that.setData({
loadingFlag
})
wx.setStorageSync('loadingFlag',loadingFlag)
});
wx.setStorageSync("loadingFlag", loadingFlag);
that.moreProduct(false)
that.moreProduct(false);
console.log('load--ok');
console.log("load--ok");
}
}).exec();
})
.exec();
},
getSaleTime(val) {
return new Date(val.replace(/-/g, "/")).getTime() - new Date().getTime();
......@@ -483,10 +541,17 @@ const componentOptions = {
return showFlag;
},
getScroll(el) {
//! 如果不是当前tab页return不执行滚动加载
if (this.data.datasIndex != this.data.goodsListIndex) return;
console.log(
this.data.datasIndex,
this.data.goodsListIndex,
"-----goodsListIndex"
);
// 是指定分类且不显示查看更多的瀑布流组件滚动加载
let { goodsSource, moreShow, style } = this.data.datas.componentData;
console.log('goodsSource, moreShow, style',goodsSource, moreShow, style);
this.lazyloading()
console.log("goodsSource, moreShow, style", goodsSource, moreShow, style);
this.lazyloading();
if (
goodsSource == "classify" &&
......@@ -514,7 +579,7 @@ const componentOptions = {
} else {
linkVal = `/pointShop/productList?categoryName=${categoryName}&categoryId=${categoryId}`;
}
app.trackCpn(e, this.data.datas.componentName, 'ViewMore查看更多')
app.trackCpn(e, this.data.datas.componentName, "ViewMore查看更多");
$themeToLink({
type: 1,
link: linkVal
......
......@@ -30,6 +30,8 @@
class="goods-item {{'goodsItemIndex'+index}}"
style="width:{{100/datas.componentData.columnNum}}%;padding-left:{{datas.componentData.proGap*2}}rpx"
>
+{{testFlag}}+
*{{goodsListIndex}}*
<!-- <goods-item
datas="{{datas}}"
items="{{goodsList[index]}}"
......
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