uniapp在app开发微信登录功能,uni.login无任何响应,代码如下:
<button id="btnwx" class="login-wxpng" open-type="getUserInfo" @click="appWxLogin"></button>
...
appWxLogin() {
uni.getProvider({
service: 'oauth',
success: function(res) {
//支持微信、qq和微博等
if (~res.provider.indexOf('weixin')) {
uni.login({
provider: 'weixin',
success: function(loginRes) {
let access_token = loginRes.authResult.access_token
let openid = loginRes.authResult.openid
console.log('-------获取openid(unionid)-----');
console.log('token', access_token)
console.log('openid', openid)
console.log(JSON.stringify(loginRes));
// 获取用户信息
uni.getUserInfo({
provider: 'weixin',
success: function(infoRes) {
console.log('-------获取微信用户所有-----');
console.log(JSON.stringify(infoRes.userInfo));
}
});
},
fail(e) {
console.log(e);
},
complete(e) {
console.log(e);
}
});
}
}
});
},
如上,uni.getProvider成功后,调用uni.login无效,无任何反应,fail与complete也没进去