From ed3e3115e3ae9fce00eee1806ebd8f58463ba88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Thu, 29 Aug 2024 19:42:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=99=84=E8=BF=91=E7=9A=84?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=9D=83=E9=99=90=E6=9C=AA=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E7=9A=84=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 2 +- stores/bluetooth.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) 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) } })