Merge branch 'new-20250827' of http://47.107.152.87:3000/liubiao/APP into new-20250827
# Conflicts: # pages/common/index/index.vue
This commit is contained in:
@ -64,7 +64,7 @@
|
||||
<view class="info-value status-running">
|
||||
{{ deviceInfo && deviceInfo.longitude ? Number(deviceInfo.longitude).toFixed(4) : '' }}
|
||||
{{ deviceInfo && deviceInfo.latitude ? Number(deviceInfo.latitude).toFixed(4) : '' }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="info-value status-running locationGPS">
|
||||
<uni-icons type="location" size="17" color="rgba(255, 255, 255, 0.8)"
|
||||
style="vertical-align: bottom;" />
|
||||
@ -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;
|
||||
@ -552,13 +570,12 @@
|
||||
// 报警模式,选中,首次上报值,或者切换设备按键上报值
|
||||
const enable = siren_alarm.enable ?? 0; // 报警开关:1=开,0=关
|
||||
const mode = siren_alarm.mode ?? 0; // 模式:0/1/2/3/4/5/6
|
||||
if (these.formData.sta_VoiceType != 7) {
|
||||
if (String(these.formData.sta_VoiceType) !== '7') {
|
||||
if (enable === 1) {
|
||||
// 开启状态
|
||||
these.formData.sta_VoiceType = mode + '';
|
||||
} else {
|
||||
// 关闭状态:赋值-1,表示关闭
|
||||
these.formData.sta_VoiceType = mode + '';
|
||||
const m = Number(mode);
|
||||
these.formData.sta_VoiceType = m === 7 ? '-1' : m + '';
|
||||
}
|
||||
} else {
|
||||
// 播放语音,上报消息
|
||||
@ -582,18 +599,15 @@
|
||||
}
|
||||
// 强制报警按键解除报警状态,app同步
|
||||
} else if (funcType === '12') {
|
||||
const enable_alarm = data.voice_strobe_alarm ??
|
||||
0; // 报警开关:1=开,0=关
|
||||
const mode_alarm = data.mode ?? 0; // 模式:0/1/2/3/4/5/6
|
||||
const enable_alarm = data.voice_strobe_alarm ?? 0;
|
||||
const mode_alarm = data.mode ?? 0;
|
||||
if (enable_alarm === 1) {
|
||||
// 开启状
|
||||
these.deviceInfo.voiceStrobeAlarm = 1;
|
||||
these.formData.sta_VoiceType = mode_alarm + ''
|
||||
these.formData.sta_VoiceType = mode_alarm + '';
|
||||
} else {
|
||||
// 关闭状态:赋值-1,表示关闭
|
||||
these.deviceInfo.voiceStrobeAlarm = -1;
|
||||
// 模式还是选中的,模式,解除也是
|
||||
these.formData.sta_VoiceType = mode_alarm + ''
|
||||
const m = Number(mode_alarm);
|
||||
these.formData.sta_VoiceType = m === 7 ? '-1' : m + '';
|
||||
}
|
||||
}
|
||||
// 警示灯模式选中切换
|
||||
@ -656,6 +670,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;
|
||||
@ -749,7 +767,9 @@
|
||||
this.formData.bleStatu = 'connecting';
|
||||
bleTool.LinkBlue(f.deviceId, f.writeServiceId, f.wirteCharactId, f.notifyCharactId).then(() => {
|
||||
this.formData.bleStatu = true;
|
||||
this.bleStateRecovry({ deviceId: f.deviceId });
|
||||
this.bleStateRecovry({
|
||||
deviceId: f.deviceId
|
||||
});
|
||||
}).catch(() => {
|
||||
this.formData.bleStatu = 'err';
|
||||
});
|
||||
@ -787,10 +807,12 @@
|
||||
// 关闭状态
|
||||
that.formData.sta_LightType = '-1';
|
||||
}
|
||||
if (this.formData.sta_VoiceType === '7' || this.formData.sta_VoiceType === 7) {
|
||||
this.formData.sta_VoiceType = (res.data.voiceStrobeAlarm ?? 0) + '';
|
||||
const alarmOnDetail = res.data.voiceStrobeAlarm === 1;
|
||||
const amDetail = res.data.alarmMode != null ? Number(res.data.alarmMode) : 0;
|
||||
if (alarmOnDetail) {
|
||||
this.formData.sta_VoiceType = amDetail + '';
|
||||
} else {
|
||||
this.formData.sta_VoiceType = res.data.alarmMode + ''
|
||||
this.formData.sta_VoiceType = amDetail === 7 ? '-1' : amDetail + '';
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -1006,18 +1028,18 @@
|
||||
item = this.dic.sta_VoiceType[index];
|
||||
}
|
||||
let val = item.key;
|
||||
const prevVoiceType = this.formData.sta_VoiceType;
|
||||
if (this.formData.sta_VoiceType === val) {
|
||||
val = '-1';
|
||||
}
|
||||
this.formData.sta_VoiceType = val;
|
||||
// 模式类型为7时才去判断
|
||||
console.log(val, 'valllll');
|
||||
const isVoiceOperate = val === '7' || val === '-1'; // 标记是否是语音开启/关闭操作
|
||||
if (this.deviceInfo.voiceStrobeAlarm == 1) {
|
||||
// 如果强制报警已经开启了,那么切换下面的模式需要时,需要触发报警指令
|
||||
// 仅「播放语音」7 的开关走播报接口;-1 只有从 7 取消时才视为关播报,避免取消内置音色选中误调播报接口
|
||||
const isVoiceOperate = val === '7' || (val === '-1' && prevVoiceType === '7');
|
||||
if (this.deviceInfo.voiceStrobeAlarm === 1) {
|
||||
// 强制报警已开启:切换下方模式需带报警下发
|
||||
const data = {
|
||||
deviceIds: [this.deviceInfo.deviceId],
|
||||
// 声光报警开关开启传1
|
||||
voiceStrobeAlarm: 1,
|
||||
mode: this.formData.sta_VoiceType
|
||||
};
|
||||
@ -1033,13 +1055,14 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
} 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,
|
||||
voiceStrobeAlarm: this.deviceInfo.voiceStrobeAlarm
|
||||
};
|
||||
deviceVoiceBroadcast(data).then((res) => {
|
||||
if (res.code == 200) {
|
||||
uni.showToast({
|
||||
@ -1052,14 +1075,55 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
uni.showToast({
|
||||
title: '下发失败,请检查蓝牙或网络',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
} else if (prevVoiceType === '7' && val !== '7' && val !== '-1') {
|
||||
// 从「播放语音」切到其它内置音色:先关播报;报警未开启时不走 forceAlarm,仅 UI 预选音色
|
||||
const data = {
|
||||
deviceId: this.deviceInfo.deviceId,
|
||||
voiceBroadcast: 0,
|
||||
mode: val,
|
||||
voiceStrobeAlarm: this.deviceInfo.voiceStrobeAlarm
|
||||
};
|
||||
deviceVoiceBroadcast(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'
|
||||
});
|
||||
});
|
||||
}
|
||||
// 未开启强制报警时,在 0–6 内置音色间切换或取消选中:只改按钮选中,不下发
|
||||
},
|
||||
// 报警模式
|
||||
sosSetting(item) {
|
||||
console.log(this.deviceInfo, '44444');
|
||||
console.log(item, 'tent');
|
||||
const isClose = item === 0;
|
||||
// 与「已解除不再重复关报警」对称:已在报警中不再弹窗重复下发「开启」,未报警时不再重复「解除」
|
||||
if (!isClose && this.deviceInfo.voiceStrobeAlarm === 1) {
|
||||
uni.showToast({ title: '当前已在报警中', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (isClose && this.deviceInfo.voiceStrobeAlarm !== 1) {
|
||||
uni.showToast({ title: '当前未在报警中', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!this.Status) this.Status = {};
|
||||
if (!this.Status.Pop) this.Status.Pop = {
|
||||
showPop: false
|
||||
@ -1089,7 +1153,8 @@
|
||||
title: isClose ? '声光报警已解除' : '强制报警已开启',
|
||||
icon: 'none'
|
||||
});
|
||||
if (isClose && this.formData.sta_VoiceType === '7') {
|
||||
// 解除后「播放语音」行与 mode7 绑定,需退出高亮(兼容 sta_VoiceType 为数字 7)
|
||||
if (isClose && String(this.formData.sta_VoiceType) === '7') {
|
||||
this.formData.sta_VoiceType = '-1';
|
||||
}
|
||||
} else {
|
||||
@ -1240,7 +1305,8 @@
|
||||
const last6 = target.slice(-6);
|
||||
const item = bleTool.data.LinkedList.find((v) => {
|
||||
const m = macNorm(v.macAddress || '');
|
||||
return v.deviceId === res.deviceId && (m === target || (m.length >= 6 && m.slice(-6) === last6));
|
||||
return v.deviceId === res.deviceId && (m === target || (m.length >= 6 && m.slice(-6) ===
|
||||
last6));
|
||||
});
|
||||
return !!item;
|
||||
},
|
||||
@ -1314,7 +1380,9 @@
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
} else {
|
||||
this.$set(this.deviceInfo, 'voiceStrobeAlarm', -1);
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
const am = Number(parsedData.alarmMode ?? 0);
|
||||
// 报警已关:设备仍可能带 mode7,避免「播放语音」仍显示为开启
|
||||
this.formData.sta_VoiceType = am === 7 ? '-1' : am + '';
|
||||
}
|
||||
}
|
||||
// 0x0A 爆闪模式:警示灯开关/模式
|
||||
@ -1340,7 +1408,8 @@
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
} else {
|
||||
this.$set(this.deviceInfo, 'voiceStrobeAlarm', -1);
|
||||
this.formData.sta_VoiceType = (parsedData.alarmMode ?? 0) + '';
|
||||
const am = Number(parsedData.alarmMode ?? 0);
|
||||
this.formData.sta_VoiceType = am === 7 ? '-1' : am + '';
|
||||
}
|
||||
}
|
||||
if (parsedData.voiceBroadcast !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user