<!-- 注册企业进度 -->
<template>
  <div class="pt-5">
    <div :class="isMobile? 'mobileBox' : 'default-width'">
      <v-btn class="my-2" color="primary" variant="text" @click="router.go(-1)">{{ `<< 返回` }}</v-btn>
    </div>
    <v-card class="pa-5" :class="isMobile? 'mobileBox' : 'default-width'" :elevation="isMobile? '0' : '3'">

      <div style="margin: 80px auto;" :style="{width: isMobile ? '' : '600px'}">

        <!-- 提交企业注册以后跳转显示页面 -->
        <div v-if="!applyInfo || !(Object.keys(applyInfo).length)" class="d-flex flex-column align-center">
          <svg-icon name="submit" size="300"></svg-icon>
          <div>提交成功，审核时间在1~3个工作日内，申请结果会以短信方式通知到您的手机上，请注意查收</div>
        </div>

        <!-- 等待审核 -->
        <div v-else-if="applyInfo.status === '0'">
          <span>您的申请正在审核中，审核时间在1~3个工作日内，申请结果会以短信方式通知到您的手机上，请注意查收</span>
          <div class="mt-5">
            <span>提交时间：{{ applyInfo.createTime }}</span>
          </div>
        </div>

        <!-- 审核不通过 -->
        <div v-else-if="applyInfo.status === '2'">
          <div class="mb-3" style="color: red;">审核不通过</div>
          <div class="mb-3">原因：{{ applyInfo.reason }}</div>
          <div v-if="applyInfo.remark">备注：{{ applyInfo.remark }}</div>
          <div class="mt-5">
            <span>审核时间：{{ applyInfo.updateTime }}</span>
          </div>
          <div class="mt-5">
            <span>提交时间：{{ applyInfo.createTime }}</span>
          </div>
        </div>

        <!-- 审核通过（审核通过不会进入此页面） -->
        <div v-else-if="applyInfo.status === '1'">
          <span>审核通过</span>
        </div>
        <div class="text-center" v-if="!isMobile">
          <v-btn class="mt-16 buttons" color="primary" to="/recruitHome">{{ $t('common.toHome') }}</v-btn>
          <v-btn v-if="applyInfo.status === '2'" class="mt-16 ml-12 buttons" color="primary" to="/recruit/enterprise/register">{{ $t('common.resubmit') }}</v-btn>
        </div>
      </div>
    </v-card>
  </div>
</template>

<script setup>
import { timesTampChange } from '@/utils/date'
import { getUserRegisterEnterpriseApply } from '@/api/personal/user'
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router'; const router = useRouter()
defineOptions({name: 'enterprise-enterpriseRegister-inReview'})

const applyInfo = ref({})

// 组件挂载后添加事件监听器  
const isMobile = ref(false)
onMounted(() => {
  const userAgent = navigator.userAgent
  isMobile.value = /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(userAgent)
})

// 查看用户是否有在申请中的数据
const getApplyInfo = async () => {
  const data = await getUserRegisterEnterpriseApply() // 已经有数据说明已经申请过了
  localStorage.setItem('userApplyInfo', JSON.stringify(data))
  const obj = {
    createTime: timesTampChange(data.createTime), // 创建时间
    updateTime: timesTampChange(data.updateTime), // 更新时间
    status: data.status, // 审核状态（0审核中 1审核通过 2审核不通过）） // 审核状态
    reason: data.reason, // 审核原因
    remark: data.remark, // 备注
  }
  applyInfo.value = obj
}
getApplyInfo()

</script>
<style lang="scss" scoped>
.mobileBox {
  width: 100vw;
  .resume-header {
    margin-bottom: 12px;
  }
}
</style>
