杨磊
2025-08-07 375513370cc01fcd976987d07797249600b0bb3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<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>