uni.login({
provider: 'sinaweibo',
success: function (res) {
// 拉起微博授权后没有进入success 和 fail
console.log('微博登录2')
uni.getUserInfo({
provider: 'sinaweibo',
success: function(info) {
console.log(info , '获取的用户信息')
// 获取用户信息成功, info.authResult保存用户信息
var data = {
code:'Wb',
openid:info.userInfo.id,
nickname:info.userInfo.nickName,
type:type //微博登录
}
that.$wqzApi.appLogin(data).then(res=>{
uni.hideLoading()
uni.showToast({
title:'登录成功',
icon:'success'
})
uni.setStorageSync('token' , res.data)
setTimeout(()=>{
uni.switchTab({
url:'/pages/my/my'
})
},1500)
}).catch(err=>{
console.log(err , '登录报错')
if(err.data.code == -6){
that.wx_info = err.data.data
uni.showToast({
title:err.data.title,
icon:'none',
})
that.phoneSHow = true
}else{
uni.showToast({
title:'登录失败',
icon:'none',
})
}
})
}
})
},
fail: function (err) {
// 拉起微博授权后没有进入success 和 fail
console.log(err , '微博报错3')
uni.hideLoading()
// 登录授权失败
// err.code是错误码
}
});
1***@qq.com
- 发布:2024-01-14 11:47
- 更新:2024-01-14 11:47
- 阅读:66
0 个回复