From 36eaed419e4ec367e9e6d137430e2d5d2cf06a07 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Tue, 11 Mar 2025 14:25:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(components):=20=E5=BA=95=E9=83=A8=20tabber?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84=E5=8F=8A=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E8=B7=B3=E8=BD=AC=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 tabber点击跳转逻辑,使用 uni.navigateTo 替代原生跳转 - 添加用户类型和 tabber 索引的本地存储支持 - 优化 tabber 数据初始化,根据用户类型动态生成 - 在学员的个人中心页面集成底部 tabber 组件 --- components/AQ/AQTabber.vue | 46 ++++++++++++++++++++++++++------------ pages/student/my/my.vue | 7 +++++- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/components/AQ/AQTabber.vue b/components/AQ/AQTabber.vue index 0bdcac1..b01d7f1 100644 --- a/components/AQ/AQTabber.vue +++ b/components/AQ/AQTabber.vue @@ -1,7 +1,7 @@ @@ -15,7 +15,7 @@ data() { return { userType:'1',//用户类型|1=教练,2=销售,3=学员 - current:'0', + tabBerIndex:'0', tabBar: [] }; }, @@ -27,30 +27,41 @@ methods: { async init(){ + uni.setStorageSync('userType','1') + + let userType = uni.getStorageSync('userType') + let tabBerIndex = uni.getStorageSync('tabBerIndex') + if(tabBerIndex){ + this.tabBerIndex = String(tabBerIndex) + }else{ + this.tabBerIndex = '0' + } + + switch (String(this.userType)){ case "1"://教练 this.tabBar = [ { text: "首页", - urlPath:'pages/student/index/index',//自定义页面跳转路径 + urlPath:'/pages/student/index/index',//自定义页面跳转路径 iconPath: "/static/images/tabbar/home.png", selectedIconPath: "/static/images/tabbar/home_selected.png" }, { text: "课表", - urlPath:'pages/student/timetable/index',//自定义页面跳转路径 + urlPath:'/pages/student/timetable/index',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" }, { text: "班级", - urlPath:'pages/student/my/my',//自定义页面跳转路径 + urlPath:'/pages/student/my/my',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" }, { text: "我的", - urlPath:'pages/student/my/my',//自定义页面跳转路径 + urlPath:'/pages/student/my/my',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" } @@ -60,19 +71,19 @@ this.tabBar = [ { text: "首页", - urlPath:'pages/student/index/index',//自定义页面跳转路径 + urlPath:'/pages/student/index/index',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" }, { text: "线索", - urlPath:'pages/student/my/my',//自定义页面跳转路径 + urlPath:'/pages/student/my/my',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" }, { text: "添加", - urlPath:'pages/student/my/my',//自定义页面跳转路径 + urlPath:'/pages/student/my/my',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png", midButton: true, @@ -81,13 +92,13 @@ }, { text: "数据", - urlPath:'pages/student/my/my',//自定义页面跳转路径 + urlPath:'/pages/student/my/my',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" }, { text: "我的", - urlPath:'pages/student/my/my',//自定义页面跳转路径 + urlPath:'/pages/student/my/my',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" } @@ -97,19 +108,19 @@ this.tabBar = [ { text: "首页", - urlPath:'pages/student/index/index',//自定义页面跳转路径 + urlPath:'/pages/student/index/index',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" }, { text: "课表", - urlPath:'pages/student/timetable/index',//自定义页面跳转路径 + urlPath:'/pages/student/timetable/index',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" }, { text: "我的", - urlPath:'pages/student/my/my',//自定义页面跳转路径 + urlPath:'/pages/student/my/my',//自定义页面跳转路径 iconPath: "/static/images/tabbar/my.png", selectedIconPath: "/static/images/tabbar/my.png" } @@ -120,6 +131,13 @@ openView(e){ console.log('点击跳转',e) + //跳转tabBar页面 + uni.setStorageSync('tabBerIndex',e.index) + + console.log('qqq',e.urlPath) + uni.navigateTo({ + url:e.urlPath + }) }, } } diff --git a/pages/student/my/my.vue b/pages/student/my/my.vue index 8a317b2..426b7c6 100644 --- a/pages/student/my/my.vue +++ b/pages/student/my/my.vue @@ -105,10 +105,14 @@ + +