<!-- 安全检查扫一扫 实验室详情 -->
<template>
	<view class="safetyCardScan">
		<scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
			<view class="header">
				<view class="tabTitle">
					<view class="tabTitle_li" @tap="tabClick(index)" :key="index" v-for="(item,index) in tabText">
						<view class="tabTitle_text">
							<img :src="item.img">
							<view
								:id="curTab==index && curTab==0?'fontColor-A':(curTab==index && curTab==1?'fontColor-B':'')">
								{{item.name}}
							</view>
						</view>
						<view :class="{on:curTab==index}" class="tabTitle_across">
							<img src="@/pages_safetyCheck/images/img_xyzc_bg@1x.png">
						</view>
						<view class="line"></view>
					</view>
				</view>
			</view>
			<view class="safetyCard" v-if="pageType==1">
				<view class="lab-info">
					<view class="lab-info-t">
						<view>一级</view>
						<view>化学类</view>
						<view>实验室名称名称名称（房间号）</view>
					</view>
					<view class="lab-info-b">
						<img src="@/pages_safetyCheck/images/icon_sys_xz@1x.png">
						楼栋楼层
					</view>
				</view>
				<view class="liability-unit">
					<view>学院单位</view>
					<view>学院单位名称</view>
				</view>
				<view class="small-title">
					<view>实验室负责人</view>
					<img src="@/pages_safetyCheck/images/icon_06_1.png">
				</view>
				<view class="sub-head">
					<view>{{newData.adminName}}</view>
					<view @click="callPhone(newData.adminPhone)">
						<img src="@/pages_manage/images/icon_aqxxp_dh.png">
						<view>{{newData.adminPhone}}</view>
					</view>
				</view>
				<view class="small-title">安全员</view>
				<view class="sub-head" v-for="(item,index) in newData.safeUserList" :key="index">
					<view>{{item.safeUserName}}</view>
					<view @click="callPhone(item.safeUserPhone)">
						<img src="@/pages_manage/images/icon_aqxxp_dh.png">
						<view>{{item.safeUserPhone}}</view>
					</view>
				</view>
				<view class="classify" v-for="(item,index) in newData.labInfoBrandModels" :key="index">
					<view v-if="item.privateList.length>0 && item.brandType==1" class="small-title">{{item.brandName}}
					</view>
					<view v-if="item.privateList.length>0 && item.brandType==1 && !item.isSpecial" class="small-items"
						v-for="(item2,index2) in item.privateList" :key="index2">
						<view>● </view>
						<view>{{item2.infoName}}</view>
					</view>
					<view v-if="item.privateList.length>0 && item.brandType==1 && item.isSpecial" class="small-items"
						v-for="(item2,index2) in item.privateList" :key="index2">
						<view></view>
						<view>{{item2.infoName}}</view>
					</view>
					<view v-if="item.privateList.length>0 && item.brandType==2" class="logotype">{{item.brandName}}
					</view>
					<view v-if="item.privateList.length>0 && item.brandType==2" class="logotype-img">
						<img v-for="(item3,index3) in item.privateList" :key="index3" :src="baseUrl+item3.infoContent">
					</view>
				</view>
			</view>
			<!-- 物联控制 -->
			<iotControl ref="iotControl" v-if="pageType == 2" :subjectData="subjectData"></iotControl>
			<!-- 进出记录 -->
			<accessRecord v-if="pageType == 4" :subjectData="subjectData"></accessRecord>
			<!-- 语音广播弹窗 -->
			<voiceBroadcast v-if="broadcastPage" :subjectData="subjectData"></voiceBroadcast>
			<!-- 空调弹窗 -->
			<airConditioning v-if="conditioningPage" :airConditioningData="airConditioningData"></airConditioning>
		</scroll-view>
	</view>

</template>

