<template>
	<view class="" style="padding: 30rpx;">
		<view style="height: var(--status-bar-height)"></view>
		<view class="" style="display: flex;align-items: center;font-size: 33.29rpx;margin-bottom: 20rpx;">
			<u--image @tap="backFn" src="/static/img/FH.png" width="50.82rpx" height="50.82rpx" alt=""></u--image>
			<text>生态概况</text>
		</view>
		<view class="" style="padding: 20rpx;box-sizing: border-box;">
			<view class="head">
				<view class="subsection">
					<view class="subsection-li" @click="changeDate(10)">
						小时
					</view>
					<view class="subsection-li" @click="changeDate(160.7)">
						天
					</view>
					<view class="subsection-li sct" @click="changeDate(311.4)">
						月
					</view>
					<view class="act" :style="{left:leftNum+'rpx'}">

					</view>
				</view>
				<view class="set" @tap="navgo">
					<view class="" style="margin: 0 10rpx;">
						<u-icon name="setting" color="white" size="15"></u-icon>
					</view> 设置
				</view>
			</view>
			<view class="">
				<view class="tit">
					养殖检测数据
				</view>
				<view class="charts-box">

					<qiun-data-charts type="mix" :opts="opts" :chartData="chartData" />
				</view>
				<view class="charts-box">
					<qiun-data-charts type="mix" :opts="opts2" :chartData="chartData2" />
				</view>
				<view class="charts-box">
					<qiun-data-charts type="mix" :opts="opts3" :chartData="chartData3" />
				</view>
			</view>
			<view class="detect">
				<view class="detecttit">
					<text class="line"></text> 种植监测
				</view>
				<view class="content" style=" text-indent: 2em;">
					<view class="">
						对动物的营养、疾病等监测可以可以确保动物摄入足够的营养物质，提高生长速度和抗病能力。评估饲料的营养水平和动物的营养需求，为饲料配方和饲养管理提供依据。通过观察动物的行为、食欲、生长状况等，以及定期进行实验室检测，可以及早发现动物的异常状况，从而采取相应的治疗和隔离措施，降低疫情传播风险。
					</view>
					<view class="">

						动物排便甲烷浓度含量监测是保障养殖场环境安全和可持续发展的重要措施之一，能够及时发现和处理养殖场内的环境问题，降低环境污染和温室气体排放，提高养殖场的经济效益和社会效益。
					</view>
					<view class="">

						对山体监测可以帮助养殖业者更好地了解山体的环境状况,对水质、土壤等样品进行检测，可以检测出其中是否存在有害微生物和寄生虫，及时采取防控措施，减少疾病的发生和传播。通过对山体温度生态环境的监测，可以了解山体生态系统的变化情况，如气候变化、水土流失、植被破坏等，可以及时采取措施维护生态平衡，优化养殖生产管理，提高养殖效率和质量，保障养殖业的可持续发展。
					</view>

				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		companyMine
	} from "@/api/test.js"
	export default {
		data() {
			return {
				leftNum: 10,
				chartData: {},
				chartData2: {},
				chartData3: {},
				//您可以通过修改 config-ucharts.js 文件中下标为 ['mix'] 的节点来配置全局默认参数，如都是默认参数，此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
				opts: {
					color: ["#1890FF", "#91CB74"],
					padding: [15, 15, 0, 15],
					enableScroll: false,
					legend: {},
					xAxis: {
						disableGrid: true,

					},
					yAxis: {
						disabled: false,
						disableGrid: false,
						splitNumber: 5,
						gridType: "dash",
						dashLength: 4,
						gridColor: "#CCCCCC",
						padding: 10,
						showTitle: true,
						data: [{
								position: "left",
								title: ""
							},
							{
								position: "right",
								min: 0,
								max: 200,
								title: "",
								textAlign: "left"
							},

						]
					},
					extra: {
						mix: {
							column: {
								width: 20
							}
						}
					}
				},
				opts2: {
					color: ["#1890FF", "#91CB74"],
					padding: [15, 15, 0, 15],
					enableScroll: false,
					legend: {},
					xAxis: {
						disableGrid: true,

					},
					yAxis: {
						disabled: false,
						disableGrid: false,
						splitNumber: 5,
						gridType: "dash",
						dashLength: 4,
						gridColor: "#CCCCCC",
						padding: 10,
						showTitle: true,
						data: [{
								position: "left",
								title: ""
							},
							{
								position: "right",
								min: 0,
								max: 200,
								title: "",
								textAlign: "left"
							},

						]
					},
					extra: {
						mix: {
							column: {
								width: 20
							}
						}
					}
				}

				,
				opts3: {
					color: ["#1890FF", "#91CB74"],
					padding: [15, 15, 0, 15],
					enableScroll: false,
					legend: {},
					xAxis: {
						disableGrid: true,

					},
					yAxis: {
						disabled: false,
						disableGrid: false,
						splitNumber: 5,
						gridType: "dash",
						dashLength: 4,
						gridColor: "#CCCCCC",
						padding: 10,
						showTitle: true,
						data: [{
								position: "left",
								title: ""
							},
							{
								position: "right",
								min: 0,
								max: 200,
								title: "",
								textAlign: "left"
							},

						]
					},
					extra: {
						mix: {
							column: {
								width: 20
							}
						}
					}
				}


			};
		},
		onReady() {
			let datas = [
				[25, 20, 17, 29, 28, 26],
				[32, 30, 25, 21, 27, 29],
				[34, 37, 29, 33, 38, 26],
				[25, 15, 172, 95, 71, 59],
				[70, 78, 73, 77, 75, 80],
				[1.8, 2.8, 1.9, 1.7, 1.3, 1.7],
				[111, 113, 129, 34, 199, 153],
				[100, 97, 93, 88, 86, 73],
				[18, 22, 25, 24, 33, 37],
				["12:00", "13:00", "14:00", "15:00", "16:00", "17:00"],
				["12:00", "13:00", "14:00", "15:00", "16:00", "17:00"],
				["12:00", "13:00", "14:00", "15:00", "16:00", "17:00"],
			]

			this.getServerData(datas)

		},
		onShow() {
			companyMine({
				id: 1,
				flag: 1
			}).then(res => {
				console.log(res.data)
			})
		},
		methods: {
			changeDate(num) {
				let datas = []
				this.leftNum = num
				if (num == 10) {
					datas = [
						[25, 20, 17, 29, 28, 26],
						[32, 30, 25, 21, 27, 29],
						[34, 37, 29, 33, 38, 26],

						[25, 15, 172, 95, 71, 59],

						[70, 78, 73, 77, 75, 80],
						[1.8, 2.8, 1.9, 1.7, 1.3, 1.7],
						[111, 113, 129, 34, 199, 153],
						[100, 97, 93, 88, 86, 73],
						[18, 22, 25, 24, 33, 37],
						["12:00", "13:00", "14:00", "15:00", "16:00", "17:00"],
						["12:00", "13:00", "14:00", "15:00", "16:00", "17:00"],
						["12:00", "13:00", "14:00", "15:00", "16:00", "17:00"],
					]
				} else if (num == 160.7) {
					datas = [
						[23, 21, 27, 23, 28, 20],
						[30, 34, 32, 36, 27, 24],
						[29, 30, 27, 26, 37, 33],
						[22, 26, 22, 27, 150, 107],

						[70, 76, 83, 87, 84, 80],
						[1.6, 1.3, 2.2, 2.0, 1.9, 2.5],
						[151, 55, 25, 146, 157, 154],
						[101, 116, 114, 109, 105, 105],
						[19, 23, 24, 27, 26, 22],
						["10-12", "10-13", "10-14", "10-15", "10-16", "10-17"],
						["10-12", "10-13", "10-14", "10-15", "10-16", "10-17"],
						["10-12", "10-13", "10-14", "10-15", "10-16", "10-17"],

					]
				} else if (num == 311.4) {
					datas = [
						[29, 23, 22, 23, 19, 17],
						[32, 33, 28, 27, 26, 23],
						[26, 25, 35, 32, 30, 33],
						[190, 172, 76, 96, 39, 23],

						[85, 84, 83, 93, 89, 85],
						[1.7, 1.8, 1.8, 1.6, 1.7, 2.0],
						[3, 140, 125, 186, 127, 14],
						[90, 95, 94, 90, 84, 80],
						[19, 23, 25, 20, 22, 26],
						["5月", "6月", "7月", "8月", "9月", "10月"],
						["5月", "6月", "7月", "8月", "9月", "10月"],
						["5月", "6月", "7月", "8月", "9月", "10月"],

					]
				}
				this.getServerData(datas)
			},


			navgo() {
				uni.navigateTo({
					url: '/pages/index3/index'
				})
			},
			backFn() {
				uni.navigateBack()
			},
			getServerData(datas) {
				//模拟从服务器获取数据时的延时
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						categories: datas[9],
						series: [{
								name: "土壤温度(℃)",
								index: 1,
								type: "column",
								data: datas[0],
							},

							{
								name: "降雨量(mm)",
								type: "line",
								color: "#2fc25b",
								data: datas[1],
							},
							{
								name: "湿度(wc)",
								type: "line",
								color: "pink",
								data: datas[2],
							},

						]
					};
					let res2 = {
						categories: datas[10],
						series: [

							{
								name: "氮气含量(%)",
								type: "line",
								color: "#2fc25b",
								data: datas[4],
							},
							{
								name: "甲烷含量(ppm)",
								type: "line",
								color: "red",
								data: datas[5],
							},

						]
					};
					let res3 = {
						categories: datas[11],
						series: [

							{
								name: "光照(lux)",
								type: "line",
								color: "#2fc25b",
								data: datas[7],
							},
							{
								name: "风速(m/h)",
								type: "line",
								color: "grey",
								data: datas[8],
							},

						]
					};
					this.chartData = JSON.parse(JSON.stringify(res));
					this.chartData2 = JSON.parse(JSON.stringify(res2));
					this.chartData3 = JSON.parse(JSON.stringify(res3));
				}, 500);
			},
		}
	};
