修复6155/7305全局订阅与详情订阅重复弹窗
This commit is contained in:
@ -9,42 +9,28 @@ class BleReceive {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentPagePath() {
|
|
||||||
|
|
||||||
const pages = getCurrentPages();
|
setBleFormData(data, f) {
|
||||||
|
if (data) {
|
||||||
if (pages.length === 0) {
|
let linkedList = uni.getStorageSync(this.StorageKey);
|
||||||
console.log("pages.length=0");
|
if (!linkedList) {
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentPage = pages[pages.length - 1];
|
|
||||||
console.log("currentPage=", currentPage.route);
|
|
||||||
return currentPage.route;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
setBleFormData(data,f) {
|
|
||||||
if(data){
|
|
||||||
let linkedList=uni.getStorageSync(this.StorageKey);
|
|
||||||
if(!linkedList){
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
linkedList.find((v)=>{
|
linkedList.find((v) => {
|
||||||
if(f.deviceId==v.deviceId){
|
if (f.deviceId == v.deviceId) {
|
||||||
let keys=Object.keys(data);
|
let keys = Object.keys(data);
|
||||||
keys.forEach((key)=>{
|
keys.forEach((key) => {
|
||||||
if(!v.formData){
|
if (!v.formData) {
|
||||||
v.formData={};
|
v.formData = {};
|
||||||
}
|
}
|
||||||
if(!f.formData){
|
if (!f.formData) {
|
||||||
f.formData={};
|
f.formData = {};
|
||||||
}
|
}
|
||||||
v.formData[key]=data[key];
|
v.formData[key] = data[key];
|
||||||
f.formData[key]=data[key];
|
f.formData[key] = data[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
uni.setStorageSync(this.StorageKey,linkedList);
|
uni.setStorageSync(this.StorageKey, linkedList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -52,26 +38,36 @@ class BleReceive {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReceiveData(receive,f,path,recArr) {
|
ReceiveData(receive, f, path, recArr) {
|
||||||
if(f && f.macAddress && f.device && f.device.id){
|
if (f && f.macAddress && f.device && f.device.id) {
|
||||||
let handler = this.HandlerMap[f.device.detailPageUrl];
|
let handler = null;
|
||||||
if(handler){
|
let keys = Object.keys(this.HandlerMap);
|
||||||
let data=handler(receive, f, path, recArr);
|
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;
|
return data;
|
||||||
}else{
|
} else {
|
||||||
console.log("已收到消息,但无指定处理程序",receive);
|
console.log("已收到消息,但无指定处理程序", receive);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
console.log("已收到该消息,但无法处理",receive);
|
console.log("已收到该消息,但无法处理", receive);
|
||||||
}
|
}
|
||||||
|
|
||||||
return receive;
|
return receive;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_650(receive,f,path,recArr) {
|
Receive_650(receive, f, path, recArr) {
|
||||||
console.log("通用程序正在处理650的数据",receive);
|
console.log("通用程序正在处理650的数据", receive);
|
||||||
|
|
||||||
var parseData = () => {
|
var parseData = () => {
|
||||||
let bytes = receive.bytes;
|
let bytes = receive.bytes;
|
||||||
@ -142,26 +138,29 @@ class BleReceive {
|
|||||||
warn = '非常强预警';
|
warn = '非常强预警';
|
||||||
}
|
}
|
||||||
|
|
||||||
let formData={};
|
let formData = {};
|
||||||
formData.battary = batteryLevel;
|
formData.battary = batteryLevel;
|
||||||
formData.xuhang = xuhang;
|
formData.xuhang = xuhang;
|
||||||
formData.cMode = lightingLevelByte === 0x6e;
|
formData.cMode = lightingLevelByte === 0x6e;
|
||||||
formData.modeCurr = modeCurr;
|
formData.modeCurr = modeCurr;
|
||||||
formData.warnLevel = warn;
|
formData.warnLevel = warn;
|
||||||
formData.iswarn = iswarn;
|
formData.iswarn = iswarn;
|
||||||
this.setBleFormData(formData,f);
|
this.setBleFormData(formData, f);
|
||||||
|
|
||||||
let route=this.getCurrentPagePath();
|
let recCnt = recArr.find(v => {
|
||||||
console.log("f=",f);
|
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
|
||||||
console.log("route="+route);
|
.replaceAll('/', '').toLowerCase();
|
||||||
if (iswarn && f.detailPageUrl.indexOf(route)==-1 ) {
|
});
|
||||||
|
if (!recCnt) {
|
||||||
|
|
||||||
|
if (iswarn) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
content:"环境存在漏电电源",
|
content: "环境存在漏电电源",
|
||||||
title:"警告",
|
title: "警告",
|
||||||
success(res){
|
success(res) {
|
||||||
if(res.confirm){
|
if (res.confirm) {
|
||||||
|
|
||||||
if(f){
|
if (f) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: f.detailPageUrl,
|
url: f.detailPageUrl,
|
||||||
events: {
|
events: {
|
||||||
@ -179,8 +178,7 @@ class BleReceive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else{
|
}
|
||||||
console.log("当前全局不处理此消息");
|
|
||||||
}
|
}
|
||||||
return formData;
|
return formData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -194,47 +192,44 @@ class BleReceive {
|
|||||||
let str = receive.str;
|
let str = receive.str;
|
||||||
|
|
||||||
if (str.indexOf('mac address:') == 0) {
|
if (str.indexOf('mac address:') == 0) {
|
||||||
let formData={};
|
let formData = {};
|
||||||
formData.macAddress = str.split(':')[1];
|
formData.macAddress = str.split(':')[1];
|
||||||
this.setBleFormData(formData,f);
|
this.setBleFormData(formData, f);
|
||||||
return formData;
|
return formData;
|
||||||
}
|
} else {
|
||||||
else{
|
let receiveData = {
|
||||||
let receiveData={a:1};
|
a: 1
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
let json=JSON.parse(str);
|
let json = JSON.parse(str);
|
||||||
|
|
||||||
if("staBlue_picture" in json){
|
if ("staBlue_picture" in json) {
|
||||||
//重发图片
|
//重发图片
|
||||||
console.log("收到重新发送图片的命令");
|
console.log("收到重新发送图片的命令");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_text" in json) {
|
||||||
else if("staBlue_text" in json){
|
|
||||||
//重发文本
|
//重发文本
|
||||||
console.log("收到重新发送文本的命令");
|
console.log("收到重新发送文本的命令");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_vidio" in json) {
|
||||||
else if("staBlue_vidio" in json){
|
|
||||||
//重发视频
|
//重发视频
|
||||||
console.log("收到重新发送视频的命令");
|
console.log("收到重新发送视频的命令");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue" in json) {
|
||||||
else if("staBlue" in json){
|
if (json.staBlue == "finish") {
|
||||||
if(json.staBlue=="finish"){
|
|
||||||
console.log("收到设备回复,全部传输完成");
|
console.log("收到设备回复,全部传输完成");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
receiveData = {};
|
||||||
receiveData={};
|
|
||||||
console.log("无法解析该文本");
|
console.log("无法解析该文本");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData={};
|
receiveData = {};
|
||||||
console.log("文本解析失败")
|
console.log("文本解析失败")
|
||||||
}
|
}
|
||||||
return receiveData;
|
return receiveData;
|
||||||
@ -247,15 +242,15 @@ class BleReceive {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let data=parseData(receive.bytes);
|
let data = parseData(receive.bytes);
|
||||||
console.log("data=",data);
|
console.log("data=", data);
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Receive_670(receive,f,path,recArr){
|
Receive_670(receive, f, path, recArr) {
|
||||||
console.log("pagh=",path);
|
console.log("pagh=", path);
|
||||||
var todo = (bytes) =>{
|
var todo = (bytes) => {
|
||||||
// console.log("todo",receive);
|
// console.log("todo",receive);
|
||||||
let receiveData = {};
|
let receiveData = {};
|
||||||
if (bytes[0] == 0x55) {
|
if (bytes[0] == 0x55) {
|
||||||
@ -281,7 +276,8 @@ class BleReceive {
|
|||||||
// console.log("todo");
|
// console.log("todo");
|
||||||
// 解析照明档位
|
// 解析照明档位
|
||||||
let lightingLevelByte = bytes[2];
|
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];
|
let lightingTime = (bytes[3] << 8) | bytes[4];
|
||||||
@ -304,34 +300,35 @@ class BleReceive {
|
|||||||
warn = 'veryhight';
|
warn = 'veryhight';
|
||||||
}
|
}
|
||||||
|
|
||||||
let staticWarn = bytes[7] == 0x01;//静止报警
|
let staticWarn = bytes[7] == 0x01; //静止报警
|
||||||
let fourGStrenth = bytes[8]; //4g信号强度
|
let fourGStrenth = bytes[8]; //4g信号强度
|
||||||
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
let sosTxt = bytes[9] == 0x00 ? 'close' : bytes[9] == 0x01 ? 'sg' : 'rb';
|
||||||
// console.log("todo");
|
// console.log("todo");
|
||||||
receiveData.modeCurr = staticLevelText;
|
receiveData.modeCurr = staticLevelText;
|
||||||
receiveData.lightCurr = lightingLevelText;
|
receiveData.lightCurr = lightingLevelText;
|
||||||
receiveData.xuhang = lightingTime ;
|
receiveData.xuhang = lightingTime;
|
||||||
receiveData.battary = batteryLevel;
|
receiveData.battary = batteryLevel;
|
||||||
receiveData.warnLevel = warn;
|
receiveData.warnLevel = warn;
|
||||||
receiveData.staticWarn = staticWarn;
|
receiveData.staticWarn = staticWarn;
|
||||||
receiveData.fourGStrenth = fourGStrenth;
|
receiveData.fourGStrenth = fourGStrenth;
|
||||||
receiveData.SOS=sosTxt;
|
receiveData.SOS = sosTxt;
|
||||||
|
|
||||||
this.setBleFormData(receiveData,f);
|
this.setBleFormData(receiveData, f);
|
||||||
console.log("recArr=",recArr);
|
console.log("recArr=", recArr);
|
||||||
let recCnt=recArr.find(v=>{
|
let recCnt = recArr.find(v => {
|
||||||
return v.key == f.device.detailPageUrl;
|
return v.key.replaceAll('/', '').toLowerCase() == f.device.detailPageUrl
|
||||||
|
.replaceAll('/', '').toLowerCase();
|
||||||
});
|
});
|
||||||
if(!recCnt){
|
if (!recCnt) {
|
||||||
if (this.formData.staticWarn) { //有静止报警
|
if (this.formData.staticWarn) { //有静止报警
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title:"警告",
|
title: "警告",
|
||||||
content:"设备静止报警中",
|
content: "设备静止报警中",
|
||||||
showCancel:false
|
showCancel: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
}
|
}
|
||||||
// console.log("todo");
|
// console.log("todo");
|
||||||
@ -359,58 +356,55 @@ class BleReceive {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// console.log("str=",str);
|
// console.log("str=",str);
|
||||||
let json=JSON.parse(str);
|
let json = JSON.parse(str);
|
||||||
if("staBlue_picture" in json){
|
if ("staBlue_picture" in json) {
|
||||||
//重发图片
|
//重发图片
|
||||||
console.log("收到重新发送图片的命令");
|
console.log("收到重新发送图片的命令");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_text" in json) {
|
||||||
else if("staBlue_text" in json){
|
|
||||||
//重发文本
|
//重发文本
|
||||||
console.log("收到重新发送文本的命令");
|
console.log("收到重新发送文本的命令");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue_vidio" in json) {
|
||||||
else if("staBlue_vidio" in json){
|
|
||||||
//重发视频
|
//重发视频
|
||||||
console.log("收到重新发送视频的命令");
|
console.log("收到重新发送视频的命令");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
} else if ("staBlue" in json) {
|
||||||
else if("staBlue" in json){
|
if (json.staBlue == "finish") {
|
||||||
if(json.staBlue=="finish"){
|
|
||||||
console.log("收到设备回复,全部传输完成");
|
console.log("收到设备回复,全部传输完成");
|
||||||
receiveData=json;
|
receiveData = json;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else{
|
receiveData = {};
|
||||||
receiveData={};
|
|
||||||
console.log("无法解析该文本");
|
console.log("无法解析该文本");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
receiveData={};
|
receiveData = {};
|
||||||
// console.log("文本解析失败",error)
|
// console.log("文本解析失败",error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(ex) {
|
} catch (ex) {
|
||||||
receiveData={};
|
receiveData = {};
|
||||||
console.log('将数据转文本失败', ex);
|
console.log('将数据转文本失败', ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log("todo",receiveData);
|
// console.log("todo",receiveData);
|
||||||
this.setBleFormData(receiveData,f);
|
this.setBleFormData(receiveData, f);
|
||||||
return receiveData;
|
return receiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let data=todo(receive.bytes);
|
let data = todo(receive.bytes);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
Receive_6155(receive,f,path,recArr) {
|
|
||||||
let bytes=receive.bytes;
|
Receive_6155(receive, f, path, recArr) {
|
||||||
|
let bytes = receive.bytes;
|
||||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -464,21 +458,33 @@ class BleReceive {
|
|||||||
let HH = Math.max(0, Math.min(100, bytes[6]));
|
let HH = Math.max(0, Math.min(100, bytes[6]));
|
||||||
let mm = Math.max(0, Math.min(100, bytes[7]));
|
let mm = Math.max(0, Math.min(100, bytes[7]));
|
||||||
lightingTime = HH + "小时" + mm + "分钟";
|
lightingTime = HH + "小时" + mm + "分钟";
|
||||||
let formData={};
|
let formData = {};
|
||||||
formData.mode = staticLevelText;
|
formData.mode = staticLevelText;
|
||||||
formData.fuMode = lightingLevelText;
|
formData.fuMode = lightingLevelText;
|
||||||
formData.battary = batteryLevel;
|
formData.battary = 20; // batteryLevel;
|
||||||
formData.statu = warn;
|
formData.statu = warn;
|
||||||
formData.xuhang = lightingTime;
|
formData.xuhang = lightingTime;
|
||||||
|
|
||||||
if (batteryLevel <= 20) {
|
batteryLevel = 20;
|
||||||
uni.showModal({
|
console.log("recArr=", recArr);
|
||||||
content:"设备电量低",
|
|
||||||
title:"提示"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.setBleFormData(formData, f);
|
||||||
return formData;
|
return formData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('数据解析错误:', error);
|
console.log('数据解析错误:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user