From 87ee56869cc3b83cbfb4d0ae8aa05b694040489d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Fri, 27 Sep 2024 10:29:15 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E9=B8=BF?= =?UTF-8?q?=E8=92=99=E7=B3=BB=E7=BB=9F=E6=9D=83=E9=99=90bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 2 +- stores/bluetooth.js | 31 ++++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index b428330..b06c90d 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "appid" : "__UNI__933D519", "description" : "", "versionName" : "1.0.2", - "versionCode" : "20", + "versionCode" : "21", "transformPx" : false, /* 小程序特有相关 */ "mp-weixin" : { diff --git a/stores/bluetooth.js b/stores/bluetooth.js index e11d0f7..79e479d 100644 --- a/stores/bluetooth.js +++ b/stores/bluetooth.js @@ -495,7 +495,7 @@ export const useBluetoothStore = defineStore('ble', { if(searchNumber === 0 && searchTipFlag) { uni.showModal({ title: '提示', - content: '长时间未搜索到任何设备,请确认微信的附近设备权限开启后再试', + content: '长时间未搜索到任何设备,请确认微信的附近设备权限开启后再试(鸿蒙系统在设置-隐私-定位服务中开启位置信息权限)', showCancel: false, success() { uni.openAppAuthorizeSetting({ @@ -756,16 +756,33 @@ export const useBluetoothStore = defineStore('ble', { return new Promise((resolve) => { uni.startBluetoothDevicesDiscovery({ success: function () { - timer2 = setTimeout(() => { - uni.stopBluetoothDevicesDiscovery() - clearInterval(timer1) - resolve({ code: -1 }) - }, 10500) + let searchFlag = false + timer2 = setTimeout(async () => { + uni.stopBluetoothDevicesDiscovery() + clearInterval(timer1) + if (!searchFlag) { + uni.showModal({ + title: '提示', + content: '长时间未搜索到任何设备,请确认微信的附近设备权限开启后再试(鸿蒙系统在设置-隐私-定位服务中开启位置信息权限)', + showCancel: false, + success () { + uni.openAppAuthorizeSetting({ + success (res) { + console.log(res) + } + }) + } + }) + } + resolve({ code: -1 }) + }, 10500) timer1 = setInterval(() => { uni.getBluetoothDevices({ success(res) { - console.log('设备列表', res) const deviceList = res.devices + if(searchFlag === false && res.devices.length > 0) { + searchFlag = true + } for(let i = 0; i < deviceList.length; i++) { if(deviceList[i]?.name === that.currentLockInfo.name) { const uuid = deviceList[i]?.advertisServiceUUIDs[0]