<template>
	<view style="padding: 30px 15px;">
		
		<view v-if="paperData!=null && paperData.id!=null">
			
				<!-- 显示感谢文字 -->
				<result-thanks v-if="paperData.resultType===1" :data="paperData" />
			
				<!-- 显示感谢文字加分数 -->
				<result-score v-if="paperData.resultType===2" :data="paperData" />
			
				<!-- 显示完整解析详情 -->
				<result-detail v-if="paperData.resultType===3" :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 { paperResult } from '@/api/paper.js'
	export default {
		components: {
			ResultDetail, ResultScore, ResultThanks
		},
		data() {
			return {
				paperId: '',
				paperData: {}
			}
		},
		onLoad(option) {
			this.paperId = option.id;
			this.fetchPaperResult()
		},
		
		onBackPress(e){
		
	// 	  //正常返回页面
	// 	  uni.redirectTo({
	// 		url:"/pages/paper/list?id="+this.paperData.examId
	// 	  })
	
	// 	  return true;
		},

		methods: {
			
			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>


