From bc819831f0b1e48119e0b797bba9efd32196965e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TOP=E7=B3=AF=E7=B1=B3?= <1130395124@qq.com> Date: Wed, 8 Mar 2023 12:57:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=86=E7=B1=BB=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cate/cate.vue | 10 +++++++++- src/pages/service/cate.vue | 12 ++++++------ src/pages/service/list.vue | 21 +++++++++++---------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/components/cate/cate.vue b/src/components/cate/cate.vue index 7c3d778..fa82962 100644 --- a/src/components/cate/cate.vue +++ b/src/components/cate/cate.vue @@ -75,6 +75,10 @@ export default { type: Number, default: 0, }, + activeId: { + type: [String, Number], + default: 0, + }, data: { type: Array, default: [], @@ -108,7 +112,6 @@ export default { // H5窗口高度会计算tabbar高度,这里减去 this.wrapHeight -= this.$utils.rpx2px(100); // #endif - // this.switchCate(5); }, destroyed() {}, methods: { @@ -247,6 +250,11 @@ export default { this.$emit("clickItem", id); }, }, + watch: { + activeId(activeId) { + this.switchCate(activeId); + }, + }, }; diff --git a/src/pages/service/cate.vue b/src/pages/service/cate.vue index eb1e1c7..e6ef764 100644 --- a/src/pages/service/cate.vue +++ b/src/pages/service/cate.vue @@ -49,7 +49,7 @@ export default { config: (state) => state.system.config, }), }, - onLoad() { + async onLoad() { let x = this.config.windowWidth - this.$utils.rpx2px(94); let y = this.config.windowHeight - this.$utils.rpx2px(94); // H5平台减去tabBar高度 @@ -61,7 +61,7 @@ export default { y: y - this.$utils.rpx2px(40), }; // 加载分类 - this.loadHot(); + await this.loadHot(); this.loadCate(); }, onShow() {}, @@ -72,8 +72,8 @@ export default { /** * 热门推荐 */ - loadHot() { - this.$request({ + async loadHot() { + await this.$request({ api: "service.hotCate", }).then((response) => { let child = []; @@ -95,8 +95,8 @@ export default { /** * 分类 */ - loadCate() { - this.$request({ + async loadCate() { + await this.$request({ api: "service.cate", }) .then((response) => { diff --git a/src/pages/service/list.vue b/src/pages/service/list.vue index d9e96cf..3df1af3 100644 --- a/src/pages/service/list.vue +++ b/src/pages/service/list.vue @@ -1,7 +1,7 @@