From bd95a6030cdeeb3acea564441d0c71feb6e708e2 Mon Sep 17 00:00:00 2001 From: YM <479443481@qq.com> Date: 星期一, 25 三月 2024 18:21:03 +0800 Subject: [PATCH] tabBar问题调整 --- pages/cart/index.js | 6 +++++- custom-tab-bar/index.js | 18 +----------------- pages/bookServices/assort/index.js | 5 +++++ pages/personalCenter/index.js | 6 +++++- pages/student/index.js | 6 +++++- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js index a38dc4a..aa4b9cd 100644 --- a/custom-tab-bar/index.js +++ b/custom-tab-bar/index.js @@ -4,11 +4,6 @@ selected: 0, list: TabMenu, }, - // observers: { - // 'active': function (newValue) { - // console.log('active鍙樺寲', newValue); - // } - // }, methods: { changeTab(item) { this.setData({ @@ -18,17 +13,6 @@ url: this.data.list[this.data.selected].url.startsWith('/') ? this.data.list[this.data.selected].url : `/${this.data.list[this.data.selected].url}`, }); - }, - - // init() { - // const page = getCurrentPages().pop(); - // const route = page ? page.route.split('?')[0] : ''; - // const active = this.data.list.findIndex( - // (item) => - // (item.url.startsWith('/') ? item.url.substr(1) : item.url) === - // `${route}`, - // ); - // this.setData({ active }); - // }, + } }, }); diff --git a/pages/bookServices/assort/index.js b/pages/bookServices/assort/index.js index d10b5cd..f86fa21 100644 --- a/pages/bookServices/assort/index.js +++ b/pages/bookServices/assort/index.js @@ -39,6 +39,11 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { + if (typeof this.getTabBar === 'function' && this.getTabBar()) { + this.getTabBar().setData({ + active: 1 + }) + } }, /** diff --git a/pages/cart/index.js b/pages/cart/index.js index 7d37d43..ad14b41 100644 --- a/pages/cart/index.js +++ b/pages/cart/index.js @@ -25,9 +25,13 @@ this.shoppingCartGet(); }, onShow() { + if (typeof this.getTabBar === 'function' && this.getTabBar()) { + this.getTabBar().setData({ + active: 3 + }) + } this.shoppingCartGet(); this.setData({ totalPrice: 0.00, selectedCount: 0, checkAll: false, }) - }, onDelete(e) { const item = e.currentTarget.dataset.item; diff --git a/pages/personalCenter/index.js b/pages/personalCenter/index.js index b7bd420..486252c 100644 --- a/pages/personalCenter/index.js +++ b/pages/personalCenter/index.js @@ -145,7 +145,11 @@ }, onShow() { - + if (typeof this.getTabBar === 'function' && this.getTabBar()) { + this.getTabBar().setData({ + active: 4 + }) + } }, /** * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔 diff --git a/pages/student/index.js b/pages/student/index.js index 9a56f81..6911ad5 100644 --- a/pages/student/index.js +++ b/pages/student/index.js @@ -26,7 +26,11 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ onShow() { - + if (typeof this.getTabBar === 'function' && this.getTabBar()) { + this.getTabBar().setData({ + active: 2 + }) + } }, /** -- Gitblit v1.9.1