Browse Source

修复售空数据未更新的问题,调整自动加载逻辑以支持售空商品

pull/11/head
徐飞洋 2 months ago
parent
commit
1e251ad000
  1. 18
      pages/index/index.js

18
pages/index/index.js

@ -778,14 +778,17 @@ Page({
lastDataTimestamp: new Date().getTime() lastDataTimestamp: new Date().getTime()
}) })
// 检查过滤后的非广告商品数量,如果不足6个且当前不是加载更多状态,则自动触发上拉加载更多 // 检查过滤后的非广告商品数量,如果不足6个,则自动触发上拉加载更多
// 对于已发布商品,在非加载更多模式下触发;对于售空商品,在加载更多模式下触发
const nonAdGoodsCount = filteredGoods.filter(item => !item.isAd).length; const nonAdGoodsCount = filteredGoods.filter(item => !item.isAd).length;
if (!isLoadMore && nonAdGoodsCount < 6 && !this.data.loadingMore && !this.data.isLoading) { if (nonAdGoodsCount < 6 && !this.data.loadingMore && !this.data.isLoading) {
console.log('非广告商品数量不足6个,自动触发上拉加载更多'); if (!isLoadMore || this.data.isQueryingSoldOut) {
// 使用setTimeout确保当前任务完成后再触发加载更多 console.log('商品数量不足6个,自动触发上拉加载更多');
setTimeout(() => { // 使用setTimeout确保当前任务完成后再触发加载更多
this.loadGoods(true); setTimeout(() => {
}, 100); this.loadGoods(true);
}, 100);
}
} }
}, },
@ -870,6 +873,7 @@ Page({
}) })
// 检查过滤后的非广告商品数量,如果不足6个,则自动触发上拉加载更多 // 检查过滤后的非广告商品数量,如果不足6个,则自动触发上拉加载更多
// 对于已发布商品,在非加载更多模式下触发;对于售空商品,在加载更多模式下触发
const nonAdGoodsCount = filteredGoods.filter(item => !item.isAd).length; const nonAdGoodsCount = filteredGoods.filter(item => !item.isAd).length;
if (nonAdGoodsCount < 6 && !this.data.loadingMore && !this.data.isLoading) { if (nonAdGoodsCount < 6 && !this.data.loadingMore && !this.data.isLoading) {
console.log('刷新后商品数量不足6个,自动触发上拉加载更多'); console.log('刷新后商品数量不足6个,自动触发上拉加载更多');

Loading…
Cancel
Save