<template>
  <div>
    <div>页面跳转中......</div>
  </div>
</template>

<script>
import storage from "@/utils/storage";
import { mapMutations } from "vuex";
export default {
  data() {
    return {};
  },
  created() {
    this.getToken();
  },
  methods: {
    ...mapMutations("user", [
      "SET_token",
      "SET_sysName",
      "SET_sysLogo",
      "SET_path",
      "SET_userInfo",
    ]),
    // 获取token
    getToken() {
      let { token, userInfo, siteid, siteName, sysName, sysLogo, path } =
        this.$route.query;
      if (token && userInfo) {
        userInfo = JSON.parse(userInfo);
        this.SET_userInfo(userInfo);
        this.SET_token(token);
        this.SET_sysName(sysName);
        this.SET_sysLogo(sysLogo);
        this.SET_path(path);
        storage.set(2, "siteId", siteid);
        storage.set(2, "siteName", siteName);
        this.$router.push("/home");
      } else {
        this.$message.warning("跳转失败,请重新登录");
        setTimeout(() => {
          location.href = process.env.VUE_APP_API_portal_URL;
        }, 2000);
      }
    },
  },
};
</script>

<style lang="less" scoped></style>
