import { state } from '@/state'
import { defineComponent } from 'vue'
import Auth from './components/auth'
import CertBrief from './components/cert-brief'
import { teacherState } from './teacherState'

export const getAssetsHomeFile = (fileName: string) => {
  const path = `../images/${fileName}`
  const modules = import.meta.globEager('../images/*')
  return modules[path].default
}

export default defineComponent({
  name: 'teacherAuth',
  async mounted() {
    try {
      // 判断是否登录
      if (state.user.status !== 'login') {
        return
      }
      // 老师入驻状态 0、未申请 UNPAALY、未申请 DOING、审核中 PASS、通过 UNPASS、不通过
      const entryStatus = state.user.data?.entryStatus || 0
      teacherState.authStatus =
        entryStatus === 'DOING' || entryStatus === 'PASS' ? true : false
      // 如果已经认证，则不用获取声部信息
      // if (teacherState.authStatus) {
      //   teacherState.active = teacherState.authStatus ? 4 : 1
      //   return
      // }
      // console.log(teacherState.authStatus, 'teacherState.authStatus')
    } catch {
      //
    }
  },
  computed: {
    authStatus(): Boolean {
      const entryStatus = state.user.data?.entryStatus || 0
      return entryStatus === 'DOING' || entryStatus === 'PASS' ? true : false
    },
    userAuth() {
      // 判断是否实名过
      const users = state.user.data || {}
      return !!(users.idCardNo && users.realName)
    }
  },
  render() {
    return (
      <div class="mt-[62px] bg-white min-h-full m-auto text-[#333]">
        {this.authStatus || !teacherState.nextStatus ? <CertBrief /> : <Auth />}
        {/* <Auth /> */}
      </div>
    )
  }
})
