<template>
	<view class="content">
		<!--  -->
		<view class="skiptop">
			<!-- <view class="status" @click="$Bluetooth.handleDevicesMac(isdevice,acd_id)"><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">
			<view class="time">{{info?info.time:''}}</view>
			<!-- <view class="LiuS">吸气速度 <text class="cgreen ml-5">{{info?info.flow_val:'--'}}L/min</text></view> -->
			<view class="item">
				<view class="image">
					<image src="../../static/bae.png" mode="widthFix"></image>
				</view>
				<view class="center  mt-15">
					<view class="level"></view>
					<view class="level level-bg" :style="{'top':info?Number(100 - info.offset)+'%':'100%'}"></view>
					<view class="level-item" v-if="info">
						<view class="ite" v-for="(ite,ind) in info.list" :style="{'height':100/info.list.length+'%'}">
							{{ite.text}}</view>
					</view>
				</view>
			</view>
			<view class="val" v-if="info">
				<text>{{info.average}}</text>
				吸气肺活量平均值
			</view>
		</view>
		<!--  -->
		<view class="gridList">
			<view class="data">
				<view class="item" @click="navTo('/pages/lunging/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 '@/element/manuallyAdd/record.vue';
	export default {
		data() {
			return {
				LiuS: 0,
				acd_id: 8,
				isdevice: true,
			}
		},
		components: {
			record
		},
		computed: {
			...mapState(["MeasureLung"]),
			info() {
				return this.MeasureLung
			}
		},
		onLoad(options) {
			let that = this
			that.acd_id = options.acd_id
			that.isdevice = options.device
			that.$store.dispatch("getLungResult", {
				aud_id: uni.getStorageSync('userid')
			})
		},
		onPullDownRefresh() {
			let that = this
			that.$store.dispatch("getLungResult", {
				aud_id: uni.getStorageSync('userid')
			})
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 1000);
		},
		methods: {
			// 历史数据删除时重新加载接口
			reload() {
				let that = this
				console.log('重新加载');
				this.$nextTick(() => {
					that.$store.dispatch("getLungResult", {
						aud_id: uni.getStorageSync('userid')
					})
				})
			},
			navTo(url) {
				uni.navigateTo({
					url: url
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	@import "@/scss/lunging.scss";
</style>