const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
code:"",
userInfo:"",
rawData:"",
signature:"",
encryptedData:"",
iv:"",
},
login:function(){
wx.login({
success:(res)=>{
this.setData({
code:res.code
})
console.log(this.data.code);
}
})
wx.getUserProfile({
desc: '用于登录账号,完善身份信息',
success: (res) => {
this.setData({
userInfo:res.userInfo,
rawData:res.rawData,
signature:res.signature,
encryptedData:res.encryptedData,
iv:res.iv,
})
console.log(this.data.encryptedData);
console.log(this.data.iv);
wx.request({//请求接口
url: 'xxxxx', //接口地址
data:{
"code":this.data.code,
"encryptedData":this.data.encryptedData,
"iv":this.data.iv,
},
method:"GET",
header: {
'content-Type': 'application/json',
'Authorization': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2ODkxMzE4NzAsImlhdCI6MTY4OTA4ODY3MCwidXNlcm5hbWUiOiJhZG1pbiJ9.1GRwSvHO6q4QhDYG7sqU3b1uza9z1PsZrAu-jmfK4qU',
'loginType':'ADMIN'
},
success: function (res) {
// 一般在这一打印下看看是否拿到数据
console.log(res)
},
// 请求失败时的一些处理
fail: function () {
// console.log('userI现场支持nfo');
wx.showToast({
icon: "none",
mask: true,
title: "接口调用失败,请稍后再试。",
});
}
})
}})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})