<template>
	<view>
		<view class="top">
			<image src="./icon/top.gif" mode="widthFix"></image>
		</view>
		<view class="content" v-if="nav.length > 0">
			<view class="segmented-control-x">
				<view class="segmented">
					<view class="title" :class="active==index?'active':''" v-for="(item,index) in nav" :key="index"
						@click="change_active(index)">
						{{item.title}}
					</view>
				</view>
				<view class="segmented-inner">
					<view class="nav" v-for="(item,index) in nav[active].list" :key="index" @click="navigator(item)">
						<view class="icon">
							<image :src="item.icon" mode=""></image>
						</view>
						<view class="name">{{item.name}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "t-p-zaoquan",
		data() {
			return {
				mine: "640181B0011010037723",
				org_num: "1014",
				mine_code: "zaoquan",

				active: 0,
				nav:[]
				// nav: [{
				// 	title: "",
				// 	list: [{
				// 		icon: '',
				// 		module: "",
				// 		name: "",
				// 		sys_code: ""
				// 	}]
				// }],

			};
		},
		mounted() {
			this.get_nav()
		},
		methods: {
			get_nav() {
				uni.request({
					url: "http://zq.oa.nxmy.com:8011/api.php?m=openDcsApi&a=dcs_door&openkey=d9302364e2a2d9fdcab2707a46fbab5a",
					method: "POST",
				}).then((res) => {
					this.nav = res[1].data.nav
				})
			},
			change_active(index) {
				this.active = index

				uni.pageScrollTo({
					scrollTop: 0,
					duration: 150
				});
			},
			navigator(item) {
				uni.showLoading({
					mask: true,
					title: "载入中..."
				})
				// 老后台权限
				// this.$p_api.product_data_query_power({
				// 	staff_num: uni.getStorageSync('user').staff_num,
				// 	data_module: item.module
				// }).then((res) => {
				// 	uni.hideLoading()
				// 	if (res.data.content.status) {
				// 		// 具备权限进入对应系统
				// 		this.navigator_handler(item)
				// 	} else {
				// 		uni.showToast({
				// 			icon: "none",
				// 			title: "没有查看权限！"
				// 		})
				// 	}
				// })
				// oa权限
				uni.request({
					url: "http://zq.oa.nxmy.com:8011/api.php?m=openDcsApi&a=dcs_auth_check&openkey=d9302364e2a2d9fdcab2707a46fbab5a",
					method: "GET",
					data: {
						staff_num: uni.getStorageSync('user').staff_num,
						sys_id: item.id
					}
				}).then((res) => {
					uni.hideLoading()
					if (res[1].data.code == '200') {
						// 具备权限进入对应系统
						console.log(item)
						this.navigator_handler(item)
					} else {
						uni.showToast({
							icon: "none",
							title: res[1].data.msg
						})
					}
				})

			},
			navigator_handler(item) {
				// 智能监测
				if (item.module == 'znjc') {
					if (item.sys_code == 'rydw') {
						uni.navigateTo({
							url: "../../production/personnel_orientation/personnel_orientation?mine=" + this.mine
						})
					}
					if (item.sys_code == 'aqjc') {
						uni.navigateTo({
							url: "../../production/safety_monitoring/safety_monitoring?mine=" + this.mine
						})
					}
					if (item.sys_code == 'spjk') {
						uni.navigateTo({
							url: "../../production/video_monitor/video_monitor?mine_code=" + this.mine_code
						})
					}
					if (item.sys_code == 'scbb') {
						uni.navigateTo({
							url: "../../production/production_report/production_report?mine=" + this.mine +
								"&org_num=" + this.org_num,
						})
					}
					if (item.sys_code == 'kjscl') {
						uni.navigateTo({
							url: "../../production/zaoquan/mine_water_treatment/mine_water_treatment?mine_code=" +
								this
								.mine_code
						})
					}
				}
				// 智能采煤
				if (item.module == 'zncm') {
					if (item.sys_code == '') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/coal_mining/coal_mining"
						})
					}
					if (item.sys_code == 'ruhuabeng') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/coal_mining/emulsion_pump/emulsion_pump"
						})
					}
					if (item.sys_code == 'caimeiji') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/coal_mining/shearer/shearer"
						})
					}
					if (item.sys_code == 'yeyazhijia') {
						uni.navigateTo({
							url: "../../production/unified_automation_system/support/support?title=液压支架&sys_code=main"
						})

					}
					if (item.sys_code == 'sanji') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/coal_mining/sanji/sanji"
						})
					}
				}
				// 智能综掘
				if (item.module == 'znjj') {
					uni.navigateTo({
						url: "../../production/zaoquan/control_platform/driving/driving"
					})
				}
				// 压风制氮
				if (item.module == 'yfzd') {
					uni.navigateTo({
						url: "../../production/zaoquan/control_platform/air_nitrogen/air_nitrogen?title=" + item
							.name + "&sys_code=" + item.sys_code
					})
				}
				// 供配电
				if (item.module == 'zngd') {
					uni.navigateTo({
						url: "../../production/zaoquan/control_platform/substation/detail/detail?title=" + item
							.name + "&type=" + item.sys_code
					})
				}
				// 供排水
				if (item.module == 'znps') {
					if (item.sys_code == 'znps') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/drainage/drainage"
						})
					} else if (item.sys_code == '5000f') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/drainage/pool/pool?title=" + item
								.name + "&sys_code=" + item.sys_code
						})
					} else {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/drainage/pump_house/pump_house?title=" +
								item.name + "&sys_code=" + item.sys_code
						})
					}
				}
				// 智能通风
				if (item.module == 'zntf') {
					if (item.sys_code == '') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/ventilate/ventilate"
						})
					} else {
						let zhutongfeng = ["east", "west", "1314", "5fq"]
						if (zhutongfeng.includes(item.sys_code)) {
							uni.navigateTo({
								url: "../../production/zaoquan/control_platform/ventilate/main_ventilation/main_ventilation" +
									"?title=" + item.name + "&sys_code=" + item.sys_code
							})
						} else {
							uni.navigateTo({
								url: "../../production/zaoquan/control_platform/ventilate/local_ventilation/local_ventilation" +
									"?title=" + item.name + "&sys_code=" + item.sys_code
							})
						}
					}
				}
				// 智能园区
				if (item.module == 'zhyq') {
					if (item.sys_code == 'zncs_dm') {
						uni.navigateTo({
							url: "../../production/zaoquan/vehicle_monitoring/speed_alarm/speed_alarm"
						})
					}
					if (item.sys_code == 'zncs_jx') {
						uni.navigateTo({
							url: "../../production/zaoquan/vehicle_monitoring/vehicle_monitoring"
						})
					}
					// 扬尘监测
					if (item.sys_code == 'ycjc') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/dust_emission/dust_emission"
						})
					}
					// 智能充电桩
					if (item.sys_code == 'zncdz') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/charging_station/charging_station"
						})
					}
				}
				// 智能园区
				if (item.module == 'ysxt') {
					// 主运输
					if (item.sys_code == 'zys') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/transport/transport"
						})
					}
					// 动井架空乘人器
					if (item.sys_code == 'djjk') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/aerial/aerial"
						})
					}
				}
				// 灾害监测
				if (item.module == 'zaihai') {
					if (item.sys_code == 'sw') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/hydrology/hydrology"
						})
					} else if (item.sys_code == 'kyjc') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/mineral_pressure/mineral_pressure"
						})
					} else if (item.sys_code == 'yjgb') {
						uni.navigateTo({
							url: "../../production/zaoquan/control_platform/emergency_broadcasting/emergency_broadcasting"
						})
					}

				}
			}

		}
	}
