<template>
  <view class="page flex-col">
    <view class="block_1 flex-row">
    
      
    </view>
    <view class="block_2 flex-col">
      <view class="box_3 flex-row">
        <image
          class="label_1"
          referrerpolicy="no-referrer"
          src="/static/lanhu_kaoshijieguoluru/FigmaDDSSlicePNGacf527a62cbe7351c6472edd8f5b2814.png"
		  @click="handleBack()"
        />
        <text class="text_1">考试结果录入</text>
        
      </view>
      <!-- <view class="box_5 flex-col">
        <view class="block_3 flex-row justify-between">
          <view class="text-group_1 flex-col justify-between">
            <text class="text_2">2025-01-20</text>
            <text class="text_3">考试名称</text>
          </view>
          <view class="text-group_2 flex-col justify-between">
            <text class="text_4">99分</text>
            <text class="text_5">考试通过</text>
          </view>
        </view>
        <view class="block_4 flex-row justify-between">
          <view class="text-wrapper_1 flex-col">
            <text class="text_6">科目二</text>
          </view>
          <view class="text-wrapper_2 flex-col">
            <text class="text_7">C2</text>
          </view>
        </view>
        <view class="text-wrapper_3 flex-row justify-between">
          <text class="text_8">考试地址：</text>
          <text class="text_9">山东省济南市历下区</text>
        </view>
        <view class="block_5 flex-row">
          <view class="text-wrapper_4 flex-col">
            <text class="text_10">开始评价</text>
          </view>
        </view>
      </view> -->
      <view class="list_1 flex-col">
        <view
          class="list-items_1 flex-col"
          v-for="(item, index) in examList"
          :key="index"
        >
          <view class="block_6 flex-row justify-between">
            <view class="text-group_3 flex-col justify-between">
              <text class="text_11" >{{ formatDate(item.examTime) }}</text>
              <text class="text_12" >{{item.courseName}}</text>
            </view>
            <view class="text-group_4 flex-col justify-between">
              <text
                class="text_13"
                :style="{ color: item.examScore }"
              >{{item.examScore}}</text>
              <text
                class="text_14"
                :style="{ color: item.examStatus }"
              >{{ getStatusText(item.examStatus) }}</text>
            </view>
          </view>
          <view class="block_7 flex-row justify-between">
            <view class="text-wrapper_5 flex-col">
              <text class="text_15" >{{getCourseTypeText(item.subject)}}</text>
            </view>
            <view class="text-wrapper_6 flex-col">
              <text class="text_16" >{{item.courseType}}</text>
            </view>
          </view>
          <!-- <view class="text-wrapper_7 flex-row justify-between">
            <text class="text_17" >{{3}}</text>
            <text class="text_18" >{{4}}</text>
          </view> -->
        </view>
      </view>
    </view>
    <view class="block_8 flex-col">
      <view class="text-wrapper_8 flex-col" @click="goScorerecord()">
        <text class="text_19">笔试成绩录入</text>
      </view>
    </view>
  </view>
</template>
<script>
import { getLocalUserInfo } from '../../utils/auth';
import request from '@/utils/request.js'
export default {
  data() {
    return {
      loopData0: [
        {
          lanhutext0: '2025-01-20',
          lanhutext1: '考试名称',
          lanhutext2: '60分',
          lanhufontColor2: 'rgba(251,66,59,1.000000)',
          lanhutext3: '考试未通过',
          lanhufontColor3: 'rgba(251,66,59,1.000000)',
          lanhutext4: '科目二',
          lanhutext5: 'C2',
          lanhutext6: '考试地址：',
          lanhutext7: '山东省济南市历下区'
        },
        {
          lanhutext0: '2025-01-20',
          lanhutext1: '考试名称',
          lanhutext2: '--',
          lanhufontColor2: 'rgba(51,51,51,1.000000)',
          lanhutext3: '待审批',
          lanhufontColor3: 'rgba(51,51,51,1.000000)',
          lanhutext4: '科目二',
          lanhutext5: 'C2',
          lanhutext6: '考试地址：',
          lanhutext7: '山东省济南市历下区'
        }
      ],
	  userInfo: {},
	  examList: {},
      constants: {}
    };
  },
  onLoad(){
	  this.userInfo = getLocalUserInfo()
	  this.getExamList()
  },
  methods: {
	  handleBack() {
	    uni.navigateBack({
	    	delta: 1 
	    });
	  },
	  
	  goScorerecord(){
		  uni.navigateTo({
		    url: '/newPages/examinationAdd/index' 
		  });
	  },
	  
	  getExamList(){
		  request({
			  url: '/app-api/process/getExamListByUserId',
			  method:'GET',
			  params: {
				  userId: this.userInfo.id,
			  }
		  }).then(res => {
			  this.examList = res.data
			  console.log('examList', this.examList)
			  console.log('res',res)
		  })
	  },
	  getStatusText(status) {
	          const statusMap = {
	            0: '未通过',
	            1: '已通过',
	            9: '已送考',
	            'null': '未送考',
	          };
	          return statusMap[status] || '未知状态';
	        },
			
	  getCourseTypeText(status) {
	          const statusMap = {
	            '1': '科目一',
	            '2': '科目二',
	            '3': '科目三',
	            '4': '科目四',
	          };
	          return statusMap[status] || '未知状态';
	        },
	  formatDate(timestamp) {
	    const date = new Date(timestamp);
	    const year = date.getFullYear();
	    const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要+1
	    const day = String(date.getDate()).padStart(2, '0');
	    return `${year}-${month}-${day}`;
	  }
  }
};
</script>
<style lang='scss'>
@import '../common/common.scss';
@import './assets/style/index.rpx.scss';
</style>
