update template/xcx/components/authorize/authorize.js.

修改小程序授权获取用户信息
This commit is contained in:
吴昊天 2021-04-06 16:33:15 +08:00 committed by Gitee
parent dfc780b20a
commit 155a8b822e

View File

@ -25,11 +25,17 @@ Component({
cloneIner: null,
loading:false,
errorSum:0,
errorNum:3
errorNum:3,
canIUseGetUserProfile: false // 判断是否为最新获取用户信息函数
},
attached() {
this.get_logo_url();
this.setAuthStatus();
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
methods: {
close(){
@ -82,6 +88,24 @@ Component({
}
})
},
// 获取用户信息
getUserProfile() {
let that = this;
wx.showLoading({ title: '正在登录中' });
wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
Util.getCodeLogin((code)=>{
let userInfo = res;
userInfo.code = code.code;
that.getWxUserInfo(userInfo);
})
},
fail: (err) => {
wx.hideLoading();
}
});
},
//授权
setUserInfo(userInfo,isLogin) {
let that = this;