100J修复使用4G还提示蓝牙的文案异常
This commit is contained in:
@ -434,7 +434,10 @@ const WAIT_BLE_CONNECTED_MS = 5000;
|
|||||||
const BLE_POLL_INTERVAL_MS = 400;
|
const BLE_POLL_INTERVAL_MS = 400;
|
||||||
const BLE_RECONNECT_MS = 2000;
|
const BLE_RECONNECT_MS = 2000;
|
||||||
|
|
||||||
/** 系统蓝牙开关是否开启(与手机设置一致,避免关机蓝牙仍白等 12s) */
|
/**
|
||||||
|
* 系统蓝牙是否可用。fail/available=false 时立即走 4G。
|
||||||
|
* 若系统报开启,再与 BleHelper.data.available 交叉校验(关蓝牙后助手往往先变为 false,避免仍弹「连蓝牙」类误导)。
|
||||||
|
*/
|
||||||
function getBleAdapterAvailable() {
|
function getBleAdapterAvailable() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (typeof uni.getBluetoothAdapterState !== 'function') {
|
if (typeof uni.getBluetoothAdapterState !== 'function') {
|
||||||
@ -442,7 +445,22 @@ function getBleAdapterAvailable() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uni.getBluetoothAdapterState({
|
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)
|
fail: () => resolve(false)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -592,7 +610,7 @@ function execWithBleFirst(bleExec, httpExec, logName, onWaiting) {
|
|||||||
return do4G();
|
return do4G();
|
||||||
}
|
}
|
||||||
if (typeof onWaiting === 'function') onWaiting();
|
if (typeof onWaiting === 'function') onWaiting();
|
||||||
else showWaitUi('蓝牙连接中…');
|
else showWaitUi('请稍候…');
|
||||||
return waitForBleConnection()
|
return waitForBleConnection()
|
||||||
.then((connected) => {
|
.then((connected) => {
|
||||||
return connected ? doBle().catch(() => {
|
return connected ? doBle().catch(() => {
|
||||||
@ -609,7 +627,7 @@ function execWithBleFirst(bleExec, httpExec, logName, onWaiting) {
|
|||||||
console.log('[100J]', logName || '指令', '系统蓝牙未开启,走4G');
|
console.log('[100J]', logName || '指令', '系统蓝牙未开启,走4G');
|
||||||
return do4G();
|
return do4G();
|
||||||
}
|
}
|
||||||
if (typeof onWaiting !== 'function') showWaitUi('正在重连蓝牙…');
|
if (typeof onWaiting !== 'function') showWaitUi('请稍候…');
|
||||||
return tryReconnectBle()
|
return tryReconnectBle()
|
||||||
.then((reconnected) => {
|
.then((reconnected) => {
|
||||||
return reconnected ? doBle().catch(() => {
|
return reconnected ? doBle().catch(() => {
|
||||||
|
|||||||
@ -514,7 +514,8 @@
|
|||||||
fileUrl,
|
fileUrl,
|
||||||
localPath,
|
localPath,
|
||||||
onProgress: (p) => { this.updateProgress = p; },
|
onProgress: (p) => { this.updateProgress = p; },
|
||||||
onWaiting: () => { uni.showToast({ title: '等待蓝牙连接中...', icon: 'none', duration: 2000 }); }
|
// 不传「蓝牙连接中」类提示:关蓝牙走 4G 时易误导;进度条 + 必要时全局请稍候即可
|
||||||
|
onWaiting: () => {}
|
||||||
};
|
};
|
||||||
// 整体超时 60 秒(仅影响蓝牙上传,4G HTTP 很快返回)
|
// 整体超时 60 秒(仅影响蓝牙上传,4G HTTP 很快返回)
|
||||||
const overallTimer = setTimeout(() => {
|
const overallTimer = setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user