首页更新,添加蓝牙电量显示
This commit is contained in:
@ -6,13 +6,13 @@ class BleReceive {
|
||||
'/pages/7305/BJQ7305': this.Receive_6155.bind(this),
|
||||
'/pages/650/HBY650': this.Receive_650.bind(this),
|
||||
'/pages/670/HBY670': this.Receive_670.bind(this),
|
||||
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
||||
'/pages/4877/BJQ4877': this.Receive_4877.bind(this),
|
||||
'/pages/100/HBY100': this.Receive_100.bind(this),
|
||||
'/pages/102/HBY102':this.Receive_102.bind(this)
|
||||
'/pages/102/HBY102': this.Receive_102.bind(this)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
setBleFormData(data, f) {
|
||||
if (data) {
|
||||
let linkedList = uni.getStorageSync(this.StorageKey);
|
||||
@ -59,7 +59,7 @@ class BleReceive {
|
||||
|
||||
if (handler) {
|
||||
let data = handler(receive, f, path, recArr);
|
||||
// console.log("设备"+f.device.deviceName+"收到消息,数据:", data);
|
||||
// console.log("设备"+f.device.deviceName+"收到消息,数据:", data);
|
||||
return data;
|
||||
} else {
|
||||
console.error("已收到消息,但无指定处理程序, deviceUrl:", f.device.detailPageUrl, "可用handlers:", keys);
|
||||
@ -99,6 +99,10 @@ class BleReceive {
|
||||
staticLevelText = '低档';
|
||||
modeCurr = "low";
|
||||
break;
|
||||
case 0x68:
|
||||
staticLevelText = '前置';
|
||||
modeCurr = "smalllow";
|
||||
break;
|
||||
case 0x64:
|
||||
staticLevelText = '关闭';
|
||||
modeCurr = "close";
|
||||
@ -162,7 +166,7 @@ class BleReceive {
|
||||
|
||||
if (iswarn) {
|
||||
uni.showModal({
|
||||
content: "'"+f.device.deviceName+"'环境存在漏电电源",
|
||||
content: "'" + f.device.deviceName + "'环境存在漏电电源",
|
||||
title: "警告",
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
@ -258,7 +262,7 @@ class BleReceive {
|
||||
Receive_670(receive, f, path, recArr) {
|
||||
// console.log("pagh=", path);
|
||||
var todo = (bytes) => {
|
||||
console.log("todo",receive);
|
||||
console.log("todo", receive);
|
||||
let receiveData = {};
|
||||
if (bytes[0] == 0x55) {
|
||||
try {
|
||||
@ -319,7 +323,7 @@ class BleReceive {
|
||||
receiveData.staticWarn = staticWarn;
|
||||
receiveData.fourGStrenth = fourGStrenth;
|
||||
receiveData.SOS = sosTxt;
|
||||
receiveData.qzwarn = sosTxt==='sg';
|
||||
receiveData.qzwarn = sosTxt === 'sg';
|
||||
this.setBleFormData(receiveData, f);
|
||||
console.log("recArr=", recArr);
|
||||
let recCnt = recArr.find(v => {
|
||||
@ -327,22 +331,22 @@ class BleReceive {
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
let msgs=[];
|
||||
if(receiveData.qzwarn){
|
||||
let msgs = [];
|
||||
if (receiveData.qzwarn) {
|
||||
msgs.push("声光报警中");
|
||||
}
|
||||
if (staticWarn) { //有静止报警
|
||||
msgs.push("静止报警中");
|
||||
}
|
||||
if(msgs.length>0){
|
||||
msgs="设备'"+f.device.deviceName+msgs.join(";");
|
||||
if (msgs.length > 0) {
|
||||
msgs = "设备'" + f.device.deviceName + msgs.join(";");
|
||||
uni.showModal({
|
||||
title: "警告",
|
||||
content:msgs,
|
||||
content: msgs,
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('数据解析错误:', error);
|
||||
@ -418,44 +422,44 @@ class BleReceive {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
Receive_6155(receive, f, path, recArr) {
|
||||
let bytes = receive.bytes;
|
||||
if (bytes[0] == 0xFB && bytes[1] == 0x64 && bytes.length >= 8) {
|
||||
try {
|
||||
|
||||
|
||||
let getName = function(type,) {
|
||||
|
||||
let getName = function(type, ) {
|
||||
let name = "";
|
||||
switch (type) {
|
||||
case 0x01:
|
||||
// name = '强光';
|
||||
name=0;
|
||||
name = 0;
|
||||
break;
|
||||
case 0x02:
|
||||
// name = '弱光';
|
||||
name=1;
|
||||
name = 1;
|
||||
break;
|
||||
case 0x03:
|
||||
// name = '爆闪';
|
||||
name=2;
|
||||
break;
|
||||
// name = '爆闪';
|
||||
name = 2;
|
||||
break;
|
||||
case 0x04:
|
||||
name = 0;//泛光
|
||||
name = 0; //泛光
|
||||
break;
|
||||
case 0x0A:
|
||||
name = 1;//强光&泛光
|
||||
name = 1; //强光&泛光
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
// name = '关闭';
|
||||
name=null;
|
||||
name = null;
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
let staticLevelText = getName(bytes[2]);
|
||||
|
||||
// 解析照明档位
|
||||
@ -484,26 +488,27 @@ class BleReceive {
|
||||
let mm = Math.max(0, Math.min(100, bytes[7]));
|
||||
lightingTime = HH + "小时" + mm + "分钟";
|
||||
let formData = {};
|
||||
formData.mode = (bytes[2]===0x00 || bytes[2]===0x0B)?'fu':'main';
|
||||
formData.light=formData.mode=='fu'?lightingLevelText:staticLevelText;
|
||||
|
||||
formData.battary = batteryLevel;
|
||||
formData.mode = (bytes[2] === 0x00 || bytes[2] === 0x0B) ? 'fu' : 'main';
|
||||
formData.light = formData.mode == 'fu' ? lightingLevelText : staticLevelText;
|
||||
|
||||
formData.battary = batteryLevel;
|
||||
formData.statu = warn;
|
||||
formData.xuhang = lightingTime;
|
||||
|
||||
|
||||
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
|
||||
return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g, '').toLowerCase();
|
||||
return v.key.replace(/\//g, "").toLowerCase() === f.device.detailPageUrl.replace(/\//g,
|
||||
'').toLowerCase();
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (batteryLevel <= 20) {
|
||||
// 会弹出两个框,暂且注释掉这段代码
|
||||
// 会弹出两个框,暂且注释掉这段代码
|
||||
uni.showModal({
|
||||
content: "设备'"+f.device.deviceName+"'电量低",
|
||||
content: "设备'" + f.device.deviceName + "'电量低",
|
||||
title: "提示"
|
||||
});
|
||||
}
|
||||
@ -520,102 +525,102 @@ class BleReceive {
|
||||
return null;
|
||||
}
|
||||
|
||||
Receive_4877(receive,f,path,recArr){
|
||||
let receiveData={};
|
||||
|
||||
Receive_4877(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
try {
|
||||
|
||||
|
||||
// console.log("str=",receive.str);
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_PowerPercent<=20) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "设备'"+f.device.deviceName+"'电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_PowerPercent <= 20) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "设备'" + f.device.deviceName + "'电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败",error)
|
||||
console.log("文本解析失败", error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Receive_100(receive,f,path,recArr){
|
||||
let receiveData={};
|
||||
|
||||
|
||||
Receive_100(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
try {
|
||||
|
||||
// console.log("str=",receive.str);
|
||||
|
||||
// console.log("str=",receive.str);
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_battery<=20) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "设备'"+f.device.deviceName+"'电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_battery <= 20) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "设备'" + f.device.deviceName + "'电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败",error)
|
||||
console.log("文本解析失败", error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Receive_102(receive,f,path,recArr){
|
||||
let receiveData={};
|
||||
|
||||
|
||||
|
||||
Receive_102(receive, f, path, recArr) {
|
||||
let receiveData = {};
|
||||
|
||||
try {
|
||||
|
||||
// console.log("str=",receive.str);
|
||||
|
||||
// console.log("str=",receive.str);
|
||||
receiveData = JSON.parse(receive.str);
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_PowerPercent<=20) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "设备'"+f.device.deviceName+"'电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
if (receiveData.sta_Intrusion===1) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "闯入报警中",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let recCnt = recArr.find(v => {
|
||||
return v.key.replace(/\//g, "").toLowerCase() == f.device.detailPageUrl
|
||||
.replace(/\//g, "").toLowerCase();
|
||||
});
|
||||
if (!recCnt) {
|
||||
if (receiveData.sta_PowerPercent <= 20) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "设备'" + f.device.deviceName + "'电量低",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
if (receiveData.sta_Intrusion === 1) {
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "闯入报警中",
|
||||
showCancel: false
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
receiveData = {};
|
||||
console.log("文本解析失败",error)
|
||||
console.log("文本解析失败", error)
|
||||
}
|
||||
return receiveData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user