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: {