添加报警功能

This commit is contained in:
liub
2025-08-28 14:05:06 +08:00
parent c2aa8bfa2f
commit 9846fe2315
18 changed files with 1212 additions and 444 deletions

View File

@ -78,6 +78,7 @@
ble.removeReceiveCallback(pagePath);
},
onUnload() {
console.log("返回时断开蓝牙连接,取消订阅");
ble.removeReceiveCallback(pagePath);
},
onLoad(option) {
@ -86,12 +87,12 @@
ble.addReceiveCallback((receive,f,path) => {
console.log("收到设备消息,", receive);
if (these.device.deviceId == receive.deviceId) {
console.log("11111");
// console.log("11111");
if (receive.bytes[0] == 0xFC || receive.str.indexOf('mac address:') == 0) {
if (f && f.macAddress) {
these.device.macAddress = f.macAddress;
console.log("222222");
// console.log("222222");
these.initDevice();
}
}
@ -99,13 +100,23 @@
},pagePath);
eventChannel = this.getOpenerEventChannel();
eventChannel.on('LinkItem', function(data) {
console.log("data=",data);
let f = ble.data.LinkedList.find((v) => {
return v.deviceId = data.deviceId;
return v.deviceId == data.deviceId;
});
if (f) {
these.device = Object.assign({}, these.device, f);
console.log("获取到设备", f);
let keys=Object.keys(f);
keys.forEach((v,index)=>{
these.device[v]=f[v];
})
console.log("LinkedList=",ble.data.LinkedList)
console.log("f=", f);
console.log("获取到设备", these.device);
if (f.macAddress) {
these.device.macAddress = f.macAddress;
these.initDevice();
}
} else {
console.log("未获取到设备");
}
@ -117,6 +128,7 @@
showLoading(these, {
text: '正在获取设备信息'
});
console.log("these.device=",these.device);
request({
url: '/app/device/getDeviceInfoByDeviceMac',
method: 'GET',
@ -130,12 +142,12 @@
if (data) {
let keys = Object.keys(data);
ble.data.LinkedList.find((v) => {
if(v.deviceId = these.device.deviceId){
if(v.deviceId == these.device.deviceId){
for (var i = 0; i < keys.length; i++) {
let key = keys[i];
v[key] = data[key];
console.log("key="+key);
console.log("value="+data[key]);
// console.log("key="+key);
// console.log("value="+data[key]);
these.$set(these.device, key, data[key]);
@ -163,7 +175,7 @@
// 调用绑定设备接口
let f = ble.data.LinkedList.find((v) => {
return v.deviceId = these.device.deviceId;
return v.deviceId == these.device.deviceId;
});
if (!f) {
these.Statu.bound = false;
@ -195,7 +207,7 @@
if (res.code == 200) {
these.Statu.bound = true;
these.Statu.boundRemark = "设备绑定成功!";
ble.removeReceiveCallback(pagePath);
uni.$emit("refreshDeviceList");
setTimeout(() => {