<template>
  <div class="login">

    <div class='loader-title'>系  统  加  载  中 . . . </div>
    <!--  底部  -->
    <div class="el-login-footer">
      <span>Copyright © 2024 my.com All Rights Reserved.</span>
    </div>
  </div>
</template>

<script>
import {getToken} from '@/utils/auth';
import {getH4aUrl} from '@/api/login'


export default {
  name: "Login",
  props: ['id'],
  data() {
    return {
      codeUrl: "",
      loginForm: {
        username: "admin",
        password: "admin123",
        rememberMe: false,
        code: "",
        uuid: "",
        token: ""
      },
      loading: false,
      redirect: undefined
    };
  },
  watch: {
    $route: {
      handler: function (route) {
        this.redirect = route.query && route.query.redirect;
      },
      immediate: true
    }
  },
  created() {
    this.handleLogin();
  },
  methods: {
    handleLogin() {
      const token = this.$route.query.token;
      if (token) {
        this.loading = true;
        this.loginForm.token = token;
        this.loginForm.loginType = 'h4a';
          this.$store.dispatch("Login", this.loginForm).then(() => {
            this.$router.push({path: this.redirect || "/"}).catch(() => {
            });
          }).catch(() => {
            this.loading = false;
          });
      } else {
        getH4aUrl().then(res => {
          window.location.href = res.url;
        })

      }
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss">
.login {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  //background-image: url("../assets/images/login-background.jpg");
  background-size: cover;
}

.loader-title {
    font-weight: bold;
    z-index: 1002;
    position: absolute;
    top: 50%;
    margin-top: 15px;
    color: #646567;
    font-size: 30px;
    width: 100%;
    height: 30px;
    text-align: center;
    opacity: 0.4;
    line-height: 30px;
}

.el-login-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #fff;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}

.login-code-img {
  height: 38px;
}
</style>
