|
@@ -128,27 +128,36 @@ export default {
|
|
} else if (option.scanCode) {
|
|
} else if (option.scanCode) {
|
|
this.scanCode = option.scanCode
|
|
this.scanCode = option.scanCode
|
|
}
|
|
}
|
|
- let that = this;
|
|
|
|
// this.from = option.from;
|
|
// this.from = option.from;
|
|
- uni.login({
|
|
|
|
- provider: 'weixin',
|
|
|
|
- success: function(loginRes) {
|
|
|
|
- that.code = loginRes.code;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ onShow() {
|
|
|
|
+ // 获取code
|
|
|
|
+ this.getwxCode()
|
|
},
|
|
},
|
|
- mounted() {},
|
|
|
|
methods: {
|
|
methods: {
|
|
|
|
+ getwxCode() {
|
|
|
|
+ uni.login({
|
|
|
|
+ provider: 'weixin',
|
|
|
|
+ success: (loginRes) => {
|
|
|
|
+ this.code = loginRes.code
|
|
|
|
+ console.log('获取的code:', this.code)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
wxLogin(e) {
|
|
wxLogin(e) {
|
|
-
|
|
|
|
- console.log(e)
|
|
|
|
-
|
|
|
|
|
|
+ console.log('eeeee:', e, this.code)
|
|
this.$api.wxLogin({
|
|
this.$api.wxLogin({
|
|
code: this.code,
|
|
code: this.code,
|
|
encryptedData: e.detail.encryptedData,
|
|
encryptedData: e.detail.encryptedData,
|
|
iv: e.detail.iv
|
|
iv: e.detail.iv
|
|
}).then(res => {
|
|
}).then(res => {
|
|
- this.loginCallback(res, 'wxlogin')
|
|
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
+ this.loginCallback(res, 'wxlogin')
|
|
|
|
+ } else {
|
|
|
|
+ this.getwxCode()
|
|
|
|
+ // this.$u.toast(res.data.msg);
|
|
|
|
+ }
|
|
})
|
|
})
|
|
},
|
|
},
|
|
canLogin() {
|
|
canLogin() {
|
|
@@ -341,8 +350,8 @@ export default {
|
|
},
|
|
},
|
|
// 微信、密码、验证码 登录成功的回调
|
|
// 微信、密码、验证码 登录成功的回调
|
|
loginCallback(res, types) {
|
|
loginCallback(res, types) {
|
|
- console.log('登录后的回调',res)
|
|
|
|
- if(res.data.data.full_info){
|
|
|
|
|
|
+ console.log('登录后的回调',res, res.data)
|
|
|
|
+ if(res.data.data && res.data.data.full_info){
|
|
//信息完善,直接进入页面
|
|
//信息完善,直接进入页面
|
|
uni.setStorageSync('user_account', res.data.data.user_account);
|
|
uni.setStorageSync('user_account', res.data.data.user_account);
|
|
uni.setStorageSync('token', res.data.data.token);
|
|
uni.setStorageSync('token', res.data.data.token);
|