运维小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. App({
  2. onLaunch() {
  3. // 检查本地是否有角色信息
  4. const role = wx.getStorageSync('partnerPosition');
  5. const hasLogin = wx.getStorageSync('hasLogin');
  6. console.log(role);
  7. if (hasLogin && role) {
  8. // 已登录且有角色信息,直接跳转对应主页
  9. this.redirectByRole(role);
  10. } else {
  11. // 未登录,跳转登录页
  12. wx.redirectTo({ url: '/pages/login/index' });
  13. }
  14. },
  15. // 根据角色跳转页面
  16. redirectByRole(role) {
  17. console.log(role.partnerPosition);
  18. switch (role.partnerPosition) {
  19. case '5':
  20. wx.reLaunch({ url: '/pages/home/index' });
  21. break;
  22. case '1':
  23. wx.reLaunch({ url: '/pages/index/index' });
  24. break;
  25. case '2':
  26. wx.reLaunch({ url: '/pages/index/index' });
  27. break;
  28. case '3':
  29. wx.reLaunch({ url: '/pages/index/index' });
  30. break;
  31. case '4':
  32. wx.reLaunch({ url: '/pages/index/index' });
  33. break;
  34. default:
  35. wx.redirectTo({ url: '/pages/login/index' });
  36. }
  37. }
  38. });