Commit 2c26227e authored by 罗成兵's avatar 罗成兵

获取用户信息

parent c8c30e69
......@@ -15,9 +15,11 @@
finished-text=""
>
<van-cell :title="'Token: '+userInfo.token"/>
<van-cell :title="'姓名: '+userInfo.nickName"/>
<van-cell :title="'性别: '+(userInfo.nickName==1?'男':'女')"/>
<van-cell :title="'账号: '+userInfo.account"/>
<van-cell :title="'用户ID: '+userInfo.userId"/>
<van-cell :title="'Token: '+userInfo.token"/>
<van-cell :title="'接入地址: '+userInfo.domain"/>
</van-list>
<br>
......
......@@ -39,7 +39,7 @@ export default {
if (path != '/') {
return;
}
vm.getUserByToken(result,false);
vm.getUserByToken(result, false);
};
},
mounted() {
......@@ -50,55 +50,52 @@ export default {
},
methods: {
init() {
if (process.env.NODE_ENV == "dev") {
let userInfo = {
account: '18487125843',
token: 'd2e2c11475a04436bbcf1ca96a7ee056',
account: null,
token: "349eb2231a36490e88bbbe34eb330a5c",
userId: null,
residentId: null,
nickName: null,
realName: null,
gender: null,
headPortrait: null,
domain: window.location.href
};
this.initUserInfo(userInfo,true);
this.getUserByToken(userInfo,true);
if (process.env.NODE_ENV == "dev1") {
this.initUserInfo(userInfo, true);
this.getUserByToken(userInfo, true);
} else {
let query = this.$route.query;
let userInfo = {
account: query.account,
token: query.token,
userId: null,
domain: window.location.href
};
this.initUserInfo(userInfo,true);
if (!userInfo.token && !userInfo.account) {
this.msg = "用户信息获取失败!"
userInfo.token = query.token
this.initUserInfo(userInfo, true);
if (!userInfo.token) {
this.msg = "获取用户信息异常!"
callMobile('init', {});
} else {
if (!userInfo.token) {
this.msg = "Token获取失败!"
return;
}
if (!userInfo.account) {
this.msg = "账号获取失败!"
return;
}
this.getUserByToken(userInfo,true)
this.getUserByToken(userInfo, true)
}
}
},
getUserByToken(userInfo,isPc) {
getUserByToken(userInfo, isPc) {
getUserByToken(userInfo.token).then(res => {
if (res.code == 'SUCCESS') {
userInfo.userId = res.data
this.initUserInfo(userInfo,isPc);
userInfo.userId = res.data.userId;
userInfo.account = res.data.account;
userInfo.residentId = res.data.residentId;
userInfo.nickName = res.data.nickName;
userInfo.gender = res.data.gender;
userInfo.headPortrait = res.data.headPortrait;
this.initUserInfo(userInfo, isPc);
this.showMsg();
} else {
this.msg = "用户id获取失败!"
this.msg = "获取用户信息异常!"
}
})
},
handleBack() {
callMobile('goIndex', {});
},
initUserInfo(val,isPc) {
initUserInfo(val, isPc) {
if (isPc) {
window.sessionStorage.setItem('userInfo', JSON.stringify(val));
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment