wlzboy
5 天以前 7de1396e315896dbc72a9d54e44f77434ea90f18
app/pages/login.vue
@@ -85,7 +85,13 @@
        isWechat: false, // 是否为微信小程序环境
        wechatOpenId: '', // 微信OpenID
        wechatUnionId: '', // 微信UnionID
        // 页面参数
        pageOptions: {}
      }
    },
    onLoad(options) {
      // 保存页面参数
      this.pageOptions = options || {}
    },
    created() {
      this.getCode()
@@ -153,7 +159,15 @@
        this.$store.dispatch('GetInfo').then(res => {
          // 触发登录成功事件,启动消息轮询
          uni.$emit('user-login')
          // 检查是否有redirect参数指定跳转页面
          if (this.pageOptions.redirect) {
            // 解码redirect参数
            const redirectUrl = decodeURIComponent(this.pageOptions.redirect)
            this.$tab.reLaunch(redirectUrl)
          } else {
            // 默认跳转到首页
          this.$tab.reLaunch('/pages/index')
          }
        })
      },
      
@@ -237,7 +251,15 @@
                  const { setToken } = require('@/utils/auth')
                  setToken(token)
                  
                  this.loginSuccess()
                  // 检查是否有redirect参数指定跳转页面
                  if (this.pageOptions.redirect) {
                    // 解码redirect参数
                    const redirectUrl = decodeURIComponent(this.pageOptions.redirect)
                    this.$tab.reLaunch(redirectUrl)
                  } else {
                    // 默认跳转到首页
                    this.$tab.reLaunch('/pages/index')
                  }
                } else {
                  this.$modal.msgError(response.msg || '登录失败')
                }
@@ -275,7 +297,15 @@
            const { setToken } = require('@/utils/auth')
            setToken(token)
            
            this.loginSuccess()
            // 检查是否有redirect参数指定跳转页面
            if (this.pageOptions.redirect) {
              // 解码redirect参数
              const redirectUrl = decodeURIComponent(this.pageOptions.redirect)
              this.$tab.reLaunch(redirectUrl)
            } else {
              // 默认跳转到首页
              this.$tab.reLaunch('/pages/index')
            }
          } else {
            // OpenID未绑定或验证失败,需要获取手机号绑定
            console.log('该OpenID尚未绑定或验证失败,需要获取手机号')