Commit 73de9c7c by 李嘉林

商品列表组件优化

parent db3d6d91
...@@ -453,7 +453,7 @@ export default { ...@@ -453,7 +453,7 @@ export default {
// 滚动节流方法 // 滚动节流方法
onPageScroll: tool.throttle(function (el) { onPageScroll: tool.throttle(function (el) {
// console.log(el); // console.log(el);
this.scrolls(el) this.scrolls(el[0])
},200), },200),
methods: { methods: {
......
...@@ -236,8 +236,9 @@ const componentOptions = { ...@@ -236,8 +236,9 @@ const componentOptions = {
this.setData({ classificationLoadPage, loading }); this.setData({ classificationLoadPage, loading });
let query = { let query = {
categoryId: this.data.datas.componentData.categoryId, categoryId: this.data.datas.componentData.categoryId,
page: this.showRowNum() ? classificationLoadPage : 1, page: classificationLoadPage,
rows: this.data.datas.componentData.classificationLoadNum, // rows: this.data.datas.componentData.classificationLoadNum,
rows: this.showRowNum() ? this.data.classificationLoadNum : this.getItemNum(),
sortColumn: goodsSort, sortColumn: goodsSort,
sortType: goodsSort != 2 ? 1 : 0, sortType: goodsSort != 2 ? 1 : 0,
whetherShowSoldOutGoods: this.data.datas.componentData whetherShowSoldOutGoods: this.data.datas.componentData
...@@ -275,7 +276,7 @@ const componentOptions = { ...@@ -275,7 +276,7 @@ const componentOptions = {
} else { } else {
goodsList = [...goodsList, ...goodsLists]; goodsList = [...goodsList, ...goodsLists];
} }
if (goodsLists && goodsLists.length < 10) { if (goodsLists && goodsLists.length < query.rows) {
this.setData({ finished: true }); this.setData({ finished: true });
} }
this.goodsListVal(goodsList, type); this.goodsListVal(goodsList, type);
...@@ -529,6 +530,13 @@ const componentOptions = { ...@@ -529,6 +530,13 @@ const componentOptions = {
return new Date(val.replace(/-/g, "/")).getTime() - new Date().getTime(); return new Date(val.replace(/-/g, "/")).getTime() - new Date().getTime();
}, },
getItemNum() { getItemNum() {
if(this.data.datas.componentData['goodsSource'] == 'classify') {
return this.data.classificationLoadNum
}
// 瀑布流模式默认查6条
if(this.data.datas.componentData.style == "waterfall" && this.data.datas.componentData["goodsSource"] == "specifyFilter"){
return 6;
}
//数量 //数量
if ( if (
this.data.datas.componentData.style === "list" && this.data.datas.componentData.style === "list" &&
...@@ -599,7 +607,7 @@ const componentOptions = { ...@@ -599,7 +607,7 @@ const componentOptions = {
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" || goodsSource == "specifyFilter") &&
moreShow == false && moreShow == false &&
style == "waterfall" style == "waterfall"
) { ) {
......
...@@ -158,6 +158,7 @@ Component({ ...@@ -158,6 +158,7 @@ Component({
); );
}, },
getScroll(el) { getScroll(el) {
console.log(el,'--------------161')
let { finished } = this.properties; let { finished } = this.properties;
let _this = this; let _this = this;
_this _this
...@@ -168,6 +169,7 @@ Component({ ...@@ -168,6 +169,7 @@ Component({
let scrollTop = parseInt(el.scrollTop); let scrollTop = parseInt(el.scrollTop);
let domHeight = parseInt(res.height); let domHeight = parseInt(res.height);
// 窗口高度+滚动高度等于 = 元素整体高度 -(预留一段距离加载) 触发父组件查询接口 // 窗口高度+滚动高度等于 = 元素整体高度 -(预留一段距离加载) 触发父组件查询接口
console.log(scrollTop,finished,'--------------finished')
if ( if (
scrollTop + _this.data.clientHeight >= domHeight - 150 && scrollTop + _this.data.clientHeight >= domHeight - 150 &&
finished == false finished == false
......
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