From e0cef19da19d560f8724a62fecc6bb1ba3d3b43f Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Fri, 27 Mar 2026 11:24:30 +0800 Subject: [PATCH] =?UTF-8?q?100J=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 2 +- pages/100J/HBY100-J.vue | 56 +++++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/config/index.js b/config/index.js index cd10922..73af4ed 100644 --- a/config/index.js +++ b/config/index.js @@ -2,7 +2,7 @@ const config = { // 开发环境 development: { - BASE_URL: 'http://192.168.110.57:8000',//http://139.224.253.23:8000 + BASE_URL: 'http://192.168.2.34:8000',//http://139.224.253.23:8000 API_PREFIX: '', // MQTT 配置 MQTT_HOST: '47.120.79.150', diff --git a/pages/100J/HBY100-J.vue b/pages/100J/HBY100-J.vue index dc2514b..c73f7f4 100644 --- a/pages/100J/HBY100-J.vue +++ b/pages/100J/HBY100-J.vue @@ -607,6 +607,8 @@ // 开启状 these.deviceInfo.voiceStrobeAlarm = 1; these.formData.sta_VoiceType = mode_alarm + '' + } else if (mode_alarm == 7) { + these.formData.sta_VoiceType !== 7 } else { // 关闭状态:赋值-1,表示关闭 these.deviceInfo.voiceStrobeAlarm = -1; @@ -771,7 +773,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'; }); @@ -809,7 +813,7 @@ // 关闭状态 that.formData.sta_LightType = '-1'; } - if (this.formData.sta_VoiceType === '7' || this.formData.sta_VoiceType === 7) { + if (this.formData.sta_VoiceType === '7' || res.data.alarmMode == 7) { this.formData.sta_VoiceType = (res.data.voiceStrobeAlarm ?? 0) + ''; } else { this.formData.sta_VoiceType = res.data.alarmMode + '' @@ -1028,18 +1032,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 }; @@ -1055,7 +1059,7 @@ icon: 'none' }); } - }) + }); } else if (isVoiceOperate) { const data = { deviceId: this.deviceInfo.deviceId, @@ -1075,25 +1079,38 @@ }); } }).catch(() => { - uni.showToast({ title: '下发失败,请检查蓝牙或网络', icon: 'none' }); + uni.showToast({ + title: '下发失败,请检查蓝牙或网络', + icon: 'none' + }); }); - } else { - // 非强制报警态下选择内置音色:原先仅改 UI 未下发,设备无播报 + } else if (prevVoiceType === '7' && val !== '7' && val !== '-1') { + // 从「播放语音」切到其它内置音色:先关播报;报警未开启时不走 forceAlarm,仅 UI 预选音色 const data = { - deviceIds: [this.deviceInfo.deviceId], - voiceStrobeAlarm: 0, + deviceId: this.deviceInfo.deviceId, + voiceBroadcast: 0, mode: val }; - deviceForceAlarmActivation(data).then((res) => { - if (res.code === 200) { - uni.showToast({ title: res.msg || '已切换', icon: 'none' }); + deviceVoiceBroadcast(data).then((res) => { + if (res.code == 200) { + uni.showToast({ + title: res.msg || '已切换', + icon: 'none' + }); } else { - uni.showToast({ title: res.msg || '操作失败', icon: 'none' }); + uni.showToast({ + title: res.msg || '操作失败', + icon: 'none' + }); } }).catch(() => { - uni.showToast({ title: '下发失败,请检查蓝牙或网络', icon: 'none' }); + uni.showToast({ + title: '下发失败,请检查蓝牙或网络', + icon: 'none' + }); }); } + // 未开启强制报警时,在 0–6 内置音色间切换或取消选中:只改按钮选中,不下发 }, // 报警模式 sosSetting(item) { @@ -1280,7 +1297,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; },