1
This commit is contained in:
@ -85,8 +85,7 @@
|
|||||||
<!-- 圆形进度条 + 全屏遮罩层(升级中显示) -->
|
<!-- 圆形进度条 + 全屏遮罩层(升级中显示) -->
|
||||||
<view v-if="isUpdating" class="mask-layer">
|
<view v-if="isUpdating" class="mask-layer">
|
||||||
<view class="circle-progress-box">
|
<view class="circle-progress-box">
|
||||||
<progress :percent="updateProgress" activeColor="#bbe600" backgroundColor="#686767" :border-radius='22'
|
<progress :percent="updateProgress" activeColor="#bbe600" backgroundColor="#686767" :border-radius='22' show-info stroke-width="15" class="custom-progress" />
|
||||||
show-info stroke-width="15" class="custom-progress" />
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -207,7 +206,7 @@
|
|||||||
},
|
},
|
||||||
updateProgress: 0, // 升级进度,0-100
|
updateProgress: 0, // 升级进度,0-100
|
||||||
isUpdating: false, // 是否正在升级(控制进度条显示/隐藏)
|
isUpdating: false, // 是否正在升级(控制进度条显示/隐藏)
|
||||||
upgradeTimer: null // 升级超时定时器,初始为null
|
mqttSubscribeSuccess: false // MQTT订阅是否成功
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@ -488,26 +487,28 @@
|
|||||||
// 解析MQTT返回的payload
|
// 解析MQTT返回的payload
|
||||||
const payloadObj = typeof payload === 'string' ? JSON.parse(
|
const payloadObj = typeof payload === 'string' ? JSON.parse(
|
||||||
payload) : payload;
|
payload) : payload;
|
||||||
// 取出进度值
|
// 取出进度值(用可选链避免字段不存在报错)
|
||||||
const progress = payloadObj.data.progress;
|
const progress = payloadObj.data?.progress;
|
||||||
if (progress !== undefined && !isNaN(progress) && progress >=
|
if (progress !== undefined && !isNaN(progress) && progress >=
|
||||||
0 && progress <= 100) {
|
0 && progress <= 100) {
|
||||||
this.updateProgress = progress;
|
this.updateProgress = progress;
|
||||||
console.log('当前升级进度:', progress + '%');
|
console.log('当前升级进度:', progress + '%');
|
||||||
// 进度到100%时
|
// 进度到100%时,触发升级完成逻辑
|
||||||
if (progress === 100) {
|
if (progress === 100) {
|
||||||
clearTimeout(this.upgradeTimer);
|
clearTimeout(this.upgradeTimer);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '更新完成!',
|
title: '升级完成!',
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
this.isUpdating = false;
|
this.isUpdating = false;
|
||||||
item.useStatus = 1
|
setTimeout(() => {
|
||||||
|
uni.navigateBack();
|
||||||
|
}, 1500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
clearTimeout(this.upgradeTimer);
|
clearTimeout(this.upgradeTimer);
|
||||||
console.error('解析MQTT payload失败:', e);
|
console.error('解析MQTT payload失败:', e);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -521,20 +522,22 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.upgradeTimer = setTimeout(() => {
|
this.upgradeTimer = setTimeout(() => {
|
||||||
// 超时后
|
// 超时后执行:隐藏进度条+提示超时+重置进度
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '响应超时',
|
title: '升级进度同步超时',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
this.isUpdating = false; // 关闭进度条
|
this.isUpdating = false; // 关闭进度条
|
||||||
this.updateProgress = 0;
|
this.updateProgress = 0; // 重置进度值
|
||||||
//this.mqttClient.unsubscribe(statusTopic);
|
// 可选:如果需要取消MQTT订阅,加这行(根据需求选择)
|
||||||
}, 20000); //20s超时
|
// this.mqttClient.unsubscribe(statusTopic);
|
||||||
|
}, 6000); // 6000ms = 6秒,时间可直接修改
|
||||||
},
|
},
|
||||||
closePop: function() {
|
closePop: function() {
|
||||||
this.Status.Pop.showPop = false;
|
this.Status.Pop.showPop = false;
|
||||||
|
|
||||||
if (this.Status.Pop.cancelCallback) {
|
if (this.Status.Pop.cancelCallback) {
|
||||||
this.Status.Pop.cancelCallback();
|
this.Status.Pop.cancelCallback();
|
||||||
}
|
}
|
||||||
@ -636,21 +639,18 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.custom-progress {
|
.custom-progress{
|
||||||
border-radius: 10rpx;
|
border-radius: 10rpx;
|
||||||
}
|
}
|
||||||
|
.custom-progress .uni-progress-bar{
|
||||||
.custom-progress .uni-progress-bar {
|
border-radius: 10rpx !important;
|
||||||
border-radius: 10rpx !important;
|
}
|
||||||
}
|
.custom-progress .uni-progress-info{
|
||||||
|
color: #BBE600;
|
||||||
.custom-progress .uni-progress-info {
|
font-size: 40rpx;
|
||||||
color: #BBE600;
|
font-weight: 600;
|
||||||
font-size: 40rpx;
|
}
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.popup-prompt {
|
.popup-prompt {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-top: 40rpx;
|
margin-top: 40rpx;
|
||||||
@ -687,8 +687,6 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.li .itemMain {}
|
|
||||||
|
|
||||||
.li .item {
|
.li .item {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
|
|||||||
Reference in New Issue
Block a user