sendUserInfo: function () {
var token = app.globalData.token;
wx.getUserInfo({
success: res => {
console.log(“getUserInfo”,res);
wx.request({
url: ‘http://127.0.0.1:3000/userinfo?token=’ + token,
method: ‘POST’,
data: {
rawData: res.rawData,
signature: res.signature,
encryptedData: res.encryptedData,
iv: res.iv
}
})
}
})
}
3.2 服务器端
3.2.1 WXBizDataCrypt.js工具类
var crypto=require(‘crypto’)
function WXBizDataCrypt(appId,sessionKey){
this.appId=appId
this.sessionKey=sessionKey
}
WXBizDataCrypt.prototype.decryptData=function(encryptedData,iv){
var sessionKey=Buffer.from(th