<template>
	<view class="app">
		<view class="top">
			<view class="device" @tap='goaddequipment'>
				<image src="@/static/pagesC/device.png" mode=""></image>
				<span class="deviceitem">智能设备</span>
				<view class="itemdata">
					绑定设备，关注健康
				</view>
			</view>
			<view class="device" @tap='gotestreport'>
				<image src="@/static/pagesC/report.png" mode=""></image>
				<span class="deviceitem">检测报告</span>
				<view class="itemdata">
					智慧驿站，免费检测
				</view>
			</view>
		</view>
		<view class="body">
			<view class="item" @tap='gohealthdata(0)'>
				<view class="itemtitle">
					血糖
				</view>
				<view class="" v-if="!dataone">
					<view class="itemtext">
						快来测量吧~
					</view>
					<view class="itemtext two">
						您暂时未测量
					</view>
					<image src="@/static/pagesC/sugar.png" mode=""></image>
				</view>
				<view class="titletexts" v-else>
					<view class="time">
						{{dataone.date}}
					</view>
					<view class="" v-if="dataone.bucket=='4'">
						<image src="@/static/pagesC/oneimage.png" mode="" v-if="Number(dataone.val)<4.4"></image>
						<image src="@/static/pagesC/twoimage.png" mode=""
							v-if="Number(dataone.val)>=4.4&&Number(dataone.val)<=7"></image>
						<image src="@/static/pagesC/threeimage.png" mode="" v-if="Number(dataone.val)>7"></image>
					</view>
					<view class="" v-else>
						<image src="@/static/pagesC/oneimage.png" mode="" v-if="Number(dataone.val)<4.4"></image>
						<image src="@/static/pagesC/twoimage.png" mode=""
							v-if="Number(dataone.val)>=4.4&&Number(dataone.val)<=10"></image>
						<image src="@/static/pagesC/threeimage.png" mode="" v-if="Number(dataone.val)>10"></image>
					</view>
					<view class="title">
						<text>{{dataone.val}}</text>
						<text>mmol/L</text>
					</view>
				</view>
			</view>
			<view class="item" @tap='gohealthdata(1)'>
				<view class="itemtitle">
					血压
				</view>
				<view class="" v-if="!datatwo">
					<view class="itemtext">
						快来测量吧~
					</view>
					<view class="itemtext two">
						您暂时未测量
					</view>
					<image src="@/static/pagesC/bloodpressure.png" mode=""></image>
				</view>
				<view class="titletexts" v-else>
					<view class="time">
						{{datatwo.date}}
					</view>
					<view class="bloodpressure">
						<view class="bloodpressureitem">
							<view class="bloodpressuretitle">
								{{datatwo.ssy}}
							</view>
							<view class="mmHg">
								mmHg
							</view>
							<view class="colorone" v-if="datatwo.ssy<90">
								<view class="dot">
								</view>
								过低
							</view>
							<view class="colortwo" v-if="datatwo.ssy>=90&&datatwo.ssy<=140">
								<view class="dot">
								</view>
								正常
							</view>
							<view class="colorthree" v-if="datatwo.ssy>=140">
								<view class="dot">
								</view>
								过高
							</view>
						</view>
						<view class="bloodpressureitem">
							<view class="bloodpressuretitle">
								{{datatwo.szy}}
							</view>
							<view class="mmHg">
								mmHg
							</view>
							<view class="colorone" v-if="datatwo.szy<60">
								<view class="dot">
								</view>
								过低
							</view>
							<view class="colortwo" v-if="datatwo.szy>=60&&datatwo.szy<=90">
								<view class="dot">
								</view>
								正常
							</view>
							<view class="colorthree" v-if="datatwo.szy>90">
								<view class="dot">
								</view>
								过高
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="item" @tap='gohealthdata(2)'>
				<view class="itemtitle">
					血脂
				</view>
				<view class="" v-if="!datathree">
					<view class="itemtext">
						快来测量吧~
					</view>
					<view class="itemtext two">
						您暂时未测量
					</view>
					<image src="@/static/pagesC/bloodfat.png" mode=""></image>
				</view>
				<view class="titletexts" v-else>
					<view class="time">
						{{datathree.date}}
					</view>
					<view class="bloodpressure" style="top:40%">
						<view class="bloodpressureitem">
							<view class="bloodpressuretitle">
								{{datathree.tc}}
							</view>
							<view class="mmHg">
								mmol/L
							</view>
							<view class="colorone" v-if="datathree.tc<3.0">
								<view class="dot">
								</view>
								过低
							</view>
							<view class="colortwo" v-if="datathree.tc>=3.0&&datathree.tc<=5.7">
								<view class="dot">
								</view>
								正常
							</view>
							<view class="colorthree" v-if="datathree.tc>5.7">
								<view class="dot">
								</view>
								过高
							</view>
						</view>
						<view class="bloodpressureitem">
							<view class="bloodpressuretitle">
								{{datathree.tg}}
							</view>
							<view class="mmHg">
								mmol/L
							</view>
							<view class="colorone" v-if="datathree.tg<0.5">
								<view class="dot">
								</view>
								过低
							</view>
							<view class="colortwo" v-if="datathree.tg>=0.5&&datathree.tg<=1.7">
								<view class="dot">
								</view>
								正常
							</view>
							<view class="colorthree" v-if="datathree.tg>1.7">
								<view class="dot">
								</view>
								过高
							</view>
						</view>
						<view class="bloodpressureitem">
							<view class="bloodpressuretitle">
								{{datathree.hdl}}
							</view>
							<view class="mmHg">
								mmol/L
							</view>
							<view class="colorone" v-if="datathree.hdl<0.9">
								<view class="dot">
								</view>
								过低
							</view>
							<view class="colortwo" v-if="datathree.hdl>=0.9&&datathree.hdl<=1.8">
								<view class="dot">
								</view>
								正常
							</view>
							<view class="colorthree" v-if="datathree.hdl>1.8">
								<view class="dot">
								</view>
								过高
							</view>
						</view>
						<view class="bloodpressureitem">
							<view class="bloodpressuretitle">
								{{datathree.ldl}}
							</view>
							<view class="mmHg">
								mmol/L
							</view>
							<view class="colorone" v-if="datathree.ldl<2.1">
								<view class="dot">
								</view>
								过低
							</view>
							<view class="colortwo" v-if="datathree.ldl>=2.1&&datathree.ldl<=3.1">
								<view class="dot">
								</view>
								正常
							</view>
							<view class="colorthree" v-if="datathree.ldl>3.1">
								<view class="dot">
								</view>
								过高
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="item" @tap='gohealthdata(3)'>
				<view class="itemtitle">
					BMI
				</view>
				<view class="" v-if="!datafour">
					<view class="itemtext">
						快来测量吧~
					</view>
					<view class="itemtext two">
						您暂时未测量
					</view>
					<image src="@/static/pagesC/dkw.png" mode=""></image>
				</view>
				<view class="titletexts" v-else>
					<view class="time">
						{{datafour.date}}
					</view>
					<view class="bmi">
						<image src="@/static/pagesC/bmi1.png" mode="" v-if="Number(datafour.val)<18.5"></image>
						<image src="@/static/pagesC/bmi2.png" mode=""
							v-if="Number(datafour.val)>=18.5&&Number(datafour.val)<=23.9"></image>
						<image src="@/static/pagesC/bmi3.png" mode=""
							v-if="Number(datafour.val)>23.9&&Number(datafour.val)<=27.9"></image>
						<image src="@/static/pagesC/bmi4.png" mode="" v-if="Number(datafour.val)>=27.9"></image>
					</view>
					<view class="title">
						<text>{{datafour.val}}</text>
						<text>kg/m^2</text>
					</view>
				</view>
			</view>
			<view class="item" @tap='gohealthdata(4)'>
				<view class="itemtitle">
					血氧
				</view>
				<view class="" v-if="!datafive">
					<view class="itemtext">
						快来测量吧~
					</view>
					<view class="itemtext two">
						您暂时未测量
					</view>
					<image src="@/static/pagesC/oxygen.png" mode=""></image>
				</view>
				<view class="titletexts" v-else>
					<view class="time">
						{{datafive.date}}
					</view>
					<image src="@/static/pagesC/xueyangone.png" mode="" v-if="Number(datafive.val)<95"></image>
					<image src="@/static/pagesC/xueyangtwo.png" mode="" v-if="Number(datafive.val)>=95"></image>
					<view class="title">
						<text>{{datafive.val}}</text>
						<text>%</text>
					</view>
				</view>
			</view>
			<view class="item" @tap='gohealthdata(5)'>
				<view class="itemtitle">
					心率
				</view>
				<view class="" v-if="!datasix">
					<view class="itemtext">
						快来测量吧~
					</view>
					<view class="itemtext two">
						您暂时未测量
					</view>
					<image src="@/static/pagesC/heartrate.png" mode=""></image>
				</view>
				<view class="titletexts" v-else>
					<view class="time">
						{{datasix.date}}
					</view>
					<image src="@/static/pagesC/oneimage.png" mode="" v-if="Number(datasix.val)<60"></image>
					<image src="@/static/pagesC/twoimage.png" mode=""
						v-if="Number(datasix.val)>=60&&Number(datasix.val)<=100"></image>
					<image src="@/static/pagesC/threeimage.png" mode="" v-if="Number(datasix.val)>100"></image>
					<view class="title">
						<text>{{datasix.val}}</text>
						<text>次/分</text>
					</view>
				</view>
			</view>
			<view class="item" @tap='gohealthdata(6)'>
				<view class="itemtitle">
					体温
				</view>
				<view class="" v-if="!dataseven">
					<view class="itemtext">
						快来测量吧~
					</view>
					<view class="itemtext two">
						您暂时未测量
					</view>
					<image src="@/static/pagesC/temperature.png" mode=""></image>
				</view>
				<view class="titletexts" v-else>
					<view class="time">
						{{dataseven.date}}
					</view>
					<image src="@/static/pagesC/oneimage.png" mode="" v-if="Number(dataseven.val)<36"></image>
					<image src="@/static/pagesC/twoimage.png" mode=""
						v-if="Number(dataseven.val)>=36&&Number(dataseven.val)<=37"></image>
					<image src="@/static/pagesC/threeimage.png" mode="" v-if="Number(dataseven.val)>37"></image>
					<view class="title">
						<text>{{dataseven.val}}</text>
						<text>℃</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		recordlast
	} from '@/api/examinationapi/add.js'
	export default {
		data() {
			return {
				dataone: null,
				datatwo: null,
				datathree: null,
				datafour: null,
				datafive: null,
				datasix: null,
				dataseven: null,
			}
		},
		onShow() {
			this.info();
		},
		methods: {
			info() {
				recordlast(uni.getStorageSync('userinfo').cardNo).then(res => {
					if (res.data && res.data.length > 0) {
						res.data.forEach(e => {
							e.type == '1' ? this.dataone = e : ''
							e.type == '2' ? this.datatwo = e : ''
							e.type == '3' ? this.datathree = e : ''
							e.type == '4' ? this.datafour = e : ''
							e.type == '5' ? this.datafive = e : ''
							e.type == '6' ? this.datasix = e : ''
							e.type == '7' ? this.dataseven = e : ''
						})
						this.datatwo.szy = this.datatwo.val.split('/')[1]
						this.datatwo.ssy = this.datatwo.val.split('/')[0]
						this.datathree.tc = this.datathree.val.split('/')[0]
						this.datathree.tg = this.datathree.val.split('/')[1]
						this.datathree.hdl = this.datathree.val.split('/')[2]
						this.datathree.ldl = this.datathree.val.split('/')[3]
					}
				})
			},
			goaddequipment() {
				uni.navigateTo({
					url: "/pagesC/devicelist/devicelist"
				})
			},
			gohealthdata(index) {
				uni.navigateTo({
					url: `/pagesC/healthdata/healthdata?index=${index}`
				})
			},
			gotestreport() {
				uni.navigateTo({
					url: "/pagesC/testreport/testreport"
				})
			},
		}
	}
</script>

<style lang="scss">
	@import './Physicalexamination.scss';
</style>