fix:修复鸿蒙系统权限bug

This commit is contained in:
范鹏 2024-09-27 10:29:15 +08:00
parent ac769296e8
commit 87ee56869c
2 changed files with 25 additions and 8 deletions

View File

@ -3,7 +3,7 @@
"appid" : "__UNI__933D519",
"description" : "",
"versionName" : "1.0.2",
"versionCode" : "20",
"versionCode" : "21",
"transformPx" : false,
/* */
"mp-weixin" : {

View File

@ -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]