<style scoped>
.bg-img {
  background-image: linear-gradient(rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 1) 90%), url("@images/auth/auth_img00.svg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50rem;
  padding: 6rem 0;
}
.area {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(0.6rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  font-family: Abel;
  color: #000;
}
.card {
  background-color: #fff;
  border-radius: 0;
  padding: 1rem 4rem;
}
.card-header {
  background-color: transparent;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-header img {
  width: 30%;
}
.card-body h1 {
  font-family: 'Noto Serif';
  font-size: 1.8rem;
  font-weight: bold;
  text-align: center;
  padding-top: 6rem;
}
.card-body h5 {
  color: #3d3d3d;
  font-size: 0.8rem;
  font-weight: bold;
  text-align: center;
  padding-top: 0.8rem;
  padding-bottom: 2rem;
}
.card-body p {
  font-size: 1rem;
  font-weight: bold;
}
.row {
  --bs-gutter-x: 0;
}
a {
  color: #000 !important;
  font-size: 1rem;
  font-weight: bold;
  -webkit-text-stroke: 0.5px #000;
}
.goto-area {
  margin-top: 6rem;
}
@media (max-width: 768px) {
  .area {
    padding: 4rem 2rem;
  }
  .card {
    padding: 1rem 2rem;
  }
}

/* #region ========= area2 */
.area2 {
  background-color: #000;
  min-height: 10rem;
}
/* #endregion */
</style>
<template>
  <div class="bg-img">
    <div class="area col-12 col-md-9 col-xl-7">
      <div class="card col-md-9 col-xl-7">
        <div class="card-header">
          <img src="@images/auth/auth_img01.svg" alt="logo" />
        </div>
        <div class="card-body p-0">
          <h1>信箱驗證</h1>
          <h5>請至信箱收取驗證信，並透過驗證信中的連結進行驗證開通！</h5>

          <p class="text-center text-danger">{{ msg }}</p>
          <br/>

          <div class="text-center goto-area">
            <router-link to="/login" class="gotoLogin" v-if="state">前往登入</router-link>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="area2"></div>
</template>
<script>
import { api } from "@/global/axios";
export default {
  data() {
    return {
      msg: "信箱驗證中...",
      state: false,
    };
  },
  mounted() {
    this.verifyEmail();
  },
  methods: {
    verifyEmail() {
      const url = `/api/email/verify/${this.$route.params.id}/${this.$route.params.hash}?expires=${this.$route.query.expires}&signature=${this.$route.query.signature}`;
      api.get(url)
        .then(response => {
          this.msg = "信箱驗證成功！";
          this.state = true;
        })
        .catch(error => {
          this.msg = `信箱驗證失敗！ \n ${error}`;
        });
    },
  }
}
</script>