1
0
forked from dyf/APP

670加入机器状态、设备详情加接口请求

This commit is contained in:
liub
2025-09-18 17:31:40 +08:00
parent 404e42a7d8
commit cb44810c6b
10 changed files with 454 additions and 221 deletions

View File

@ -415,6 +415,9 @@ class BleHelper {
uni.onBluetoothAdapterStateChange((state) => {
console.log('蓝牙状态发生变化:' + JSON.stringify(state));
if(this.data.available==state.available){
return;
}
this.data.available = state.available;
this.data.discovering = state.discovering;
if (this.data.available && this.data
@ -1095,7 +1098,7 @@ class BleHelper {
},
fail: (ex) => {
ex = this.getError(ex);
console.log("蓝牙连接失败" + JSON.stringify(ex));
console.log("蓝牙"+deviceId+"连接失败" + JSON.stringify(ex));
// 连接超时后自动重试
if (ex.code === 10012 && retryCount < maxRetries) {

View File

@ -15,90 +15,92 @@ function checkAndUpdateWgt(updateUrl) {
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
const currentVersion = widgetInfo.version;
console.log("当前版本:" + currentVersion);
request({
url:'/app/auth/version',
method: 'get'
}).then(res=>{
console.log("检查版本更新:",res);
let os=plus.os.name.toLowerCase();
if(res.code!=200){
return;
}
let f=res.data.find(v=>{
if(v.dictLabel.toLowerCase()==os){
return true;
}
return false;
});
if(f){
if(f.dictValue==currentVersion){
return;
}
uni.showModal({
title: '检测到更新',
content: '当前版本“'+currentVersion+'”,发现新版本“'+f.dictValue+'”,是否立即更新?',
confirmText: '立即更新',
cancelText: '稍后更新',
success: (modalRes) => {
if (modalRes.confirm) {
downloadAndInstallWgt(f.remark);
}
}
});
}
}).catch(ex=>{
console.log("检查更新失败:",ex);
});
// 2. 调用后端接口检查是否有更新
// uni.request({
// url: updateUrl,
// method: 'GET',
// data: {
// currentVersion: currentVersion,
// platform: uni.getSystemInfoSync().platform
// },
// success: (res) => {
// uni.hideLoading();
// console.log("res=", res)
// if (res.statusCode === 200) {
// const updateInfo = res.data.data;
// if (!updateInfo.hasUpdate) {
// return;
// }
// // 3. 显示更新提示
// uni.showModal({
// title: '检测到更新',
// content: updateInfo.description || '有新版本可用,是否立即更新?',
// confirmText: '立即更新',
// cancelText: '稍后更新',
// success: (modalRes) => {
// if (modalRes.confirm) {
// downloadAndInstallWgt(updateInfo.downloadUrl);
// }
// }
// });
// } else {
// uni.showToast({
// title: '当前已是最新版本',
// icon: 'none',
// duration: 2000
// });
// }
// },
// fail: (err) => {
// uni.hideLoading();
// uni.showToast({
// title: '检查更新失败',
// icon: 'none',
// duration: 2000
// });
// console.error('检查更新失败:', err);
// request({
// url:'/app/auth/version',
// method: 'get'
// }).then(res=>{
// console.log("检查版本更新:",res);
// let os=plus.os.name.toLowerCase();
// if(res.code!=200){
// return;
// }
// let f=res.data.find(v=>{
// if(v.dictLabel.toLowerCase()==os){
// return true;
// }
// return false;
// });
// if(f){
// if(f.dictValue==currentVersion){
// return;
// }
// uni.showModal({
// title: '检测到更新',
// content: '当前版本“'+currentVersion+'”,发现新版本“'+f.dictValue+'”,是否立即更新?',
// confirmText: '立即更新',
// cancelText: '稍后更新',
// success: (modalRes) => {
// if (modalRes.confirm) {
// downloadAndInstallWgt(f.remark);
// }
// }
// });
// }
// }).catch(ex=>{
// console.log("检查更新失败:",ex);
// });
// 2. 调用后端接口检查是否有更新
uni.request({
url: updateUrl,
method: 'GET',
data: {
currentVersion: currentVersion,
platform: uni.getSystemInfoSync().platform
},
success: (res) => {
uni.hideLoading();
console.log("检查更新成功=", res)
if (res.statusCode === 200) {
const updateInfo = res.data.data;
if (!updateInfo.hasUpdate) {
return;
}
// 3. 显示更新提示
uni.showModal({
title: '检测到更新',
content: updateInfo.description || '有新版本可用,是否立即更新?',
confirmText: '立即更新',
cancelText: '稍后更新',
success: (modalRes) => {
if (modalRes.confirm) {
downloadAndInstallWgt(updateInfo.downloadUrl);
}
}
});
} else {
uni.showToast({
title: '当前已是最新版本',
icon: 'none',
duration: 2000
});
}
},
fail: (err) => {
uni.hideLoading();
uni.showToast({
title: '检查更新失败',
icon: 'none',
duration: 2000
});
console.error('检查更新失败:', err);
}
});
});
}