修复100J

This commit is contained in:
微微一笑
2026-03-26 15:39:50 +08:00
parent a18b2b81e8
commit e7b40dbed6
3 changed files with 90 additions and 16 deletions

View File

@ -469,23 +469,41 @@
const eventChannel = this.getOpenerEventChannel();
var these = this;
// 低电量提示同一百分比不重复弹MQTT/蓝牙反复上报时避免刷屏);恢复高于 20% 后再次降低可再提示
// 低电量:语音上传/蓝牙分包时电量字段易抖动,防抖 + 上传中不弹,避免「发送中频繁低电量」误报
this._lastBatteryLowToastPct = null;
this.$watch("deviceInfo.batteryPercentage", (newVal) => {
const n = Number(newVal);
this._batteryLowDebounceTimer = null;
this.$watch("deviceInfo.batteryPercentage", () => {
if (bleTool.isVoiceUploading && bleTool.isVoiceUploading()) {
if (this._batteryLowDebounceTimer) {
clearTimeout(this._batteryLowDebounceTimer);
this._batteryLowDebounceTimer = null;
}
return;
}
const n = Math.round(Number(this.deviceInfo.batteryPercentage));
if (!Number.isFinite(n)) return;
if (n > 20) {
this._lastBatteryLowToastPct = null;
if (this._batteryLowDebounceTimer) {
clearTimeout(this._batteryLowDebounceTimer);
this._batteryLowDebounceTimer = null;
}
return;
}
if (n <= 20 && this._lastBatteryLowToastPct !== n) {
this._lastBatteryLowToastPct = n;
if (this._batteryLowDebounceTimer) clearTimeout(this._batteryLowDebounceTimer);
this._batteryLowDebounceTimer = setTimeout(() => {
this._batteryLowDebounceTimer = null;
if (bleTool.isVoiceUploading && bleTool.isVoiceUploading()) return;
const cur = Math.round(Number(this.deviceInfo.batteryPercentage));
if (!Number.isFinite(cur) || cur > 20) return;
if (this._lastBatteryLowToastPct === cur) return;
this._lastBatteryLowToastPct = cur;
uni.showToast({
title: '设备电量低',
icon: 'none',
duration: 2000
});
}
}, 800);
});
eventChannel.on('detailData', function(data) {
var device = data.data;
@ -656,6 +674,10 @@
this.Status.pageHide = true;
},
onUnload() {
if (this._batteryLowDebounceTimer) {
clearTimeout(this._batteryLowDebounceTimer);
this._batteryLowDebounceTimer = null;
}
if (this._hby100jBleAdapterHandler && typeof uni.offBluetoothAdapterStateChange === 'function') {
uni.offBluetoothAdapterStateChange(this._hby100jBleAdapterHandler);
this._hby100jBleAdapterHandler = null;
@ -1035,11 +1057,11 @@
}
})
} else if (isVoiceOperate) {
console.log('我是谁');
let data = {
const data = {
deviceId: this.deviceInfo.deviceId,
voiceBroadcast: Number(this.formData.sta_VoiceType) === -1 ? 0 : 1
}
voiceBroadcast: Number(this.formData.sta_VoiceType) === -1 ? 0 : 1,
mode: this.formData.sta_VoiceType
};
deviceVoiceBroadcast(data).then((res) => {
if (res.code == 200) {
uni.showToast({
@ -1052,7 +1074,25 @@
icon: 'none'
});
}
})
}).catch(() => {
uni.showToast({ title: '下发失败,请检查蓝牙或网络', icon: 'none' });
});
} else {
// 非强制报警态下选择内置音色:原先仅改 UI 未下发,设备无播报
const data = {
deviceIds: [this.deviceInfo.deviceId],
voiceStrobeAlarm: 0,
mode: val
};
deviceForceAlarmActivation(data).then((res) => {
if (res.code === 200) {
uni.showToast({ title: res.msg || '已切换', icon: 'none' });
} else {
uni.showToast({ title: res.msg || '操作失败', icon: 'none' });
}
}).catch(() => {
uni.showToast({ title: '下发失败,请检查蓝牙或网络', icon: 'none' });
});
}
},
// 报警模式