From bc9b2b8e9c260f8359df952c1010e793e723d23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Dchenxuelian=E2=80=9C?= <“chenxuelian@cjiedata.com”> Date: Fri, 6 Jan 2023 20:44:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=B8=8E=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E9=A1=B5=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods-category-search/category-index.vue | 15 ++++++++++----- pages/index/index.vue | 6 +++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packageSearch/goods-category-search/category-index.vue b/packageSearch/goods-category-search/category-index.vue index 22c8da7..81b008f 100644 --- a/packageSearch/goods-category-search/category-index.vue +++ b/packageSearch/goods-category-search/category-index.vue @@ -199,14 +199,15 @@ isAllData: false } }, - onLoad() { + onLoad(options) { + console.log(options) const menuButtonInfo = uni.getMenuButtonBoundingClientRect(); this.searchBarTop = menuButtonInfo.top; this.searchBarHeight = menuButtonInfo.height; this.imgUrl = uni.getStorageSync('img_url') this.goodsList = [] this.isAllData = false - this.getCategoryList() + this.getCategoryList(options.categoryId) }, onReady() { let that = this; @@ -303,13 +304,17 @@ url: '../search/search' }) }, - getCategoryList() { + getCategoryList(selectedCategoryId) { this.$apiServe.getCategories().then(res => { this.categoryList = res.data.data.map((item, index) => { item.icon = this.imgUrl + item.icon - if (this.selectedCategory && this.selectedCategory === index) { + if(selectedCategoryId && selectedCategoryId === item.id) { item.active = true - } else if (!this.selectedCategory && !index) { + this.selectedCategory = index + } else if (selectedCategoryId === null && this.selectedCategory && this.selectedCategory === index) { + item.active = true + active = true + } else if (selectedCategoryId === null && !this.selectedCategory && !index) { item.active = true } else { item.active = false diff --git a/pages/index/index.vue b/pages/index/index.vue index 16aa0b5..cb8acbd 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -13,7 +13,7 @@ - + @@ -177,9 +177,9 @@ }) }, //点击一级分类跳转到分类页 - toClassify() { + toClassify(id) { uni.navigateTo({ - url: '../../packageSearch/goods-category-search/category-index' + url: '../../packageSearch/goods-category-search/category-index?categoryId=' + id }) }, getImgUrl() {