1
0
forked from dyf/APP

102主从机告警

This commit is contained in:
liub
2025-11-21 16:22:35 +08:00
parent 864dd59b4c
commit 1558045882

View File

@ -46,11 +46,10 @@
</view> -->
</view>
<view class="warnnig" :class="(formData.sta_Intrusion===1)?'':'displayNone'"
>
<view class="warnnig" :class="{'displayNone':formData.sta_sosadd===''}">
<view>闯入报警</view>
<view class="netContent">
{{formData.sta_IntrusTime}}s
{{getWarDevice(formData.sta_sosadd)}}
</view>
</view>
@ -66,13 +65,6 @@
</view>
<view class="lamp">
<view class="title">
<text>警示灯</text>
@ -267,7 +259,7 @@
sta_RadarType: '',
sta_Online: '',
warnTime: '',
sta_Intrusion: 0,
sta_sosadd: "",
sta_IntrusTime: ''
},
@ -356,7 +348,7 @@
detailPageUrl: "/pages/650/HBY650",
showConfirm: false
},
groupDevices: [],
audioData: {
packetCtn: 0,
hexs: []
@ -421,8 +413,8 @@
ble.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(res => {
these.formData.bleStatu = true;
});
these.formData.sta_IntrusTime=0;
these.formData.sta_Intrusion=0;
these.formData.sta_IntrusTime = 0;
these.formData.sta_sosadd = "";
these.setBleFormData();
@ -744,8 +736,21 @@
urls: [img]
})
},
getWarDevice(macStr){//获取正在报警的设备名
let f = this.groupDevices.find(v => {
return v.deviceMac === macStr;
});
if (f) {
return f.deviceName;
}
bleValueNotify: function(receive, device, path, recArr) { //订阅消息
if(macStr == this.device.deviceMac) {
return this.device.deviceName;
}
return '';
},
bleValueNotify(receive, device, path, recArr) { //订阅消息
if (receive.deviceId !== this.formData.deviceId) {
return;
}
@ -755,14 +760,14 @@
let json = recei.ReceiveData(receive, device, pagePath, recArr);
console.log("json=",json)
console.log("json=", json)
let keys = Object.keys(json);
keys.forEach(key => {
if (key in this.formData) {
// console.log("key=",key+",value=",json[key]);
this.formData[key] = json[key] ;
// console.log("key=",key+",value=",json[key]);
this.formData[key] = json[key];
}
});
let msg = [];
@ -770,29 +775,91 @@
msg.push("设备电量低");
}
if (this.formData.sta_Intrusion === 1) {
msg.push("闯入报警中");
if (this.formData.sta_sosadd !== "") {
this.searchDevice(this.formData.sta_sosadd).catch(ex => {}).then(dev => {
if (dev) {
msg.push('"' + dev.deviceName + '"闯入报警中');
} else {
msg.push('闯入报警中');
}
this.showMsg(msg.join(','));
});
return;
// clearInterval(instrusionTime);
// instrusionTime = 0;
// setInterval(() => {
// instrusionTime++;
// if(instrusionTime>60){
// this.formData.sta_sosadd="";
// clearInterval(instrusionTime);
// return;
// }
// this.formData.sta_IntrusTime=instrusionTime;
// }, 1000);
} else {
clearInterval(instrusionTime);
instrusionTime = 0;
setInterval(() => {
instrusionTime++;
if(instrusionTime>60){
this.formData.sta_Intrusion=0;
clearInterval(instrusionTime);
return;
}
this.formData.sta_IntrusTime=instrusionTime;
}, 1000);
}else{
clearInterval(instrusionTime);
instrusionTime=0;
this.formData.sta_IntrusTime=0;
this.formData.sta_IntrusTime = 0;
}
if (msg.length > 0) {
this.showMsg(msg.join(','));
}
},
searchDevice(macStr) {
return new Promise((resolve, reject) => {
if (macStr.includes(':')) {
macStr = macStr;
} else {
macStr = macStr.replace(/(.{2})/g, '$1:').slice(0, -1)
}
let f = this.groupDevices.find(v => {
return v.deviceMac === macStr;
});
if (f) {
resolve(f);
return;
}
if (macStr == this.device.deviceMac) {
resolve(this.device);
return;
}
request({
url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET',
data: {
deviceMac: these.device.macAddress
}
}).then(res => {
console.log("获取设备信息", res);
if (res && res.code == 200) {
console.log("res=", res);
let data = res.data;
if (data) {
this.groupDevices.push({
deviceMac: data.deviceMac,
deviceName: data.deviceName
})
resolve(data);
return;
}
}
resolve(null);
}).catch(ex => {
resolve(null);
});
});
},
getDevice: function() {