<template>
	<view class="page-view">
		<top-return color="#FFF"></top-return>
		<!-- 背景 -->
		<view class="bg1"></view>

		<view class="flex-row">
			<view class="flex-column" style="margin: 120rpx 0 0 50rpx;">
				<view class="report-title">评测</view>
				<view class="report-title">分析报告</view>
				<view class="report-subtitle">{{examData[index].examInfo.name}}</view>
			</view>
			<view class="detail-image1" :style="{backgroundImage:`url(${image1})`}"></view>
			<view class="detail-image2" :style="{backgroundImage:`url(${image2})`}"></view>
		</view>


		<view class="card-view">
			<view class="card-item">
				<view class="card-box">
					<view class="card-image" :style="{backgroundImage:`url(${image3})`}"></view>
					<view class="flex-column">
						<view class="title">成绩总分:</view>

						<view class="flex-row">
							<view class="YS-title">{{reportData.totalScore}}</view>
							<view class="title" style="margin: 12rpx 0 0 4rpx;">分</view>
						</view>
					</view>
				</view>
				<view class="card-data">
					<view class="flex-column" v-for="(item,i) in reportData.gradeData" :key="i">
						<view class="YS-title">{{item.subject}}</view>
						<view class="flex-baseline">
							<view class="title">{{item.grade}}</view>
							<view class="subtitle">/{{item.score}}</view>
						</view>
					</view>
				</view>
			</view>

			<view class="card-item">
				<view class="title-box">
					<view class="title-tag"></view>
					<view class="title">成绩对比</view>
					<view class="subsection">
						<u-subsection :list="contrastList" :current="contrastCurrent" @change="changeContrast"
							activeColor="#FFF">
						</u-subsection>
					</view>
				</view>
				<view class="table-container">
					<uni-table :loading="tableLoading">
						<!-- 表头行 -->
						<uni-tr>
							<uni-th width="40" align="center">科目</uni-th>
							<uni-th width="25" align="center">分数</uni-th>
							<!-- <uni-th>名次</uni-th> -->
							<uni-th width="25" align="center">平均分</uni-th>
							<uni-th width="25" align="center">最高分</uni-th>
							<uni-th width="25" align="center">差距分</uni-th>
						</uni-tr>
						<uni-tr v-for="(item,index) in reportData.tableData" :key="index">
							<uni-td width="40" align="center">
								<view class="title">{{item.subject}}</view>
							</uni-td>
							<uni-td width="25" align="center">
								<view class="YS-title" :style="{color: item.grade > item.average ?'#23b46c':'#ff5959'}">
									{{item.grade}}
								</view>
							</uni-td>
							<uni-td width="25" align="center">
								<view class="YS-title" style="color: #909399;">{{item.average}}</view>
							</uni-td>
							<uni-td width="25" align="center">
								<view class="YS-title" style="color: #ff8caf;">{{item.top}}</view>
							</uni-td>
							<uni-td width="25" align="center">
								<view class="YS-title" :style="{color: item.gap === 0 ?'#23b46c':'#f9c752'}">
									{{item.gap}}
								</view>
							</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view class="msg-box">
					<view class="flex-baseline">
						<view class="subtitle">班级</view>
						<view class="title">{{reportData.classNum}}</view>
						<view class="subtitle">人</view>
					</view>
					<view class="flex-baseline">
						<view class="subtitle">年级</view>
						<view class="title">{{reportData.gradeNum}}</view>
						<view class="subtitle">人</view>
					</view>
					<view class="flex-baseline">
						<view class="subtitle">联考</view>
						<view class="title">{{reportData.areaNum}}</view>
						<view class="subtitle">人</view>
					</view>
				</view>
			</view>

			<view class="card-item">
				<view class="title-box">
					<view class="title-tag"></view>
					<view class="title">成绩分布</view>
					<view class="subsection">
						<u-subsection :list="distributionList" :current="distributionCurrent"
							@change="changeDistribution" activeColor="#FFF">
						</u-subsection>
					</view>
				</view>
				<view class="chart-box" style="height: 420rpx;">
					<qiun-data-charts type="column" ontouch="true" :chartData="reportData.distributionChartData"
						tooltipFormat="distributionColumn"
						:opts="{legend:{show:false},padding:[20, 20, 20, 10],yAxis:{gridType: 'dash',dashLength: 10},extra:{column:{barBorderCircle: false ,barBorderRadius: [6,6,0,0]}}}" />
				</view>
				<view class="distribution-box">
					<view class="segment-data">
						<view class="text">孩子分段数</view>
						<view class="text">{{reportData.distributionNum}}分</view>
					</view>
					<view class="sutdent-data">
						<view class="data-item">
							<view class="title-box">
								<view class="title">班级学生数</view>
							</view>
							<view class="YS-title">{{reportData.distributionData[0]}}人</view>
						</view>
						<view class="data-item">
							<view class="title-box">
								<view class="title">年级学生数</view>
							</view>
							<view class="YS-title">{{reportData.distributionData[1]}}人</view>
						</view>
						<view class="data-item">
							<view class="title-box">
								<view class="title">联考学生数</view>
							</view>
							<view class="YS-title">{{reportData.distributionData[2]}}人</view>
						</view>
					</view>
				</view>
			</view>

			<view class="card-item">
				<view class="title-box">
					<view class="title-tag"></view>
					<view class="title">科目优劣</view>
					<view class="subsection">
						<u-subsection :list="meritsList" :current="meritsCurrent" @change="changeMerits"
							activeColor="#FFF">
						</u-subsection>
					</view>
				</view>
				<view class="chart-box">
					<qiun-data-charts type="radar" ontouch="true" :chartData="reportData.advantageChartData" tooltipFormat="meritsRadar"/>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		computed: {
			...mapState('m_children', ['examData'])
		},
		data() {
			return {
				index: '',
				reportData: {
					totalScore: 525,
					gradeData: [{
						subject: '语文',
						grade: 82,
						score: 100,
					}, {
						subject: '数学',
						grade: 94,
						score: 100,
					}, {
						subject: '英语',
						grade: 84,
						score: 100,
					}, {
						subject: '科学',
						grade: 78,
						score: 100,
					}, {
						subject: '思品',
						grade: 95,
						score: 100,
					}, {
						subject: '体育',
						grade: 92,
						score: 100,
					}],
					tableData: [{
							subject: '总分',
							grade: 525,
							average: 499,
							top: 521,
							gap: 38
						},
						{
							subject: '语文',
							grade: 83,
							average: 80,
							top: 92,
							gap: 9
						},
						{
							subject: '数学',
							grade: 93,
							average: 84,
							top: 99,
							gap: 6
						},
						{
							subject: '外语',
							grade: 92,
							average: 87,
							top: 96,
							gap: 4
						},
						{
							subject: '思品',
							grade: 80,
							average: 83,
							top: 92,
							gap: 3
						},
						{
							subject: '体育',
							grade: 99,
							average: 87,
							top: 99,
							gap: 0
						},
						{
							subject: '科学',
							grade: 93,
							average: 89,
							top: 96,
							gap: 3
						}
					],
					classNum: 55,
					gradeNum: 1200,
					areaNum: 16000,
					distributionChartData: {
						"categories": ["0-100", "100-200", "200-300", "300-400", "400-500", "500-600", "600-700"],
						"series": [{
								"name": "年级学生数",
								"data": [7, 15, 72, 252, 333, 243, 18]
							},
							{
								"name": "班级学生数",
								"data": [1, 5, 12, 23, 22, 7, 1]
							}
						]
					},
					distributionNum: "500-600",
					distributionData: [12, 130, 333],
					advantageChartData: {
						"categories": ["语文", "数学", "英语", "思品", "科学", "体育"],
						"series": [{
								"name": "个人得分率",
								"data": [90, 75, 85, 78, 82, 92]
							},
							{
								"name": "平均得分率",
								"data": [88, 67, 90, 82, 75, 81]
							},
							{
								"name": "最高得分率",
								"data": [96, 92, 94, 91, 89, 90]
							}
						]
					}
				},
				contrastList: ['班级', '年级', '联考'],
				contrastCurrent: 0,
				distributionList: ['校级', '联考'],
				distributionCurrent: 0,
				meritsList: ['班级', '年级', '联考'],
				meritsCurrent: 0,
				tableLoading: false,
				image1: 'https://ouch-cdn2.icons8.com/PvGwCISfYx-NAQwl4UsdY2QXtMMiNDB6LllqLZ4jGoA/rs:fit:367:456/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9wbmcvNzg1/LzhiM2MwZWU2LWFl/ODMtNDM2Mi05MGQy/LTBmMDk0N2M4N2E1/OC5wbmc.png',
				image2: 'https://ouch-cdn2.icons8.com/I-PEjM-V1LXrgVE1_yaPi7LY2XrgFXgKmEvBD3r1h_Y/rs:fit:484:456/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9wbmcvMzcy/LzA0ZDY3Y2NlLTM3/YTUtNGE3OC1iZTVi/LTY4MzgyYTQ2YmUz/Zi5wbmc.png',
				image3: 'https://cdn-icons-png.flaticon.com/512/4524/4524486.png',
			};
		},
		onLoad(param) {
			this.index = param.index
		},
		methods: {
			changeContrast(e) {
				this.contrastCurrent = e
			},
			changeDistribution(e) {
				this.distributionCurrent = e
			},
			changeMerits(e) {
				this.meritsCurrent = e
			}
		},
	}
