From 11a75699e7967d30b6f6ebf0bc3c4453f379cdf2 Mon Sep 17 00:00:00 2001 From: fanpeng <438123081@qq.com> Date: Mon, 14 Jul 2025 11:03:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=93=9D=E7=89=99?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9=E4=B8=8D=E5=90=8C=E5=B9=B3=E5=8F=B0=E7=9A=84?= =?UTF-8?q?=E8=93=9D=E7=89=99=E6=89=93=E5=BC=80=E6=8F=90=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/main/lockDetail.vue | 2 +- stores/bluetooth.js | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pages/main/lockDetail.vue b/pages/main/lockDetail.vue index f68c6be..2bb62fb 100644 --- a/pages/main/lockDetail.vue +++ b/pages/main/lockDetail.vue @@ -422,7 +422,7 @@ // #endif } if (code === 0) { - $bluetooth + await $bluetooth .syncRecord({ keyId: $bluetooth.currentLockInfo.keyId.toString(), uid: $user.userInfo.uid.toString() diff --git a/stores/bluetooth.js b/stores/bluetooth.js index fd3a977..5763d41 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -233,7 +233,7 @@ export const useBluetoothStore = defineStore('ble', { fail(err) { console.log('蓝牙初始化失败', err) // 系统蓝牙未打开 - if (err.errCode === 10001) { + if (err.errCode === 10001 || err.code === 10001) { if (that.bluetoothStatus === 2) { that.bluetoothStatus = 3 } else { @@ -883,6 +883,7 @@ export const useBluetoothStore = defineStore('ble', { if (this.bluetoothStatus === 1) { const initResult = await this.initBluetooth() if (!initResult) { + // #ifdef MP-WEIXIN uni.showModal({ title: '提示', content: '蓝牙尚未打开,请先打开蓝牙', @@ -897,6 +898,23 @@ export const useBluetoothStore = defineStore('ble', { } } }) + // #endif + // #ifdef APP-PLUS + const systemInfo = uni.getSystemInfoSync() + if (systemInfo.platform === 'android') { + const main = plus.android.runtimeMainActivity() + const Intent = plus.android.importClass('android.content.Intent') + const BluetoothAdapter = plus.android.importClass('android.bluetooth.BluetoothAdapter') + const intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE) + main.startActivity(intent) + } else if (systemInfo.platform === 'ios') { + uni.showModal({ + title: '提示', + content: '蓝牙尚未打开,请先打开蓝牙', + showCancel: false + }) + } + // #endif } } else if (this.bluetoothStatus === 2 || this.bluetoothStatus === 3) { uni.showModal({