feat: 更新蓝牙初始化逻辑,增加对不同平台的蓝牙打开提示,优化错误处理
This commit is contained in:
parent
95118d44dc
commit
11a75699e7
@ -422,7 +422,7 @@
|
|||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
$bluetooth
|
await $bluetooth
|
||||||
.syncRecord({
|
.syncRecord({
|
||||||
keyId: $bluetooth.currentLockInfo.keyId.toString(),
|
keyId: $bluetooth.currentLockInfo.keyId.toString(),
|
||||||
uid: $user.userInfo.uid.toString()
|
uid: $user.userInfo.uid.toString()
|
||||||
|
|||||||
@ -233,7 +233,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
fail(err) {
|
fail(err) {
|
||||||
console.log('蓝牙初始化失败', err)
|
console.log('蓝牙初始化失败', err)
|
||||||
// 系统蓝牙未打开
|
// 系统蓝牙未打开
|
||||||
if (err.errCode === 10001) {
|
if (err.errCode === 10001 || err.code === 10001) {
|
||||||
if (that.bluetoothStatus === 2) {
|
if (that.bluetoothStatus === 2) {
|
||||||
that.bluetoothStatus = 3
|
that.bluetoothStatus = 3
|
||||||
} else {
|
} else {
|
||||||
@ -883,6 +883,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
if (this.bluetoothStatus === 1) {
|
if (this.bluetoothStatus === 1) {
|
||||||
const initResult = await this.initBluetooth()
|
const initResult = await this.initBluetooth()
|
||||||
if (!initResult) {
|
if (!initResult) {
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '蓝牙尚未打开,请先打开蓝牙',
|
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) {
|
} else if (this.bluetoothStatus === 2 || this.bluetoothStatus === 3) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user