1
0
forked from dyf/APP

修复首页蓝牙连接断开时更新状态,修复670 SOS报警时红色提示

This commit is contained in:
liub
2025-12-24 14:47:21 +08:00
parent fce2f2ebcf
commit 830288e107
3 changed files with 68 additions and 30 deletions

View File

@ -57,7 +57,7 @@
<view class="device-callpolice"
v-if="item.communicationMode==0 && item.onlineStatus==1 && item.alarmStatus==1">
报警中</view>
<view v-if="item.communicationMode==1">
<view v-if="item.communicationMode==1 || item.communicationMode==2">
<view class="device-status" :class="item.bleStatu?'online':'unline'">
{{item.bleStatu?'已连接':'未连接'}}
</view>
@ -69,7 +69,7 @@
</uni-swipe-action>
</view>
<!-- <view v-else class="noDATA">
<!-- <view v-else class="noDATA">
<view> <uni-icons type="image-filled" size="120" color="rgba(255, 255, 255, 0.9)"></uni-icons>
</view>
暂无数据
@ -143,7 +143,7 @@
deviceUnbind, //删除设备
deviceReName
} from '@/api/common/index.js'
import BleHelper from '@/utils/BleHelper.js';
import bleTool from '@/utils/BleHelper.js';
import MescrollUni from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-uni.vue'
@ -267,14 +267,17 @@
this.getData();
},
bleStateBreak(){
console.error("蓝牙适配器不可用");
this.updateBleStatu();
},
bleStateRecovery() {
console.log("蓝牙适配器恢复可用,重连断开的设备");
ble.linkAllDevices();
},
bleBreak(res) {
console.log("蓝牙断开连接", res);
console.error("蓝牙断开连接", res);
if (res.deviceId) {
this.updateBleStatu(res.deviceId);
}
@ -392,6 +395,11 @@
isAsc:'desc',
orderByColumn:'bindingTime'
}
if(!data.pageNum){
this.mescroll.endSuccess(0, false);
resolve();
return;
}
deviceInfo(data).then((res) => {
if (res.code == 200) {
@ -401,33 +409,36 @@
}));
// 如果是第一页或切换分类,替换数据
this.deviceList = data.pageNum === 1 ? newDevices :this.deviceList.concat(newDevices);
if(data.pageNum === 1){
this.deviceList =newDevices
}else{
//防止后端返回的数据包含已有数据
for (var i = 0; i < newDevices.length; i++) {
let device=newDevices[i];
let f=this.deviceList.find(v=>{
return v.id===device.id;
});
if(!f){
this.deviceList.push(device);
}
}
}
this.updateBleStatu();
this.total = res.total;
// 判断是否加载完成
let hasNext = true;
if (res.rows.length < this.size || this.deviceList.length >= this
.total) {
if (res.rows.length < this.size || this.deviceList.length >= this.total) {
hasNext = false;
} else {
hasNext = true;
}
this.mescroll.endSuccess(res.rows.length, hasNext);
}else{
this.mescroll.endSuccess(0, false);
}
}).finally(() => {
resolve();
});
});
@ -713,24 +724,31 @@
console.log('列表收到消息了么');
this.downCallback();
});
ble = BleHelper.getBleTool();
ble = bleTool.getBleTool();
//蓝牙连接成功的回调
ble.addRecoveryCallback((res) => {
console.log("11111");
console.log("蓝牙连接成功的回调");
this.bleRecovery(res);
}, pagePath);
//蓝牙断开连接的回调
ble.addDisposeCallback((res) => {
console.log("2222222");
console.log("蓝牙断开连接的回调");
this.bleBreak(res);
}, pagePath);
//蓝牙适配器恢复可用的回调,一般是重连设备
ble.addStateRecoveryCallback(res => {
console.log("蓝牙适配器恢复可用的回调");
this.bleStateRecovery();
}, pagePath);
//蓝牙适配器不可用的回调
ble.addStateBreakCallback(res=>{
console.error("蓝牙适配器不可用的回调");
this.bleStateBreak();
},pagePath);
this.getSystemInfoSyncH();
},