如题,获取OpenID:
uni.login({
provider: 'weixin',
success: function(res) {
console.info("获取的resCode是:" + res.code);
let url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + this.appid + '&secret=' +
this.secret + '&js_code=' +
res.code + '&grant_type=authorization_code';
uni.request({
url: url, // 请求路径
success: result => {
console.info("用户的OpenID是:" + result.data.openid);
},
});
}
});