app.js调用wx.login
登录授权页 做成button
<button open-type="getUserInfo" class="tologin" bindgetuserinfo="getKonw">确认授权</button>
getKonw: function ({ detail }) {
console.log('getKnow', detail)
let userInfo = detail.userInfo
console.log(userInfo)
let that = this
wx.setStorageSync('userInfo', userInfo)
if (userInfo) {
that.setUser(userInfo) //后台接口请求的函数
} else{
wx.openSetting({
success: (res) => {
wx.getUserInfo({
success: function (res) {
let userinfo = res.userInfo
that.setUser(userinfo)
}
})
}
})
}
},