<button open-type="getUserInfo" bindgetuserinfo="loginGetUserInfo">授权登录</button>
var code, iv, encrypteData
Page({
data: {
},
//用户授权登录登录
loginGetUserInfo: function(e) {
// console.log('1111111', e)
iv = e.detail.iv
if (e.detail.iv == undefined) { //如果用户拒绝授权
wx.showToast({
title: '用户拒绝授权,登录失败!',
icon: 'none'
})
return
} else {
wx.login({ //调用登录api,获取 code
success: function(res) {
// console.log('22222222',res)
code = res.code
wx.getUserInfo({//调用授权api,获取用户信息
success: function(res) {
// console.log('3333333',res)
encrypteData = res.encryptedData
wx.request({
url: '接口',
data: {