uni.login({
provider: 'weixin',
success: function(loginRes) {
// 获取用户信息
uni.getUserInfo({
provider: 'weixin',
success: function(infoRes) {
self.appUserInfo = infoRes.userInfo
if( infoRes.userInfo){
self.wxLoginApi()
}else{
uni.showModal({
content: '没有获取到授权,请重新点击按钮授权登陆',
showCancel: false
});
}
},
fail() {
uni.showToast({
title: '获取用户信息失败',
icon: 'none',
duration: 2000
})
},
complete() {
uni.hideLoading()
}
});
},
fail(ex) {
console.log("失败原因",ex)
uni.hideLoading()
uni.showToast({
title: "失败原因:"+ex.errMsg,
icon: 'none',
duration: 2000
})
}
});