<script>
	import {
		iotControl
	} from '@/pages_manage/views/laboratory/iotControl.vue'
	import {
		accessRecord
	} from '@/pages_manage/views/laboratory/accessRecord.vue'
	import {
		voiceBroadcast
	} from '@/pages_manage/views/laboratory/voiceBroadcast.vue'
	import {
		airConditioning
	} from '@/pages_manage/views/laboratory/airConditioning.vue'
	import {
		config
	} from '@/api/request/config.js'
	import {

	} from '@/pages/api/index.js'
	export default {
		name: "safetyCardScan",
		components: {
			iotControl,
			accessRecord,
			voiceBroadcast,
			airConditioning,
		},
		data() {
			return {
				baseUrl: config.base_url,
				pageType: 1,
				tabText: [{
						name: '安全信息牌',
						img: require('@/pages_safetyCheck/images/icon_sys_aqxxp@1x.png'),
					},
					{
						name: '监测控制',
						img: require('@/pages_safetyCheck/images/icon_sys_jckz@1x.png'),
					},
					{
						name: '进出记录',
						img: require('@/pages_safetyCheck/images/icon_sys_jcjl@1x.png'),
					},
				],
				curTab: 0,
				newData: {
					adminName: '李飘飘',
					adminPhone: '13655668899',
					safeUserList: [{
							safeUserName: '周游',
							safeUserPhone: '13655668899',
						},
						{
							safeUserName: '周游',
							safeUserPhone: '13655668899',
						},
					],
				},
				//语音广播弹窗
				broadcastPage: false,
				//空调弹窗
				conditioningPage: false,
				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 20,
				},
				subjectData: null,
				// 空调弹窗
				airConditioningData: null,
				saoCodeType: false,

			}
		},
		// 父页面
		onReachBottom() {
			uni.$emit('onReachBottom') // 设置监听事件
		},
		onPullDownRefresh() {
			uni.$emit('onPullDownRefresh') // 设置监听事件
		},
		onLoad(option) {
			//this.$set(this, 'newData', JSON.parse(decodeURIComponent(option.infoData)));
			//this.$set(this, 'subjectData', JSON.parse(decodeURIComponent(option.infoData)));
			if (option.saoCode) {
				this.$set(this, 'saoCodeType', true);
				this.$set(this, 'currentIndex', 1);
				this.$set(this, 'pageType', 3);
			} else {
				this.$set(this, 'saoCodeType', false);
				this.$set(this, 'currentIndex', 0);
				this.$set(this, 'pageType', 2);
			}

		},
		onShow() {

		},
		mounted() {

		},
		methods: {
			//滚动事件
			scrollGet() {},
			//顶部tab点击
			tabClick(index) {
				this.curTab = index;
				if (index == 0) {
					//安全信息牌
					this.$set(this, 'pageType', 1);
				} else if (index == 1) {
					//监测控制
					this.$set(this, 'pageType', 2);
				} else if (index == 2) {
					//进出记录
					this.$set(this, 'pageType', 4);
				}
			},
			goVideoPage() {
				console.log('视频')
				let obj = {
					type: 4,
					subId: this.newData.subId
				}
				uni.navigateTo({
					url: '/pages_manage/views/laboratory/videoPlayer?item=' + encodeURIComponent(JSON.stringify(
						obj))
				});
			},
			getIotControlData() {
				this.$refs['iotControl'].iotAppHardwareFindByType();
			},
			buttonClick(type, row) {
				let self = this;
				if (type == 'subDetail') {
					//实验室详情
				} else if (type == 'broadcastOpen') {
					//语音弹窗开启
					this.$set(this, 'broadcastPage', true);
				} else if (type == 'broadcastClose') {
					//语音弹窗关闭
					this.$set(this, 'broadcastPage', false);
				} else if (type == 'conditioningOpen') {
					//空调弹窗开启
					this.$set(this, 'airConditioningData', row);
					this.$set(this, 'conditioningPage', true);
				} else if (type == 'conditioningClose') {
					//空调弹窗关闭
					this.$set(this, 'conditioningPage', false);
				} else if (type == 'back') {
					this.$set(this, 'pageType', 2);
				}
			},

		}
	}
</script>

