From dab62370f21a68506a6345078858f72e19611743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Fri, 9 Jan 2026 11:48:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=95=86=E5=93=81=E4=B8=8D?= =?UTF-8?q?=E8=B6=B36=E4=B8=AA=E6=97=B6=E8=87=AA=E5=8A=A8=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E4=B8=8A=E6=8B=89=E5=8A=A0=E8=BD=BD=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pages/index/index.js b/pages/index/index.js index c5e1890..44bdf45 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -777,6 +777,16 @@ Page({ page: this.data.page + 1, lastDataTimestamp: new Date().getTime() }) + + // 检查过滤后的非广告商品数量,如果不足6个且当前不是加载更多状态,则自动触发上拉加载更多 + const nonAdGoodsCount = filteredGoods.filter(item => !item.isAd).length; + if (!isLoadMore && nonAdGoodsCount < 6 && !this.data.loadingMore && !this.data.isLoading) { + console.log('非广告商品数量不足6个,自动触发上拉加载更多'); + // 使用setTimeout确保当前任务完成后再触发加载更多 + setTimeout(() => { + this.loadGoods(true); + }, 100); + } }, // 处理刷新数据 - 查重并保持原有商品 @@ -858,6 +868,16 @@ Page({ this.setData({ categoryQueryCache: newCategoryQueryCache }) + + // 检查过滤后的非广告商品数量,如果不足6个,则自动触发上拉加载更多 + const nonAdGoodsCount = filteredGoods.filter(item => !item.isAd).length; + if (nonAdGoodsCount < 6 && !this.data.loadingMore && !this.data.isLoading) { + console.log('刷新后商品数量不足6个,自动触发上拉加载更多'); + // 使用setTimeout确保当前任务完成后再触发加载更多 + setTimeout(() => { + this.loadGoods(true); + }, 100); + } }, // 插入广告位数据