1
0
forked from dyf/APP

首页更新,添加蓝牙电量显示

This commit is contained in:
liub
2026-01-06 16:13:28 +08:00
parent d08d109fd1
commit 78adc0bfed
870 changed files with 3941 additions and 525 deletions

View File

@ -293,29 +293,42 @@
},
updateBleStatu(deviceId) { //更新列表的蓝牙连接状态
updateBleStatu() { //更新列表的蓝牙连接状态,电池 电量
if (ble) {
for (var i = 0; i < this.deviceList.length; i++) {
let bleStatu = false;
let f=null;
if (ble.data && ble.data.LinkedList) {
ble.data.LinkedList.find(v => {
if (deviceId && v.deviceId != deviceId) {
return false;
}
f=ble.data.LinkedList.find(v => {
if (v.macAddress && v.device && v.device.id) {
if (v.device.id == this.deviceList[i].id && v.Linked) {
bleStatu = true;
return true;
}
return v.device.id == this.deviceList[i].id;
}
return false;
});
}
this.$set(this.deviceList[i], 'bleStatu', bleStatu);
if(f){
this.$set(this.deviceList[i], 'bleStatu', f.Linked);
if(f.formData){
let battary=0;
if('battary' in f.formData){
battary=f.formData.battary;
}
else if('sta_PowerPercent' in f.formData){
battary=f.formData.sta_PowerPercent;
}
else if('sta_battery' in f.formData){
battary=f.formData.sta_battery;
}
this.$set(this.deviceList[i], 'battery',battary);
}
}
}
@ -672,7 +685,7 @@
let url = item.detailPageUrl;
// console.log("url=",url);
// if(!url){
//url="/pages/670/HBY670"
// url="/pages/6075/BJQ6075"
// }
uni.navigateTo({
url: url,
@ -718,6 +731,13 @@
.filter(Boolean);
},
},
onShow(){
if(ble){
//因为vue视图只能后退不能隐藏后再显示
//所以回到首页后将其他所有页面的订阅都删除
ble.removeAllCallbackByRetain(pagePath);
}
},
onLoad() {
console.error("首页加载");
this.getTab()
@ -757,6 +777,11 @@
console.error("蓝牙适配器不可用的回调");
this.bleStateBreak();
},pagePath);
//接收到消息的回调
ble.addReceiveCallback((rec,f,path,arr)=>{
this.updateBleStatu();
},pagePath);
this.getSystemInfoSyncH();
},
@ -767,7 +792,7 @@
},
onUnload() {
uni.$off('deviceStatusUpdate');
ble && ble.removeAllCallback();
ble && ble.removeAllCallback(pagePath);
}
}