App({
  onLaunch() {
    // 检查本地是否有角色信息
    const role = wx.getStorageSync('partnerPosition');
    const hasLogin = wx.getStorageSync('hasLogin');
console.log(role);
    if (hasLogin && role) {
      // 已登录且有角色信息，直接跳转对应主页
      this.redirectByRole(role);
    } else {
      // 未登录，跳转登录页
      wx.redirectTo({ url: '/pages/login/index' });
    }
  },

  // 根据角色跳转页面
  redirectByRole(role) {
    console.log(role.partnerPosition);
    switch (role.partnerPosition) {
      case '5':
        wx.reLaunch({ url: '/pages/home/index' });
        break;
      case '1':
        wx.reLaunch({ url: '/pages/index/index' });
        break;
        case '2':
          wx.reLaunch({ url: '/pages/index/index' });
          break;
          case '3':
            wx.reLaunch({ url: '/pages/index/index' });
            break;
            case '4':
              wx.reLaunch({ url: '/pages/index/index' });
              break;
      default:
        wx.redirectTo({ url: '/pages/login/index' });
    }
  }
});