修改安卓蓝牙未开启定位服务的问题
This commit is contained in:
@ -481,9 +481,9 @@
|
||||
}
|
||||
|
||||
plus.android.requestPermissions(
|
||||
['android.permission.ACCESS_FINE_LOCATION'],
|
||||
['android.permission.BLUETOOTH','android.permission.BLUETOOTH_ADMIN','android.permission.ACCESS_FINE_LOCATION','android.permission.ACCESS_COARSE_LOCATION'],
|
||||
(result) => {
|
||||
if (result.granted.length > 0) {
|
||||
if (result.granted && result.granted.length > 0) {
|
||||
console.log('定位权限已授予');
|
||||
resolve(true);
|
||||
} else {
|
||||
@ -537,7 +537,7 @@
|
||||
let time = null;
|
||||
let startSearch = () => {
|
||||
|
||||
if(time){
|
||||
if(time!==null){
|
||||
clearTimeout(time);
|
||||
}
|
||||
|
||||
@ -546,43 +546,27 @@
|
||||
these.PairEquip = [];
|
||||
|
||||
ble.StartSearch().then(result => {
|
||||
console.log("Fresh scan started successfully.");
|
||||
}).catch(err => {
|
||||
console.error("Failed to start fresh scan:", err);
|
||||
console.log("开始搜索成功",result);
|
||||
|
||||
}).catch(err => {
|
||||
console.error("开始搜索失败:", err);
|
||||
if (err.code === 10001) {
|
||||
these.showOpenSetting();
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '开始搜索失败:' + err.msg
|
||||
content: '出现错误:' + err.msg
|
||||
});
|
||||
|
||||
}
|
||||
}).finally(()=>{
|
||||
hideLoading(these);
|
||||
});
|
||||
}, 500);
|
||||
}, 200);
|
||||
|
||||
}
|
||||
|
||||
ble.StopSearch().finally(() => {
|
||||
|
||||
let disconnectPromises = [];
|
||||
if (ble.data && ble.data.LinkedList) {
|
||||
ble.data.LinkedList.forEach(device => {
|
||||
if (device.Linked) {
|
||||
disconnectPromises.push(ble.disconnectDevice(device.deviceId));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (disconnectPromises.length > 0) {
|
||||
Promise.allSettled(disconnectPromises).finally(() => {
|
||||
startSearch();
|
||||
});
|
||||
} else {
|
||||
startSearch();
|
||||
}
|
||||
});
|
||||
ble.StopSearch().finally(startSearch);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user