From b511b9797921aa116df6554262c5970bfb46a943 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 12:58:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6=E6=97=B6=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=88=90=E5=8A=9F=E6=8F=90=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=88=B7=E6=96=B0=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 | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index d606077..b021e00 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -431,7 +431,7 @@ Page({ }) }, - onRefresh: function () { + onRefresh: function (showToast = true) { if (this.data.isRefreshing) { return } @@ -482,11 +482,13 @@ Page({ if (res.success && res.products) { this.processRefreshData(res.products, existingGoods) - wx.showToast({ - title: '刷新成功', - icon: 'success', - duration: 1500 - }) + if (showToast) { + wx.showToast({ + title: '刷新成功', + icon: 'success', + duration: 1500 + }) + } } else if (res.products.length === 0) { // 如果published状态没有商品,则查询sold_out状态 console.log('没有published状态的商品,查询sold_out状态的商品'); @@ -507,11 +509,13 @@ Page({ if (soldOutRes.success && soldOutRes.products && soldOutRes.products.length > 0) { this.processRefreshData(soldOutRes.products, existingGoods); - wx.showToast({ - title: '刷新成功', - icon: 'success', - duration: 1500 - }); + if (showToast) { + wx.showToast({ + title: '刷新成功', + icon: 'success', + duration: 1500 + }); + } } else { this.setData({ isLoading: false, @@ -1583,7 +1587,7 @@ Page({ if (filteredGoods.length < 3 && this.data.searchKeyword) { console.log('searchGoods - 本地过滤结果不足3个,将重新加载数据'); // 调用下拉刷新函数实现自动刷新 - this.onRefresh(); + this.onRefresh(false); } else { // 本地商品足够,直接使用本地过滤结果 console.log('searchGoods:使用本地商品过滤结果,数量:', filteredGoods.length);