在app.js中
userLogin: function () {
// 登录
var that = this;
wx.login({
success: res => {
console.log(res)
if (res.code) {
wx.request({
url: '接口名称',
data: {
code: res.code,
time: that.globalData.time,
rand: that.globalData.pwd,
sign: that.globalData.jiamiStr
},
header: {
'content-type': 'application/json'
},
success: function (data) {
console.log(data)
if (data.data.status == 200 && data.data.session_key != null) {
wx.setStorageSync('session_key', data.data.session_key);
that.userInfo();
}
}
});
} else {
console.log('登录失败!' + res.errMsg)
}
}
});
},
userInfo: function () {