支付宝小程序的getPhoneNumber
时间: 2023-12-04 13:04:37 浏览: 120
函数如何使用?
可以使用以下代码获取用户的手机号:
wx.login({
success: function(res) {
var code = res.code;
wx.getUserInfo({
withCredentials: true,
success: function(res_user) {
var encryptedData = res_user.encryptedData;
var iv = res_user.iv;
wx.request({
url: 'https://xx.com/decrypted',
data: {
appId: 'wxXXXXXX',
encryptedData: encryptedData,
iv: iv,
code: code
},
method: 'POST',
success: function(res) {
var phoneNumber = res.data.phoneNumber;
console.log(phoneNumber);
}
});
}
})
}
})
阅读全文