<template>
  <div class="box" style="overflow-x: hidden;">
    <navBar :showLoginBtn="false" class="navBar"></navBar>
    <PhonePage v-if="!valid" :isCompany="true" @success="handleValidate" :isLogin="query.login ? true : false"></PhonePage>
  </div>
</template>

<script setup>
defineOptions({ name: 'registerCompany'})
import { getUserRegisterEnterpriseApply } from '@/api/personal/user'
import navBar from '@/layout/personal/navBar.vue'
import { ref } from 'vue'
import PhonePage from './person.vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const query = router.currentRoute.value.query

const valid = ref(false)
const handleValidate = async () => {
  // 已短信登录
  valid.value = true
  if (query.login) {
    router.push({ path: '/recruit/entRegister' })
    return
  } 
  // 查看用户是否有在申请中的数据
  const data = await getUserRegisterEnterpriseApply()
  const bool = data && Object.keys(data).length && data.status !== '1' // 已经有数据说明已经申请过了 且申请状态如果为已通过，则跳转到注册页面让用户可以注册新的企业
  const path = bool ? '/recruit/entRegister/inReview' : '/recruit/entRegister'
  router.push({ path, query: { type: 'noLoginToRegister' } })
}
// handleValidate() // 测试

</script>

<style scoped lang="scss">
.navBar {
  position: absolute;
  top: 0;
  z-index: 2;
}
.box {
  position: relative;
  width: 100%;
  height: 100%;
  background-image: url('https://minio.menduner.com/dev/menduner/login-banner.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
}
.content {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: 600px;
  height: 90%;
  overflow: auto;
  background-color: #fff;
  border-radius: 10px;
}
.note {
  color: var(--color-666);
  font-size: 14px;
  line-height: 32px;
}
.login-tips {
  width: 100%;
  font-size: 14px;
  text-align: center;
}
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-thumb, .temporaryAdd ::-webkit-scrollbar-thumb, .details_edit ::-webkit-scrollbar-thumb {
  // 滚动条-颜色
  background: #c3c3c379;
}
::-webkit-scrollbar-track, .temporaryAdd ::-webkit-scrollbar-track, .details_edit ::-webkit-scrollbar-track {
  // 滚动条-底色
  background: #e5e5e58f;
}
</style>
