<template>
	<page-meta :root-font-size="fontsize+'px'" style="display: block;">
	<view>
		<Headers></Headers>
		<view class="project">
			<view style="width: 12rem;margin: auto;">职业技能在线考试系统</view>
		</view>
		
		<view class="project-content ddflex">
			<!-- 成绩区域 -->
			<view class="test-box">
				<view class="test-title">{{examResult.title}}</view>
				<view class="test-time">
					<text style="color: #999999;margin-right: 0.1rem;">考试时间</text>
					<text>{{examResult.createDate}}</text>
				</view>
				<!--  用户考试状态 0未交卷 1已交卷 2阅卷中 3缺考 4 阅卷完成 -->
				<view v-if="examResult.state!=4">
					<image class="yj-icon" src="/static/images/yuejuan.png"></image>
					<view class="yj-label">
						<block v-if="examResult.state==0">未交卷</block>
						<block v-if="examResult.state==1">已交卷,等待阅卷中</block>
						<block v-if="examResult.state==3">缺考</block>
					</view>
				</view>
				<view v-else class="chufen-number" :style="examResult.score>=paper.passScore?'color:green;':''">
					{{examResult.score}}<text style="font-size: 0.18rem;margin-left: 0.1rem;">分</text>
					<view style="font-size: 0.16rem;">
						{{examResult.score>=paper.passScore?'考试合格':'考试不合格'}}
					</view>
				</view>
				
				<view class="score ddflex" >
					<view>
						<view class="score-label">总题数</view>
						<view class="score-value">{{examResult.questionCount?examResult.questionCount:0}}</view>
					</view>
					<view class="line"></view>
					<view>
						<view class="score-label">考试用时</view>
						<view class="score-value">{{examResult.time?timeChangeHMS(examResult.time):'00:00:00'}}</view>
					</view>
				</view>
				<navigator class="back-btn ddflex" hover-class="none" open-type="navigateBack">
					<image src="/static/images/back3.png"></image>
					<text>返回上一页</text>
				</navigator>
			</view>
			<!-- 答题卡区域 -->
			<view class="test-info ddflex">
				<view class="test-people ddflex">
					<image :src="examResult.avatar"></image>
					<view class="test-people-info ddflex">
						<view class="ddflex">
							<view class="test-people-label">考生姓名</view>
							<view class="fflex">{{examResult.userName}}</view>
						</view>
						<view class="ddflex">
							<view class="test-people-label">身份证号</view>
							<view class="fflex" style="word-break: break-all;">{{examResult.idNumber}}</view>
						</view>
						<view class="ddflex">
							<view class="test-people-label">考试科目</view>
							<view class="fflex">{{examResult.title}}</view>
						</view>
					</view>
				</view>
				<view class="note-box">
					<view class="note-title ddflex">
						<image class="note-title-icon" src="/static/images/ksgg.png"></image>
						<view>考试公告</view>
					</view>
					<view>
						<view class="note-item ddflex" v-for="item,index in otherInfo" :key="index" @click="jumpUrl('/pages/contentDetail/contentDetail?id='+item.id)">
							<view class="note-item-content">{{item.title}}</view>
						</view>
					</view>
				</view>
				<!-- 注意事项 -->
				<view class="note-box">
					<view class="note-title ddflex">
						<image class="note-title-icon" src="/static/images/zysx.png"></image>
						<view>注意事项</view>
					</view>
					<view>
						<view class="note-item ddflex" v-for="item,index in noteInfo" :key="index+'zy'" @click="jumpUrl('/pages/contentDetail/contentDetail?id='+item.id)">
							<view class="note-item-content">{{item.title}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<Foot></Foot>
	</view>
	</page-meta>
</template>

<script>
	const app = getApp();
	const req = require('../../utils/request.js');
	const utils = require('../../utils/util.js');
	const api = require('../../utils/api.js')
	export default {
		data() {
			return {
				paperId:null,
				admissionNo:null,
				paper: '', //试卷详情
				examResult:{},//考试详情
				
				otherInfo:[],
				noteInfo:[],
				fontsize:'100px'
			}
		},
		onReady() {},
		onLoad(options) {
			let srceenNunber = 19.2; //因设计图是1920所有把设计图分为19.2份，所以html字体大小为100px
			    let that = this;
			
			    //窗体改变大小触发事件
			    uni.onWindowResize((res) => {
			        console.log('变化后的窗口宽度=', res.size.windowWidth);
			        that.fontsize = parseFloat(res.size.windowWidth) / srceenNunber;
			    })
			
			    //打开获取屏幕大小
			    uni.getSystemInfo({
			        success(res) {
			            console.log('设备信息：', res);
			            that.fontsize = res.screenWidth / srceenNunber;
			            console.log('字体大小：', that.fontsize);
			        }
			    })
			
			
			this.paperId = options.paperId;
			this.admissionNo = options.admissionNo;
			
			this.getPaper()
			this.getTextOtherInfo()
			this.getTextNoteInfo()
		},
		methods: {
			jumpUrl(url){
				uni.navigateTo({
					url:url
				})
			},
			//获取考试对象
			getPaper() {
				var _ts = this;
				req.getRequest(api.paper_detail + _ts.paperId, {}, res => {
						_ts.paper = res;
						this.getResult()
				});
			},
			// 获取考试对象的答题记录
			getResult(){
				req.getRequest('/api/v3/exam/user/manager/result', {admission:this.admissionNo,paperId:this.paperId}, res => {
						this.examResult = res;
				});
			},
			// 考试公告
			getTextOtherInfo(){
				let form={
					code:req.public.ksggCode,
					page:1,
					limit:3
				}
				req.getRequest('/api/content/list',form,res=>{
					this.otherInfo = res
				})
			},
			// 注意事项
			getTextNoteInfo(){
				let form={
					code:req.public.zysxCode,
					page:1,
					limit:3
				}
				req.getRequest('/api/content/list',form,res=>{
					this.noteInfo = res
				})
			},
			// 秒转换时分秒
			timeChangeHMS(time){
				let _ts = this
				var times = {};
				times.hour = _ts.cut22(Math.floor(time / 3600));
				var leave2 = time % 3600;
				times.minutes = _ts.cut22(Math.floor(leave2 / 60));
				var leave3 = leave2 % 60;
				times.seconds = _ts.cut22(Math.round(leave3));
				return times.hour+":"+times.minutes+":"+times.seconds
			},
			cut22(n) {
				n = n.toString();
				return n[1] ? n : '0' + n;
			},
		}
	}

</script>

<style>
	@import url('./scoreQuery.css');
</style>