<template>
  <div class="vh100">
    <!-- 导航栏 -->
    <div class="nav-bar">
      <div class="back-btn" @click="$router.back()">
        <i class="arrow-left"></i>
      </div>
      <div class="title">实名认证</div>
    </div>

    <div class="plr20 ptb10">
      <div class="flex alcenter between ptb10 ft16">
        <div class="ft18 bold">认证信息</div>
        <div class="blue2" @click="$router.push('/real-authentication')">实名认证</div>
      </div>

      <div class="u-gap" style="height: 5px;"></div>

      <div class="mt10 ft14">
        <div class="flex alcenter mt10">
          <img src="@/assets/tssp.png" class="wt15 h15" alt="提示" />
          <div class="chengse ft14">丨为保障您的资产安全，请实名认证</div>
        </div>

        <div class="u-gap" style="height: 15px;"></div>
        <div class="u-line"></div>
      </div>

      <div class="u-gap" style="height: 15px;"></div>

      <!-- 认证状态展示 -->
      <div class="auth-info">
        <div class="info-item">
          <span class="label">认证状态：</span>
          <span class="value">{{ userInfo.is_auth ? '已认证' : '未认证' }}</span>
        </div>
        <div class="info-item" v-if="userInfo.is_auth">
          <span class="label">真实姓名：</span>
          <span class="value">{{ userInfo.real_name }}</span>
        </div>
        <div class="info-item" v-if="userInfo.is_auth">
          <span class="label">身份证号：</span>
          <span class="value">{{ userInfo.id_card }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getUserInfo } from '@/api/home';

export default {
  name: 'UserCenter',
  data() {
    return {
      userInfo: {}
    }
  },
  created() {
    this.getUserInfo();
  },
  methods: {
    async getUserInfo() {
      try {
        const res = await getUserInfo();
        this.userInfo = res.data;
      } catch (error) {
        console.error('获取用户信息失败:', error);
      }
    }
  }
}
</script>

<style scoped>
.vh100 {
  min-height: 100vh;
  background: #fff;
}

.nav-bar {
  height: 44px;
  background-color: #ed4b39;
  color: #fff;
  display: flex;
  align-items: center;
  position: relative;
  padding: 0 15px;
}

.back-btn {
  width: 24px;
  height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.arrow-left {
  width: 12px;
  height: 12px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(45deg);
}

.title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: 500;
}

.plr20 { padding: 0 20px; }
.ptb10 { padding: 10px; }
.mt10 { margin-top: 10px; }
.ft14 { font-size: 14px; }
.ft16 { font-size: 16px; }
.ft18 { font-size: 18px; }
.bold { font-weight: bold; }

.flex { display: flex; }
.alcenter { align-items: center; }
.between { justify-content: space-between; }

.blue2 { color: #007AFF; }
.chengse { color: #ff6b00; }

.wt15 {
  width: 15px;
  height: 15px;
}

.h15 {
  height: 15px;
}

.u-gap {
  margin: 0;
}

.u-line {
  margin: 0;
  border-bottom: 1px solid rgba(85, 89, 105, 0.12);
  width: 100%;
  transform: scaleY(0.5);
}

.auth-info {
  margin-top: 20px;
}

.info-item {
  margin-bottom: 15px;
  font-size: 14px;
}

.info-item .label {
  color: #666;
}

.info-item .value {
  color: #333;
  margin-left: 5px;
}
</style> 