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;