diff --git a/pages/100J/HBY100-J.vue b/pages/100J/HBY100-J.vue index 7e0df3d..d5cafbf 100644 --- a/pages/100J/HBY100-J.vue +++ b/pages/100J/HBY100-J.vue @@ -173,10 +173,10 @@ 频率 - {{ formData.strobeFrequency }}HZ + {{ strobeFrequencySlider }}HZ - @@ -331,7 +331,7 @@ sta_VoiceType: '0', volume: 10, sta_LightType: '', - strobeFrequency: 0.5, + strobeFrequency: 1, lightBrightness: 10, sta_system: '', warnTime: 0, @@ -552,8 +552,9 @@ // 设备按键, app同步 } else if (funcType == '14') { // 调节亮度,音量,频率相关字段 - these.formData.strobeFrequency = led_strobe.frequency || - 0.5; //频率 + these.formData.strobeFrequency = these.normalizeStrobeFreq( + led_strobe.frequency != null ? led_strobe.frequency : 1 + ); these.formData.volume = volume || 10; //音量 these.formData.lightBrightness = brightness.red || 10; //亮度值 @@ -693,6 +694,10 @@ this.$nextTick(() => this.sync100JBleUiFromHelper()); }, computed: { + /** 与 slider min/max(1~10) 对齐;离线未拉到详情时避免 0.5 等非法值导致滑块渲染飞出 */ + strobeFrequencySlider() { + return this.normalizeStrobeFreq(this.formData.strobeFrequency); + }, getbleStatu() { if (this.formData.bleStatu === true) { return '已连接'; @@ -711,6 +716,15 @@ }, methods: { + /** 警示灯频率 UI:slider 为 1~10,与协议 0~12 取交集 */ + normalizeStrobeFreq(v) { + const n = Number(v); + if (!Number.isFinite(n)) return 1; + const r = Math.round(n); + if (r < 1) return 1; + if (r > 10) return 10; + return r; + }, /** 与 BleHelper 实际连接状态对齐(系统关蓝牙再开、从后台回前台等) */ sync100JBleUiFromHelper() { const mac = (this.device && this.device.deviceMac) || (this.deviceInfo && this.deviceInfo.deviceMac); @@ -796,6 +810,7 @@ }) ); Object.assign(this.formData, validData); + that.formData.strobeFrequency = that.normalizeStrobeFreq(that.formData.strobeFrequency); that.deviceInfo = res.data; that.$nextTick(() => that.sync100JBleUiFromHelper && that.sync100JBleUiFromHelper()); const strobeEnable = res.data.strobeEnable ?? 0; // 0=关闭,1=开启 @@ -1417,15 +1432,17 @@ else if (this.formData.sta_VoiceType === '7') this.formData.sta_VoiceType = '-1'; } if (parsedData.volume !== undefined) this.formData.volume = parsedData.volume; - if (parsedData.strobeFrequency !== undefined) this.formData.strobeFrequency = parsedData - .strobeFrequency; + if (parsedData.strobeFrequency !== undefined) { + this.formData.strobeFrequency = this.normalizeStrobeFreq(parsedData.strobeFrequency); + } if (parsedData.redBrightness !== undefined) this.formData.lightBrightness = parsedData .redBrightness; } // 0x09 音量、0x0D 亮度:单独响应时同步 if (fc === 0x09 && parsedData.volume !== undefined) this.formData.volume = parsedData.volume; - if (fc === 0x0B && parsedData.strobeFrequency !== undefined) this.formData.strobeFrequency = parsedData - .strobeFrequency; + if (fc === 0x0B && parsedData.strobeFrequency !== undefined) { + this.formData.strobeFrequency = this.normalizeStrobeFreq(parsedData.strobeFrequency); + } if (fc === 0x0D && parsedData.redBrightness !== undefined) this.formData.lightBrightness = parsedData .redBrightness; }, @@ -1932,6 +1949,9 @@ .slider-container { padding: 0px; + width: 100%; + overflow: hidden; + box-sizing: border-box; } .addIco {