<template>
	<view>
		<view class="top">
			<image src="../img/top.jpg" mode="widthFix"></image>
		</view>

		<view class="container">
			<view class="btn">
				<view class="left">
					<view class="icon">
						<image src="../img/btn_icon.png" mode="widthFix"></image>
					</view>
					<view class="title">
						通风智能决策及控制系统
					</view>
				</view>
				<!-- <view class="right">
					<uni-icons type="arrowright" color="#FFF"></uni-icons>
				</view> -->
			</view>

			<view class="info">
				<view class="chart">
					<view class="charts-box">
						<qiun-data-charts type="ring" :opts="opts_1" :chartData="chartData_1" />
					</view>
					<view class="charts-box">
						<qiun-data-charts type="ring" :opts="opts_2" :chartData="chartData_2" />
					</view>
				</view>
				<view class="box">
					<view class="item" v-for="(item,index) in info" :key="index">
						<view class="label">{{item.label}}</view>
						<view class="value">{{item.value}}</view>
					</view>
				</view>
			</view>

			<view class="content">
				<view class="section" v-for="(item,index) in list" :key="index">
					<view class="title">
						<view class="left">{{item.title}}</view>
						<view class="right" @click="goto_url(item)">点击查看详情</view>
					</view>
					<view class="inner">
						<view class="item" v-for="(item_2,index_2) in item.info" :key="index_2">
							<view class="label">{{item_2.label}}</view>
							<view class="value">
								<view class="state" :style="{'backgroundColor':item_2.state == 1?'#00BD00':'#D6000F'}">
								</view>
								<view class="text">{{item_2.text}}</view>
							</view>
						</view>
					</view>
				</view>

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

