<template>
  <div class="px-5">
    <Login
      title="欢迎来到乐映"
      :accountStatusCheckFunc="accountStatusCheckFunc"
      :sendSmsFunc="sendSmsFunc"
      :sendVoiceFunc="sendVoiceFunc"
      :registerFunc="registerFunc"
      :loginByCodeFunc="loginByCodeFunc"
      :loginByPwdFunc="loginByPwdFunc"
    />
  </div>
</template>
  
<script lang="ts">
import Vue from "vue";
import Login from "./Login.vue";
import { eAccountType } from "./types";

function delay(n: number) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(1);
    }, n * 1000);
  });
}

export default Vue.extend({
  components: { Login },
  methods: {
    async accountStatusCheckFunc(phone: string) {
      await delay(1);
      return eAccountType.REG;
    },
    async sendSmsFunc(phone: string) {
      await delay(1);
      return 1;
    },
    async sendVoiceFunc(phone: string) {
      await delay(1);
      return 1;
    },
    async registerFunc(phone: string, code: string) {
      await delay(2);
      // 如果注册成功，保存token
      const success = false;
      if (success) {
        this.$router.push({
          name: "Home",
        });
      } else {
        // 如果注册失败，提示用户失败
      }
    },
    async loginByCodeFunc(phone: string, code: string) {
      delay(1);
    },
    async loginByPwdFunc(phone: string, pwd: string) {
      delay(1);
    },
  },
});
</script>

<style>
</style>