100J修复使用4G还提示蓝牙的文案异常

This commit is contained in:
微微一笑
2026-03-26 15:12:16 +08:00
parent 6715384b0a
commit a18b2b81e8
2 changed files with 24 additions and 5 deletions

View File

@ -434,7 +434,10 @@ const WAIT_BLE_CONNECTED_MS = 5000;
const BLE_POLL_INTERVAL_MS = 400;
const BLE_RECONNECT_MS = 2000;
/** 系统蓝牙开关是否开启(与手机设置一致,避免关机蓝牙仍白等 12s */
/**
* 系统蓝牙是否可用。fail/available=false 时立即走 4G。
* 若系统报开启,再与 BleHelper.data.available 交叉校验(关蓝牙后助手往往先变为 false避免仍弹「连蓝牙」类误导
*/
function getBleAdapterAvailable() {
return new Promise((resolve) => {
if (typeof uni.getBluetoothAdapterState !== 'function') {
@ -442,7 +445,22 @@ function getBleAdapterAvailable() {
return;
}
uni.getBluetoothAdapterState({
success: (res) => resolve(!!res.available),
success: (res) => {
if (!res.available) {
resolve(false);
return;
}
import('@/utils/BleHelper.js').then((m) => {
try {
const ble = m.default.getBleTool();
if (ble && ble.data && ble.data.available === false) {
resolve(false);
return;
}
} catch (e) {}
resolve(true);
}).catch(() => resolve(true));
},
fail: () => resolve(false)
});
});
@ -592,7 +610,7 @@ function execWithBleFirst(bleExec, httpExec, logName, onWaiting) {
return do4G();
}
if (typeof onWaiting === 'function') onWaiting();
else showWaitUi('蓝牙连接中…');
else showWaitUi('请稍候…');
return waitForBleConnection()
.then((connected) => {
return connected ? doBle().catch(() => {
@ -609,7 +627,7 @@ function execWithBleFirst(bleExec, httpExec, logName, onWaiting) {
console.log('[100J]', logName || '指令', '系统蓝牙未开启走4G');
return do4G();
}
if (typeof onWaiting !== 'function') showWaitUi('正在重连蓝牙…');
if (typeof onWaiting !== 'function') showWaitUi('请稍候…');
return tryReconnectBle()
.then((reconnected) => {
return reconnected ? doBle().catch(() => {