</script>

<style lang="scss">
	page {
		background: linear-gradient(to bottom, #E4F8FF, #F3F5F9);
		background-color: #F3F5F9;
	}

	.top {
		image {
			width: 750rpx;
		}
	}

	.content {
		padding-bottom: 60rpx;
		background-color: #F3F5F9;

		.segmented-control-x {
			display: flex;
			justify-content: space-between;

			.segmented {
				margin-right: 20rpx;
				flex: 1.2;
				background-color: #FFF;
				border-radius: 0 20rpx 20rpx 0;
				overflow: hidden;

				.title {
					padding: 30rpx;
					font-size: 34rpx;
					font-weight: 700;
					text-align: center;
					line-height: 1.5;
					color: #999;
				}

				.active {
					background-color: #F3F5F9;
					color: #000;
				}
			}

			.segmented-inner {
				background-color: #FFF;
				flex: 2;
				border-radius: 20rpx 0 0 20rpx;
				overflow: hidden;
				box-sizing: border-box;
				padding: 40rpx 20rpx;

				display: grid;
				grid-template-columns: repeat(2, 1fr);
				grid-auto-rows: 200rpx;
				gap: 20rpx;

				.nav {
					text-align: center;

					.icon {
						margin-bottom: 10rpx;

						image {
							width: 80rpx;
							height: 80rpx;
						}
					}

					.name {
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
						overflow: hidden;
						text-overflow: ellipsis;
						font-weight: 700;
						line-height: 1.5;
						font-size: 28rpx;
					}
				}
			}
		}
	}
</style>