<template>
	<div class="app-box">
		<div class="con-box">
			<div class="tabCon">
				<template v-for="(item,index) in gradeData">
					<div class="tabLeft">
						<div><span>考试名称：</span>{{item.name}}</div>
						<div><span>考试时间：</span>{{item.createTime}}</div>
						<div><span>考试成绩：</span>{{item.score}}分</div>
					</div>
					<div class="tabRight" @click="detail(item)">查看</div>
				</template>
			</div>
		</div>
	</div>
</template>

<script setup>
import { reactive, inject, watch, ref, onMounted,onBeforeUnmount,computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
const { $api,urls , navTo,navBack , vacanciesTo, formatTotal, config } = inject('globalFunction');
import useUserStore from '@/stores/useUserStore';
import useDictStore from '@/stores/useDictStore';
const userInfo = ref({});
const rows = ref({});
const Authorization = ref('');
const gradeData = ref([]);
onLoad((options) => {
	rows.value=options
	Authorization.value=uni.getStorageSync('Padmin-Token')||''
	getHeart();
});
function getHeart() {
	const raw =Authorization.value;
	const token = typeof raw === "string" ? raw.trim() : "";
	const headers = token ? { 'Authorization': raw.startsWith("Bearer ") ? raw : `Bearer ${token}` }: {}
	$api.myRequest("/dashboard/auth/heart", {}, "POST", 10100, headers).then((resData) => {
      if (resData.code == 200) {
        getUserInfo();
      } else {
		  navTo('/packageB/login')
      }
    });
};
function getUserInfo(){
	let header={
		'Authorization':Authorization.value
	}
	$api.myRequest('/system/user/login/user/info', {},'get',10100,header).then((resData) => {
		userInfo.value = resData.info || {};
		// userId.value=resData.info.userId
		queryData()
	});
};
function queryData(){
	$api.myRequest('/train/public/trainExamDash/getExamByIdTable', {
		userId:userInfo.value.userId,
		examPaperId:rows.value.examPaperId,
	}).then((resData) => {
		if(resData&&resData.code==200){
			gradeData.value=resData.rows
		}
	});
}
function detail(row){
	navTo('/packageB/train/mockExam/paperDetails?examPaperId='+row.examPaperId+'&examId='+row.examId+'&name='+row.name);
}
</script>

<style lang="stylus" scoped>
.app-box{
	width: 100%;
	height: 100vh;
	position: relative;
	.con-box{
		position: absolute;
		width: 100%;
		height: 100%;
		left: 0;
		top:0;
		z-index: 10;
		padding: 20rpx 28rpx;
		box-sizing: border-box;
		overflow-y: auto;
		.tabCon{
			border-top: 1px solid #ccc;
			border-left: 1px solid #ccc;
			display: flex;
			flex-wrap: wrap;
			.tabLeft{
				width: 80%;
				height: 150rpx;
				border-bottom: 1px solid #ccc;
				border-right: 1px solid #ccc;
				box-sizing: border-box;
				view{
					line-height: 45rpx
					color: #2175F3;
					label{
						color: #666;
					}
				}
			}
			.tabRight{
				width: 20%;
				height: 150rpx;
				border-bottom: 1px solid #ccc;
				border-right: 1px solid #ccc;
				box-sizing: border-box;
				font-size: 30rpx;
				text-align: center;
				line-height: 140rpx;
				color: #2175F3;
			}
		}
	}
}
</style>