<template>
	<view class="content">
		<!--  -->
		<view class="skiptop">
			<!-- <view class="status"><text>设备连接</text></view> -->
			<view class="item">
				<view class="item-ite">平均吸气肺活量<text>{{info?info.average:'--'}}</text></view>
				<view class="item-ite">吸气速度<text>--</text></view>
				<view class="item-ite">是否达标<text>{{info?info.level:'--'}}</text></view>
			</view>
		</view>
		<!--自由训练  -->
		<view class="box1" v-if="info">
			<view class="time">{{info?info.time:'--'}}</view>
			<view class="item">
				<view class="image">
					<image src="../../static/bae.png" mode="widthFix"></image>
				</view>
				<view class="center">
					<view class="level"></view>
					<view class="level level-bg" :style="{'top':Number(100 - info.offset)+'%'}"></view>
					<view class="level-item">
						<view class="ite" v-for="(ite,ind) in info.list">{{ite}}</view>
					</view>
				</view>
			</view>
			<view class="val">
				<text>{{info.average}}</text>
				吸气肺活量平均值
			</view>
		</view>
		<view class="nolist" v-else>
			<image src="@/static/none.png"></image>
			<text>暂无数据，请手动添加~</text>
		</view>
		<!--  -->
		<view class="gridList">
			<view class="data">
				<view class="item" @click="navTo('/pages/vitalcapacity/charts')">
					<view class="image">
						<image src="../../static/charts.png"></image>
					</view>
					<view class="name">运动曲线</view>
				</view>
				<view class="item" @click="navTo('/pages/history/history?acd_id='+acd_id)">
					<view class="image">
						<image src="../../static/add.png"></image>
					</view>
					<view class="name">历史记录</view>
				</view>
				<view class="item" @click="navTo('/pages/compk/contrast?acd_id='+acd_id)">
					<view class="image">
						<image src="../../static/pk.png"></image>
					</view>
					<view class="name">数据对比</view>
				</view>
				<view class="item" @click="$store.commit('changeRecord',true)">
					<view class="image">
						<image src="../../static/history.png"></image>
					</view>
					<view class="name">添加记录</view>
				</view>
			</view>
		</view>
		<!-- 手动记录 -->
		<record :rtype='acd_id'></record>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	import record from '@/components/manuallyAdd/record.vue';
	export default {
		data() {
			return {}
		},
		components: {
			record
		},
		computed: {
			...mapState(["MeasureLung"]),
			info() {
				console.log("11111",this.MeasureLung)
				return this.MeasureLung
			}
		},
		onLoad(options) {
			let that = this
			that.acd_id = options.acd_id
		},
		onShow() {
			let that = this
			that.$store.dispatch("getLungResult", {
				aud_id: uni.getStorageSync('userid')
			})
		},
		methods: {
			navTo(url) {
				uni.navigateTo({
					url: url
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		padding-top: 10px;
		min-height: 100vh;
		background-color: #000;
	}

	.top {
		background: $maincolor;
		border-radius: 10px;
		margin: 0 15px 10px;
		font-size: 14px;
		padding: 15px 10px;
		color: #fff;

		.status {
			margin-bottom: 25px;

			text {
				width: auto;
				color: #333;
				background-color: #fff;
				border-radius: 15px;
				padding: 5px 10px;
			}
		}

		.item {
			display: flex;
			justify-content: space-between;

			text {
				display: block;
				width: 100%;
				text-align: center;
				margin-top: 15px;
			}
		}
	}

	.box1 {
		color: #fff;
		margin: 15px;
		width: calc(100%- 30px);

		.time {
			width: 100%;
			font-size: 14px;
			margin-bottom: 20px;
		}

		.item {
			width: 100%;
			font-size: 14px;
			padding: 10px 0;
			border-radius: 15px;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-bottom: 15px;
			position: relative;

			.image {
				width: 80%;

				image {
					width: 100%;
				}
			}

			.center {
				top: -10px;
				bottom: 20px;
				position: absolute;
				width: 55px;
				margin: auto;
				text-align: center;
				background-color: #333;
				border-radius: 10px;
				z-index: 9;
			}

			.level-bg {
				position: absolute;
				width: 55px;
				margin: auto;
				text-align: center;
				background-color: #4d6c7b;
				border-radius: 0 0 10px 10px;
				bottom: 0px;
				z-index: 19;
			}

			.level-item {
				width: 55px;
				height: 100%;
				position: absolute;
				z-index: 99;

				:last-child {
					border-bottom: none;
				}

			}

			.ite {
				margin: 0 5px;
				width: calc(100% - 10px);
				height: 40px;
				line-height: 40px;
				font-size: 12px;
				color: #fff;
				z-index: 99;
				border-bottom: 1px solid #999;
			}
		}

		.val {
			width: 100%;
			text-align: center;
			margin: 20px 0;
			color: #fff;
			font-size: 14px;

			text {
				display: block;
				color: #39D9C9 !important;
				font-size: 32px;
				margin-bottom: 10px;
			}
		}
	}

	.box {
		padding: 0;
		display: flex;
		flex-wrap: wrap;
		border-radius: 10px;
		margin: 15px;
		width: calc(100%- 30px);
		justify-content: space-between;

		.data {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: space-between;
			width: 100%;
		}

		.item {
			width: 47.5%;
			font-size: 14px;
			background: #fff;
			padding: 10px 0;
			border-radius: 15px;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-bottom: 15px;
		}

		.val {
			width: 40px;
			height: 40px;
			border-radius: 50%;

			image {
				width: 70%;
				height: 70%;
			}
		}
	}
</style>