<template>
  <div class="email-registration">
    <!-- 完成注册 -->
    <div class="form">
      <div class="title">
        {{ Hinttext }}
      </div>
    </div>
  </div>
</template>
<script setup>
import { useRoute, useRouter } from "vue-router";
import { ref, watch, onMounted, onUpdated, onUnmounted,onBeforeMount} from "vue";
import { checkAccount } from "@/api/account";
const route = useRoute();
const router = useRouter();
const token = ref("");
import { ElMessage } from "element-plus";
import { setLocale } from "@/i18n";
//
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const language = ref(null); // 语言
window["$t"] = t;
//
const Hinttext = ref(t('VerificationInProgressPleaseWaitAMoment'));
// gj验证中，请稍候
//确认
function nextStep() {
    checkAccount(token.value,
  )
    .then(() => {
      Hinttext.value = t('VerificationSuccessfulPleaseLogIn');
      // gj登录成功，跳转到首页
      setTimeout(() => {
        router.push("/");
      }, 3000);
    })
    .catch(() => {
      Hinttext.value = t('VerificationFailed');
      // gj验证失败
    });
}
onBeforeMount(() => {
  // 语言
  getPromiseStorage("language")
    .then((res) => {
      console.log("获取语言成功", res);
      language.value = res;
      setLocale(language.value);
    })
    .catch((err) => {
      console.log("获取语言失败", err);
    });
});
onMounted(() => {
  token.value = route.params.token;
  nextStep();
});

onUpdated(() => {
  // 组件更新后执行
});

onUnmounted(() => {
  // 组件销毁前执行
});
</script>

<style scoped>
.email-registration {
  padding: 0;
  margin: 0;
  width: 100vw;
  height: 100vh;
  background-image: url(../assets/bg.png);
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.form {
  margin-top: 30px;
  width: 80%;
  height: 80%;
  background-image: linear-gradient(180deg, #dbf0f1, #ffffff);
  border-radius: 10px;
  border: 1px solid #4fcacd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.title {
  font-size: 100px;
  color: #03aba8;
  font-weight: bold;
  transition: all 0.5s ease-in-out;
}
</style>
