小程序 用户授权登录

1.index.wxml中

<button open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
 
2.index.js中
getUserInfo: function(e) {
  console.log(e)
  app.globalData.userInfo = e.detail.userInfo
  this.setData({
    userInfo: e.detail.userInfo,
    hasUserInfo: true
  })
}
原文地址:https://www.cnblogs.com/mcll/p/11475033.html