修改安卓蓝牙未开启定位服务的问题

This commit is contained in:
liub
2026-02-03 13:08:49 +08:00
parent fcea5b1dba
commit b1eab86ba6
5 changed files with 53 additions and 47 deletions

View File

@ -2,7 +2,7 @@
"name" : "星汉物联",
"appid" : "__UNI__A21EF43",
"description" : "设备管控",
"versionName" : "1.0.14",
"versionName" : "1.0.15",
"versionCode" : "100",
"transformPx" : false,
/* 5+App */

View File

@ -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);

View File

@ -76,12 +76,12 @@ class BleHelper {
// recei.ReceiveData(receive, f, path, recArr);
// }, "BleReceiveData");
setTimeout(() => {
this.OpenBlue().then(() => {
this.linkAllDevices();
});
// setTimeout(() => {
// this.OpenBlue().then(() => {
// this.linkAllDevices();
// });
}, 10);
// }, 10);
this.dic = {
errRemarks: [{
@ -139,6 +139,10 @@ class BleHelper {
{
key: '10013',
remark: '连接 deviceId 为空或者是格式不正确'
},
{
key: '10016',
remark: '定位服务已关闭'
}
]
}
@ -445,7 +449,7 @@ class BleHelper {
getError(ex) {
let code = ex.code;
ex.msg = "未知的异常"
ex.msg = code
let f = this.dic.errRemarks.find((v) => {
return v.key == code;
});

View File

@ -5,7 +5,16 @@ const request = (options) => {
console.log("options" + JSON.stringify(options), BASE.BASE_URL)
return new Promise((resolve, reject) => {
// 处理GET请求参数
let url = BASE.BASE_URL + options.url;
let url ="";
if(options.url.indexOf('http://')===0 || options.url.indexOf('https://')===0){
url=options.url;
if(options.url.indexOf(BASE.BASE_UR)===-1){
options.isAuthen=false;
}
}else{
url=BASE.BASE_URL + options.url;
}
console.log("url" + url)
if (options.method === 'GET' && options.data) {
// 使用qs序列化参数

View File

@ -12,7 +12,7 @@ function checkAndUpdateWgt(updateUrl) {
}
// 显示加载提示
let urls = ['https://dmsapp.skf.com.cn/HummerService/app/CheckUpdate'];
let urls = ['https://dmsapp.skf.com.cn/HummerService/app/CheckUpdate'];//
// 1. 获取当前应用版本信息
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
@ -130,7 +130,8 @@ function checkAndUpdateWgt(updateUrl) {
let Update1 = () => {
return request({
url: '/app/auth/version',
method: 'get'
method: 'get',
isAuthen:false
});
}
@ -212,16 +213,24 @@ function downloadAndInstallWgt(wgtUrl) {
console.log("无法删除临时文件");
},
complete() {
wating.close();
uni.showModal({
title: '更新完成',
content: '应用已更新,是否重启应用?',
showCancel: false,
success: () => {
// 3. 重启应用
plus.runtime.restart();
}
});
wating.setTitle("应用已更新,正在重启");
setTimeout(()=>{
wating.close();
plus.runtime.restart();
},1000);
// uni.showModal({
// title: '更新完成',
// content: '应用已更新,点击确定重启应用',
// showCancel: false,
// success() {
// plus.runtime.restart();
// }
// });
}
});