<template>
	<view class="content">
		<view class="test">幼儿体质检测记录</view>
		<view class="title" v-if="StudentScore==0">
			暂无体质检测记录
		</view>
		<view class="score" v-for="item in StudentScore" v-else>
			<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" @tap='showToast'>查看报告</view> -->
			<!-- <u-cell class='report' v-if="item.existFlag==false" :title="aitem.title" v-for="(aitem, index) in list"
				:key="index" :icon="aitem.iconUrl" @click="showToast(aitem)">
			</u-cell> -->
			<view class="report" style="color: #4486e8;" @tap='lookbook(item)' v-if="item.existFlag">查看报告</view>
			<view class="report" @tap='showToast(item)' v-else>查看报告</view>
		</view>
		<u-toast ref="uToast" />
		<!-- <u-cell-group title-bg-color="rgb(243, 244, 246)">
		</u-cell-group> -->
	</view>
</template>

<script>
	import {
		getStudentScore,
		getReportDownAddress
	} from '@/api/index/index.js'
	import baseurl from '@/api/baseurl.js'
	export default {
		data() {
			return {
				show: false,
				yonghuwx: [],
				studentId: '',
				StudentScore: [],
				show: false,
				list: [{
					type: 'error',
					icon: false,
					title: '查看报告',
					message: "暂无报告",
				}],
			}
		},
		onLoad(options) {
			this.studentId = options.studentId
			this.getStudentScore()
		},
		methods: {
			showToast() {
				this.$refs.uToast.show({
					message: '暂无报告',
					type: 'error'
				})
			},

			lookbook(item) {
				uni.showLoading({
					title: '获取报告中'
				});
				var that = this
				wx.downloadFile({
					url: baseurl + item.downloadAddress,
					success: function(res) {
						var filePath = res.tempFilePath;
						wx.openDocument({
							filePath: filePath,
							showMenu: true,
							success: function(res) {
								uni.hideLoading();
							},
							fail: function(err) {
								uni.hideLoading();
							}
						});
					},
					fail: function(err) {
						uni.hideLoading();
						that.$refs.uToast.show({
							message: '请求报告失败',
							type: 'error'
						})
					}
				});
				// getReportDownAddress(this.studentId, item.batchCode).then(res => {
				// 	if (res.data.downloadAddress != null) {
				// 	}
				// })
			},
			getStudentScore() {
				getStudentScore(this.studentId).then(res => {
					this.StudentScore = res.data;
				})
			},
			getPhoneNumberp(val) {
				wx.login({
					provider: 'weixin',
					success: function(loginRes) {}
				});
			},
			wxGetUserInfo() {
				let that = this;
				uni.getUserProfile({
					desc: "获取用户信息",
					lang: "zh_CN",
					success(res) {
						that.yonghuwx = res.userInfo
					},
					fail(res) {
						//失败则返回home页面
					},
				});
			},
		},
	}
</script>

<style lang="scss">
	.title {
		width: 80%;
		margin: 0 auto;
		text-align: center;
		font-size: 40rpx;
		color: #707374;
	}

	.u-page {
		padding: 0;
	}


	.u-cell-group__title__text {
		font-weight: bold;
		height: 100rpx;
		/* width: 50%; */
		line-height: 100rpx;
		text-align: center;
		font-size: 36rpx;
	}

	::v-deep .u-cell__title-text {
		text-align: center;
	}







	.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>
