<template>
  <div>
    第三方登录...
  </div>
</template>

<script>
export default {
  name: "StudentAccess",
  async mounted() {
    const search = location.search;
    let obj = {};
    for (const [k, v] of new URLSearchParams(location.search).entries()) {
      obj[k] = v;
    }

    const {
      accountType,
      accountValue,
      rootOrgId,
      appId,
      timestamp,
      token,
      redirectUrl,
    } = obj;

    if (
      accountType &&
      accountValue &&
      rootOrgId &&
      appId &&
      timestamp &&
      token &&
      redirectUrl
    ) {
      try {
        const response = await this.$http.post(
          "/api/ecs_core/auth/thirdPartyStudentAccess" + search
        );
        const domain = response.data.rootOrgDomain;
        this.$router.push("/login/" + domain + search);
      } catch (error) {
        window._hmt.push(["_trackEvent", "第三方登录页面", "接口出错", ""]);
        this.$Modal.error({
          title: "返回",
          content: "第三方登录访问错误",
          onOk: () => {
            history.back();
          },
        });
      }
    } else {
      this.$Modal.error({
        title: "返回",
        content: "第三方登录参数错误",
        onOk: () => {
          history.back();
        },
      });
    }
  },
  methods: {
    goBack() {
      history.back();
    },
  },
};
</script>
