<template>
  <div class="archives table_form-container">
    <div class="bar">
      <h4>档案管理</h4>
      <span :class="['status', isActive === true ? 'active' : '']">{{
        isActive ? '已认证' : '未认证'
      }}</span>
      <span class="info">资料审核包含身份信息/联络信息/实名认证/合规文件，需要管理员审核</span>
    </div>
    <div class="content">
      <div class="tab">
        <div class="tab-item">
          <el-button
            :type="tabType === 'identity' ? 'primary' : 'default'"
            @click="tabType = 'identity'"
            >身份信息</el-button
          >
        </div>
      </div>
      <article>
        <p class="warn">
          <el-icon>
            <WarnTriangleFilled />
          </el-icon>
          请填写正确的个人身份信息，以确保所有功能正常使用
        </p>

        <div class="upload">
          <div>
            <p class="warn">证件正面照片</p>
            <img :src="cardInfo.card_1" :key="cardInfo.card_1" alt="证件正面照片" />
          </div>
          <div>
            <p class="warn">证件反面照片</p>
            <img :src="cardInfo.card_2" :key="cardInfo.card_2" alt="证件反面照片" />
          </div>
        </div>
      </article>
    </div>
  </div>
</template>

<script setup lang="ts">
defineOptions({
  name: 'Kyc',
})
import { WarnTriangleFilled } from '@element-plus/icons-vue'
import { getCardInfo } from '@/api/modules/livenessVerification.ts'
import { useUserStore } from '@/stores/modules/user.ts'
import { ref } from 'vue'
const userStore = useUserStore()
// 判断是否认证
const isActive = ref(true)
// 判断信息类型
const tabType = ref('identity')

const cardInfo = ref({
  card_1: '',
  card_2: '',
})

const init = async () => {
  isActive.value = userStore?.userInfo?.real_check !== 1

  const data = await getCardInfo()
  console.log(data)
  cardInfo.value = data[0]
}

onMounted(() => {
  init()
})
</script>

<style scoped lang="scss">
.archives {
  height: 100%;

  .bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;

    .status {
      background: #f56c6c;
      border-radius: 5px;
      padding: 4px;
      margin: 0 10px;
    }

    .active {
      background: var(--el-color-primary);
    }

    .info {
      background: var(--el-color-primary-light-5);
      padding: 4px;
      border-radius: 5px;
    }
  }

  .content {
    display: flex;
    gap: 20px;
    height: calc(100% - 55px);

    .tab {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    article {
      flex: 1;
      height: 100%;
      border: 1px solid #e4e7ed;
      border-radius: 5px;
      padding: 20px;

      .warn {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;

        .el-icon {
          font-size: 20px;
          color: #f56c6c;
        }
      }

      .upload {
        display: flex;
        gap: 20px;

        img {
          width: 200px;
          height: 120px;
          object-fit: cover;
          border-radius: 4px;
          border: 1px solid #e4e7ed;
        }
      }
    }
  }
}
</style>
