1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- // 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'
- });
- },
- mapView() {
- wx.navigateTo({
- url: '/shoping/mapView/mapView'
- });
- }
- });
|