diff --git a/App.vue b/App.vue index 14cd9b0..6758c35 100644 --- a/App.vue +++ b/App.vue @@ -24,7 +24,7 @@ const checkResult = await this.checkSetting() console.log(checkResult) if(checkResult === true) { - this.initAndListenBluetooth() + this.initAndListenBluetooth(false) } }, onShow() { diff --git a/stores/bluetooth.js b/stores/bluetooth.js index 98c72b1..b39891b 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -91,9 +91,9 @@ export const useBluetoothStore = defineStore('ble', { return { code, data, message } }, // 初始化并监听 - async initAndListenBluetooth() { + async initAndListenBluetooth(tipFlag) { // 初始化蓝牙 - const initResult = await this.initBluetooth() + const initResult = await this.initBluetooth(tipFlag) if (initResult) { // 更新蓝牙初始化状态 this.updateInitBluetooth(true) @@ -114,7 +114,7 @@ export const useBluetoothStore = defineStore('ble', { this.isInitBluetooth = value }, // 初始化蓝牙模块 - initBluetooth() { + initBluetooth(tipFlag = true) { const that = this // 初始化蓝牙模块 return new Promise(resolve => { @@ -147,6 +147,14 @@ export const useBluetoothStore = defineStore('ble', { resolve(true) return } + if(err.errno === 3 && tipFlag) { + uni.showModal({ + title: '提示', + content: '蓝牙功能需要附近设备权限,请前往设置开启微信的附近设备权限后再试', + showCancel: false, + confirmText: '确定', + }) + } resolve(false) } })