From 1bd4ca5934dd0c41609cef78e00ac1fbb59026ea Mon Sep 17 00:00:00 2001 From: donqi Date: Tue, 2 Aug 2022 14:02:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9E=82=E7=9B=B4=E7=B1=BB?= =?UTF-8?q?=E7=9B=AE=E5=B1=95=E7=A4=BA=EF=BC=8C=E6=A0=B9=E6=8D=AE=E5=B7=A6?= =?UTF-8?q?=E4=BE=A7=E9=80=89=E4=B8=AD=E7=B1=BB=E7=9B=AE=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E4=B8=8B=E7=BA=A7=E7=B1=BB=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/multi-level-nav/vertical-nav.vue | 70 ++++----------------- 1 file changed, 12 insertions(+), 58 deletions(-) diff --git a/components/multi-level-nav/vertical-nav.vue b/components/multi-level-nav/vertical-nav.vue index 7ad77a2..919f5d2 100644 --- a/components/multi-level-nav/vertical-nav.vue +++ b/components/multi-level-nav/vertical-nav.vue @@ -9,16 +9,15 @@ --> - - + {{item.goodsCategoryName}} - - + @@ -56,70 +55,25 @@ } }, data() { - return { - // list: [], - childrenList: [], + return { tabCur: 0, - mainCur: 0, - load: true, - verticalNavTop: 0, + // mainCur: 0, + // load: true, + // verticalNavTop: 0, curNavItem: {} } }, onReady() { this.loadData(); - }, - // onLoad() { - // this.loadData(); - // }, + }, methods: { loadData() { // this.list = await this.$api.data('categoryList'); - this.tabCur = this.list[0].goodsCategoryId; - for (let i = 0; i < this.list.length; i++) { - let children = this.list[i].child; - if (children && children.length > 0) { - for (let j = 0; j < children.length; j++) { - children[j].pIndex = i; - // children[j].pId = this.list[i].id; - } - this.childrenList = this.childrenList.concat(children); - } - } + // this.tabCur = this.list[0].goodsCategoryId; }, tabSelect(e) { - this.tabCur = e.currentTarget.dataset.id; - this.mainCur = e.currentTarget.dataset.mainCur; - this.verticalNavTop = (e.currentTarget.dataset.index - 1) * 50; - }, - verticalMain(e) { - // #ifdef MP-ALIPAY - return false //支付宝小程序暂时不支持双向联动 - // #endif - let that = this; - let tabHeight = 0; - if (this.load) { - for (let i = 0; i < this.childrenList.length; i++) { - let view = uni.createSelectorQuery().select("#main-" + this.childrenList[i].goodsCategoryId); - view.fields({ - size: true - }, data => { - this.childrenList[i].top = tabHeight; - tabHeight = tabHeight + data.height; - this.childrenList[i].bottom = tabHeight; - }).exec(); - } - this.load = false - } - let scrollTop = e.detail.scrollTop + 10; - for (let i = 0; i < this.childrenList.length; i++) { - if (scrollTop > this.childrenList[i].top && scrollTop < this.childrenList[i].bottom) { - this.verticalNavTop = (this.childrenList[i].pIndex - 1) * 50 - this.tabCur = this.childrenList[i].parentCategoryId; - console.log(scrollTop + ";tabCur=" + this.tabCur) - return false - } - } + this.tabCur = e.currentTarget.dataset.index; + // this.mainCur = e.currentTarget.dataset.mainCur; }, chooseNavItem(curNavItem) { this.curNavItem = curNavItem;