<template>
|
<div v-loading="loading" element-loading-text="正在登录"></div>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
loading: true,
|
};
|
},
|
created() {
|
console.log(this.$route.query);
|
this.$store.dispatch("setToken", this.$route.query.token);
|
this.getUserInfo();
|
},
|
methods: {
|
getUserInfo(callback) {
|
this.MG.identity.getCurrentAppUser().then((res) => {
|
// 用户信息优先级:教师认证 > 微信 > 学生(注册时默认)
|
if (res) {
|
let teacherRole = res.roleLinks.find(
|
(item) => item.role.refCode == "teacher"
|
);
|
let teacherInfo = res.infoList.find(
|
(item) => item.type == "teacherInfo"
|
);
|
let wechatInfo = res.infoList.find((item) => item.type == "WeChat");
|
let studentInfo = res.infoList.find((item) => item.type == "Default");
|
let phoneInfo = res.secretList.find(
|
(item) => item.type == "MobilePhone"
|
);
|
if (teacherRole && teacherInfo) {
|
let data = {};
|
try {
|
data = JSON.parse(teacherInfo.data);
|
} catch (error) {
|
data = {};
|
}
|
this.$store.dispatch("setUserInfo", {
|
...data,
|
name: data.fullName,
|
phoneNumber: phoneInfo?.credential,
|
role: "Teacher",
|
roleId: teacherRole.role.id,
|
});
|
} else if (wechatInfo) {
|
this.$store.dispatch("setUserInfo", {
|
...wechatInfo,
|
phoneNumber: phoneInfo?.credential,
|
role: "Student",
|
});
|
} else if (studentInfo) {
|
this.$store.dispatch("setUserInfo", {
|
...studentInfo,
|
phoneNumber: phoneInfo?.credential,
|
role: "Student",
|
});
|
}
|
}
|
// 清空本地储存的申请样书清单
|
this.$store.commit("emptyBookList");
|
|
this.loading = false;
|
this.$router.push({
|
path: this.$route.query.url
|
? decodeURIComponent(this.$route.query.url)
|
: "/home",
|
});
|
});
|
},
|
},
|
};
|
</script>
|
<style lang="less" scoped>
|
div {
|
margin: auto;
|
height: 100vh;
|
}
|
</style>
|