<template>
	<view class="content">
		<view class="test">幼儿体质检测记录</view>
		<view class="score" v-for="item in StudentScore">
			<view class="">
				<view class="itemName">批次名称：{{item.batchName}}</view>
			</view>
			<view class="th">
				<view class="overallScore">综合得分：{{item.totalFraction}}</view>
				<view class="time">时间：{{item.createTime}}</view>
			</view>
			<view class="report" v-show="item.existFlag==false">查看报告</view>
			<view class="report" style="color: #4486e8;" @tap='lookbook(item)' v-show="item.existFlag">查看报告</view>
			<u-loading-page :loading="loading" loading-text="正在打开报告" loading-mode="semicircle"></u-loading-page>
		</view>
	</view>
</template>

<script>
	import {
		getStudentScore,
		getReportDownAddress
	} from '@/api/index/index.js'
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				show: false,
				loading: false,
				yonghuwx: [],
				studentId: '',
				StudentScore: [],
			}
		},
		onLoad(options) {
			console.log(options)
			this.studentId = options.studentId
			this.getStudentScore()
		},
		methods: {
			lookbook(item) {
				console.log(item)
				this.loading = true
				var that = this
				uni.downloadFile({
					url: baseurl + item.downloadAddress,
					success: function(res) {
						var filePath = res.tempFilePath;
						uni.openDocument({
							filePath: filePath,
							showMenu: true,
							success: function(res) {
								that.loading = false
							},
							fail: function(err) {
								that.loading = false
							}
						});
					}
				});


				// getReportDownAddress(this.studentId, item.batchCode).then(res => {
				// 	console.log(res)
				// 	if (res.data.downloadAddress != null) {
				// 	}
				// })
			},
			getStudentScore() {
				getStudentScore(this.studentId).then(res => {
					console.log((res))
					this.StudentScore = res.data;
				})
			},
			getPhoneNumberp(val) {
				wx.login({
					provider: 'weixin',
					success: function(loginRes) {
						console.log(loginRes)
					}
				});
			},
			wxGetUserInfo() {
				let that = this;
				uni.getUserProfile({
					desc: "获取用户信息",
					lang: "zh_CN",
					success(res) {
						console.log(res)
						that.yonghuwx = res.userInfo
					},
					fail(res) {
						//失败则返回home页面
					},
				});
			},
		},
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #ffffff;
		min-height: 100vh;
		background-image: linear-gradient(#55C5E3, #fff);
	}

	/* 测试成绩 */
	.test {
		width: 380rpx;
		height: 104rpx;
		line-height: 104rpx;
		font-size: 40rpx;
		/* background-color: #ffffff; */
		color: #4486e8;
		border-radius: 30%;
		margin-top: 80rpx;
		text-align: center;
		margin-bottom: 50rpx;

	}

	.score {
		/* 	position: absolute; */
		width: 700rpx;
		height: 306rpx;
		background-color: #eef9fc;
		/* background-color: red; */
		color: #707374;
		margin-bottom: 70rpx;
		border-radius: 20rpx;
		font-size: 33rpx;
	}

	.itemName {
		height: 100rpx;
		/* width: 50%; */
		/* border-right: lightsteelblue 2rpx solid; */
		line-height: 55px;
		/* padding-bottom: 15px; */
		border-bottom: lightsteelblue 2rpx solid;
		text-align: center;
		/* padding-left: 40rpx; */
	}


	.overallScore {
		height: 100rpx;
		width: 50%;
		border-right: lightsteelblue 2rpx solid;
		line-height: 100rpx;
		/* padding-bottom: 15px; */
		border-bottom: lightsteelblue 2rpx solid;
		text-align: center;
		padding-left: 40rpx;

	}

	.time {
		height: 100rpx;
		width: 50%;
		line-height: 100rpx;
		border-bottom: lightsteelblue 2rpx solid;
		text-align: center;
		/* border-right: lightsteelblue 2rpx solid; */
		/* background-color: #4486e8; */
		/* float: left; */
	}

	.report {
		height: 100rpx;
		/* width: 50%; */
		line-height: 100rpx;
		text-align: center;
		/* border-bottom: lightsteelblue 2rpx solid; */
		/* margin-top: 100rpx; */
	}



	.th {
		/* background-color: orange; */
		display: flex;
		justify-content: flex-start;
		/* border-top:lightsteelblue 1px solid; */

	}
</style>
