dedsudiyu 11 mesiacov pred
rodič
commit
662856f8be

+ 1 - 1
api/request/request.js

@@ -370,7 +370,7 @@ export function loginTimeout(params) {
 	uni.removeStorageSync('userType');
 	setTimeout(function() {
 		uni.redirectTo({
-			url: '/pages/login/login',
+			url: '/pages/views/login/login',
 		});
 	}, 2000);
 }

+ 134 - 126
pages/component/topWarn.vue

@@ -1,187 +1,195 @@
 <!-- 顶部警告 -->
 <template>
 	<view class="top-warn" v-if="pageType">
-		<view>{{text}}</view>
-		<view @click="buttonClick" v-if="whetherRoute">查看</view>
+		<view class="text-view">{{text}}</view>
+		<view class="button-view" @click="buttonClick">查看</view>
 	</view>
 </template>
 
 <script>
-    import { selectTriggerInfo,evacuate,closeRiskPlan } from '@/pages/api/index.js'
+	import $mqtt from '@/utils/mqtt.min.js';
+	import {
+		laboratoryBigViewSelectTriggerInfo,
+		laboratoryPlanCloseRiskPlan,
+	} from '@/pages_manage/api/index.js'
 
 	export default {
 		data() {
 			return {
-				pageType:false,
-				text:"",
-				buildId:"",
-				floorId:"",
-				subId:"",
-				closePlan:false,//  true 火焰报警,false 没有火焰报警
-				whetherRoute:true,
-
-				subjectId:"",
-				buildingId:"",
-				subjectName:"",
-				groupId:"",
+				pageType: false,
+				text: "",
+				buildId: "",
+				floorId: "",
+				subId: "",
+				//预案MQTT
+				mtopic: 'lab/risk/plan/change',
+				client: {},
+				planData: {},
 			}
 		},
 		created() {
 
 		},
-		mounted(){
-			this.getWarn();
-			getApp().watch(this.lineDataFunction,'lineData');
+		mounted() {
+			this.offPlanMQTT('on');
+			this.laboratoryBigViewSelectTriggerInfo();
 		},
 		methods: {
-			//应急变更
-			lineDataFunction(val){
-				this.getWarn();
+			//预案-MQTT连接
+			offPlanMQTT(type) {
+				let self = this;
+				if (self.client.unsubscribe) {
+					self.client.unsubscribe(self.mtopic, error => {
+						if (error) {
+							// console.log('mqtt关闭连接错误:', error)
+						}
+					})
+					self.client.end();
+					this.$set(this, 'client', {});
+				}
+				//判断传入参数如果存在 发起一次新的连接
+				if (type) {
+					this.planMQTT();
+				}
 			},
-			buttonClick(){
+			//预案-MQTT订阅
+			planMQTT() {
 				let self = this;
-				let list = [];
-				if(self.closePlan){
-					list = ['查看', '结束预案'];
-				}else{
-					self.goPage();
+				this.client = $mqtt.connect('wxs://' + uni.getStorageSync('mqttUrl'), {
+					username: uni.getStorageSync('mqttUser'),
+					password: uni.getStorageSync('mqttPassword')
+				});
+				this.client.on("connect", e => {
+					this.client.subscribe(this.mtopic, (err) => {
+						if (!err) {
+							console.log("预案订阅成功:" + this.mtopic);
+						} else {
+							// console.log("连接错误:" + err);
+						}
+					});
+				});
+				this.client.on("message", (topic, message) => {
+					console.log('message', message);
+					console.log('topic,', topic);
+					if (message) {
+						if (topic == this.mtopic) {
+							//预案触发
+							console.log('触发预案')
+							this.laboratoryBigViewSelectTriggerInfo();
+						}
+					}
+				});
+			},
+			//获取预案数据
+			async laboratoryBigViewSelectTriggerInfo(type) {
+				let self = this;
+				const {
+					data
+				} = await laboratoryBigViewSelectTriggerInfo();
+				if (data.code == 200) {
+					// console.log('条幅触发',data.data);
+					if (data.data[0]) {
+						// console.log('条幅触发-有');
+						this.$set(this, 'planData', data.data);
+						this.$set(this, 'text', data.data[1] ? '有多个实验室发生预案' : '有实验室发生预案');
+						this.$set(this, 'pageType', true);
+					} else {
+						// console.log('条幅触发-无');
+						this.$set(this, 'pageType', false);
+						this.$set(this, 'planData', []);
+						this.$set(this, 'text', '');
+					}
 				}
+			},
+			//条幅操作按钮
+			buttonClick() {
+				let self = this;
+				let list = [];
+				list = ['查看', '结束预案'];
 				uni.showActionSheet({
 					itemList: list,
-					success: function (res) {
-						if(res.tapIndex == 0){
+					success: function(res) {
+						if (res.tapIndex == 0) {
 							self.goPage();
-						}else if(res.tapIndex == 1){
-							self.offEvacuationClick();
+						} else if (res.tapIndex == 1) {
+							self.closePlan();
 						}
 					},
-					fail: function (res) {
+					fail: function(res) {
 						console.log(res.errMsg);
 					}
 				});
 			},
-			//结束预案
-			offEvacuationClick(){
+			//结束预案弹窗
+			closePlan() {
 				let self = this;
 				uni.showModal({
-					content: '确认结束预案?',
-					cancelColor:"#999",
-					confirmColor:"#0183FA",
-					success: function (res) {
+					content: '传感器数据监测异常,确定要强制结束预案?关闭报警后,3分钟内系统不再触发预案报警,请核实确认后再执行此操作?',
+					cancelColor: "#999",
+					confirmColor: "#0183FA",
+					success: function(res) {
 						if (res.confirm) {
 							self.closeRiskPlan();
 						} else if (res.cancel) {
+
 						}
 					}
 				});
 			},
-			async closeRiskPlan(){
-				const {data} = await closeRiskPlan({id:this.groupId});
-				if(data.code == 200){
+			//结束预案方法
+			async closeRiskPlan() {
+				const {
+					data
+				} = await laboratoryPlanCloseRiskPlan({
+					eventId: this.planData[0].eventId
+				});
+				if (data.code == 200) {
 					uni.showToast({
 						title: '操作成功',
-						icon:"none",
-						mask:true,
+						icon: "none",
+						mask: true,
 						duration: 2000
 					});
-					this.pageType = false;
+					this.laboratoryBigViewSelectTriggerInfo();
 				}
 			},
 			//页面跳转
-			goPage(){
+			goPage() {
 				let obj = {
-				  buildId: this.buildId,
-				  floorId:this.floorId,
-				  subId:this.subId,
-				  groupId:this.groupId,
+					buildId: this.planData[0].buildId,
+					floorId: this.planData[0].floorId,
+					subId: this.planData[0].subId,
+					groupId: this.planData[0].eventId,
 				}
 				uni.navigateTo({
-					url:'/pages_manage/views/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
+					url: '/pages_manage/views/emergencyEvacuationBig?item=' + encodeURIComponent(JSON.stringify(obj))
 				});
 			},
-			//获取报警信息
-			async getWarn(){
-				let self = this;
-				const {data} = await selectTriggerInfo();
-					if(data.data[0]){
-					  this.$set(this,'text',data.data.length>1?'有多个实验室发生预案':'有实验室发生预案');
-					  this.$set(this,'buildId',data.data[0].buildId);
-					  this.$set(this,'floorId',data.data[0].floorId);
-					  this.$set(this,'subId',data.data[0].subId);
-					  if(data.data[0].riskAttribute == 1){
-						this.$set(this,'closePlan',true);
-						this.$set(this,'groupId',data.data[0].groupId);
-					  }
-					  this.$set(this,'pageType',true);
-					 //  for(let i=0;i<data.data.length;i++){
-						// if(data.data[i].riskAttribute == '1'&&data.data[i].ifCheck != '1'){
-						// 	let obj = {
-						// 	  buildId: data.data[i].buildId,
-						// 	  floorId:data.data[i].floorId,
-						// 	  subId:data.data[i].subId,
-						// 	  riskPlanId:data.data[i].riskPlanId,
-						// 	}
-						// 	uni.navigateTo({
-						// 		url:'/pages/views/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
-						// 	});
-						// 	return
-						// }
-					 //  }
-					  //没有火焰预案并且没有查看过
-					  for(let i=0;i<data.data.length;i++){
-						if(data.data[i].riskAttribute != '1'&&data.data[i].ifCheck != '1'){
-							let obj = {
-							  buildId: data.data[i].buildId,
-							  floorId:data.data[i].floorId,
-							  subId:data.data[i].subId,
-							  groupId:data.data[i].groupId,
-							}
-							uni.navigateTo({
-								url:'/pages_manage/views/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
-							});
-							return
-						}
-					  }
-					}else{
-					  this.$set(this,'pageType',false);
-					}
-			},
-			timeFuncontion(){
-				let self = this;
-				var t1 = setInterval(refreshCount, 300);
-				function refreshCount() {
-					let txt = self.text
-					let start = txt.substring(0, 1);//取该字符串的第一个字符
-					let end = txt.substring(1);//取该字符串的从1之后的所有字符
-					let newText = end + start;//拼接新的字符串
-					self.$set(self,'text',newText)
-				}
-			}
 		}
 	}
 </script>
 
 <style lang="stylus" scoped>
-	.top-warn{
-		height:80rpx;
-		line-height:80rpx;
-		background rgba(2550,0,0,0.2)
-		margin:20rpx 0;
+	.top-warn {
+		height: 80rpx;
+		line-height: 80rpx;
+		background rgba(2550, 0, 0, 0.2);
+		margin: 20rpx 0;
 		display flex;
-		overflow hidden
-		view:nth-child(1){
-			padding-left:20rpx;
-			color:#FF0000;
-			flex:1;
-			view{
-				padding-left:20rpx;
-				white-space:nowrap;
-			}
+		overflow hidden;
+
+		.text-view {
+			padding-left: 20rpx;
+			color: #FF0000;
+			flex: 1;
+			padding-left: 20rpx;
+			white-space: nowrap;
 		}
-		view:nth-child(2){
-			width:140rpx;
-			color:#0183FA;
+
+		.button-view {
+			width: 140rpx;
+			color: #0183FA;
 			text-align center;
 		}
 	}
-</style>
+</style>

+ 1 - 0
pages/views/login/login.vue

@@ -184,6 +184,7 @@
 				});
 				if (data.code == 200) {
 					let obj = JSON.parse(data.data.configValue)
+					console.log('obj',obj)
 					//文件预览地址
 					uni.setStorageSync('filePreviewUrl', 'https://' + obj.fileExtranetUrl)
 					//摄像头代理访问地址

+ 179 - 185
pages_manage/views/emergencyEvacuationBig.vue

@@ -47,8 +47,10 @@
 				<!-- 头部 -->
 				<view class="evacuation-title-box">
 					<view class="evacuation-title-left">
-						<view class="evacuation-title-name-box">{{subName}}</view>
-						<view class="site"><img src="@/pages_manage/images/icon_14.png">{{buildingName}} {{floorName}}</view>
+						<view class="evacuation-title-name-box">{{textFiltration(subName)}}</view>
+						<view class="site"><img src="@/pages_manage/images/icon_14.png">{{textFiltration(buildingName)}}
+							{{textFiltration(floorName)}}
+						</view>
 					</view>
 					<view class="evacuation-title-right" @click="backButton()">选择房间</view>
 				</view>
@@ -62,8 +64,9 @@
 						<view class="emergencyEvacuationBigFullScreen-page" v-if="mapType"
 							:style="'width:'+mapWidth+'rpx;height:'+mapHeight+'rpx;transform: scale('+zoomData+');margin-top:-'+mapHeight/2+'rpx;margin-left:-'+mapWidth/2+'rpx;'">
 							<view class="map-max-box" :style="'width:'+mapWidth+'rpx;height:'+mapHeight+'rpx;'">
-								<view class="map-max-for-box for-map-box" v-if="item.type == 1"
-									v-for="(item,index) in mapList" :key="index" :class="!item.policeType && subId ==item.subId ? 'room-type-one':(
+								<!-- 实验室 -->
+								<view class="map-max-for-box for-map-box" v-if="item.type == 1" v-for="(item,index) in mapList"
+									:key="index" :class="!item.policeType && subId ==item.subId ? 'room-type-one':(
 									item.policeType && subId !=item.subId ? 'room-type-two':(
 									item.policeType && subId ==item.subId ? 'room-type-three':(
 									!item.loginAdmin ? 'room-type-noe':'')))"
@@ -80,8 +83,9 @@
 										</view>
 									</view>
 								</view>
-								<view class="map-max-for-box for-map-box-one" v-if="item.type == 2"
-									v-for="(item,index) in mapList" :key="index"
+								<!-- 走廊 -->
+								<view class="map-max-for-box for-map-box-one" v-if="item.type == 2" v-for="(item,index) in mapList"
+									:key="index"
 									:style="'top:'+item.y+'rpx;left:'+item.x+'rpx;width:'+item.w+'rpx;height:'+item.h+'rpx;'">
 									<view class="map-max-for-min-box">
 										<view class="position-box"
@@ -94,9 +98,9 @@
 										</view>
 									</view>
 								</view>
-								<view class="map-max-for-box for-map-box-two" v-if="item.type == 3"
-									v-for="(item,index) in mapList" :key="index"
-									:class="item.roomCheckType?'for-map-box-two-check':''"
+								<!-- 疏散口 -->
+								<view class="map-max-for-box for-map-box-two" v-if="item.type == 3" v-for="(item,index) in mapList"
+									:key="index" :class="item.roomCheckType?'for-map-box-two-check':''"
 									:style="'top:'+item.y+'rpx;left:'+item.x+'rpx;width:'+item.w+'rpx;height:'+item.h+'rpx;'">
 								</view>
 							</view>
@@ -105,10 +109,10 @@
 				</view>
 				<!-- 视频部分 -->
 				<view class="video-max-box" v-if="urlList[0]">
-					<video v-for="(item,index) in urlList" :key="index" ref="videoRef" :src="item.url"
-						:poster="videoCover" :custom-cache='false' :autoplay="true" :controls="true"
-						:enable-danmu="false" :muted="true" :show-fullscreen-btn="true" :show-center-play-btn="false"
-						:show-play-btn="false" @error="videoErrorCallback">
+					<video v-for="(item,index) in urlList" :key="index" ref="videoRef" :src="item.url" :poster="videoCover"
+						:custom-cache='false' :autoplay="true" :controls="true" :enable-danmu="false" :muted="true"
+						:show-fullscreen-btn="true" :show-center-play-btn="false" :show-play-btn="false"
+						@error="videoErrorCallback">
 					</video>
 				</view>
 				<view class="bottom-button-box">
@@ -127,8 +131,7 @@
 					<!-- 按钮部分 -->
 					<view class="trumpet-max-box">
 						<view @click="trumpetClick(index)" class="trumpet-for-box"
-							:class="item.type?'trumpet-color-a':'trumpet-color-b'" v-for="(item,index) in trumpetList"
-							:key="index">
+							:class="item.type?'trumpet-color-a':'trumpet-color-b'" v-for="(item,index) in trumpetList" :key="index">
 							<img src="@/pages_manage/images/icon_sskz_zc.png" v-if="!item.type">
 							<img src="@/pages_manage/images/icon_sskz_xz.png" v-if="item.type">
 							{{item.deviceName}}
@@ -206,50 +209,8 @@
 				floorId: "",
 				//实验室
 				fjListArray: [],
-				//疏散方向
-				buttonArray: [{
-						name: "向左疏散",
-						id: "1"
-					},
-					{
-						name: "向右疏散",
-						id: "2"
-					},
-					{
-						name: "两侧疏散",
-						id: "0"
-					},
-				],
-				buttonArrayIndex: "2",
 				//视频数据
 				urlList: [],
-				//布局数据
-				fjList: [],
-				lightList: [{
-						id: "5",
-						type: false,
-					},
-					{
-						id: "2",
-						type: false,
-					},
-					{
-						id: "3",
-						type: false,
-					},
-					{
-						id: "4",
-						type: false,
-					},
-					{
-						id: "1",
-						type: false,
-					},
-					{
-						id: "6",
-						type: false,
-					},
-				],
 				//接收参数
 				subId: "",
 				subName: "",
@@ -281,17 +242,22 @@
 				mapList: [],
 				mapWidth: null, //40边框距离
 				mapHeight: null, //40边框距离
-				//新MQTT
-				floorClient: {},
-				evacuationTopic: "lab/floor/exit/line", //疏散
-
+				//MQTT请求参数-预案
+				mtopic: "lab/risk/plan/change",
+				//MQTT请求参数-疏散
+				mtopicOne: "lab/floor/exit/line",
+				client: {},
 				groupId: null,
 				planStatus: false,
+				warnData: null,
 			}
 		},
 		onLoad(option) {
+			console.log('option', option);
 			if (option.item) {
 				let obj = JSON.parse(decodeURIComponent(option.item));
+				this.$set(this, 'warnData', obj);
+				console.log('obj', obj);
 				this.$set(this, 'buildingId', obj.buildId);
 				this.$set(this, 'deptId', obj.buildId);
 				this.$set(this, 'floorId', obj.floorId);
@@ -299,23 +265,58 @@
 				this.$set(this.itemData, 'subjectId', obj.subId);
 				this.$set(this, 'groupId', obj.groupId);
 				this.$set(this, 'pageType', 2);
-				this.confirmBtn();
-				this.riskPlanId(obj.groupId);
 			}
 
 		},
 		onShow() {
-			this.laboratoryBigViewGetBuildByBigView();
-			if (this.floorId && this.subId) {
-				this.getBuildingData();
+			if (this.warnData) {
+				this.getDataA();
+			} else {
+				this.laboratoryBigViewGetBuildByBigView();
 			}
 		},
 		onUnload() {},
 		methods: {
+			//跳转进来后的初始化
+			async getDataA() {
+				const {
+					data
+				} = await laboratoryBigViewGetBuildByBigView({
+					type: 2
+				})
+				if(data.code == 200){
+					this.$set(this, 'buildingList', data.data);
+					data.data.forEach((item)=>{
+						if(this.buildingId == item.id){
+							this.$set(this,'buildingName',item.name);
+						}
+					}),
+					this.selectTriggerInfo(1);
+					this.getDataB()
+				}
+			},
+			async getDataB() {
+				const {
+					data
+				} = await laboratoryBigViewGetBuildByBigView({
+					type: 3,
+					id: this.deptId
+				})
+				if (data.code == 200) {
+					this.$set(this, 'floorList', data.data);
+					data.data.forEach((item)=>{
+						if(this.floorId == item.id){
+							this.$set(this,'floorName',item.name);
+						}
+					}),
+					this.selectTriggerInfo(2);
+					this.confirmBtn();
+					this.getBuildingData();
+				}
+			},
 			//返回按钮
 			backButton() {
 				let self = this;
-				this.offMQTT();
 				this.$set(this, 'pageType', 1);
 				this.$set(this, 'urlList', []);
 				this.laboratoryBigViewGetBuildByBigView();
@@ -418,15 +419,6 @@
 				this.$set(this, 'subId', this.fjListArray[e.detail.value].subId);
 				this.$set(this.itemData, 'subjectId', this.fjListArray[e.detail.value].subId);
 			},
-			async riskPlanId(id) {
-				let obj = {
-					groupId: id,
-					ifCheck: 1,
-				};
-				const {
-					data
-				} = await riskPlanId(obj);
-			},
 			shadeTypeClick() {
 				this.broadcastType = !this.broadcastType
 			},
@@ -462,20 +454,40 @@
 					if (type == 3) {
 						//标记实验室
 						for (let o = 0; o < self.fjListArray.length; o++) {
+							let num = 0;
 							for (let i = 0; i < data.data.length; i++) {
 								if (data.data[i].subId == self.fjListArray[o].subId) {
-									console.log('预案')
-									console.log(data.data[i])
-									self.planStatus = true; //如果有预案发生
+									num++
 									self.$set(this, 'groupId', data.data[i].groupId)
 									self.fjListArray[o].subName.replace('(预案发生)')
 									self.fjListArray[o].subName = '(预案发生) ' + self.fjListArray[o].subName
 								}
 							}
+							if (num != 0) {
+								self.planStatus = true; //如果有预案发生
+							} else {
+								self.planStatus = false; //如果有预案发生
+								self.fjListArray[o].subName.replace('(预案发生)')
+							}
+						}
+						for (let o = 0; o < self.mapList.length; o++) {
+							if (self.mapList[o].type == 1) {
+								let num = 0;
+								for (let i = 0; i < data.data.length; i++) {
+									if (data.data[i].subId == self.mapList[o].subId) {
+										num++
+									}
+								}
+								if (num != 0) {
+									self.mapList[o].policeType = true;
+								} else {
+									self.mapList[o].policeType = false;
+								}
+							}
 						}
 					}
+          this.$forceUpdate();
 				}
-				console.log('data.data', data.data);
 			},
 			getAppExitLine() {
 				let list = [{
@@ -864,9 +876,15 @@
 							// }
 						}
 						this.$set(this, 'fjListArray', subList);
+						subList.forEach((item)=>{
+							if(this.subId == item.subId){
+								this.$set(this,'subName',item.subName);
+							}
+						})
 						this.$set(this, 'mapList', JSON.parse(JSON.stringify(list)));
 						// this.$set(this, 'shadeMapList', JSON.parse(JSON.stringify(list)));
 						this.$set(this, 'mapType', true);
+						this.offMQTT('on');
 						this.selectTriggerInfo(3);
 					}
 					setTimeout(function() {
@@ -886,6 +904,7 @@
 				} = await laboratoryExitLineGetRedisEvacuation(obj)
 				if (data.code == 200) {
 					if (data.data.doorPointNames) {
+						this.$set(this, 'isEvacuate', false);
 						for (let o = 0; o < self.mapList.length; o++) {
 							if (self.mapList[o].type == 2) {
 								for (let x = 0; x < self.mapList[o].lightList.length; x++) {
@@ -897,24 +916,31 @@
 											}
 										}
 									}
-									console.log('灯', num)
 									self.mapList[o].lightList[x].openType = num != 0;
 								}
 							}
-						}
-						for (let i = 0; i < data.data.doorPointNames.length; i++) {
-							for (let o = 0; o < self.mapList.length; o++) {
-								if (self.mapList[o].type == 3) {
+							if (self.mapList[o].type == 3) {
+								let age = 0;
+								for (let i = 0; i < data.data.doorPointNames.length; i++) {
 									if (data.data.doorPointNames[i] == self.mapList[o].key) {
-										self.mapList[o].roomCheckType = true;
+										age++
 									}
 								}
+								self.mapList[o].roomCheckType = age != 0;
 							}
 						}
-						this.$set(this, 'isEvacuate', false)
-						this.$forceUpdate();
 					} else {
-						this.$set(this, 'isEvacuate', true)
+						this.$set(this, 'isEvacuate', true);
+						for (let o = 0; o < self.mapList.length; o++) {
+							if (self.mapList[o].type == 2) {
+								for (let x = 0; x < self.mapList[o].lightList.length; x++) {
+									self.mapList[o].lightList[x].openType = false;
+								}
+							}
+							if (self.mapList[o].type == 3) {
+								self.mapList[o].roomCheckType = false;
+							}
+						}
 					}
 				};
 			},
@@ -1051,121 +1077,88 @@
 					});
 				}
 			},
-			/*MQTT*/
-			//订阅
-			onMQTT() {
+			videoErrorCallback(e) {
+				//console.log("播放失败",e);
+				// uni.showToast({
+				//     title: '视频播放失败',
+				//     icon:"none",
+				//     mask:true,
+				//     duration: 3000
+				// });
+			},
+			//过滤'预案发生'标记文字并返回数据
+			textFiltration(str) {
+				if (str.indexOf("(预案发生)") != -1) {
+					return str.slice(str.indexOf(")") + 1);
+				} else {
+					return str
+				}
+			},
+			//MQTT订阅
+			sensorMQTT() {
 				let self = this;
-				const mqttOptions = {
-					keepalive: 30,
-					clean: true, //保留会话
-					connectTimeout: 60000, // 超时时间
-					reconnectPeriod: 5000, // 重连间隔
-					clientId: uni.getStorageSync('token') + 'lab/function/data',
+				this.client = $mqtt.connect('wxs://' + uni.getStorageSync('mqttUrl'), {
 					username: uni.getStorageSync('mqttUser'),
-					password: uni.getStorageSync('mqttPassword'),
-				}
-				const connectUrl = uni.getStorageSync('mqttUrl');
-				self.floorClient = $mqtt.connect('wxs://' + connectUrl, mqttOptions);
-				self.floorClient.on('connect', () => {
-					self.floorClient.subscribe(self.evacuationTopic + self.floorId, (err) => {
+					password: uni.getStorageSync('mqttPassword')
+				});
+				this.client.on("connect", e => {
+					this.client.subscribe(this.mtopic, (err) => {
 						if (!err) {
-							console.log("疏散-订阅成功", )
-							self.getBuildingData();
+							console.log("预案订阅成功:" + this.mtopic);
+						} else {
+							// console.log("连接错误:" + err);
+						}
+					});
+					this.client.subscribe(this.mtopicOne, (err) => {
+						if (!err) {
+							console.log("疏散订阅成功:" + this.mtopicOne);
+						} else {
+							// console.log("连接错误:" + err);
 						}
 					});
-
-				});
-				// 自动重连
-				this.floorClient.on('reconnect', (msg) => {
-					console.log('自动重连-reconnect-1', msg)
-				});
-				// 错误
-				this.floorClient.on('error', () => {
-					console.log('错误-error-1')
-				});
-				// 断开
-				this.floorClient.on('end', () => {
-					console.log('断开-end-1')
-				});
-				// 掉线
-				this.floorClient.on('offline', (msg) => {
-					console.log('掉线-offline-1', msg)
 				});
-				// 收到消息
-				this.floorClient.on('message', (topic, message) => {
-					let data = JSON.parse(message)
-					console.log('设备状态' + data)
-					if (data) {
-						if (topic == (this.evacuationTopic + this.floorId)) {
-							console.log('疏散通知', data)
-							let pages = getCurrentPages();
-							let currPage = pages[pages.length - 1]
-
-							console.log('pages', pages)
-							// let currPage = pages[pages.length - 1] //当前页面
-							// let prePage = pages[pages.length - 2] //上一个页面
-							// prePage.$vm.aaa()
-							//疏散消息
-							if (data.data == 'FLOOR_EXITLINE') {
-								this.getRedisEvacuation();
-								if (currPage.route == 'pages_manage/emergencyEvacuationBigFullScreen') {
-									currPage.$vm.mqttPageFunction('FLOOR_EXITLINE')
-								}
-							} else if (data.data == 'FLOOR_OVER_EXITLINE') {
-								if (currPage.route == 'pages_manage/emergencyEvacuationBigFullScreen') {
-									currPage.$vm.mqttPageFunction('FLOOR_OVER_EXITLINE')
-								}
-								uni.showToast({
-									title: '疏散已结束',
-									icon: "none",
-									mask: true,
-									duration: 2000
-								});
-								setTimeout(function() {
-									self.getBuildingData();
-								}, 2000);
-							}
-						} else if (topic == (self.fireTopic + self.fireCode)) {
-							//传感器状态
-							console.log('传感器状态');
+				this.client.on("message", (topic, message) => {
+					console.log('message', message);
+					console.log('topic,', topic);
+					if (message) {
+						if (topic == this.mtopic) {
+							//预案触发
+							this.selectTriggerInfo(3);
+						} else if (topic == this.mtopicOne) {
+							//疏散触发
+							this.getRedisEvacuation();
 						}
 					}
 				});
-				// 全局监听是否有关闭mqtt的消息的事件
-				uni.$on('closeMqtt', () => {
-					this.floorClient.end(true); // 主动断开连接
-				})
 			},
-			//关闭MQTT连接
+			//取消订阅关闭MQTT连接
 			offMQTT(type) {
 				let self = this;
-				if (this.floorClient.unsubscribe) {
-					this.floorClient.unsubscribe(this.evacuationTopic + this.floorId, error => {
+				if (self.client.unsubscribe) {
+					self.client.unsubscribe(self.mtopicOne, error => {
 						if (error) {
-							console.log('疏散连接-关闭错误', error)
+							// console.log('mqtt关闭连接错误:', error)
 						}
-					});
-
-					this.floorClient.end(true);
-					this.$set(this, 'floorClient', {});
+					})
+					self.client.unsubscribe(self.mtopic, error => {
+						if (error) {
+							// console.log('mqtt关闭连接错误:', error)
+						}
+					})
+					self.client.end();
+					this.$set(this, 'client', {});
 				}
+				//判断传入参数如果存在 发起一次新的连接
 				if (type) {
-					this.onMQTT();
+					this.sensorMQTT();
 				}
 			},
-			videoErrorCallback(e) {
-				//console.log("播放失败",e);
-				// uni.showToast({
-				//     title: '视频播放失败',
-				//     icon:"none",
-				//     mask:true,
-				//     duration: 3000
-				// });
-			},
 		},
 		beforeDestroy() {
-			this.offMQTT();
-		}
+			//清除定时器
+			let self = this;
+			self.offMQTT();
+		},
 	}
 </script>
 
@@ -1830,6 +1823,7 @@
 							font-weight: 500;
 							line-height: 170rpx;
 							text-align: center;
+
 							>img {
 								width: 142rpx;
 								height: 142rpx;
@@ -1913,4 +1907,4 @@
 			border-radius: 20rpx;
 		}
 	}
-</style>
+</style>

+ 63 - 88
pages_manage/views/emergencyEvacuationBigFullScreen.vue

@@ -4,8 +4,8 @@
 			:style="'width:'+mapWidth+'px;height:'+mapHeight+'px;transform: scale('+zoomData+');margin-top:-'+mapHeight/2+'px;margin-left:-'+mapWidth/2+'px;'">
 			<view class="map-max-box" :style="'width:'+mapWidth+'px;height:'+mapHeight+'px;'">
 				<!-- :style="'width:'+mapW+'px;height:'+mapH+'px;'" -->
-				<view class="map-max-for-box for-map-box" v-if="item.type == 1" v-for="(item,index) in mapList"
-					:key="index" :class="!item.policeType && checkSubId ==item.subId ? 'room-type-one':(
+				<view class="map-max-for-box for-map-box" v-if="item.type == 1" v-for="(item,index) in mapList" :key="index"
+					:class="!item.policeType && checkSubId ==item.subId ? 'room-type-one':(
                            item.policeType && checkSubId !=item.subId ? 'room-type-two':(
                            item.policeType && checkSubId ==item.subId ? 'room-type-three':(
                            !item.loginAdmin ? 'room-type-noe':''
@@ -22,15 +22,15 @@
 						</view>
 					</view>
 				</view>
-				<view class="map-max-for-box for-map-box-one" v-if="item.type == 2" v-for="(item,index) in mapList"
-					:key="index" :style="'top:'+item.y+'px;left:'+item.x+'px;width:'+item.w+'px;height:'+item.h+'px;'">
+				<view class="map-max-for-box for-map-box-one" v-if="item.type == 2" v-for="(item,index) in mapList" :key="index"
+					:style="'top:'+item.y+'px;left:'+item.x+'px;width:'+item.w+'px;height:'+item.h+'px;'">
 					<view class="map-max-for-min-box">
 						<view class="position-box" @click="lighButton(minItem)"
 							:class="minItem.state=='1'&&minItem.openType?'lightTopOn':(minItem.state=='1'&&!minItem.openType?'lightTopOff':
 									(minItem.state=='2'&&minItem.openType?'lightBottomOn':(minItem.state=='2'&&!minItem.openType?'lightBottomOff':
 									(minItem.state=='3'&&minItem.openType?'lightLeftOn':(minItem.state=='3'&&!minItem.openType?'lightLeftOff':
-									(minItem.state=='4'&&minItem.openType?'lightRightOn':(minItem.state=='4'&&!minItem.openType?'lightRightOff':'')))))))"
-							v-for="(minItem,minIndex) in item.lightList" :key="minIndex"
+									(minItem.state=='4'&&minItem.openType?'lightRightOn':(minItem.state=='4'&&!minItem.openType?'lightRightOff':'')))))))" v-for="(minItem,minIndex) in item.lightList"
+							:key="minIndex"
 							:style="'top:'+minItem.y+'px;left:'+minItem.x+'px;width:'+minItem.w+'px;height:'+minItem.h+'px;'">
 						</view>
 					</view>
@@ -42,7 +42,7 @@
 			</view>
 		</view>
 		<view class="position-button" @click="backButton">退出全屏</view>
-		<view class="position-button-two" @click="executeEvacuation">已确定疏散出口,立即执行疏散</view>
+		<view class="position-button-two" @click="executeEvacuation" v-if="isEvacuate">已确定疏散出口,立即执行疏散</view>
 	</view>
 </template>
 
@@ -82,11 +82,12 @@
 				mapHeight: null, //40边框距离
 				//弹层地图数据
 				buildingOptions: {},
-				//mqtt
-				floorClient: {},
-				evacuationTopic: "lab/floor/exit/line", //疏散
+				//MQTT请求参数-疏散
+				mtopicOne: "lab/floor/exit/line",
+				client: {},
 				//疏散按钮
-				buttonType: false
+				buttonType: false,
+				isEvacuate:false,
 			}
 		},
 		onLoad(option) {
@@ -219,6 +220,7 @@
 						}
 						this.$set(this, 'mapList', JSON.parse(JSON.stringify(list)));
 						this.$set(this, 'mapType', true);
+						this.offMQTT('on');
 						setTimeout(function() {
 							self.getRedisEvacuation();
 						}, 500);
@@ -238,6 +240,7 @@
 				} = await laboratoryExitLineGetRedisEvacuation(obj)
 				if (data.code == 200) {
 					if (data.data.doorPointNames) {
+						this.$set(this, 'isEvacuate', false);
 						for (let o = 0; o < self.mapList.length; o++) {
 							if (self.mapList[o].type == 2) {
 								for (let x = 0; x < self.mapList[o].lightList.length; x++) {
@@ -252,17 +255,28 @@
 									self.mapList[o].lightList[x].openType = num != 0;
 								}
 							}
-						}
-						for (let i = 0; i < data.data.doorPointNames.length; i++) {
-							for (let o = 0; o < self.mapList.length; o++) {
-								if (self.mapList[o].type == 3) {
+							if (self.mapList[o].type == 3) {
+								let age = 0;
+								for (let i = 0; i < data.data.doorPointNames.length; i++) {
 									if (data.data.doorPointNames[i] == self.mapList[o].key) {
-										self.mapList[o].roomCheckType = true;
+										age++
 									}
 								}
+								self.mapList[o].roomCheckType = age != 0;
+							}
+						}
+					} else {
+						this.$set(this, 'isEvacuate', true);
+						for (let o = 0; o < self.mapList.length; o++) {
+							if (self.mapList[o].type == 2) {
+								for (let x = 0; x < self.mapList[o].lightList.length; x++) {
+									self.mapList[o].lightList[x].openType = false;
+								}
+							}
+							if (self.mapList[o].type == 3) {
+								self.mapList[o].roomCheckType = false;
 							}
 						}
-						this.$forceUpdate();
 					}
 				};
 			},
@@ -354,13 +368,13 @@
 				this.$set(this, 'mapHeight', maxHeight);
 				let zoomNumOne = height / maxHeight;
 				if (parseInt(this.accMul(zoomNumOne, maxHeight)) <= height && parseInt(this.accMul(zoomNumOne,
-					maxWidth)) <= width) {
+						maxWidth)) <= width) {
 					zoomData = zoomNumOne;
 					this.$set(this, 'zoomData', zoomNumOne);
 				}
 				let zoomNumTwo = width / maxWidth;
 				if (parseInt(this.accMul(zoomNumTwo, maxHeight)) <= height && parseInt(this.accMul(zoomNumTwo,
-					maxWidth)) <= width) {
+						maxWidth)) <= width) {
 					zoomData = zoomNumTwo;
 					this.$set(this, 'zoomData', zoomNumTwo);
 				}
@@ -377,93 +391,54 @@
 				} catch (e) {}
 				return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
 			},
-			/*MQTT*/
-			//订阅
-			onMQTT() {
+			//MQTT订阅
+			sensorMQTT() {
 				let self = this;
-				const mqttOptions = {
-					keepalive: 30,
-					clean: true, //保留会话
-					connectTimeout: 600000, // 超时时间
-					reconnectPeriod: 5000, // 重连间隔
-					clientId: uni.getStorageSync('token') + 'lab/function/data',
+				this.client = $mqtt.connect('wxs://' + uni.getStorageSync('mqttUrl'), {
 					username: uni.getStorageSync('mqttUser'),
-					password: uni.getStorageSync('mqttPassword'),
-				}
-				const connectUrl = uni.getStorageSync('mqttUrl');
-				this.floorClient = $mqtt.connect('wxs://' + connectUrl, mqttOptions);
-				this.floorClient.on('connect', () => {
-					this.floorClient.subscribe(this.evacuationTopic + this.floorId, (err) => {
+					password: uni.getStorageSync('mqttPassword')
+				});
+				this.client.on("connect", e => {
+					this.client.subscribe(this.mtopicOne, (err) => {
 						if (!err) {
-							console.log("疏散-订阅成功", )
-							this.getBuildingData();
+							console.log("疏散订阅成功:" + this.mtopicOne);
+						} else {
+							// console.log("连接错误:" + err);
 						}
 					});
 				});
-				// 自动重连
-				this.floorClient.on('reconnect', (msg) => {
-					console.log('自动重连-reconnect-1', msg)
-				});
-				// 错误
-				this.floorClient.on('error', () => {
-					console.log('错误-error-1')
-				});
-				// 断开
-				this.floorClient.on('end', () => {
-					console.log('断开-end-1')
-				});
-				// 掉线
-				this.floorClient.on('offline', (msg) => {
-					console.log('掉线-offline-1', msg)
-				});
-				// 收到消息
-				this.floorClient.on('message', (topic, message) => {
-					let data = JSON.parse(message)
-					if (data) {
-						if (topic == (this.evacuationTopic + this.floorId)) {
-							console.log('疏散通知', data)
-							//疏散消息
-							if (data.data == 'FLOOR_EXITLINE') {
-								this.getRedisEvacuation();
-							} else if (data.data == 'FLOOR_OVER_EXITLINE') {
-								uni.showToast({
-									title: '疏散已结束',
-									icon: "none",
-									mask: true,
-									duration: 2000
-								});
-								setTimeout(function() {
-									self.getBuildingData();
-								}, 2000);
-							}
+				this.client.on("message", (topic, message) => {
+					if (message) {
+						if (topic == this.mtopicOne) {
+							//疏散触发
+							this.getRedisEvacuation();
 						}
 					}
 				});
-				// 全局监听是否有关闭mqtt的消息的事件
-				uni.$on('closeMqtt', () => {
-					this.floorClient.end(true); // 主动断开连接
-				})
 			},
-			//关闭MQTT连接
+			//取消订阅关闭MQTT连接
 			offMQTT(type) {
-				if (this.floorClient.unsubscribe) {
-					this.floorClient.unsubscribe(this.evacuationTopic + this.floorId, error => {
+				let self = this;
+				if (self.client.unsubscribe) {
+					self.client.unsubscribe(self.mtopicOne, error => {
 						if (error) {
-							console.log('疏散连接-关闭错误', error)
+							// console.log('mqtt关闭连接错误:', error)
 						}
-					});
-					this.floorClient.end(true);
-					this.$set(this, 'floorClient', {});
+					})
+					self.client.end();
+					this.$set(this, 'client', {});
 				}
+				//判断传入参数如果存在 发起一次新的连接
 				if (type) {
-					this.onMQTT();
+					this.sensorMQTT();
 				}
 			},
 		},
 		beforeDestroy() {
-			//断开mqtt连接
-			this.offMQTT();
-		}
+			//清除定时器
+			let self = this;
+			self.offMQTT();
+		},
 	}
 </script>
 
@@ -652,4 +627,4 @@
 			border: none;
 		}
 	}
-</style>
+</style>

+ 6 - 4
pages_manage/views/laboratory/iotControl.vue

@@ -8,7 +8,7 @@
 			</view>
 		</view>
 		<!-- 传感器监测 -->
-		<view class="small-title">
+		<view class="small-title" v-if="sensorData[0]">
 			<view></view>
 			<view>传感器监测</view>
 		</view>
@@ -19,7 +19,7 @@
 			</view>
 		</view>
 		<!-- 智能控制 -->
-		<view class="small-title">
+		<view class="small-title" v-if="labHardwareVOList[0]">
 			<view></view>
 			<view>智能控制</view>
 		</view>
@@ -36,7 +36,7 @@
 			</view>
 		</view>
 		<!-- 智能终端 -->
-		<view class="small-title">
+		<view class="small-title" v-if="terminalData[0]">
 			<view></view>
 			<view>智能终端</view>
 		</view>
@@ -180,7 +180,7 @@
 				const {
 					data
 				} = await iotAppHardwareFindByType({
-					subId: this.subId
+					subjectId: this.subId
 				});
 				if (data.code == 200) {
 					this.$set(this, 'labHardwareVOList', data.data);
@@ -229,6 +229,8 @@
 					});
 				});
 				this.client.on("message", (topic, message) => {
+							console.log('message',message);
+							console.log('topic,',topic);
 					if (message) {
 						if (topic == this.mtopic + this.subId) {
 							//传感器

+ 17 - 8
pages_manage/views/laboratory/meLaboratory.vue

@@ -93,19 +93,19 @@
 			}
 		},
 		onLoad() {
-
-		},
-		onShow() {
 			this.systemDeptDropList();
 			this.laboratoryClassTypeGetList();
 			this.laboratoryClassLevelGetList();
 			this.getList()
 		},
+		onShow() {
+		},
 		methods: {
 			//选择学院
 			facultyChange: function(e) {
 				if (this.facultyArray[0]) {
 					this.facultyIndex = parseInt(e.target.value);
+					this.$set(this.queryParams,'page',1);
 					this.getList();
 				}
 			},
@@ -113,6 +113,7 @@
 			subjectChange: function(e) {
 				if (this.subjectArray[0]) {
 					this.subjectIndex = parseInt(e.target.value);
+					this.$set(this.queryParams,'page',1);
 					this.getList();
 				}
 			},
@@ -120,6 +121,7 @@
 			levelChange: function(e) {
 				if (this.levelArray[0]) {
 					this.levelIndex = parseInt(e.target.value);
+					this.$set(this.queryParams,'page',1);
 					this.getList();
 				}
 			},
@@ -207,10 +209,18 @@
 					data
 				} = await laboratoryAppletSubList(obj);
 				if (data.code == 200) {
-					this.dataList = [...this.dataList, ...data.data.records]
-					this.total = data.data.total;
-					if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
-						this.$set(this, 'getDataType', true);
+					if(self.queryParams.page == 1){
+						this.dataList = data.data.records;
+						this.total = data.data.total;
+						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
+							this.$set(this, 'getDataType', true);
+						}
+					}else{
+						this.dataList = [...this.dataList, ...data.data.records]
+						this.total = data.data.total;
+						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
+							this.$set(this, 'getDataType', true);
+						}
 					}
 				}
 			},
@@ -219,7 +229,6 @@
 				if (type == 'subDetail') {
 					//实验室详情
 					this.laboratoryAppletGetSubDetailInfo(row.infoId)
-
 				}
 			},
 			//获取实验室详情