添加附近的设备权限未开启的报错提示
This commit is contained in:
parent
1cc09adb59
commit
ed3e3115e3
2
App.vue
2
App.vue
@ -24,7 +24,7 @@
|
|||||||
const checkResult = await this.checkSetting()
|
const checkResult = await this.checkSetting()
|
||||||
console.log(checkResult)
|
console.log(checkResult)
|
||||||
if(checkResult === true) {
|
if(checkResult === true) {
|
||||||
this.initAndListenBluetooth()
|
this.initAndListenBluetooth(false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
|
|||||||
@ -91,9 +91,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
return { code, data, message }
|
return { code, data, message }
|
||||||
},
|
},
|
||||||
// 初始化并监听
|
// 初始化并监听
|
||||||
async initAndListenBluetooth() {
|
async initAndListenBluetooth(tipFlag) {
|
||||||
// 初始化蓝牙
|
// 初始化蓝牙
|
||||||
const initResult = await this.initBluetooth()
|
const initResult = await this.initBluetooth(tipFlag)
|
||||||
if (initResult) {
|
if (initResult) {
|
||||||
// 更新蓝牙初始化状态
|
// 更新蓝牙初始化状态
|
||||||
this.updateInitBluetooth(true)
|
this.updateInitBluetooth(true)
|
||||||
@ -114,7 +114,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
this.isInitBluetooth = value
|
this.isInitBluetooth = value
|
||||||
},
|
},
|
||||||
// 初始化蓝牙模块
|
// 初始化蓝牙模块
|
||||||
initBluetooth() {
|
initBluetooth(tipFlag = true) {
|
||||||
const that = this
|
const that = this
|
||||||
// 初始化蓝牙模块
|
// 初始化蓝牙模块
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@ -147,6 +147,14 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
resolve(true)
|
resolve(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(err.errno === 3 && tipFlag) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '蓝牙功能需要附近设备权限,请前往设置开启微信的附近设备权限后再试',
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '确定',
|
||||||
|
})
|
||||||
|
}
|
||||||
resolve(false)
|
resolve(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user