From c03f7b47d0fdcee831c0faf059c026b029e71c5c Mon Sep 17 00:00:00 2001 From: chenzhihao <1798906853@qq.com> Date: Thu, 26 Mar 2026 11:11:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96BLVRQ=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8A=9F=E8=83=BD=E6=A0=87=E7=AD=BE=E5=92=8C=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 6 +- .../BluetoothDebugging/BLVRQPage/BLVRQPage.js | 84 ++++++--- .../BLVRQPage/BLVRQPage.json | 1 + .../BLVRQPage/BLVRQPage.wxml | 36 ++-- .../BLVRQPage/BLVRQPage.wxss | 160 +++++++++++++----- 5 files changed, 206 insertions(+), 81 deletions(-) diff --git a/app.json b/app.json index 8bf590e..e6eba92 100644 --- a/app.json +++ b/app.json @@ -1,10 +1,8 @@ { "pages": [ - - "pages/autho/index", + + "pages/autho/index", "pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage", - - "pages/basics/BluetoothDebugging/B13page/B13page", "pages/login/login", "pages/index/index", diff --git a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.js b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.js index e4f9c8c..d1fbe5f 100644 --- a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.js +++ b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.js @@ -1,5 +1,22 @@ const app = getApp() +const FUNCTION_LABELS = Array.from({ length: 16 }, (_, i) => { + switch (i) { + case 0x00: + return '不设置' + case 0x01: + return '普通按键' + case 0x02: + return '清理按键' + case 0x03: + return '投诉按键' + default: + return `功能${i}` + } +}) + +const KEY_BITMAPS = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80] + function ab2hex(buffer) { const view = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer || []) return Array.from(view).map(b => b.toString(16).padStart(2, '0').toUpperCase()).join(' ') @@ -78,18 +95,18 @@ function formatBleError(err) { } function createFunctionOptions() { - const names = { - 0x00: '不设置', - 0x01: '普通按键功能', - 0x02: '清理按键', - 0x03: '投诉按键' - } return Array.from({ length: 16 }, (_, i) => ({ code: i, - label: `${i}: ${names[i] || '无效'}` + label: `${i}: ${FUNCTION_LABELS[i] || '无效'}` })) } +function getFunctionOptionIndex(functionCode) { + const code = Number(functionCode || 0) & 0x0F + const index = createFunctionOptions().findIndex(item => item.code === code) + return index >= 0 ? index : 0 +} + function createKeys(count) { return Array.from({ length: count }, (_, i) => ({ hwIndex: i + 1, @@ -97,7 +114,10 @@ function createKeys(count) { mappedKeyIndex: i + 1, originalMappedKey: i + 1, functionCode: 0x01, - functionIndex: 1 + functionIndex: 1, + functionOptionIndex: getFunctionOptionIndex(0x01), + functionLabel: FUNCTION_LABELS[1], + mappedKeyLabel: `键值${i + 1}` })) } @@ -136,6 +156,7 @@ Page({ }, bleNameInput: '', canSetBleName: false, + bleNameFeatureEnabled: true, deviceInfo: { model: 'BLV_RQ', softwareVersion: '-', @@ -192,7 +213,7 @@ Page({ canOperateKeyConfig: false }) this.appendLog('CFG', `进入BLV_RQ页面:${devName}`) - this.updateSetBleNameState('') + this.updateSetBleNameState(devName) if (app.globalData && app.globalData.pendingBleNavigation && app.globalData.pendingBleNavigation.target === 'BLV_RQ') { app.globalData.pendingBleNavigation = null } @@ -249,7 +270,7 @@ Page({ }, updateSetBleNameState(value) { - const can = /^[A-Za-z0-9]{1,8}$/.test(value || '') && !!this.data.bleInfo.connected + const can = !!this.data.bleNameFeatureEnabled && /^[A-Za-z0-9]{1,8}$/.test(value || '') && !!this.data.bleInfo.connected this.setData({ bleNameInput: value, canSetBleName: can }) }, @@ -278,7 +299,9 @@ Page({ const keys = [...this.data.keyConfig.keys] if (!keys[index]) return keys[index].functionIndex = value + keys[index].functionOptionIndex = value keys[index].functionCode = this.data.functionOptions[value].code + keys[index].functionLabel = FUNCTION_LABELS[this.data.functionOptions[value].code] || FUNCTION_LABELS[0] this.setData({ 'keyConfig.keys': keys, 'keyConfig.keySlots': createKeySlots(keys) }) }, @@ -290,6 +313,10 @@ Page({ }, async onSetBleName() { + if (!this.data.bleNameFeatureEnabled) { + wx.showToast({ title: '功能暂未开放', icon: 'none' }) + return + } if (!this.data.canSetBleName) { wx.showToast({ title: '名称不合法', icon: 'none' }) return @@ -350,8 +377,8 @@ Page({ async onTriggerKey(e) { const index = Number(e.currentTarget.dataset.index) const item = this.data.keyConfig.keys[index] - if (!item || !item.mappedKey) { - wx.showToast({ title: '当前按键未配置映射', icon: 'none' }) + if (!item) { + wx.showToast({ title: '当前按键不存在', icon: 'none' }) return } const keyCount = Number(this.data.keyConfig.selectedKeyCount || 0) @@ -359,9 +386,9 @@ Page({ wx.showToast({ title: '请先选择按键类型', icon: 'none' }) return } - const bitmap = 1 << (item.mappedKey - 1) + const bitmap = KEY_BITMAPS[item.hwIndex - 1] || (1 << (item.hwIndex - 1)) this.setData({ keySendingIndex: index }) - await this.sendCommand(0x06, [keyCount, bitmap], `触发按键${item.hwIndex} -> 键值${item.mappedKey}(${keyCount}键)`) + await this.sendCommand(0x06, [1, bitmap], `点按按键${item.hwIndex} -> P1=0x${bitmap.toString(16).toUpperCase().padStart(2, '0')}`) this.setData({ keySendingIndex: -1 }) }, @@ -702,24 +729,39 @@ Page({ const count = Number(params[0] || 0) const safeCount = count > 0 && count <= 8 ? count : this.data.keyConfig.selectedKeyCount const keys = createKeys(safeCount) + const slotPatch = {} for (let i = 0; i < safeCount; i += 1) { const cfg = params[i + 1] || 0 - const mappedKey = cfg & 0x0F - const functionCode = (cfg >> 4) & 0x0F + const mappedKey = i + 1 + const functionCode = cfg & 0x0F + const functionOptionIndex = getFunctionOptionIndex(functionCode) keys[i].mappedKey = mappedKey || null keys[i].originalMappedKey = mappedKey || null keys[i].mappedKeyIndex = mappedKey || 0 keys[i].functionCode = functionCode - keys[i].functionIndex = functionCode + keys[i].functionIndex = functionOptionIndex + keys[i].functionOptionIndex = functionOptionIndex + keys[i].functionLabel = FUNCTION_LABELS[functionCode] || FUNCTION_LABELS[0] + keys[i].mappedKeyLabel = mappedKey ? `键值${mappedKey}` : '未配置' + slotPatch[`keyConfig.keySlots[${i}].functionIndex`] = functionOptionIndex + slotPatch[`keyConfig.keySlots[${i}].functionOptionIndex`] = functionOptionIndex + slotPatch[`keyConfig.keySlots[${i}].functionLabel`] = FUNCTION_LABELS[functionCode] || FUNCTION_LABELS[0] + slotPatch[`keyConfig.keySlots[${i}].mappedKey`] = mappedKey || null + slotPatch[`keyConfig.keySlots[${i}].mappedKeyIndex`] = mappedKey || 0 + slotPatch[`keyConfig.keySlots[${i}].mappedKeyLabel`] = mappedKey ? `键值${mappedKey}` : '未配置' } const keyTypeIndex = this.data.keyConfig.keyCountValues.indexOf(safeCount) + const nextKeyTypeIndex = keyTypeIndex >= 0 ? keyTypeIndex : 0 + const nextKeyCount = safeCount + const nextKeySlots = createKeySlots(keys) this.setData({ readingKeyConfig: false, - 'keyConfig.selectedKeyTypeIndex': keyTypeIndex >= 0 ? keyTypeIndex : 0, - 'keyConfig.selectedKeyCount': safeCount, + 'keyConfig.selectedKeyTypeIndex': nextKeyTypeIndex, + 'keyConfig.selectedKeyCount': nextKeyCount, 'keyConfig.keys': keys, - 'keyConfig.keySlots': createKeySlots(keys), - canOperateKeyConfig: true + 'keyConfig.keySlots': nextKeySlots, + canOperateKeyConfig: nextKeyCount > 0, + ...slotPatch }) if (count && count !== this.data.keyConfig.selectedKeyCount) { wx.showToast({ title: `已按设备返回${count}键修正`, icon: 'none' }) diff --git a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.json b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.json index 518243f..5faefbf 100644 --- a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.json +++ b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.json @@ -2,6 +2,7 @@ "navigationBarBackgroundColor": "#fff", "navigationBarTextStyle": "black", "navigationStyle": "custom", + "disableScroll": true, "usingComponents": { "cu-custom": "/colorui/components/cu-custom" } diff --git a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxml b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxml index e252c2b..5a3f2b9 100644 --- a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxml +++ b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxml @@ -10,8 +10,8 @@ 🔵 - 蓝牙名称: - {{bleInfo.devName || '-'}} + 蓝牙名称: + {{bleInfo.devName || '-'}} @@ -20,12 +20,12 @@ - 连接状态: + 连接状态: {{isConnecting ? '连接中' : (bleInfo.connected ? '已连接' : '未连接')}} - 信号强度: - {{bleInfo.signalText || '-'}} + 信号强度: + {{bleInfo.signalText || '-'}} @@ -38,8 +38,8 @@ - 蓝牙名称: - + 蓝牙名称: + @@ -52,12 +52,12 @@ - 软件版本: - {{deviceInfo.softwareVersion}} + 软件版本: + {{deviceInfo.softwareVersion}} - 硬件版本: - {{deviceInfo.hardwareVersion}} + 硬件版本: + {{deviceInfo.hardwareVersion}} @@ -83,11 +83,15 @@ - 按键{{item.hwIndex}} - - {{functionOptionLabels[item.functionIndex] || '请选择功能'}} - - + + 按键{{item.hwIndex}} + + + + + {{functionOptionLabels[item.functionOptionIndex] || '请选择功能'}} + + 预留{{item.hwIndex}} diff --git a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxss b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxss index b89d0d1..04333a7 100644 --- a/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxss +++ b/pages/basics/BluetoothDebugging/BLVRQPage/BLVRQPage.wxss @@ -71,7 +71,7 @@ page { } .panel-title { - font-size: 30rpx; + font-size: 34rpx; font-weight: 700; color: #0f172a; line-height: 1.2; @@ -113,6 +113,34 @@ page { flex: 1; } +.status-signal-row { + justify-content: space-between; +} + +.status-signal-row .status-cell, +.status-signal-row .signal-cell { + min-width: 0; +} + +.status-signal-row .status-cell { + flex: 0 0 180rpx; + width: 180rpx; +} + +.status-signal-row .signal-cell { + flex: 0 0 auto; + width: auto; + margin-left: auto; + justify-content: flex-end; +} + +.status-signal-row .signal-cell .cell-value.field-value-lg { + flex: 0 0 96rpx; + width: 96rpx; + min-width: 96rpx; + text-align: left; +} + .action-cell, .button-cell, .action-cell-inline { @@ -147,9 +175,36 @@ page { flex-shrink: 0; } -.software-version-cell .cell-value, -.hardware-version-cell .cell-value { - font-size: 24rpx; +.field-label-lg { + font-size: 34rpx; +} + +.field-value-lg { + font-size: 35rpx; +} + +.software-version-cell .cell-label.field-label-lg, +.hardware-version-cell .cell-label.field-label-lg, +.name-action-row .cell-label.field-label-lg, +.status-signal-row .cell-label.field-label-lg, +.firmware-row .cell-label.field-label-lg { + font-size: 34rpx; +} + +.software-version-cell .cell-value.field-value-lg, +.hardware-version-cell .cell-value.field-value-lg, +.name-action-row .cell-value.field-value-lg, +.status-signal-row .cell-value.field-value-lg, +.firmware-row .cell-value.field-value-lg { + font-size: 35rpx; +} + +.status-signal-row .cell-label.field-label-lg { + font-size: 32rpx; +} + +.status-signal-row .cell-value.field-value-lg { + font-size: 33rpx; } .key-type-cell { @@ -157,11 +212,11 @@ page { } .device-icon { - font-size: 30rpx; + font-size: 34rpx; } .cell-label { - font-size: 26rpx; + font-size: 30rpx; color: #606266; white-space: nowrap; display: inline-flex; @@ -171,7 +226,7 @@ page { .cell-value { flex: 1; min-width: 0; - font-size: 27rpx; + font-size: 31rpx; font-weight: 600; color: #333333; white-space: nowrap; @@ -184,14 +239,14 @@ page { .status-chip { min-width: 120rpx; height: 100%; - min-height: 48rpx; + min-height: 56rpx; align-self: stretch; padding: 0 12rpx; display: inline-flex; align-items: center; justify-content: center; border-radius: 10rpx; - font-size: 24rpx; + font-size: 32rpx; font-weight: 700; box-sizing: border-box; } @@ -218,13 +273,13 @@ page { flex: 1; min-width: 0; height: 100%; - min-height: 48rpx; + min-height: 56rpx; align-self: stretch; padding: 0 12rpx; background: #f7f8fa; border: 1rpx solid #e5e9f2; border-radius: 10rpx; - font-size: 24rpx; + font-size: 32rpx; box-sizing: border-box; } @@ -233,9 +288,9 @@ page { font-weight: 600; white-space: nowrap; padding: 0 12rpx; - font-size: 28rpx; + font-size: 32rpx; height: 100%; - min-height: 52rpx; + min-height: 60rpx; align-self: stretch; line-height: 1.2; display: flex; @@ -246,7 +301,7 @@ page { } .read-version-cell .action-btn { - font-size: 26rpx; + font-size: 30rpx; padding: 0 8rpx; } @@ -287,7 +342,7 @@ page { } .picker-view { - min-height: 48rpx; + min-height: 56rpx; height: 100%; align-self: stretch; padding: 0 12rpx; @@ -296,7 +351,7 @@ page { background: #f7f8fa; border: 1rpx solid #e5e9f2; border-radius: 10rpx; - font-size: 23rpx; + font-size: 27rpx; color: #0f172a; box-sizing: border-box; } @@ -338,10 +393,10 @@ page { gap: 0; padding: 0; background: #ffffff; - border: none; + border: 2rpx solid #cbd5e1; border-radius: 14rpx; box-sizing: border-box; - box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04); + box-shadow: 0 6rpx 14rpx rgba(15, 23, 42, 0.08); } .reserve-card { @@ -357,11 +412,26 @@ page { .key-card-content { width: 100%; display: flex; - align-items: center; - gap: 6rpx; + flex-direction: column; + align-items: stretch; + gap: 8rpx; min-width: 0; } +.key-card-top-row { + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + gap: 8rpx; +} + +.key-card-bottom-row { + width: 100%; + display: flex; + align-items: stretch; +} + .reserve-card-empty { width: 100%; min-height: 86rpx; @@ -371,21 +441,27 @@ page { } .reserve-card-text { - font-size: 24rpx; + font-size: 28rpx; color: #94a3b8; letter-spacing: 2rpx; } .inline-key-label { - min-width: 70rpx; - font-size: 22rpx; + flex: 1; + min-width: 0; + font-size: 26rpx; font-weight: 700; color: #0f172a; white-space: nowrap; } .inline-send-btn { - min-width: 104rpx; + min-width: 124rpx; + flex: 0 0 124rpx; +} + +.key-card-bottom-row .inline-key-picker { + width: 100%; } .dialog-btn { @@ -446,14 +522,14 @@ page { .log-time { color: #9aa0a6; - font-size: 22rpx; + font-size: 26rpx; font-family: inherit; white-space: nowrap; min-width: 78rpx; } .log-dir { - font-size: 22rpx; + font-size: 26rpx; font-family: inherit; font-weight: 700; white-space: nowrap; @@ -485,7 +561,7 @@ page { flex: 1; min-width: 0; color: #333333; - font-size: 24rpx; + font-size: 28rpx; line-height: 1.35; word-break: break-all; font-family: inherit; @@ -493,7 +569,7 @@ page { .log-text.packet { color: #333333; - font-size: 24rpx; + font-size: 28rpx; line-height: 1.45; font-family: inherit; word-break: break-all; @@ -505,7 +581,7 @@ page { .log-text.plain { color: #333333; - font-size: 24rpx; + font-size: 28rpx; line-height: 1.45; font-family: inherit; word-break: break-all; @@ -531,14 +607,14 @@ page { } .dialog-title { - font-size: 32rpx; + font-size: 36rpx; font-weight: 700; color: #1f2d3d; margin-bottom: 12rpx; } .dialog-content { - font-size: 26rpx; + font-size: 30rpx; color: #475467; line-height: 1.7; margin-bottom: 16rpx; @@ -583,14 +659,14 @@ page { } .keep-inline-row .cell-label { - font-size: 20rpx; + font-size: 24rpx; } .keep-inline-row .cell-value, .keep-inline-row .name-input, .keep-inline-row .picker-view, .keep-inline-row .inline-key-label { - font-size: 20rpx; + font-size: 24rpx; } .name-action-row .device-name-cell { @@ -645,16 +721,20 @@ page { } .status-signal-row .status-cell { - flex: 0 0 230rpx; + flex: 0 0 190rpx; + width: 190rpx; } .status-signal-row .signal-cell { - flex: 1; + flex: 0 0 auto; + width: auto; + margin-left: auto; + min-width: 0; } .keep-inline-row .action-btn, .keep-inline-actions .action-btn { - font-size: 24rpx; + font-size: 28rpx; } .name-action-row .action-btn, @@ -669,7 +749,7 @@ page { } .keep-inline-head .panel-title { - font-size: 30rpx; + font-size: 34rpx; } .read-version-cell { @@ -677,7 +757,7 @@ page { } .read-version-cell .action-btn { - font-size: 24rpx; + font-size: 28rpx; padding: 0; } @@ -706,10 +786,10 @@ page { } .log-time { - min-width: 74rpx; + min-width: 78rpx; } .log-dir { - min-width: 50rpx; + min-width: 54rpx; } }