From a0c883f4e3dfafa6805090eaebaffec811f50aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=BE=AE=E4=B8=80=E7=AC=91?= <709648985@qq.com> Date: Wed, 5 Nov 2025 10:22:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=93=9D=E7=89=99=E8=BF=9E?= =?UTF-8?q?=E6=8E=A57305=E5=90=8C=E6=AD=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/7305/BJQ7305.vue | 52 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/pages/7305/BJQ7305.vue b/pages/7305/BJQ7305.vue index 2148a84..ed98b1f 100644 --- a/pages/7305/BJQ7305.vue +++ b/pages/7305/BJQ7305.vue @@ -333,6 +333,13 @@ console.log("连接成功"); these.formData.bleStatu = true; + // 连接成功后,同步BleHelper中的连接状态 + if (f) { + f.Linked = true; + ble.updateCache(); + console.log("页面初始化连接成功,同步BleHelper连接状态为已连接"); + } + // 确保订阅消息已开启 let linkedDevice = ble.data.LinkedList.find(v => v.deviceId == f.deviceId); if (linkedDevice && !linkedDevice.notifyState) { @@ -413,8 +420,15 @@ if (res.deviceId == these.formData.deviceId) { this.formData.bleStatu = true; - // 连接恢复后,确保重新订阅消息以接收设备上报的数据 + // 连接恢复后,同步BleHelper中的连接状态 let f = this.getDevice(); + if (f) { + f.Linked = true; + ble.updateCache(); + console.log("设备连接恢复,同步BleHelper连接状态为已连接"); + } + + // 连接恢复后,确保重新订阅消息以接收设备上报的数据 if (f && (f.notifyServiceid || f.notifyCharactId)) { console.log("连接恢复,重新订阅消息"); ble.subScribe(res.deviceId, true).then(() => { @@ -474,6 +488,13 @@ }); ble.LinkBlue(these.formData.deviceId).then(() => { these.formData.bleStatu = true; + // 连接成功后,同步BleHelper中的连接状态 + let f = this.getDevice(); + if (f) { + f.Linked = true; + ble.updateCache(); + console.log("蓝牙状态恢复后连接成功,同步BleHelper连接状态为已连接"); + } updateLoading(these, { text: '连接成功' }); @@ -982,6 +1003,13 @@ return; } + // 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态 + if (this.formData.bleStatu && f) { + f.Linked = true; + ble.updateCache(); + console.log("发送模式指令前同步连接状态为已连接"); + } + showLoading(these, { text: "请稍候..." }); @@ -1113,6 +1141,14 @@ text: "请稍候..." }); this.setBleFormData(); + + // 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态 + if (this.formData.bleStatu && f) { + f.Linked = true; + ble.updateCache(); + console.log("发送人员信息前同步连接状态为已连接"); + } + let task = async () => { var sendTxtPackge = (rgbdata, type, str, lineIndex) => { @@ -1320,6 +1356,13 @@ let f = this.getDevice(); if (f) { + // 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态 + if (this.formData.bleStatu && f) { + f.Linked = true; + ble.updateCache(); + console.log("发送亮度指令前同步连接状态为已连接"); + } + // 发送数据 ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex => { @@ -1369,6 +1412,13 @@ dataView.setUint8(3, '9C41'); // 数据长度 let f = this.getDevice(); if (f) { + // 发送前确保连接状态同步:如果页面显示已连接,同步更新 BleHelper 中的 Linked 状态 + if (this.formData.bleStatu && f) { + f.Linked = true; + ble.updateCache(); + console.log("发送命令前同步连接状态为已连接"); + } + // 发送数据 ble.sendData(f.deviceId, buffer, f.writeServiceId, f.wirteCharactId, 100).catch(ex => {