<template>
	<view style="padding: 30px 15px;">

		<view v-if="paperData!=null && paperData.id!=null">
			<uni-forms :modelValue="postForm" ref="form" :label-width="100">
				<!-- 显示感谢文字 -->
				<!-- <result-thanks v-if="paperData.resultType===1" :data="paperData" /> -->
				
				<!-- 显示感谢文字加分数 -->
				<!-- <result-score v-if="paperData.resultType===2" :data="paperData" /> -->
				<uni-forms-item label="姓名" name="realName" style="margin-bottom: 0px;">
					<view style="height: 36px;line-height: 36px;">{{postForm.realName}}</view>
				</uni-forms-item>


				<uni-forms-item label="身份证号" name="idCard" style="margin-bottom: 0px;">
					<view style="height: 36px;line-height: 36px;">{{postForm.idCard}}</view>
				</uni-forms-item>

				<uni-forms-item label="手机号" name="mobile" style="margin-bottom: 10px;">
					<view style="height: 36px;line-height: 36px;">{{postForm.mobile}}</view>
				</uni-forms-item>
				<view style="height: 150px;display: flex;justify-content: space-around;">
					<img :src="postForm.avatar" style="width: 100%;max-width: 100px;;max-height: 150px" alt="">
					<img :src="postForm.face" style="width: 100%;max-width: 200px;max-height: 150px" alt="">
				</view>
				<!-- <uni-forms-item label="照片" name="avatar">
					<img :src="postForm.avatar" style="width: 100px;max-height: 200px" alt="">
				</uni-forms-item>

				<uni-forms-item label="身份证" name="face">
					<img :src="postForm.face" style="width: 100%;max-height: 150px" alt="">
				</uni-forms-item> -->

			</uni-forms>

			<!-- 显示完整解析详情 -->
			<!-- <result-detail v-if="paperData.resultType===3" :data="paperData" /> -->
			<result-detail style="margin-top: 20px;" :data="paperData" />
		</view>

	</view>

</template>

<script>
	import ResultDetail from "./components/ResultDetail.vue"
	import ResultScore from "./components/ResultScore.vue"
	import ResultThanks from "./components/ResultThanks.vue"

	import {
		info
	} from '@/api/user'
	import {
		paperResult
	} from '@/api/paper.js'
	export default {
		components: {
			ResultDetail,
			ResultScore,
			ResultThanks
		},
		data() {
			return {
				paperId: '',
				paperData: {},
				postForm: {
					avatar: '',
					face: ''
				},
			}
		},
		onLoad(option) {
			this.paperId = option.id;
			this.fetchPaperResult()
			this.handleInfo()
		},

		onBackPress(e) {

			// 	  //正常返回页面
			// 	  uni.redirectTo({
			// 		url:"/pages/paper/list?id="+this.paperData.examId
			// 	  })

			// 	  return true;
		},

		methods: {
			// 获取当前用户信息
			handleInfo() {
				let token = uni.getStorageSync('token');

				info(token).then(res => {
					this.postForm = res
				})
			},

			backHome() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			},

			// 加载考试列表
			fetchPaperResult() {
				uni.showLoading({
					title: '加载中..'
				});

				paperResult(this.paperId).then(data => {
					this.paperData = data
					uni.hideLoading()
				}, error => {
					console.log(error);
				})
			}
		}
	}
</script>
