From d3426c92839209f4f959300bec63abcec03a88b8 Mon Sep 17 00:00:00 2001 From: fanfan Date: Wed, 13 Mar 2024 15:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/activity/charts.vue | 6 +++--- pages/category/index.vue | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pages/activity/charts.vue b/pages/activity/charts.vue index b206c65..c113942 100644 --- a/pages/activity/charts.vue +++ b/pages/activity/charts.vue @@ -59,9 +59,9 @@ 更多榜单 - + + :style="{ backgroundImage: 'url(' + (item.image!=null?item.image.external_url:'') + ')', }"> {{item.name}}榜 @@ -125,7 +125,7 @@ message, data } = await GoodsApi.typeList({ - is_in_store: 0 + is_in_store: '' }); if (status == 200) { this.rankList = data.list diff --git a/pages/category/index.vue b/pages/category/index.vue index fa18bda..704af6a 100644 --- a/pages/category/index.vue +++ b/pages/category/index.vue @@ -13,7 +13,8 @@ {{item.name}} - + @@ -45,6 +46,7 @@ tabbar: [], tabbarList: [], scrollRightTop: 0, + oldScrollTop: 0, } }, onLoad() { @@ -70,8 +72,12 @@ async swichMenu(index) { this.tabbarList = [] this.current = index; + this.scrollRightTop = this.oldScrollTop; this.tabbarList = this.tabbar[index]; - this.getMenuItemTop() + this.$nextTick(function() { + this.getMenuItemTop() + }) + }, getGoodsTypeList() { const that = this; @@ -80,20 +86,26 @@ // is_hot: 0 }) .then(res => { + // 合并新数据 + console.log(res, '分类数据') that.tabbar = res.data.list; that.tabbarList = res.data.list[0] }) .catch(reject) }) }, + // 右边菜单滚动 + async rightScroll(e) { + this.oldScrollTop = e.detail.scrollTop; + }, // 获取右边菜单每个item到顶部的距离 getMenuItemTop() { + let that = this new Promise(resolve => { let selectorQuery = uni.createSelectorQuery(); selectorQuery.selectAll('.class-item').boundingClientRect((rects) => { rects.forEach((rect) => { - console.log(rects[0].top) - this.scrollRightTop = rects[0].top + that.scrollRightTop = rect.top - rects[0].top resolve(); }) }).exec() @@ -179,6 +191,7 @@ } .page-view { + padding: 0 16rpx 16rpx; overflow: hidden; }