<style lang="stylus" scoped>
	.safetyCardScan {
		height: 100%;

		#fontColor-A {
			color: #00DEDE;
		}

		#fontColor-B {
			color: #FF8C00;
		}

		.header {
			width: 100%;
			position: fixed;
			top: 0rpx;
			z-index: 100;
			background: #fff;

			.tabTitle {
				width: 750rpx;
				height: 188rpx;
				display flex;
				justify-content: flex-start;
				align-items: center;
				border-bottom: 4rpx solid #F5F5F5;

				.tabTitle_li {
					height: 188rpx;
					flex: 1;
					position: relative;
					text-align center;

					.tabTitle_text {
						display: flex;
						justify-content: center;
						flex-direction: column;
						align-items: center;

						>img {
							width: 80rpx;
							height: 80rpx;
							margin-top: 20rpx;
						}

						>view:nth-of-type(1) {
							font-size: 30rpx;
							color: #333333;
							line-height: 42rpx;
							text-align: left;
							margin-top: 10rpx;
						}

						>view:nth-of-type(2) {
							font-size: 24rpx;
							color: #666666;
							line-height: 34rpx;
							text-align: left;
						}


						position: relative;

						&.on {}
					}

					.line {
						width: 2rpx;
						height: 40rpx;
						background: #D8D8D8;
						position: absolute;
						top: 40%;
					}

					.tabTitle_across {
						/* width: 50rpx;
						height: 4rpx;
						background: #0183FA;
						border-radius: 2rpx; */
						margin-left: 38%;
						margin-top: 12rpx;
						display none;

						>img {
							width: 40rpx;
							height: 26rpx;
						}

						&.on {
							display block;
						}
					}

				}
			}
		}

		/* 安全信息牌 */
		.safetyCard {
			margin-top: 190rpx;

			.lab-info {
				background: #FFFFFF;

				.lab-info-t {
					width: 750rpx;
					height: 80rpx;
					border: 2rpx dashed #E0E0E0;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					padding: 0 30rpx;
					box-sizing: border-box;

					>view:nth-of-type(1) {
						width: 100rpx;
						height: 60rpx;
						background: #FF0000;
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						font-size: 30rpx;
						color: #FFFFFF;
						line-height: 60rpx;
						text-align: center;
					}

					>view:nth-of-type(2) {
						width: 130rpx;
						height: 60rpx;
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						border: 2rpx solid #FF8C00;
						font-size: 30rpx;
						color: #FF8C00;
						line-height: 60rpx;
						text-align: center;
						margin: 0 30rpx 0 10rpx;
					}

					>view:nth-of-type(3) {
						font-size: 30rpx;
						color: #333333;
						line-height: 42rpx;
						text-align: left;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}

				.lab-info-b {
					height: 80rpx;
					padding: 0 30rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: flex-start;
					align-items: center;

					>img {
						width: 34rpx;
						height: 34rpx;
						margin-right: 12rpx;
					}

					font-size: 30rpx;
					color: #333333;
					line-height: 42rpx;
					text-align: left;
				}
			}

			.liability-unit {
				width: 750rpx;
				height: 80rpx;
				background: #FFFFFF;
				border-bottom: 1rpx solid #E0E0E0;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				margin-top: 14rpx;

				>view:nth-of-type(1) {
					font-size: 30rpx;
					color: #333333;
					line-height: 80rpx;
					text-align: left;
				}

				>view:nth-of-type(2) {
					font-size: 30rpx;
					color: #666666;
					line-height: 80rpx;
					text-align: left;
				}
			}

			.small-title {
				width: 750rpx;
				height: 80rpx;
				background: #FFFFFF;
				border-bottom: 1rpx solid #E0E0E0;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;

				>view {
					font-size: 30rpx;
					color: #333333;
					line-height: 80rpx;
					text-align: left;
				}

				>img {
					width: 24rpx;
					height: 12rpx;
				}
			}

			.sub-head {
				width: 750rpx;
				height: 80rpx;
				background: #fff;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1rpx solid #E0E0E0;

				>view:nth-of-type(1) {
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 30rpx;
					color: #666666;
					line-height: 30rpx;
				}

				>view:nth-of-type(2) {
					display: flex;
					justify-content: flex-end;
					align-items: center;

					>img {
						width: 34rpx;
						height: 34rpx;
						margin-right: 14rpx;
					}

					>view {
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 30rpx;
						color: #0183FA;
						line-height: 30rpx;
					}
				}
			}

			.sub-head:last-child {
				border-bottom: none;
			}

			.classify {
				.small-items {
					padding-left: 20rpx;
					box-sizing: border-box;
					background: #fff;
					display: flex;
					justify-content: flex-start;
					padding: 20rpx;
					box-sizing: border-box;

					>view:nth-of-type(1) {
						color: #999999;
						margin-right: 12rpx;
					}

					>view:nth-of-type(2) {
						display: block;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						line-height: 34rpx;
						color: #999999;
					}

				}

				.logotype {
					width: 750rpx;
					height: 100rpx;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #333333;
					line-height: 100rpx;
					padding-left: 20rpx;
					box-sizing: border-box;
					background: #0183FA;
				}

				.logotype-img {
					padding: 26rpx 0 34rpx 0;
					box-sizing: border-box;
					background: #fff;

					>img {
						display: inline-block;
						width: 86rpx;
						height: 114rpx;
						margin-left: 30rpx;
						margin-bottom: 20rpx;
					}
				}
			}
		}
	}
</style>
