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

获取用户信息

parent c8c30e69
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
finished-text="" 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="'账号: '+userInfo.account"/>
<van-cell :title="'用户ID: '+userInfo.userId"/> <van-cell :title="'用户ID: '+userInfo.userId"/>
<van-cell :title="'Token: '+userInfo.token"/>
<van-cell :title="'接入地址: '+userInfo.domain"/> <van-cell :title="'接入地址: '+userInfo.domain"/>
</van-list> </van-list>
<br> <br>
......
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
if (path != '/') { if (path != '/') {
return; return;
} }
vm.getUserByToken(result,false); vm.getUserByToken(result, false);
}; };
}, },
mounted() { mounted() {
...@@ -50,55 +50,52 @@ export default { ...@@ -50,55 +50,52 @@ export default {
}, },
methods: { methods: {
init() { init() {
if (process.env.NODE_ENV == "dev") { let userInfo = {
let userInfo = { account: null,
account: '18487125843', token: "349eb2231a36490e88bbbe34eb330a5c",
token: 'd2e2c11475a04436bbcf1ca96a7ee056', userId: null,
userId: null, residentId: null,
domain: window.location.href nickName: null,
}; realName: null,
this.initUserInfo(userInfo,true); gender: null,
this.getUserByToken(userInfo,true); headPortrait: null,
domain: window.location.href
};
if (process.env.NODE_ENV == "dev1") {
this.initUserInfo(userInfo, true);
this.getUserByToken(userInfo, true);
} else { } else {
let query = this.$route.query; let query = this.$route.query;
let userInfo = { userInfo.token = query.token
account: query.account, this.initUserInfo(userInfo, true);
token: query.token, if (!userInfo.token) {
userId: null, this.msg = "获取用户信息异常!"
domain: window.location.href
};
this.initUserInfo(userInfo,true);
if (!userInfo.token && !userInfo.account) {
this.msg = "用户信息获取失败!"
callMobile('init', {}); callMobile('init', {});
} else { } else {
if (!userInfo.token) { this.getUserByToken(userInfo, true)
this.msg = "Token获取失败!"
return;
}
if (!userInfo.account) {
this.msg = "账号获取失败!"
return;
}
this.getUserByToken(userInfo,true)
} }
} }
}, },
getUserByToken(userInfo,isPc) { getUserByToken(userInfo, isPc) {
getUserByToken(userInfo.token).then(res => { getUserByToken(userInfo.token).then(res => {
if (res.code == 'SUCCESS') { if (res.code == 'SUCCESS') {
userInfo.userId = res.data userInfo.userId = res.data.userId;
this.initUserInfo(userInfo,isPc); 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(); this.showMsg();
} else { } else {
this.msg = "用户id获取失败!" this.msg = "获取用户信息异常!"
} }
}) })
}, },
handleBack() { handleBack() {
callMobile('goIndex', {}); callMobile('goIndex', {});
}, },
initUserInfo(val,isPc) { initUserInfo(val, isPc) {
if (isPc) { if (isPc) {
window.sessionStorage.setItem('userInfo', JSON.stringify(val)); window.sessionStorage.setItem('userInfo', JSON.stringify(val));
return; 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