Commit 0cc72546 by 李嘉林

横向标签加载修改

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