修复6155/7305全局订阅与详情订阅重复弹窗

This commit is contained in:
liub
2025-10-24 10:56:37 +08:00
parent 0033649677
commit 45328120c1

View File

@ -9,20 +9,6 @@ class BleReceive {
};
}
getCurrentPagePath() {
const pages = getCurrentPages();
if (pages.length === 0) {
console.log("pages.length=0");
return "";
}
const currentPage = pages[pages.length - 1];
console.log("currentPage=", currentPage.route);
return currentPage.route;
}
setBleFormData(data, f) {
if (data) {
@ -54,7 +40,17 @@ class BleReceive {
ReceiveData(receive, f, path, recArr) {
if (f && f.macAddress && f.device && f.device.id) {
let handler = this.HandlerMap[f.device.detailPageUrl];
let handler = null;
let keys = Object.keys(this.HandlerMap);
for (let index = 0; index < keys.length; index++) {
let key = keys[index].replaceAll('/', '').toLowerCase();
let devKey = f.device.detailPageUrl ? f.device.detailPageUrl.replaceAll('/', '').toLowerCase() : '';
if (key == devKey) {
handler = this.HandlerMap[keys[index]];
break;
}
}
if (handler) {
let data = handler(receive, f, path, recArr);
return data;
@ -151,10 +147,13 @@ class BleReceive {
formData.iswarn = iswarn;
this.setBleFormData(formData, f);
let route=this.getCurrentPagePath();
console.log("f=",f);
console.log("route="+route);
if (iswarn && f.detailPageUrl.indexOf(route)==-1 ) {
let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase();
});
if (!recCnt) {
if (iswarn) {
uni.showModal({
content: "环境存在漏电电源",
title: "警告",
@ -179,8 +178,7 @@ class BleReceive {
}
}
})
}else{
console.log("当前全局不处理此消息");
}
}
return formData;
} catch (error) {
@ -198,9 +196,10 @@ class BleReceive {
formData.macAddress = str.split(':')[1];
this.setBleFormData(formData, f);
return formData;
}
else{
let receiveData={a:1};
} else {
let receiveData = {
a: 1
};
try {
let json = JSON.parse(str);
@ -208,25 +207,21 @@ class BleReceive {
//重发图片
console.log("收到重新发送图片的命令");
receiveData = json;
}
else if("staBlue_text" in json){
} else if ("staBlue_text" in json) {
//重发文本
console.log("收到重新发送文本的命令");
receiveData = json;
}
else if("staBlue_vidio" in json){
} else if ("staBlue_vidio" in json) {
//重发视频
console.log("收到重新发送视频的命令");
receiveData = json;
}
else if("staBlue" in json){
} else if ("staBlue" in json) {
if (json.staBlue == "finish") {
console.log("收到设备回复,全部传输完成");
receiveData = json;
}
}
else{
} else {
receiveData = {};
console.log("无法解析该文本");
}
@ -281,7 +276,8 @@ class BleReceive {
// console.log("todo");
// 解析照明档位
let lightingLevelByte = bytes[2];
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight': lightingLevelByte === 0x6e ? 'low': 'close';
let lightingLevelText = lightingLevelByte === 0x6d ? 'hight' : lightingLevelByte === 0x6e ?
'low' : 'close';
// 解析剩余照明时间(第三和第四字节,小端序)
let lightingTime = (bytes[3] << 8) | bytes[4];
@ -320,7 +316,8 @@ class BleReceive {
this.setBleFormData(receiveData, f);
console.log("recArr=", recArr);
let recCnt = recArr.find(v => {
return v.key == f.device.detailPageUrl;
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
.replaceAll('/', '').toLowerCase();
});
if (!recCnt) {
if (this.formData.staticWarn) { //有静止报警
@ -364,25 +361,21 @@ class BleReceive {
//重发图片
console.log("收到重新发送图片的命令");
receiveData = json;
}
else if("staBlue_text" in json){
} else if ("staBlue_text" in json) {
//重发文本
console.log("收到重新发送文本的命令");
receiveData = json;
}
else if("staBlue_vidio" in json){
} else if ("staBlue_vidio" in json) {
//重发视频
console.log("收到重新发送视频的命令");
receiveData = json;
}
else if("staBlue" in json){
} else if ("staBlue" in json) {
if (json.staBlue == "finish") {
console.log("收到设备回复,全部传输完成");
receiveData = json;
}
}
else{
} else {
receiveData = {};
console.log("无法解析该文本");
}
@ -409,6 +402,7 @@ class BleReceive {
return data;
}
Receive_6155(receive, f, path, recArr) {
let bytes = receive.bytes;
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
@ -467,17 +461,29 @@ class BleReceive {
let formData = {};
formData.mode = staticLevelText;
formData.fuMode = lightingLevelText;
formData.battary = batteryLevel;
formData.battary = 20; // batteryLevel;
formData.statu = warn;
formData.xuhang = lightingTime;
batteryLevel = 20;
console.log("recArr=", recArr);
let recCnt = recArr.find(v => {
return v.key.replaceAll('/', '').toLowerCase() === f.device.detailPageUrl.replaceAll(
'/', '').toLowerCase();
});
if (!recCnt) {
if (batteryLevel <= 20) {
uni.showModal({
content: "设备电量低",
title: "提示"
});
}
}
this.setBleFormData(formData, f);
return formData;
} catch (error) {