未授权用户授权后getUserInfo回调信息encryptedData解密报错
wxml:
<button type=‘warn’ open-type=“getUserInfo” class=‘btn’ bindgetuserinfo=“getUserInfo”>确认授权</button>
js:
getUserInfo: function (e) {
const appId = ‘******’;
const sessionKey = wx.getStorageSync(‘sessionKey’);
const encryptedData = e.detail.encryptedData;
const iv = e.detail.iv;
const pc = new WXBizDataCrypt(appId, sessionKey);
const data = pc.decryptData(encryptedData, iv);
wx.setStorageSync(‘openId’, data.unionId);
},
调试报错信息如下: