微信小程序获取用户电话号码code、用户信息
2022-06-28 本文已影响0人
hao_developer
wxml文件
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">电话</button>
<button bindtap="getUserProfile">获取用户信息</button>
js文件方法
//通过code云开发获取电话号码
getPhoneNumber(res) {
console.log('电话获取')
console.log(res)
wx.cloud.callFunction({
name:"getPhone",
data:{
code: res.detail.code
}
}).then(res =>{
console.log(res);
}).catch(err =>{
console.log(err);
})
}
//用户信息
getAuthorize() {
wx.authorize({
scope: 'scope.bluetooth',
success: (res) => {
console.log(JSON.stringify(res));
},
fail: (res) => {
console.log(JSON.stringify(res));
}
})
}
