123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // pages/Home/Home.js
- Page({
- data: {
- selected: 0
- },
- // 页面显示时的逻辑
- onShow: function() {
- // 检查缓存中的登录用户
- const currentUser = wx.getStorageSync('currentUser');
-
- // 如果用户已登录,跳转到 /pages/threshold/threshold 页面
- if (currentUser) {
- wx.switchTab({
- url: '/pages/threshold/threshold'
- });
- return; // 停止后续代码执行
- }
- // 如果没有登录,则正常显示页面内容
- if (typeof this.getTabBar === 'function' && this.getTabBar()) {
- this.getTabBar().setData({
- selected: 0 // 当前页面在tabBar中的索引
- });
- }
- // 隐藏返回首页按钮
- if (wx.hideHomeButton) {
- wx.hideHomeButton();
- }
- },
- // 其他跳转方法
- SoilPro() {
- wx.navigateTo({
- url: '/shoping/SoilPro/SoilPro'
- });
- },
- Overview: function() {
- wx.navigateTo({
- url: '/shoping/Overview/Overview'
- });
- },
- ResearchFindings() {
- wx.navigateTo({
- url: '/shoping/ResearchFindings/ResearchFindings'
- });
- },
- Unit_Team_Profile() {
- wx.navigateTo({
- url: '/shoping/Unit Team Profile/Unit Team Profile'
- });
- }
- });
|