From eb8a29a2f5c1b78d046baede8b00f0c0394004af Mon Sep 17 00:00:00 2001 From: donqi Date: Thu, 4 Aug 2022 23:39:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B1=BB=E7=9B=AE=E5=85=A8=E9=83=A8=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=BB=8E=E7=AC=AC=E4=BA=8C=E7=BA=A7=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E5=B1=95=E7=A4=BA=EF=BC=88=E7=AC=AC=E4=B8=80=E7=BA=A7?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=BA=E6=9C=8D=E5=8A=A1=E5=95=86=E5=9F=8E?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/home.vue | 22 +++++++++++++++++----- pages/index/worker-home.vue | 15 ++++++++++++++- pages/product/filtered-products.vue | 23 ++++++++++++++++++----- pages/product/product-category.vue | 9 +++++++-- 4 files changed, 56 insertions(+), 13 deletions(-) diff --git a/pages/index/home.vue b/pages/index/home.vue index 7784372..177cc2e 100644 --- a/pages/index/home.vue +++ b/pages/index/home.vue @@ -225,13 +225,25 @@ let subSubTypeList = []; for (let i = 0; i < item.child.length; i++) { - if (item.child[i].child && item.child[i].child.length) { - subSubTypeList = subSubTypeList.concat(item.child[i].child); - if (subSubTypeList.length >= 15) { - subSubTypeList = subSubTypeList.slice(0, 15); - break; + let stopFlag = false; + let secondList = item.child[i].child; + if (secondList && secondList.length) { + for (let k = 0; k < secondList.length; k++) { + let thirdList = secondList[k].child; + if (thirdList && thirdList.length) { + for (let j = 0; j < thirdList.length; j++) { + subSubTypeList = subSubTypeList.concat(thirdList[j]); + if (subSubTypeList.length >= 15) { + subSubTypeList = subSubTypeList.slice(0, 15); + stopFlag = true; + break; + } + } + } + if (stopFlag) break; } } + if (stopFlag) break; } let subCategoryOpt = await this.$api.data('subCategories'); diff --git a/pages/index/worker-home.vue b/pages/index/worker-home.vue index 3228d5b..2a53b4b 100644 --- a/pages/index/worker-home.vue +++ b/pages/index/worker-home.vue @@ -175,7 +175,14 @@ } }, async loadCategoryList(idArr) { - let typeList = await this.$request.listByStepWithAllNode(); + let res = await this.$request.listByStep({ + type: 1 + }); + res = res.data; + let typeList = await this.$request.listByStepWithAllNode({ + goodsCategoryId: res[0].goodsCategoryId, + type: 1 + }); typeList = typeList.data; // let col1Id = idArr ? idArr[0] : typeList[0].goodsCategoryId; // let subTypeList = await this.$request.listByStepWithAllNode({ @@ -262,6 +269,12 @@ for (let i = chosenCategory.length - 1; i >= 0; i--) { if (i === 0) { lastCategory = chosenCategory[i]; + if (lastCategory && lastCategory.isAllNode) { + let res = await this.$request.listByStep({ + type: 1 + }); + lastCategory = res.data[0]; + } break; } lastCategory = chosenCategory[i]; diff --git a/pages/product/filtered-products.vue b/pages/product/filtered-products.vue index daf23da..39de819 100644 --- a/pages/product/filtered-products.vue +++ b/pages/product/filtered-products.vue @@ -226,7 +226,14 @@ this.pageNum++; }, async loadCategoryList(idArr) { - let typeList = await this.$request.listByStepWithAllNode(); + let res = await this.$request.listByStep({ + type: 1 + }); + res = res.data; + let typeList = await this.$request.listByStepWithAllNode({ + goodsCategoryId: res[0].goodsCategoryId, + type: 1 + }); typeList = typeList.data; // let col1Id = idArr ? idArr[0] : typeList[0].goodsCategoryId; // let subTypeList = await this.$request.listByStepWithAllNode({ @@ -335,15 +342,21 @@ } }, async categoryChange(e) { - this.categoryMultiIndex = e.detail.value; - let chosenCategory = []; - for (let i = 0; i < this.categoryList.length; i++) { - chosenCategory.push(this.categoryList[i][this.categoryMultiIndex[i]]); + this.categoryMultiIndex = e.detail.value; + let chosenCategory = []; + for (let i = 0; i < this.categoryList.length; i++) { + chosenCategory.push(this.categoryList[i][this.categoryMultiIndex[i]]); } let lastCategory = null; for (let i = chosenCategory.length - 1; i >= 0; i--) { if (i === 0) { lastCategory = chosenCategory[i]; + if (lastCategory && lastCategory.isAllNode) { + let res = await this.$request.listByStep({ + type: 1 + }); + lastCategory = res.data[0]; + } break; } lastCategory = chosenCategory[i]; diff --git a/pages/product/product-category.vue b/pages/product/product-category.vue index 1993d5b..3a24698 100644 --- a/pages/product/product-category.vue +++ b/pages/product/product-category.vue @@ -19,7 +19,7 @@ data() { return { containerHeight: '100vh - ' + this.CustomBar + 'px', - categoryList: null + categoryList: [] } }, onLoad() { @@ -33,7 +33,12 @@ async loadData(params = {}) { // this.categoryList = await this.$api.data('categoryList'); let res = await this.$request.getProductCategories(params); - this.categoryList = res[1].data.data; + res = res[1].data.data; + res.forEach(firstCategory => { + if (firstCategory.child && firstCategory.child.length) { + this.categoryList = this.categoryList.concat(firstCategory.child) + } + }) }, bindEvent() { uni.$on(this.$globalFun.VERTICAL_NAV_GET_ITEM, this.chooseSubType);