From 1bd50cee451c44873f53ae48066060f3a471cc14 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Fri, 9 Oct 2026 09:50:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(buyer):=20=E4=BF=AE=E5=A4=8D=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8=E8=B7=AF=E7=94=B1=E5=8F=98=E5=8C=96?= =?UTF-8?q?=E6=97=B6=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - $route watcher 中 handleSearch 与末尾兜底调用重叠,带 keyword 时同一请求发两次,改为互斥分支 - 修复从关键词搜索切换到分类/促销路由时 params.keyword 残留旧值的问题 --- buyer/src/pages/GoodsList.vue | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/buyer/src/pages/GoodsList.vue b/buyer/src/pages/GoodsList.vue index 7ebfdaf61..26f3c01df 100644 --- a/buyer/src/pages/GoodsList.vue +++ b/buyer/src/pages/GoodsList.vue @@ -142,22 +142,25 @@ export default { }, watch: { $route() { - const keyword = this.$route.query.keyword; - if (keyword) { - this.handleSearch(keyword); - } - if (this.$route.query.categoryId) { - let cateId = this.$route.query.categoryId.split(","); + const { keyword, categoryId, promotionType, promotionsId } = this.$route.query; + if (categoryId) { + const cateId = categoryId.split(","); Object.assign(this.params, this.$route.query); this.params.categoryId = cateId[cateId.length - 1]; } - if (this.$route.query.promotionType) { - this.params.promotionType = this.$route.query.promotionType; + if (promotionType) { + this.params.promotionType = promotionType; } - if (this.$route.query.promotionsId) { - this.params.promotionsId = this.$route.query.promotionsId; + if (promotionsId) { + this.params.promotionsId = promotionsId; + } + if (keyword) { + // handleSearch 内部会调 getGoodsList,此处不再重复请求 + this.handleSearch(keyword); + } else { + this.params.keyword = ""; + this.getGoodsList(); } - this.getGoodsList(); }, }, computed: {