</script>

<style lang="less" scoped>
	.head {
		// height: 10vh;
		display: flex;
		justify-content: space-between;
		align-items: center;

		// background-color: red;
		.subsection {
			display: flex;
			width: 466.12rpx;
			height: 98.13rpx;
			background-color: #F4F4F4;
			border-radius: 50.82rpx 50.82rpx 50.82rpx 50.82rpx;
			line-height: 5vh;
			position: relative;

			.subsection-li {
				width: 150.7rpx;
				height: 84.11rpx;
				border-radius: 50.82rpx 50.82rpx 50.82rpx 50.82rpx;
				text-align: center;
				line-height: 94rpx;
				z-index: 8;
				// margin-top: 10rpx;

			}

			.act {
				position: absolute;
				width: 150.7rpx;
				height: 84.11rpx;
				border-radius: 50.82rpx 50.82rpx 50.82rpx 50.82rpx;
				background-color: #fff;
				top: 50%;
				transform: translateY(-50%);
				transition: .5s;

			}
		}

		.set {
			width: 131.43rpx;
			height: 63rpx;
			background-color: #0BC677;
			border-radius: 31.54rpx 31.54rpx 31.54rpx 31.54rpx;
			color: white;
			text-align: center;
			line-height: 63rpx;
			display: flex;
			align-items: center;
		}
	}

	.tit {
		text-align: center;
		margin: 30rpx 0;
		font-size: 36.8rpx;
	}

	.charts-box {
		width: 100%;
		height: 300px;
		border: 1px solid black;
		margin-bottom: 40rpx;
	}

	.detect {
		.line {
			width: 7.01rpx;
			height: 31.54rpx;
			background-color: #4CC593;
			display: inline-block;
			margin-right: 10rpx;
		}

		.detecttit {
			font-size: 31.54rpx;
			display: flex;
			align-items: center;
		}

		.content {
			padding-top: 20rpx;
		}


	}
</style>