</script>

<style lang="scss">
	@import 'data_pages.scss';
	@import 'top_info.scss';

	.bg1 {
		position: fixed;
		width: 100%;
		height: 800rpx;
		background-size: 100%;
		background-repeat: no-repeat;
		background-image: linear-gradient(to top, #f3f4f9, #ff8caf);
	}

	.detail-image1 {
		position: absolute;
		top: 150rpx;
		left: 580rpx;
		width: 300rpx;
		height: 350rpx;
		background-size: 100%;
		background-repeat: no-repeat;
		z-index: 51;
	}

	.detail-image2 {
		position: absolute;
		top: 200rpx;
		left: 380rpx;
		width: 300rpx;
		height: 350rpx;
		background-size: 100%;
		background-repeat: no-repeat;
		z-index: 50;
	}

	.card-item {
		width: 100%;

		.card-box {
			display: flex;
			padding: 20rpx 30rpx;
			justify-content: space-around;
			height: 180rpx;
			border-radius: $border-radius;
			background-color: #ff8caf;
			opacity: 0.8;

			.flex-column {
				height: 100%;
				justify-content: space-around;

				.title {
					color: #FFF;
					font-size: 38rpx;
					font-weight: 400;
				}

				.YS-title {
					font-size: 80rpx;
					color: #FFF;
				}
			}

			.card-image {
				position: relative;
				top: -20rpx;
				height: 220rpx;
				width: 220rpx;
				background-size: cover;
				background-repeat: no-repeat;
				z-index: 2;
			}
		}

		.card-data {
			padding: 20rpx;
			display: flex;
			flex-flow: row wrap;
			justify-content: space-between;

			.flex-column {
				justify-content: space-around;
				height: 120rpx;
				margin: 20rpx 40rpx;

				.title {
					font-size: 40rpx;
				}

				.subtitle {
					font-weight: 400;
				}

				.YS-title {
					font-size: 40rpx;
				}
			}
		}

		.title-box {
			display: flex;
			align-items: center;
			padding: 20rpx 0;

			.title-tag {
				margin-left: -10rpx;
				margin-right: 20rpx;
				height: 100%;
				width: 20rpx;
				border-radius: 100rpx;
				background-color: #ff8caf;
				z-index: 99;
			}

			.title {
				font-size: 35rpx;
				line-height: 50rpx;
			}

			.subsection {
				width: 300rpx;
				height: 100%;
				margin: 0 30rpx 0 auto;

				.u-subsection--button__bar {
					background-color: #ff8caf !important;
				}
			}
		}

		.table-container {
			margin-bottom: 20rpx;

			.title {
				line-height: 30rpx;
				font-size: 30rpx;
				color: $title;
			}
		}

		.msg-box {
			margin: 0 20rpx 40rpx 20rpx;
			padding: 20rpx;
			display: flex;
			border-radius: $border-radius;
			justify-content: space-around;
			background-color: #f3f4f9;

			.title {
				color: #ff8caf;
				margin: 0 6rpx;
				line-height: 30rpx;
			}
		}

		.chart-box {
			height: 650rpx;
		}

		.distribution-box {
			margin: 0 20rpx 40rpx 20rpx;
			height: 150rpx;
			display: flex;
			border-radius: $border-radius;
			background-color: #f3f4f9;
			overflow: hidden;

			.segment-data {
				display: flex;
				flex-direction: column;
				align-items: center;
				background-color: #ff8caf;
				justify-content: space-around;
				padding: 16rpx 0;
				width: 30%;

				.text {
					font-size: 30rpx;
					line-height: 30rpx;
					color: #FFF;
				}
			}

			.sutdent-data {
				display: flex;
				justify-content: space-around;
				width: 70%;

				.data-item {
					display: flex;
					flex-direction: column;
					align-items: center;
					width: 33%;
					height: 100%;

					.title-box {
						display: flex;
						align-items: center;
						justify-content: center;
						background-color: #ffe6ed;
						height: 40rpx;
						width: 101%;

						.title {
							line-height: 28rpx;
							font-size: 28rpx;
							font-weight: 400;
							color: $title;
						}
					}

					.YS-title {
						line-height: 70rpx;
						font-size: 36rpx;
					}
				}
			}
		}
	}
</style>
