mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-12 03:48:55 +08:00
fix(buyer): 修复商品列表路由变化时重复请求
- $route watcher 中 handleSearch 与末尾兜底调用重叠,带 keyword 时同一请求发两次,改为互斥分支 - 修复从关键词搜索切换到分类/促销路由时 params.keyword 残留旧值的问题
This commit is contained in:
@@ -142,22 +142,25 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
$route() {
|
$route() {
|
||||||
const keyword = this.$route.query.keyword;
|
const { keyword, categoryId, promotionType, promotionsId } = this.$route.query;
|
||||||
if (keyword) {
|
if (categoryId) {
|
||||||
this.handleSearch(keyword);
|
const cateId = categoryId.split(",");
|
||||||
}
|
|
||||||
if (this.$route.query.categoryId) {
|
|
||||||
let cateId = this.$route.query.categoryId.split(",");
|
|
||||||
Object.assign(this.params, this.$route.query);
|
Object.assign(this.params, this.$route.query);
|
||||||
this.params.categoryId = cateId[cateId.length - 1];
|
this.params.categoryId = cateId[cateId.length - 1];
|
||||||
}
|
}
|
||||||
if (this.$route.query.promotionType) {
|
if (promotionType) {
|
||||||
this.params.promotionType = this.$route.query.promotionType;
|
this.params.promotionType = promotionType;
|
||||||
}
|
}
|
||||||
if (this.$route.query.promotionsId) {
|
if (promotionsId) {
|
||||||
this.params.promotionsId = this.$route.query.promotionsId;
|
this.params.promotionsId = promotionsId;
|
||||||
|
}
|
||||||
|
if (keyword) {
|
||||||
|
// handleSearch 内部会调 getGoodsList,此处不再重复请求
|
||||||
|
this.handleSearch(keyword);
|
||||||
|
} else {
|
||||||
|
this.params.keyword = "";
|
||||||
|
this.getGoodsList();
|
||||||
}
|
}
|
||||||
this.getGoodsList();
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
Reference in New Issue
Block a user