导入base64的包来解析
npm install --save base-64
getUser(returntoken) {
var base64 = require('base-64');
// alert('11.' + JSON.stringify(base64))
let splitStr = returntoken.split(".")[1];
// alert('12.' + splitStr)
let userstr = base64.decode(splitStr); // 解码
// alert('13.' + userstr)
let userinfo = JSON.parse(userstr);
// alert('9.获取用户信息成功')
sessionService.setSessionStorage({
token: returntoken,
tempToken: userinfo.tempToken,
name: decodeURI(userinfo.user_name),
nickname: decodeURI(userinfo.user_nickname),
tenant_id: userinfo.tenant_id,
tenant_uid: userinfo.tenant_uid,
tel: userinfo.user_tel,
id_number: userinfo.user_id_number,
userId: userinfo.user_id,
tenant_name: '',
tenant_shortName: '',
qydm: userinfo.tenant_id,
qyId: userinfo.tenant_uid,
user_id_number: userinfo.user_id_number,
user_kind: userinfo.user_kind,
user_tel: userinfo.user_tel,
time: new Date(),
});
this.$router.push({ path: '/home' });
},