美文网首页
微信小程序获取用户电话号码code、用户信息

微信小程序获取用户电话号码code、用户信息

作者: hao_developer | 来源:发表于2022-06-28 15:00 被阅读0次

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));
      }
    })
  }
image.png

相关文章

网友评论

      本文标题:微信小程序获取用户电话号码code、用户信息

      本文链接:https://www.haomeiwen.com/subject/qcnavrtx.html