<!--
 * @Title: 
 * @Description: 测站实时数据
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
	<view class="wrap">
		<uni-nav-bar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
			@clickLeft="toBack">
			<view class="nav-title">
				<text>{{title}}</text>
			</view>
		</uni-nav-bar>
		<view class="container">
			<uni-section v-if="isRain == 1" title="雨量站" type="line">
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">采集时间：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{rainData.tm}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">上报时间：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{rainData.fromTime}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">时段长：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content" v-if="rainData.intv == 1">小时</text>
							<text class="content" v-else-if="rainData.intv == 0.05">5分钟</text>
							<text class="content" v-else>--</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">时段降水：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{rainData.drp}}</text>
						</view>
					</uni-col>
				</uni-row>
			</uni-section>
			<uni-section v-if="isRiver == 1 || isRes == 1" title="水位站" type="line">
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">采集时间：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{waterData.wlTime}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">上报时间：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{waterData.wlUpTime}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">水位：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{waterData.wl}}</text>
						</view>
					</uni-col>
				</uni-row>
			</uni-section>
			<uni-section v-if="isGround == 1" title="墒情站" type="line">
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">采集时间：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.tm}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">上报时间：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.fromTime}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">垂线平均含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.vtavslm}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">表层含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.srlslm}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">10CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm10}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">20CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm20}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">30CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm30}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">40CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm40}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">50CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm50}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">60CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm60}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">80CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm80}}</text>
						</view>
					</uni-col>
				</uni-row>
				<uni-row>
					<uni-col :span="10">
						<view class="line-text">
							<text class="title">100CM深度含水量：</text>
						</view>
					</uni-col>
					<uni-col :span="14">
						<view class="line-text">
							<text class="content">{{groundData.slm100}}</text>
						</view>
					</uni-col>
				</uni-row>
			</uni-section>
		</view>
	</view>
</template>

<script>
	import http from '@/http/api.js';

	export default {
		components: {

		},
		onLoad(option) {
			this.query['rtuCode'] = option.rtuCode;
			this.isRain = option.isRain;
			this.isRiver = option.isRiver;
			this.isRes = option.isRes;
			this.isGround = option.isGround;
			this.getData();
		},
		data() {
			return {
				title: '测站实时数据信息',
				loading: false,
				query: {},
				isRain: 0,
				isRiver: 0,
				isRes: 0,
				isGround: 0,
				rainData: {},
				//riverData: {},
				//rsvrData: {},
				waterData: {},
				groundData: {},
			}
		},
		computed: {

		},
		onShow() {},
		methods: {
			toBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 获取数据
			getData(params = {}) {
				let that = this;
				let postData = Object.assign(params, this.query);
				http.request({
					url: '/galaxy-business/rtu/data/ground/detail',
					method: 'GET',
					params: postData,
				}).then(res => {
					that.groundData = res.data;
				}).catch(err => {
					console.log(err)
				})

				http.request({
					url: '/galaxy-business/rtu/data/rain/detail',
					method: 'GET',
					params: postData,
				}).then(res => {
					that.rainData = res.data;
				}).catch(err => {
					console.log(err)
				})

				http.request({
					url: '/galaxy-business/rtu/data/river/detail',
					method: 'GET',
					params: postData,
				}).then(res => {
					console.log(JSON.stringify(res))
					if (res.success) {
						if (res.data.tm) {
							let data = {};
							data['wlTime'] = res.data.tm;
							data['wlUpTime'] = res.data.fromTime;
							data['wl'] = res.data.z;
							that.waterData = data;
						}
					}
				}).catch(err => {
					console.log(err)
				})

				http.request({
					url: '/galaxy-business/rtu/data/rsvr/detail',
					method: 'GET',
					params: postData,
				}).then(res => {
					console.log(JSON.stringify(res))
					if (res.success) {
						if (res.data.tm) {
							let data = {};
							data['wlTime'] = res.data.tm;
							data['wlUpTime'] = res.data.fromTime;
							data['wl'] = res.data.rz;
							that.waterData = data;
						}
					}
				}).catch(err => {
					console.log(err)
				})
			},
		}
	}
</script>

<style scoped>
	/* page {
		background-color: rgb(240, 242, 244);
	} */
</style>

<style lang="scss" scoped>

	.line-text {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		margin-top: 5px;
		margin-bottom: 5px;
		padding-left: 10px;
	}

	.line-text .title {
		font-size: 0.7rem;
	}

	.line-text .content {
		color: darkcyan;
		font-size: 0.7rem;
	}

</style>
