| @@ -141,6 +141,8 @@ | |||
| smsCode: null, //短信验证码 | |||
| codeTime: null, //短信验证码发送时间 | |||
| openId: null, // openId | |||
| headimgurl: "", // 微信头像url | |||
| nickname: "", // 微信昵称 | |||
| // memberName: null, //身份信息 | |||
| // idcard: null, //身份号码 | |||
| // rememberMe: false | |||
| @@ -149,8 +151,6 @@ | |||
| codeUrl: "", //验证码 | |||
| isSmsLogin: false, //是否手机验证码 | |||
| computeTime: 0, | |||
| headimgurl: "", | |||
| nickname: "", | |||
| }; | |||
| }, | |||
| created() { | |||
| @@ -165,6 +165,7 @@ | |||
| this.showMessage = !this.showMessage | |||
| }, | |||
| wxAuth() { | |||
| var _this = this; | |||
| // 非静默授权:snsapi_userinfo,有弹框弹出需要用户手动点击确认授权。可以获取openId,用户的头像、昵称等 | |||
| return new Promise((resolve, reject) => { | |||
| let openid = this.$cookie.get('openid'); | |||
| @@ -193,15 +194,20 @@ | |||
| }).then(res => { | |||
| if (res.data.code == 200) { | |||
| console.log("微信授权完成"); | |||
| this.headimgurl = res.data.headimgurl; | |||
| this.nickname = res.data.nickname; | |||
| console.log(this.headimgurl); | |||
| console.log(this.nickname); | |||
| resolve(res.data); | |||
| } else { | |||
| reject("换取openid失败"); | |||
| console.log("换取openid失败"); | |||
| } | |||
| }); | |||
| } | |||
| }).then(function (res) { | |||
| if(res.data != null && res.data != undefined){ | |||
| _this.formData.headimgurl = res.data.headimgurl; | |||
| _this.formData.nickname = res.data.nickname; | |||
| } | |||
| }).catch(function (reason) { | |||
| console.log(reason); | |||
| }); | |||
| // 静默授权:snsapi_base,没有弹窗,只能获取用户的openId。 | |||
| @@ -307,8 +313,8 @@ | |||
| method: 'post', | |||
| data: this.$http.adornParams({ | |||
| 'openId': this.$cookie.get('openid'), | |||
| 'headimgurl': this.headimgurl, | |||
| 'nickname': this.nickname, | |||
| 'headimgurl': this.formData.headimgurl, | |||
| 'nickname': this.formData.nickname, | |||
| 'mobile': this.formData.mobile, | |||
| 'code': this.formData.smsCode, | |||
| 'codeTime': this.formData.codeTime | |||