| | |
| | | isWechat: false, // 是否为微信小程序环境 |
| | | wechatOpenId: '', // 微信OpenID |
| | | wechatUnionId: '', // 微信UnionID |
| | | // 页面参数 |
| | | pageOptions: {} |
| | | } |
| | | }, |
| | | onLoad(options) { |
| | | // 保存页面参数 |
| | | this.pageOptions = options || {} |
| | | }, |
| | | created() { |
| | | this.getCode() |
| | |
| | | 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') |
| | | } |
| | | }) |
| | | }, |
| | | |
| | |
| | | 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 || '登录失败') |
| | | } |
| | |
| | | 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尚未绑定或验证失败,需要获取手机号') |