Home.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Page({
  2. data: {
  3. selected: 0
  4. },
  5. // 页面显示时的逻辑
  6. onShow: function() {
  7. // 检查缓存中的登录用户
  8. const currentUser = wx.getStorageSync('currentUser');
  9. // 如果用户已登录,跳转到 /pages/threshold/threshold 页面
  10. if (currentUser) {
  11. wx.switchTab({
  12. url: '/pages/threshold/threshold'
  13. });
  14. return; // 停止后续代码执行
  15. }
  16. // 如果没有登录,则正常显示页面内容
  17. if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  18. this.getTabBar().setData({
  19. selected: 0 // 当前页面在tabBar中的索引
  20. });
  21. }
  22. // 隐藏返回首页按钮
  23. if (wx.hideHomeButton) {
  24. wx.hideHomeButton();
  25. }
  26. },
  27. // 其他跳转方法
  28. SoilPro() {
  29. wx.navigateTo({
  30. url: '/shoping/SoilPro/SoilPro'
  31. });
  32. },
  33. Overview: function() {
  34. wx.navigateTo({
  35. url: '/shoping/Overview/Overview'
  36. });
  37. },
  38. ResearchFindings() {
  39. wx.navigateTo({
  40. url: '/shoping/ResearchFindings/ResearchFindings'
  41. });
  42. },
  43. Unit_Team_Profile() {
  44. wx.navigateTo({
  45. url: '/shoping/Unit Team Profile/Unit Team Profile'
  46. });
  47. },
  48. mapView() {
  49. wx.navigateTo({
  50. url: '/shoping/mapView/mapView'
  51. });
  52. }
  53. });