<script>
	export default {
		data() {
			return {
				chartData_1: {
					series: [{
						data: [{
							"name": "有效风",
							"value": 0
						}, {
							"name": "无效风",
							"value": 0
						}]
					}]
				},
				opts_1: {
					color: ["#00FF00", "#FFFF00"],
					dataLabel: false,
					legend: {
						show: true,
						fontColor: "#FFF",
						fontSize: 10,
						position: "bottom",
						margin: 0,
						padding: 0
					},
					title: {
						name: "90%",
						fontSize: 12,
						color: "#FFF"
					},
					subtitle: {
						name: "有效风率",
						fontSize: 10,
						color: "#FFF"
					},
					extra: {
						ring: {
							centerColor: "#34ADFE",
							ringWidth: 20,
							border: false,
						}
					}
				},

				chartData_2: {
					series: [{
						data: [{
							"name": "供风量",
							"value": 16052
						}, {
							"name": "需风量",
							"value": 15052
						}]
					}]
				},
				opts_2: {
					color: ["#51FFF1", "#FFB944"],
					dataLabel: false,
					legend: {
						show: true,
						fontColor: "#FFF",
						fontSize: 10,
						position: "bottom",
						margin: 0,
						padding: 0
					},
					title: {
						name: "1.07",
						fontSize: 12,
						color: "#FFF"
					},
					subtitle: {
						name: "供需比",
						fontSize: 10,
						color: "#FFF"
					},
					extra: {
						ring: {
							centerColor: "#34ADFE",
							ringWidth: 20,
							border: false,
						}
					}
				},

				info: [{
						label: "自动风门",
						value: "2扇"
					},
					{
						label: "自动风窗",
						value: "2扇"
					},
					{
						label: "变频风扇",
						value: "6扇"
					}
				],


				list: [{
						title: "东井通风机",
						sys_code: "east",
						info: [{
								label: "1#风机",
								state: 0,
								text: "停止"
							},
							{
								label: "2#风机",
								state: 1,
								text: "运行"
							}
						]
					},
					{
						title: "西井通风机",
						sys_code: "west",
						info: [{
								label: "1#风机",
								state: 0,
								text: "停止"
							},
							{
								label: "2#风机",
								state: 1,
								text: "运行"
							}
						]
					},
					{
						title: "1314 立井通风机",
						sys_code: "1314",
						info: [{
								label: "1#风机",
								state: 1,
								text: "运行"
							},
							{
								label: "2#风机",
								state: 0,
								text: "停止"
							}
						]
					},
					{
						title: "220708 辅助巷通风机",
						sys_code: "220708fzx",
						info: [{
								label: "1#风机",
								state: 1,
								text: "运行"
							},
							{
								label: "2#风机",
								state: 0,
								text: "停止"
							}
						]
					},
					{
						title: "220708 胶带巷通风机",
						sys_code: "220708jdx",
						info: [{
								label: "1#风机",
								state: 1,
								text: "运行"
							},
							{
								label: "2#风机",
								state: 0,
								text: "停止"
							}
						]
					}
				],
			};
		},
		mounted() {
			this.getServerData()
		},
		methods: {
			getServerData() {
				this.$api.zaoquan_dcs_getFan({
					sys_code: "index"
				}).then((res) => {
					console.log(res.data)
					
					this.chartData_1 = res.data.chartData_1
					this.chartData_2 = res.data.chartData_2
					this.info = res.data.info
					this.list = res.data.list
				})
			},
			goto_url(item) {
				let zhutongfeng = ["east", "west", "1314","5fq"]

				if (zhutongfeng.includes(item.sys_code)) {
					uni.navigateTo({
						url: "./main_ventilation/main_ventilation" + "?title=" + item.title + "&sys_code=" + item
							.sys_code
					})
				} else {
					uni.navigateTo({
						url: "./local_ventilation/local_ventilation" + "?title=" + item.title + "&sys_code=" + item
							.sys_code
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F7F7;
	}

	.top {
		margin-top: -80rpx;

		image {
			width: 750rpx;
		}
	}

	.container {
		margin: -900rpx 0 0 0;
		position: relative;

		.btn {
			margin: 0 auto;
			width: 680rpx;
			height: 120rpx;
			background-image: url("../img/btn.png");
			background-size: cover;

			display: flex;
			align-items: center;
			justify-content: space-between;

			box-sizing: border-box;
			padding: 0 40rpx;

			.left {
				display: flex;
				align-items: center;

				.icon {
					margin-right: 20rpx;
					font-size: 0;

					image {
						width: 36rpx;
					}
				}

				.title {
					font-size: 34rpx;
					font-weight: 700;
					color: #FFF;
				}
			}

			.right {
				font-weight: 700;
			}
		}

		.info {
			margin: 25rpx;
			padding-bottom: 20rpx;
			background-color: #34ADFE40;
			border-radius: 16rpx;

			.chart {
				display: flex;

				.charts-box {
					width: 50%;
					height: 300rpx;
				}
			}

			.box {
				margin: 20rpx 40rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;

				.item {
					font-size: 26rpx;
					display: flex;

					.label {
						color: #FFF;
					}

					.value {
						margin-left: 20rpx;
						color: #FFFF00;
					}
				}
			}
		}

		.content {
			background-color: #F7F7F7;
			border-radius: 35rpx 35rpx 0 0;
			box-sizing: border-box;
			padding: 35rpx;

			.section {
				margin-bottom: 40rpx;
				border-radius: 14rpx;
				overflow: hidden;

				.title {
					background: linear-gradient(-90deg, #FFFFFF, #E6FAFF);

					display: flex;
					align-items: flex-end;
					justify-content: space-between;

					box-sizing: border-box;
					padding: 24rpx;

					.left {
						border-left: 6rpx solid #33C777;
						padding-left: 10rpx;
						font-size: 34rpx;
						font-weight: 700;
						color: #343434;
					}

					.right {
						font-size: 22rpx;
						color: #3394F9;
					}
				}

				.inner {
					background-color: #FFFFFF;
					padding: 30rpx 20rpx;
					display: grid;
					grid-template-columns: repeat(2, 1fr);
					gap: 0 40rpx;

					.item {
						display: flex;
						align-items: center;
						justify-content: space-around;
						line-height: 60rpx;

						.label {
							width: 140rpx;
							color: #8D8D8D;
							font-size: 26rpx;
						}

						.value {
							display: flex;
							align-items: center;

							.state {
								width: 30rpx;
								height: 30rpx;
								background: #D6000F;
								border-radius: 6rpx;
							}

							.text {
								margin-left: 20rpx;
								font-size: 26rpx;
							}
						}
					}
				}
			}


		}
	}
</style>