{ "openId": "OPENID", "nickName": "NICKNAME", "gender": GENDER, "city": "CITY", "province": "PROVINCE", "country": "COUNTRY", "avatarUrl": "AVATARURL", "unionId": "UNIONID", "watermark": { "appid":"APPID", "timestamp":TIMESTAMP }} |
官方文档中对encryptedData解密后的数据结构如上,但是我在dev环境中解密的结果,并没有拿到unionId.
此处获取到的user包含encryptedData信息。然后this.getAccount的方法是将iv跟encryptedData上传至服务器解密。
wx.getUserInfo({ withCredentials: true, success: (user) => { this.getAccount(user.encryptedData, user.iv) .then((account) => { this._user = <User> user.userInfo; this._user.account = account; this.store(); resolve(this._user); }) .catch(() => { reject(); }); }, fail: () => { console.log('failed'); reject(); }, complete: () => { wx.hideLoading(); } }); |
解密结果:
{ openId: 'obIwK0d6tIohLqXnvU9J2km1_XR4', nickName: '乔治林', gender: 1, language: 'zh_CN', city: '', province: '', country: 'CN', avatarUrl: 'xxxx', watermark: { timestamp: 1491535474, appid: 'xxxxxxx' } } |
