小程序unionID获取

发布于 8 年前作者 rchang15169 次浏览最后编辑 8 年前来自 ask

原先通过wx.login接口获取到code用来换取session-key,再通过wx.getUserInfo接口将

encryptedData和iv、session-key来换取unionID,现在接口调整后怎么获取啊,官方文档上说wx.login接口可以得到unionID。

2 回复
jintao
jintao1 楼6 年前

感谢大佬回答,我先试试。

guiyinghe
guiyinghe2 楼6 年前

<button open-type=“getUserInfo” bindgetuserinfo=“userInfoHandler”> Click me </button>

userInfoHandler:function(e){
    console.log(e)
    if (e.detail.errMsg === "getUserInfo:ok"){
      //用户同意授权,执行wx.login、wx.getUserinfo
       
    }else{
      console.log('用户拒绝授权')
    }
  },