比较提交

..
11 次代码提交
作者 SHA1 备注 提交日期
Guoguo edf15eb32a docs: fix stale region-layout comments to match measured mapping 2026-07-28 07:26:29 -07:00
Guoguo 21dccd2274 fix(mapping): correct region↔IO mapping per on-device measurement
Measured on real hardware: IO1=right IO2=left IO3=top IO4=middle IO5=bottom
(0x01=right 0x02=left 0x04=top 0x08=middle 0x10=bottom). The earlier verbal
'left=IO1/upper=IO2...' spec was wrong; this reverts to the original Phase-1
mapping, which the measurement confirms.

- protocol.js REGION constants + getRegionName + REGION_NAMES
- CRITICAL: buildVendorCommand ioMasks was built from REGION.* constants whose
  values just flipped, scrambling IO slot order; pin to literal [0x01..0x10]
- diagnosis.js REGION_DEFS key↔mask; pd_region_map values unchanged (PD is
  keyed by orientation, which is stable) — right=PD5 left=PD1 top=PD2
  middle=PD3,6,7 bottom=PD4
- common.js region labels back to right/left/top/middle/bottom (上/中/下)
- treatment-setup / manual-treatment / treating / scan-report / ble-debug
  face-map bindings and REGION_MAP realigned
- verified: mock pipeline lands left→IO2, middle→IO4 correctly
2026-07-28 07:22:36 -07:00
Guoguo 74b0c5fa86 feat(debug): temporary BLE debug page for on-device verification
- entry in profile menu, visible only while a device is connected
- live FFE4 readout: 7x PD, VBAT, fitting, scan wave marker, run state
- tap a face-map region to fire a 2s single-region treat command
  (verifies region-to-IO mapping on the physical mask)
- wavelength selector (red/ir/uv/yellow) to verify color byte order
- scan command / full-face 2s / stop buttons, hex log of every write
- intentionally not i18n'd; remove page before release
2026-07-28 06:58:03 -07:00
Guoguo c0de0b03a2 fix(ui): show manual care entry only when smart mode is selected 2026-07-28 06:47:36 -07:00
Guoguo 431d4058a8 feat(ui): use face-map layout for report zones and manual region picker; restrict manual care to smart mode
- scan-report: replace zone card grid with the same oval face-map layout as
  treatment-setup, zones tinted by recommended light with mode label; restore
  the per-light legend under the map
- manual-treatment: region picker now uses the same face-map layout
- manual care mode selection is smart-mode only: entry link hidden for
  non-subscribers and the page itself checks subscription (free mode passes
  since the backend reports it as active)
2026-07-28 06:44:34 -07:00
Guoguo 39177e5ff4 ui: 报告分区/手动区域选择改用「使用设置」同款卡片栅格布局(弃面罩大矩形);修复使用设置脸型图label-idx错位 2026-07-28 06:35:37 -07:00
Guoguo 9745b6d7b8 chore: 版本号 v0.2.0 → v0.2.1 2026-07-28 06:24:21 -07:00
Guoguo 88ca7dec6b feat: 治疗亮度全路径统一204(80%)——手动模式140与普通模式200一并对齐 2026-07-28 05:01:05 -07:00
Guoguo dff82a6a82 feat(diagnosis): 回填固件确认的PD区域映射(左PD1/中上PD2/中PD3,6,7/中下PD4/右PD5) 2026-07-28 04:58:48 -07:00
Guoguo a67a7357cf chore(sql): 增量迁移脚本 scan_reports建表+diagnosis_config新种子(幂等) 2026-07-28 04:48:24 -07:00
Guoguo 6b91ebe35d feat(diagnosis): 按新协议实现多光谱诊断算法+分区差异化下发+报告面罩图
- 新协议《协议简述-添加扫描时光色》落地: FFE4 Byte17 高3位=扫描光色(1红/2红外/3紫外/4暖黄),
  低5位保留贴合状态; Byte18=0xFF 故障; auto-scan 按光色分桶采集(旧固件无标识归 red 桶降级)
- diagnosis.js 重写: PD极性(值大=吸收多,固件已确认) NR=本区/本色5区平均-1;
  每区4色argmax>0.10判定; 3路PD区几何平均+MAD剔奇异(3σ对n=3失效,审计实证);
  严重度0.05/0.15/0.30仅展示; 全参数走 diagnosis_config 热调(极性/阈值/PD映射/亮度)
- buildVendorCommand 支持 plan 多区多色单命令下发(每IO独立 红/红外/紫外/暖黄);
  builder层安全硬上限 治疗亮度≤204(80%) 时长≤600s
- 区域映射修正: 掩码=IO纵列 左0x01/中上0x02/中0x04/中下0x08/右0x10,
  修复 treatment-setup/manual/treating/getRegionName/i18n 共7处标签错位, FULL_FACE 0x7F→0x1F
- 扫描报告页: 新增分区面罩示意图(5区按推荐光着色+模式名+严重度,点击跳光疗介绍),
  推荐护理改一条命令多色下发(亮度204); 扫描中设备故障即时中止
- schema.sql diagnosis_config 种子更新(新结构); i18n 清理死键,中英对齐25/24键
2026-07-28 04:36:51 -07:00
修改 31 个文件,包含 782 行新增248 行删除
二进制文件未显示。
+3 -2
查看文件
@@ -20,7 +20,8 @@
"pages/contact/contact",
"pages/light-info/light-info",
"pages/manual-treatment/manual-treatment",
"pages/scan-report/scan-report"
"pages/scan-report/scan-report",
"pages/ble-debug/ble-debug"
],
"window": {
"navigationBarBackgroundColor": "#ffffff",
@@ -65,4 +66,4 @@
],
"style": "v2",
"sitemapLocation": "sitemap.json"
}
}
+2
查看文件
@@ -17,6 +17,7 @@ module.exports = {
doneStatusPost: ' 帧),正在启动治疗...',
notWorn: '面膜未佩戴好,请重新佩戴后再试',
timeout: '检测超时,未收到数据,请重试',
deviceFault: '设备异常,扫描已停止,请重启设备后再试',
cmdFailed: '检测命令发送失败'
},
en: {
@@ -35,6 +36,7 @@ module.exports = {
doneStatusPost: ' frames), starting treatment...',
notWorn: 'The mask is not worn properly. Please re-fit and try again',
timeout: 'Scan timed out with no data. Please try again',
deviceFault: 'Device error — scan stopped. Please restart the device and try again',
cmdFailed: 'Failed to send scan command'
}
}
+2
查看文件
@@ -18,6 +18,8 @@ module.exports = {
saveFailed: '保存失败',
networkError: '网络异常,请重试',
deviceNotConnected: '设备未连接',
// 区域 = IO↔物理位置(实测):right=IO1(0x01) left=IO2(0x02) top=IO3(0x04)
// middle=IO4(0x08) bottom=IO5(0x10)。语义以掩码为准。
regions: {
right: '右区',
left: '左区',
+4 -2
查看文件
@@ -19,7 +19,8 @@ module.exports = {
starting: '启动中...',
noRegionSelected: '请至少选择一个区域',
startFailed: '启动失败',
entryLink: '手动选择波长护理 '
entryLink: '手动选择波长护理 ',
smartOnly: '手动选择护理模式为智能模式专属,开通订阅后即可使用'
},
en: {
navTitle: 'Manual Care',
@@ -39,6 +40,7 @@ module.exports = {
starting: 'Starting...',
noRegionSelected: 'Please select at least one region',
startFailed: 'Failed to start',
entryLink: 'Manual wavelength care '
entryLink: 'Manual wavelength care ',
smartOnly: 'Choosing a care mode manually is a Smart Mode feature. Subscribe to unlock it.'
}
}
+16 -12
查看文件
@@ -5,6 +5,9 @@ module.exports = {
subtitle: '基于多光谱反射的肤质倾向参考',
scannedAt: '扫描时间',
overallTitle: '整体倾向',
faceTitle: '分区光疗方案',
faceTapHint: '点击分区可查看该光的功效介绍',
allNormalHint: '未发现明显问题区域,可进行日常舒缓养护',
regionTitle: '分区分析',
recommendTitle: '推荐护理',
noProblem: '未见明显倾向',
@@ -19,12 +22,11 @@ module.exports = {
pigment: '色素 / 暗黄',
deep: '深层循环 / 疲劳'
},
regionNames: {
right: '右脸',
left: '左脸',
top: '额头',
middle: '鼻区',
bottom: '下巴'
modeNames: {
red: '嫩肤焕亮',
ir: '深层焕活',
uv: '净痘控油',
yellow: '匀净提亮'
}
},
en: {
@@ -32,6 +34,9 @@ module.exports = {
subtitle: 'Skin-tendency reference from multispectral reflection',
scannedAt: 'Scanned at',
overallTitle: 'Overall Tendency',
faceTitle: 'Zone Care Map',
faceTapHint: 'Tap a zone to learn about its light',
allNormalHint: 'No notable concerns found — a gentle daily care session works well',
regionTitle: 'Zone Analysis',
recommendTitle: 'Recommended Care',
noProblem: 'No notable tendency',
@@ -46,12 +51,11 @@ module.exports = {
pigment: 'Pigment / Sallowness',
deep: 'Deep circulation / Fatigue'
},
regionNames: {
right: 'Right cheek',
left: 'Left cheek',
top: 'Forehead',
middle: 'Nose',
bottom: 'Chin'
modeNames: {
red: 'Glow & Firm',
ir: 'Deep Revive',
uv: 'Clear & Balance',
yellow: 'Even & Brighten'
}
}
}
-4
查看文件
@@ -7,8 +7,6 @@ module.exports = {
smartMode: '✨ 智能模式',
normalMode: '🔄 普通模式',
allRegions: '全区域',
regionTopLeft: '左上区',
regionTopRight: '右上区',
relax1: '请放松心情',
relax2: '享受美好时光',
stopBtn: '停止使用',
@@ -35,8 +33,6 @@ module.exports = {
smartMode: '✨ Smart Mode',
normalMode: '🔄 Normal Mode',
allRegions: 'All regions',
regionTopLeft: 'Top-left',
regionTopRight: 'Top-right',
relax1: 'Relax and unwind',
relax2: 'Enjoy your moment',
stopBtn: 'Stop',
+45 -19
查看文件
@@ -51,7 +51,8 @@ Page({
return
}
self._pdSum = [0, 0, 0, 0, 0, 0, 0]
// 按扫描光色分桶累加(FFE4 Byte17 高三位,新协议)。旧固件无标识 → 全部归 red 桶。
self._buckets = {}
self._frameCount = 0
self._completed = false
self._collecting = false
@@ -81,6 +82,15 @@ Page({
self._lastRunState = data.run_state
}
// 设备故障(Byte18=0xFF):立即中止,不等 3 分钟超时
if (data.run_state === 0xFF) {
console.error('[SCAN] 设备故障,中止扫描')
self._completed = true
self._cleanup()
self.setData({ phase: 'ready', error: i18n.t('autoScan.deviceFault') })
return
}
if (data.run_state === 1) {
self._seenRunState1 = true
}
@@ -110,10 +120,17 @@ Page({
if (self._completed || !self._collecting) return
if (!data || !data.pd || data.pd.length < 7) return
self._frameCount++
for (var i = 0; i < 7; i++) {
self._pdSum[i] += data.pd[i]
var wave = data.scan_wave || 'red' // 旧固件帧无光色标识,按单波长红光兼容
var bucket = self._buckets[wave]
if (!bucket) {
bucket = { sum: [0, 0, 0, 0, 0, 0, 0], n: 0 }
self._buckets[wave] = bucket
}
bucket.n++
for (var i = 0; i < 7; i++) {
bucket.sum[i] += data.pd[i]
}
self._frameCount++
self.setData({
frameCount: self._frameCount,
vbat: data.vbat || self.data.vbat,
@@ -155,28 +172,35 @@ Page({
this._completed = true
this._cleanup()
var avg = []
var count = this._frameCount || 1
for (var i = 0; i < 7; i++) {
avg.push(Math.round(this._pdSum[i] / count))
// 每个光色桶各自求平均 → waves: { red:[7], ir:[7], uv:[7], yellow:[7] }(有几色算几色)
var waves = {}
var firstAvg = []
for (var wave in this._buckets) {
if (!this._buckets.hasOwnProperty(wave)) continue
var b = this._buckets[wave]
if (!b.n) continue
var avg = []
for (var i = 0; i < 7; i++) avg.push(Math.round(b.sum[i] / b.n))
waves[wave] = avg
if (!firstAvg.length) firstAvg = avg
}
this.setData({ phase: 'done', pdAvg: avg, frameCount: count })
getApp().globalData.lastScanPdAvg = avg
console.log('[SCAN] PD平均值:', avg, '帧数:', count)
this.setData({ phase: 'done', pdAvg: firstAvg, frameCount: this._frameCount })
getApp().globalData.lastScanPdAvg = firstAvg
console.log('[SCAN] 分桶结果:', JSON.stringify(Object.keys(waves).map(function (k) { return k })), '帧数:', this._frameCount)
this._buildAndGoReport(avg)
this._buildAndGoReport(waves)
},
// Scan finished -> run the (placeholder) diagnosis, store + persist a report, and
// navigate to the report page so the user sees their skin tendencies and chooses
// care. This replaces the previous auto-start-treatment behavior.
//
// NOTE: today only single-wavelength red PD is collected, and the thresholds +
// PD->region mapping in services/diagnosis.js are placeholders pending calibration.
// Report + persistence work end to end regardless; the numbers get real after
// 4-wavelength scan collection and calibration land.
_buildAndGoReport: function (avg) {
// NOTE: thresholds + PD->region mapping in services/diagnosis.js are placeholders
// pending hardware confirmation / calibration (tunable via server diagnosis_config).
// Old firmware sends no wave marker -> everything lands in the red bucket and the
// pipeline degrades to single-wavelength gracefully.
_buildAndGoReport: function (waves) {
var self = this
var app = getApp()
var mask = self.data.regions || 0x1F
@@ -185,7 +209,7 @@ Page({
var scannedAt = Date.now()
function proceed(config) {
var scanData = diagnosis.fromRedScan(avg, mask, deviceId, scannedAt)
var scanData = diagnosis.buildScanData(waves, mask, deviceId, scannedAt)
var report = diagnosis.analyze(scanData, config || diagnosis.DEFAULT_CONFIG)
app.globalData.lastScanReport = report
@@ -205,7 +229,9 @@ Page({
}
api.getDiagnosisConfig().then(function (cfg) {
proceed(cfg && cfg.levels ? cfg : diagnosis.DEFAULT_CONFIG)
// 非空对象即采用——缺失字段由 analyze 逐项回退 DEFAULT;只发部分字段(如仅调 pd_region_map)也生效
var usable = cfg && typeof cfg === 'object' && Object.keys(cfg).length > 0
proceed(usable ? cfg : diagnosis.DEFAULT_CONFIG)
}).catch(function () {
proceed(diagnosis.DEFAULT_CONFIG)
})
+130
查看文件
@@ -0,0 +1,130 @@
// TEMPORARY debug page for on-device verification (region↔IO mapping, color byte
// order, scan wave bucketing, PD polarity). Guoguo-only tooling — intentionally
// NOT i18n'd; remove this page before any release build.
var ble = require('../../services/ble')
var protocol = require('../../services/ble/protocol')
var WAVES = [
{ key: 'red', code: 2, label: '红光' },
{ key: 'ir', code: 1, label: '红外' },
{ key: 'uv', code: 3, label: '紫外' },
{ key: 'yellow', code: 4, label: '暖黄' }
]
var REGION_LABELS = { 1: '右区/IO1', 2: '左区/IO2', 4: '上区/IO3', 8: '中区/IO4', 16: '下区/IO5' }
var RUN_STATES = { 0: 'IDLE', 1: '检测', 2: '治疗', 255: '故障(0xFF)' }
function hex(bytes) {
return bytes.map(function (b) { return ('0' + b.toString(16)).slice(-2).toUpperCase() }).join(' ')
}
Page({
data: {
statusBarHeight: 44,
connected: false,
waves: WAVES,
selectedWave: 'red',
// live FFE4 status
pd: [], vbat: 0, battery: 0, fitting: -1, scanWave: '-', runState: '-', frames: 0,
logs: []
},
onLoad: function () {
this.setData({ statusBarHeight: getApp().globalData.statusBarHeight })
},
onShow: function () {
var self = this
self.setData({ connected: ble.isConnected() })
self._onAdc = function (d) {
self.setData({
pd: d.pd || [],
vbat: d.vbat || 0,
battery: d.battery || 0,
fitting: d.fitting,
scanWave: d.scan_wave || '-',
runState: RUN_STATES[d.run_state] !== undefined ? RUN_STATES[d.run_state] : String(d.run_state),
frames: self.data.frames + 1
})
}
ble.on('adc', self._onAdc)
},
onHide: function () { this._cleanup() },
onUnload: function () { this._cleanup() },
_cleanup: function () {
if (this._onAdc) { ble.off('adc', this._onAdc); this._onAdc = null }
},
onBack: function () {
wx.navigateBack({ fail: function () { wx.switchTab({ url: '/pages/profile/profile' }) } })
},
_log: function (msg) {
var logs = this.data.logs
logs.unshift(new Date().toTimeString().slice(0, 8) + ' ' + msg)
if (logs.length > 20) logs.pop()
this.setData({ logs: logs })
},
_send: function (label, options) {
var self = this
if (!ble.isConnected()) {
self.setData({ connected: false })
wx.showToast({ title: '设备未连接', icon: 'none' })
return
}
var bytes = protocol.buildVendorCommand(options)
self._log(label)
self._log('→ ' + hex(bytes))
ble.setParams(options).then(function () {
self._log('✓ 写入成功')
}).catch(function (err) {
self._log('✗ 写入失败: ' + ((err && err.msg) || JSON.stringify(err)))
})
},
onSelectWave: function (e) {
this.setData({ selectedWave: e.currentTarget.dataset.key })
},
_waveCode: function () {
var key = this.data.selectedWave
for (var i = 0; i < WAVES.length; i++) if (WAVES[i].key === key) return WAVES[i].code
return 2
},
// 点脸型图分区:该区 2 秒治疗(验证物理位置对不对)
onTapRegion: function (e) {
var mask = parseInt(e.currentTarget.dataset.mask)
this._send('治疗 2s ' + REGION_LABELS[mask] + ' ' + this.data.selectedWave, {
region_mask: mask, wavelength: this._waveCode(), brightness: 204,
hold_time: 2, control: 0x02
})
},
// 检测指令(与 auto-scan 同参:红光 128 全脸,设备自跑序贯扫描)
onScanCmd: function () {
this._send('检测指令 control=0x01', {
region_mask: 0x1F, wavelength: 2, brightness: 128,
hold_time: 0, control: 0x01
})
},
// 全脸当前波长 2 秒
onTreatAll: function () {
this._send('治疗 2s 全脸 ' + this.data.selectedWave, {
region_mask: 0x1F, wavelength: this._waveCode(), brightness: 204,
hold_time: 2, control: 0x02
})
},
// 停止 / IDLE
onStop: function () {
var self = this
self._log('停止 → IDLE 全零帧')
ble.stopTreatment().then(function () { self._log('✓ 已停止') })
.catch(function (err) { self._log('✗ 停止失败: ' + ((err && err.msg) || '')) })
},
onClearLog: function () { this.setData({ logs: [], frames: 0 }) }
})
@@ -0,0 +1,4 @@
{
"navigationStyle": "custom",
"navigationBarTitleText": "调试工具"
}
@@ -0,0 +1,65 @@
<!-- 临时调试页:真机联调用(区域/波长/极性/分桶验证),上线前移除,不走 i18n -->
<view class="page">
<view class="page-header page-header-gradient" style="padding-top: {{statusBarHeight + 8}}px;">
<view class="nav-back nav-back-light" bindtap="onBack"> 返回</view>
<view class="page-header-title">调试工具(临时)</view>
<view class="page-header-subtitle">{{connected ? '设备已连接' : '设备未连接'}}</view>
</view>
<view class="page-content">
<!-- 实时状态 -->
<view class="card">
<view class="card-title">FFE4 实时状态 <text class="frames">({{frames}} 帧)</text></view>
<view class="pd-row">
<view class="pd-cell" wx:for="{{pd}}" wx:key="*this">
<view class="pd-idx">PD{{index + 1}}</view>
<view class="pd-val">{{item}}</view>
</view>
</view>
<view class="status-row">
<text>VBAT {{vbat}}mV ({{battery}}%)</text>
<text>贴合 {{fitting}}</text>
<text>光色 {{scanWave}}</text>
<text>状态 {{runState}}</text>
</view>
</view>
<!-- 波长选择 -->
<view class="card">
<view class="card-title">波长(点分区/全脸时使用)</view>
<view class="wave-row">
<view class="wave-chip {{selectedWave === item.key ? 'active' : ''}}" wx:for="{{waves}}" wx:key="key"
bindtap="onSelectWave" data-key="{{item.key}}">{{item.label}}</view>
</view>
</view>
<!-- 脸型图:点区发 2 秒治疗 -->
<view class="card">
<view class="card-title">点分区 → 该区 2 秒治疗(对物理位置)</view>
<view class="face-map">
<view class="face-region forehead" bindtap="onTapRegion" data-mask="4">上\nIO3</view>
<view class="face-region left-cheek" bindtap="onTapRegion" data-mask="2">左\nIO2</view>
<view class="face-region right-cheek" bindtap="onTapRegion" data-mask="1">右\nIO1</view>
<view class="face-region nose" bindtap="onTapRegion" data-mask="8">中\nIO4</view>
<view class="face-region chin" bindtap="onTapRegion" data-mask="16">下\nIO5</view>
</view>
</view>
<!-- 指令按钮 -->
<view class="card">
<view class="card-title">指令</view>
<view class="btn-row">
<button class="dbg-btn" bindtap="onScanCmd">检测指令</button>
<button class="dbg-btn" bindtap="onTreatAll">全脸 2s</button>
<button class="dbg-btn dbg-btn-stop" bindtap="onStop">停止</button>
</view>
</view>
<!-- 日志 -->
<view class="card">
<view class="card-title">发送日志 <text class="log-clear" bindtap="onClearLog">清空</text></view>
<view class="log-line" wx:for="{{logs}}" wx:key="*this">{{item}}</view>
<view class="log-empty" wx:if="{{logs.length === 0}}">暂无</view>
</view>
</view>
</view>
@@ -0,0 +1,39 @@
/* 临时调试页样式(上线前随页面一并移除) */
.page { min-height: 100vh; background: #f5f6f8; }
.page-content { padding: 24rpx; }
.card { background: #fff; border-radius: 24rpx; padding: 24rpx; margin-bottom: 20rpx; }
.card-title { font-size: 28rpx; font-weight: 600; color: #333; margin-bottom: 16rpx; }
.frames { font-size: 22rpx; color: #999; font-weight: 400; }
.pd-row { display: flex; flex-wrap: wrap; gap: 12rpx; }
.pd-cell { flex: 0 0 calc((100% - 72rpx) / 7); text-align: center; background: #FAFAFA; border-radius: 12rpx; padding: 10rpx 0; }
.pd-idx { font-size: 20rpx; color: #999; }
.pd-val { font-size: 24rpx; color: #333; font-weight: 600; }
.status-row { display: flex; flex-wrap: wrap; gap: 20rpx; margin-top: 16rpx; font-size: 24rpx; color: #666; }
.wave-row { display: flex; gap: 16rpx; }
.wave-chip { flex: 1; text-align: center; padding: 18rpx 0; border: 4rpx solid #e5e5e5; border-radius: 20rpx; font-size: 26rpx; color: #999; }
.wave-chip.active { border-color: #E6508C; background: rgba(230, 80, 140, 0.12); color: #E6508C; }
.face-map { width: 280rpx; height: 340rpx; margin: 0 auto; position: relative; }
.face-region {
position: absolute; border: 4rpx solid #d5d5d5; border-radius: 50%;
display: flex; align-items: center; justify-content: center; text-align: center;
font-size: 22rpx; color: #666; background: #FAFAFA; white-space: pre-line; line-height: 1.3;
}
.face-region:active { background: rgba(230, 80, 140, 0.25); border-color: #E6508C; color: #E6508C; }
.face-region.forehead { top: 5%; left: 25%; width: 50%; height: 15%; border-radius: 40rpx 40rpx 50% 50%; }
.face-region.left-cheek { top: 25%; left: 5%; width: 30%; height: 25%; }
.face-region.right-cheek { top: 25%; right: 5%; width: 30%; height: 25%; }
.face-region.nose { top: 45%; left: 35%; width: 30%; height: 18%; border-radius: 40%; }
.face-region.chin { top: 68%; left: 25%; width: 50%; height: 20%; border-radius: 0 0 50% 50%; }
.btn-row { display: flex; gap: 16rpx; }
.dbg-btn { flex: 1; font-size: 26rpx; padding: 0; line-height: 76rpx; border-radius: 20rpx; background: #4A90D9; color: #fff; }
.dbg-btn::after { border: none; }
.dbg-btn-stop { background: #E8503A; }
.log-clear { float: right; font-size: 22rpx; color: #4A90D9; font-weight: 400; }
.log-line { font-family: monospace; font-size: 20rpx; color: #555; padding: 4rpx 0; border-bottom: 1rpx solid #f2f2f2; word-break: break-all; }
.log-empty { font-size: 22rpx; color: #bbb; }
+5 -2
查看文件
@@ -15,9 +15,12 @@ Page({
modeColors: ['#E8503A', '#7C4DFF', '#F5B841', '#8B2E3C', '#F08AA8']
},
onLoad: function () {
onLoad: function (options) {
var app = getApp()
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
// 报告页分区跳转带 ?wave=red|ir|uv|yellow,高亮对应光卡片('ir' 对应本页 key 'infrared'
var focus = (options && options.wave) || ''
if (focus === 'ir') focus = 'infrared'
this.setData({ statusBarHeight: app.globalData.statusBarHeight, focusWave: focus })
},
onShow: function () {
+1 -1
查看文件
@@ -8,7 +8,7 @@
<view class="page-content">
<!-- 四种光 -->
<view class="section-title">{{i18n.lightInfo.lightsSectionTitle}}</view>
<view class="light-card" wx:for="{{lights}}" wx:key="key">
<view class="light-card {{focusWave === item.key ? 'light-card-focus' : ''}}" wx:for="{{lights}}" wx:key="key">
<view class="light-card-top">
<view class="swatch" style="background: {{item.color}};"></view>
<view class="light-head">
@@ -123,3 +123,9 @@
line-height: 1.6;
text-align: center;
}
/* 从扫描报告分区跳转时高亮对应光 */
.light-card-focus {
border: 2rpx solid rgba(60, 60, 60, 0.35);
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.10);
}
@@ -11,10 +11,9 @@ var i18n = require('../../i18n/index')
Page({
data: {
statusBarHeight: 44,
// fixed safe brightness for care sessions: 140 ≈ 55% (护理中档位).
// Do NOT expose a brightness slider (safety); the hardware also enforces
// its own current/thermal limits regardless of this value.
brightness: 140,
// 治疗亮度统一 204 = 80%(果果 2026-07-28 定案,与智能推荐一致)。
// Do NOT expose a brightness slider (safety); builder 层另有 ≤204 硬上限兜底。
brightness: 204,
functions: [
{ id: 'rejuvenate', wavelength: 2, wl: 'red', color: '#E8503A' },
{ id: 'acne', wavelength: 3, wl: 'uv', color: '#7C4DFF' },
@@ -23,7 +22,7 @@ Page({
],
selectedFunctionId: 'rejuvenate',
selectedWavelength: 2,
// region mask mapping identical to treatment-setup: 右=0x01 左=0x02 上=0x04 中=0x08 下=0x10
// 掩码 = IO↔物理位置(实测):右=0x01 左=0x02 上=0x04 中=0x08 下=0x10
regions: [
{ key: 'right', mask: 0x01, checked: true },
{ key: 'left', mask: 0x02, checked: true },
@@ -49,6 +48,23 @@ Page({
onShow: function () {
i18n.bind(this)
this.refreshDurationOptions()
this._checkAccess()
},
// 手动选择护理模式为智能模式专属(果果 2026-07-28 定案)。普通模式用户不可用——
// 入口链接已按订阅隐藏,此处兜底拦截直达(smart_mode_free 开启时后端返回 active,同样放行)。
_checkAccess: function () {
var http = require('../../utils/request')
http.get('/api/v1/subscription').then(function (sub) {
if (sub && sub.status === 'active') return
wx.showModal({
content: i18n.t('manual.smartOnly'),
showCancel: false,
complete: function () {
wx.navigateBack({ fail: function () { wx.reLaunch({ url: '/pages/index/index' }) } })
}
})
}).catch(function () {}) // 网络失败不拦(避免误伤),实际下发仍有 BLE/后端校验
},
// Duration labels carry a dynamic number, which WXML cannot substitute, so
@@ -24,15 +24,13 @@
</view>
<view class="page-title section-title">{{i18n.manual.regionTitle}}</view>
<view class="region-grid">
<view
wx:for="{{regions}}"
wx:key="key"
class="region-chip {{item.checked ? 'active' : ''}}"
bindtap="onToggleRegion"
data-idx="{{index}}">
{{i18n.common.regions[item.key]}}
</view>
<!-- 脸型图布局(与「使用设置」一致);位置↔idx(实测):0=右 1=左 2=上 3=中 4=下 -->
<view class="face-map">
<view class="face-region forehead {{regions[2].checked ? 'active' : ''}}" bindtap="onToggleRegion" data-idx="2">{{i18n.common.regions.top}}</view>
<view class="face-region left-cheek {{regions[1].checked ? 'active' : ''}}" bindtap="onToggleRegion" data-idx="1">{{i18n.common.regions.left}}</view>
<view class="face-region right-cheek {{regions[0].checked ? 'active' : ''}}" bindtap="onToggleRegion" data-idx="0">{{i18n.common.regions.right}}</view>
<view class="face-region nose {{regions[3].checked ? 'active' : ''}}" bindtap="onToggleRegion" data-idx="3">{{i18n.common.regions.middle}}</view>
<view class="face-region chin {{regions[4].checked ? 'active' : ''}}" bindtap="onToggleRegion" data-idx="4">{{i18n.common.regions.bottom}}</view>
</view>
<view class="page-title section-title">{{i18n.manual.durationTitle}}</view>
@@ -56,29 +56,33 @@
}
/* region checkbox grid */
.region-grid {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
justify-content: center;
/* face-map 脸型图(与 treatment-setup 同款) */
.face-map {
width: 240rpx;
height: 280rpx;
margin: 0 auto 24rpx;
position: relative;
}
.region-chip {
min-width: 140rpx;
padding: 20rpx 0;
text-align: center;
.face-region {
position: absolute;
border: 4rpx solid #e5e5e5;
border-radius: 16rpx;
font-size: 26rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #999999;
flex: 1 1 26%;
}
.region-chip.active {
.face-region.active {
border-color: #E6508C;
background: rgba(230, 80, 140, 0.12);
background: rgba(230, 80, 140, 0.2);
color: #E6508C;
}
.face-region.forehead { top: 5%; left: 25%; width: 50%; height: 15%; border-radius: 40rpx 40rpx 50% 50%; }
.face-region.left-cheek { top: 25%; left: 5%; width: 30%; height: 25%; }
.face-region.right-cheek { top: 25%; right: 5%; width: 30%; height: 25%; }
.face-region.nose { top: 45%; left: 35%; width: 30%; height: 18%; border-radius: 40%; }
.face-region.chin { top: 68%; left: 25%; width: 50%; height: 20%; border-radius: 0 0 50% 50%; }
/* duration segmented control */
.segmented {
+7
查看文件
@@ -19,6 +19,13 @@ Page({
onShow: function () {
i18n.bind(this)
this.loadProfile()
// 临时调试入口:仅设备已连接时显示(上线前随 ble-debug 页一并移除)
var ble = require('../../services/ble')
this.setData({ debugVisible: ble.isConnected() })
},
onOpenDebug: function () {
wx.navigateTo({ url: '/pages/ble-debug/ble-debug' })
},
onLightInfo: function () {
+7 -1
查看文件
@@ -50,6 +50,12 @@
<view class="menu-text">{{i18n.profile.menuHistory}}</view>
<text class="menu-arrow"></text>
</view>
<!-- 临时调试入口:仅设备已连接时显示,上线前移除 -->
<view class="menu-item" wx:if="{{debugVisible}}" bindtap="onOpenDebug">
<view class="menu-icon">🔧</view>
<view class="menu-text">调试工具(临时)</view>
<text class="menu-arrow"></text>
</view>
<view class="menu-item" bindtap="onViewSubscription" wx:if="{{!subscription || subscription.plan !== 'free'}}">
<view class="menu-icon">💳</view>
<view class="menu-text">{{i18n.profile.menuSubscription}}</view>
@@ -80,7 +86,7 @@
<view class="logout-btn" bindtap="onLogout">{{i18n.profile.logout}}</view>
<view class="version-text">v0.2.0</view>
<view class="version-text">v0.2.1</view>
</view>
<!-- Edit profile modal -->
+50 -18
查看文件
@@ -3,7 +3,8 @@ var ble = require('../../services/ble')
var diagnosis = require('../../services/diagnosis')
var i18n = require('../../i18n/index')
var WAVE_CODE_KEY = { 1: 'infrared', 2: 'red', 3: 'uv', 4: 'yellow' }
// diagnosis 的 wave key ('ir') 与 common.wavelengths 的 key ('infrared') 不同名,需映射
var WAVE_COMMON_KEY = { red: 'red', ir: 'infrared', uv: 'uv', yellow: 'yellow' }
function pad2(n) { return (n < 10 ? '0' : '') + n }
@@ -24,6 +25,7 @@ Page({
overallList: [],
regionList: [],
recommendList: [],
faceZones: [],
starting: false,
error: ''
},
@@ -111,9 +113,16 @@ Page({
return { label: d.problems[o.type] || o.type, level: o.level, levelLabel: levelLabel(o.level) }
})
function regionName(key) {
return (common.regions && common.regions[key]) || key
}
function modeName(waveKey) {
return (d.modeNames && d.modeNames[waveKey]) || ''
}
var regionList = (report.regions || []).map(function (r) {
return {
name: d.regionNames[r.region] || r.region,
name: regionName(r.region),
level: r.level,
levelLabel: levelLabel(r.level),
problemLabel: r.top_problem ? (d.problems[r.top_problem] || r.top_problem) : d.noProblem,
@@ -121,22 +130,34 @@ Page({
}
})
var defs = diagnosis.REGION_DEFS
// 推荐护理:现在 recommend_plan 每区一条(可不同色),一条 BLE 命令可全部下发
var recommendList = (report.recommend_plan || []).map(function (p) {
var names = []
for (var i = 0; i < defs.length; i++) {
if (p.mask & defs[i].mask) names.push(d.regionNames[defs[i].key] || defs[i].key)
}
var waveKey = WAVE_CODE_KEY[p.wavelength]
return {
label: d.problems[p.label_key] || '',
wavelengthLabel: (waveKey && common.wavelengths[waveKey]) || '',
regionsLabel: names.join('、'),
wavelength: p.wavelength,
modeLabel: modeName(p.wave),
wavelengthLabel: common.wavelengths[WAVE_COMMON_KEY[p.wave]] || '',
regionsLabel: regionName(p.region),
levelLabel: levelLabel(p.level),
mask: p.mask
}
})
// 面罩示意图数据(固定 5 区,未扫描/无问题的区置灰)
var byKey = {}
;(report.regions || []).forEach(function (r) { byKey[r.region] = r })
var faceZones = diagnosis.REGION_DEFS.map(function (def) {
var r = byKey[def.key]
var hasProblem = !!(r && r.top_problem && r.wave)
return {
key: def.key,
waveKey: hasProblem ? r.wave : null,
name: regionName(def.key),
hasProblem: hasProblem,
modeLabel: hasProblem ? modeName(r.wave) : '',
levelLabel: hasProblem ? levelLabel(r.level) : '',
colorClass: hasProblem ? 'zone-' + r.wave : 'zone-none'
}
})
this._report = report
this.setData({
loading: false,
@@ -146,26 +167,37 @@ Page({
overallList: overallList,
regionList: regionList,
recommendList: recommendList,
faceZones: faceZones,
error: ''
})
},
onTapZone: function (e) {
var wave = e.currentTarget.dataset.wave
wx.navigateTo({ url: '/pages/light-info/light-info' + (wave ? '?wave=' + wave : '') })
},
onStartRecommend: function () {
var self = this
var report = self._report || {}
var plan = report.recommend_plan || []
if (!ble.isConnected()) {
self.setData({ error: i18n.t('common.deviceNotConnected') })
return
}
var plan = (report.recommend_plan && report.recommend_plan[0]) || null
var mask = plan ? plan.mask : (report.recommend_mask || 0x1F)
var wl = plan ? plan.wavelength : 2
if (!mask) mask = 0x1F
if (!plan.length) return
// 一条 33B 命令携带全部分区差异化方案(每区各自的光色,亮度来自 diagnosis config,默认 204=80%
var mask = report.recommend_mask || 0
var wl = plan[0].wavelength || 2 // treating 页展示用(多色场景显示首个)
self.setData({ starting: true, error: '' })
ble.setParams({
region_mask: mask, wavelength: wl, brightness: 140,
duration_ms: 600000, mode: 1, control: 0x02
plan: plan.map(function (p) {
return { mask: p.mask, wave: p.wave, brightness: p.brightness }
}),
duration_ms: 600000,
control: 0x02
}).then(function () {
return ble.startTreatment(mask)
}).then(function () {
+38 -1
查看文件
@@ -30,6 +30,43 @@
<view class="empty-hint" wx:else>{{i18n.report.noProblem}}</view>
</view>
<!-- Face zones — 脸型图布局(与「使用设置」区域选择一致,果果 2026-07-28 定稿) -->
<view class="card">
<view class="card-title">{{i18n.report.faceTitle}}</view>
<!-- 脸型图(与「使用设置」同款布局);faceZones 由 REGION_DEFS 定序:0=右 1=左 2=上 3=中 4=下 -->
<view class="face-map">
<view class="face-region forehead {{faceZones[2].colorClass}}" bindtap="onTapZone" data-wave="{{faceZones[2].waveKey}}">
<view class="fz-name">{{faceZones[2].name}}</view>
<view class="fz-mode" wx:if="{{faceZones[2].hasProblem}}">{{faceZones[2].modeLabel}}</view>
</view>
<view class="face-region left-cheek {{faceZones[1].colorClass}}" bindtap="onTapZone" data-wave="{{faceZones[1].waveKey}}">
<view class="fz-name">{{faceZones[1].name}}</view>
<view class="fz-mode" wx:if="{{faceZones[1].hasProblem}}">{{faceZones[1].modeLabel}}</view>
</view>
<view class="face-region right-cheek {{faceZones[0].colorClass}}" bindtap="onTapZone" data-wave="{{faceZones[0].waveKey}}">
<view class="fz-name">{{faceZones[0].name}}</view>
<view class="fz-mode" wx:if="{{faceZones[0].hasProblem}}">{{faceZones[0].modeLabel}}</view>
</view>
<view class="face-region nose {{faceZones[3].colorClass}}" bindtap="onTapZone" data-wave="{{faceZones[3].waveKey}}">
<view class="fz-name">{{faceZones[3].name}}</view>
<view class="fz-mode" wx:if="{{faceZones[3].hasProblem}}">{{faceZones[3].modeLabel}}</view>
</view>
<view class="face-region chin {{faceZones[4].colorClass}}" bindtap="onTapZone" data-wave="{{faceZones[4].waveKey}}">
<view class="fz-name">{{faceZones[4].name}}</view>
<view class="fz-mode" wx:if="{{faceZones[4].hasProblem}}">{{faceZones[4].modeLabel}}</view>
</view>
</view>
<!-- 底部图例:各光简要功效(果果指定保留) -->
<view class="face-legend">
<view class="legend-item"><view class="legend-dot dot-red"></view><text class="legend-label">{{i18n.report.modeNames.red}}</text></view>
<view class="legend-item"><view class="legend-dot dot-ir"></view><text class="legend-label">{{i18n.report.modeNames.ir}}</text></view>
<view class="legend-item"><view class="legend-dot dot-uv"></view><text class="legend-label">{{i18n.report.modeNames.uv}}</text></view>
<view class="legend-item"><view class="legend-dot dot-yellow"></view><text class="legend-label">{{i18n.report.modeNames.yellow}}</text></view>
</view>
<view class="face-tap-hint">{{i18n.report.faceTapHint}}</view>
<view class="face-all-normal-hint" wx:if="{{!hasProblem}}">{{i18n.report.allNormalHint}}</view>
</view>
<!-- Per-region -->
<view class="card">
<view class="card-title">{{i18n.report.regionTitle}}</view>
@@ -48,7 +85,7 @@
<view class="rec-row" wx:for="{{recommendList}}" wx:key="mask">
<view class="rec-dot"></view>
<view class="rec-body">
<text class="rec-label">{{item.label}}</text>
<text class="rec-label">{{item.modeLabel}}</text>
<text class="rec-meta">{{item.wavelengthLabel}} · {{item.regionsLabel}}</text>
</view>
</view>
@@ -60,6 +60,53 @@
.empty-hint { color: #999; font-size: 26rpx; }
/* 脸型图 — 与「使用设置」同款布局,放大以容纳模式名 */
.face-map {
width: 320rpx;
height: 400rpx;
margin: 0 auto 16rpx;
position: relative;
}
.face-region {
position: absolute;
border: 3rpx solid #e5e5e5;
border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: #FAFAFA;
color: #999;
}
.face-region:active { transform: scale(0.96); }
.fz-name { font-size: 22rpx; font-weight: 600; }
.fz-mode { font-size: 18rpx; margin-top: 2rpx; }
.face-region.forehead { top: 5%; left: 25%; width: 50%; height: 15%; border-radius: 40rpx 40rpx 50% 50%; }
.face-region.left-cheek { top: 25%; left: 5%; width: 30%; height: 25%; }
.face-region.right-cheek { top: 25%; right: 5%; width: 30%; height: 25%; }
.face-region.nose { top: 45%; left: 35%; width: 30%; height: 18%; border-radius: 40%; }
.face-region.chin { top: 68%; left: 25%; width: 50%; height: 20%; border-radius: 0 0 50% 50%; }
/* 波长配色(置于 .face-region 之后以覆盖默认色) */
.zone-red { background: rgba(232, 93, 93, 0.14); border-color: rgba(232, 93, 93, 0.55); color: #B23C3C; }
.zone-ir { background: rgba(192, 107, 74, 0.14); border-color: rgba(192, 107, 74, 0.55); color: #8C4A2E; }
.zone-uv { background: rgba(142, 107, 216, 0.14); border-color: rgba(142, 107, 216, 0.55); color: #5F3FAE; }
.zone-yellow { background: rgba(232, 185, 61, 0.16); border-color: rgba(232, 185, 61, 0.6); color: #8A6A10; }
.zone-none { background: #FAFAFA; border-color: #e5e5e5; color: #999; }
/* 底部图例:各光简要功效 */
.face-legend { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 8rpx; }
.legend-item { display: flex; align-items: center; margin: 0 16rpx 10rpx 0; }
.legend-dot { width: 16rpx; height: 16rpx; border-radius: 50%; margin-right: 8rpx; }
.dot-red { background: #E85D5D; }
.dot-ir { background: #C06B4A; }
.dot-uv { background: #8E6BD8; }
.dot-yellow { background: #E8B93D; }
.legend-label { font-size: 22rpx; color: #888; }
.face-tap-hint { font-size: 22rpx; color: #bbb; margin-top: 14rpx; text-align: center; }
.face-all-normal-hint { font-size: 24rpx; color: #6BBF59; text-align: center; margin-top: 12rpx; }
.region-row {
display: flex;
align-items: center;
+4 -5
查看文件
@@ -23,16 +23,15 @@ Page({
},
_getRegionText: function (regionMask) {
// 掩码 = IO↔物理位置(实测):0x01右 0x02左 0x04上 0x08中 0x10下
var REGION_MAP = {
1: 'common.regions.right',
2: 'common.regions.left',
4: 'common.regions.top',
8: 'common.regions.middle',
16: 'common.regions.bottom',
32: 'treating.regionTopLeft',
64: 'treating.regionTopRight'
16: 'common.regions.bottom'
}
if (regionMask === 0x7F) return i18n.t('treating.allRegions')
if (regionMask === 0x1F) return i18n.t('treating.allRegions')
var names = []
for (var bit in REGION_MAP) {
if (regionMask & parseInt(bit)) names.push(i18n.t(REGION_MAP[bit]))
@@ -48,7 +47,7 @@ Page({
var app = getApp()
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
this._deviceId = ble.getDeviceId() || (app.globalData.currentDevice && app.globalData.currentDevice.device_id) || ''
var regions = parseInt(options.regions) || 0x7F
var regions = parseInt(options.regions) || 0x1F
this.setData({
regions: regions,
wavelength: parseInt(options.wavelength) || 2,
@@ -34,6 +34,7 @@ Page({
var app = getApp()
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
i18n.bind(this)
// 顺序对应 data.regions 掩码 0x01..0x10 = IO1..IO5 = 右/左/上/中/下(实测)
var regionKeys = ['right', 'left', 'top', 'middle', 'bottom']
var regions = this.data.regions
regions.forEach(function (r, i) {
@@ -104,7 +105,7 @@ Page({
ble.setParams({
region_mask: mask,
wavelength: 2,
brightness: 200,
brightness: 204, // 治疗亮度统一 80%(果果 2026-07-28 定案)
duration_ms: self.data.fixedDurationMs,
mode: self.data.selectedMode,
control: 0x02
@@ -25,6 +25,7 @@
<view class="page-title" style="font-size:28rpx;">{{i18n.setup.selectRegion}}</view>
<view class="mode-tip" wx:if="{{selectedMode === 0}}">{{i18n.setup.normalTip}}</view>
<!-- 位置↔idx(实测 IO↔物理位置):idx0=右(0x01) idx1=左(0x02) idx2=上(0x04) idx3=中(0x08) idx4=下(0x10) -->
<view class="face-map">
<view class="face-region forehead {{regions[2].checked ? 'active' : ''}} {{selectedMode === 0 ? 'disabled' : ''}}" bindtap="onToggleRegion" data-idx="2">{{i18n.common.regions.top}}</view>
<view class="face-region left-cheek {{regions[1].checked ? 'active' : ''}} {{selectedMode === 0 ? 'disabled' : ''}}" bindtap="onToggleRegion" data-idx="1">{{i18n.common.regions.left}}</view>
@@ -37,7 +38,7 @@
{{i18n.setup.startBtn}}
</button>
<view class="manual-entry" bindtap="onManual" style="text-align:center;color:#E8503A;font-size:26rpx;margin-top:28rpx;">{{i18n.manual.entryLink}}</view>
<view class="manual-entry" wx:if="{{selectedMode === 1}}" bindtap="onManual" style="text-align:center;color:#E8503A;font-size:26rpx;margin-top:28rpx;">{{i18n.manual.entryLink}}</view>
<view class="error-text" wx:if="{{error}}">{{error}}</view>
</view>
+1 -1
查看文件
@@ -99,7 +99,7 @@ function handleValueChange(res) {
console.warn('[BLE] ADC checksum mismatch, dropping')
return
}
emit('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct, fitting: parsed.fitting, run_state: parsed.run_state })
emit('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct, fitting: parsed.fitting, scan_wave: parsed.scan_wave, run_state: parsed.run_state, is_fault: parsed.is_fault })
emit('battery', { battery: batteryPct, vbat: vbatMv })
emit('fitting', { fitting: parsed.fitting })
emit('run_state', { run_state: parsed.run_state })
+75 -33
查看文件
@@ -57,18 +57,23 @@ var TREAT_MODE = {
SMART: 1
}
// 区域 = IO↔物理位置(果果 2026-07-28 真机实测):右=IO1(0x01) 左=IO2(0x02) 上=IO3(0x04)
// 中=IO4(0x08) 下=IO5(0x10)。此前口头给的"纵列左IO1/中上IO2…"实测不符,以本表为准。
var REGION = {
LEFT_CHEEK: 0x01,
RIGHT_CHEEK: 0x02,
FOREHEAD: 0x04,
CHIN: 0x08,
NOSE: 0x10,
LEFT_EYE: 0x20,
RIGHT_EYE: 0x40,
FULL_FACE: 0x7F
RIGHT: 0x01,
LEFT: 0x02,
TOP: 0x04,
MIDDLE: 0x08,
BOTTOM: 0x10,
FULL_FACE: 0x1F
}
var REGION_NAMES = ['left_cheek', 'right_cheek', 'forehead', 'chin', 'nose', 'left_eye', 'right_eye']
var REGION_NAMES = ['right', 'left', 'top', 'middle', 'bottom']
// FFE4 Byte17 高三位 = 扫描时光色指示(协议简述-添加扫描时光色.docx 2026-07):
// 001=红光 010=红外 011=紫外(蓝) 100=暖黄。注意与下发命令的 WAVELENGTH 编码
// (IR=1,R=2,UV=3,Y=4) 不同——1/2 正好是红与红外互换,绝不能复用那套常量。
var SCAN_WAVE_KEY = { 1: 'red', 2: 'ir', 3: 'uv', 4: 'yellow' }
var DEVICE_ERR = {
0x00: 'SUCCESS',
@@ -167,37 +172,66 @@ var CONTROL = {
TREAT: 0x02
}
// 每 IO 6 字节,颜色格顺序 [红][红外][紫外][暖黄](厂商原表,新版协议简述再次确认)。
// 两种调用方式:
// 单色广播(旧):{ region_mask, wavelength(编码), brightness, ... }
// 分区差异化(新):{ plan: [{ mask, wave:'red'|'ir'|'uv'|'yellow', brightness }], hold_time, control }
// —— 同一条命令里不同区可用不同颜色不同亮度(协议本身就支持 5 IO × 4 色独立)。
var WAVE_BYTE_OFFSET = { red: 0, ir: 1, uv: 2, yellow: 3 }
// 安全包线(builder 层硬上限,纵深防御——即使服务端 diagnosis_config 误配也不可突破):
// 治疗亮度 ≤204(80%),单次时长 ≤600s(10min)。固件侧安全机制大多未实现,此处是最后防线。
var MAX_TREAT_BRIGHTNESS = 204
var MAX_HOLD_SECONDS = 600
function buildVendorCommand(options) {
options = options || {}
var regionMask = options.region_mask || REGION.FULL_FACE
var wavelength = options.wavelength || WAVELENGTH.R
var brightness = clampByte(options.brightness === undefined ? 200 : options.brightness)
var gain = clampUInt16(options.current_gain === undefined ? 0 : options.current_gain)
var durationMs = options.duration_ms || 600000
var holdSeconds = clampUInt16(options.hold_time === undefined ? Math.round(durationMs / 1000) : options.hold_time)
var control = options.control !== undefined ? options.control : CONTROL.TREAT
var regions = [
REGION.LEFT_CHEEK,
REGION.RIGHT_CHEEK,
REGION.FOREHEAD,
REGION.CHIN,
REGION.NOSE
]
if (holdSeconds > MAX_HOLD_SECONDS) holdSeconds = MAX_HOLD_SECONDS
var isTreat = control === CONTROL.TREAT
function clampTreat(b) {
b = clampByte(b)
return isTreat && b > MAX_TREAT_BRIGHTNESS ? MAX_TREAT_BRIGHTNESS : b
}
// IO1..IO5 物理槽位 = bit 升序(Byte n*6 对应 mask 1<<n)。直接用字面量,不依赖
// REGION 常量名——区域↔mask 语义调整时这里必须始终是 0x01,0x02,0x04,0x08,0x10。
var ioMasks = [0x01, 0x02, 0x04, 0x08, 0x10] // IO1=右 IO2=左 IO3=上 IO4=中 IO5=下
var bytes = []
var i, j
for (var i = 0; i < regions.length; i++) {
var enabled = (regionMask & regions[i]) !== 0
var red = 0
var infrared = 0
var uv = 0
var warmYellow = 0
if (enabled) {
if (wavelength === WAVELENGTH.R) red = brightness
if (wavelength === WAVELENGTH.IR) infrared = brightness
if (wavelength === WAVELENGTH.UV) uv = brightness
if (wavelength === WAVELENGTH.Y) warmYellow = brightness
if (options.plan && options.plan.length) {
for (i = 0; i < ioMasks.length; i++) {
var slot = [0, 0, 0, 0]
for (j = 0; j < options.plan.length; j++) {
var p = options.plan[j]
if ((p.mask & ioMasks[i]) === 0) continue
var off = WAVE_BYTE_OFFSET[p.wave]
if (off === undefined) continue
slot[off] = clampTreat(p.brightness === undefined ? 200 : p.brightness)
}
bytes.push(slot[0], slot[1], slot[2], slot[3], (gain >> 8) & 0xFF, gain & 0xFF)
}
} else {
var regionMask = options.region_mask || REGION.FULL_FACE
var wavelength = options.wavelength || WAVELENGTH.R
var brightness = clampTreat(options.brightness === undefined ? 200 : options.brightness)
for (i = 0; i < ioMasks.length; i++) {
var enabled = (regionMask & ioMasks[i]) !== 0
var red = 0
var infrared = 0
var uv = 0
var warmYellow = 0
if (enabled) {
if (wavelength === WAVELENGTH.R) red = brightness
if (wavelength === WAVELENGTH.IR) infrared = brightness
if (wavelength === WAVELENGTH.UV) uv = brightness
if (wavelength === WAVELENGTH.Y) warmYellow = brightness
}
bytes.push(red, infrared, uv, warmYellow, (gain >> 8) & 0xFF, gain & 0xFF)
}
bytes.push(red, infrared, uv, warmYellow, (gain >> 8) & 0xFF, gain & 0xFF)
}
bytes.push((holdSeconds >> 8) & 0xFF, holdSeconds & 0xFF)
@@ -217,13 +251,18 @@ function parseVendorStatus(buffer) {
for (var p = 0; p < 7; p++) {
pds19.push(bytes[p * 2] | (bytes[p * 2 + 1] << 8))
}
// Byte17 复用:低位=贴合状态(0/1),高三位=扫描时光色指示(0 表示无标识/非扫描态或旧固件)。
// Byte18 运行状态:0=IDLE 1=检测 2=治疗 0xFF=故障。
var scanWaveCode = (bytes[16] >> 5) & 0x07
return {
type: 'adc',
is_heartbeat: false,
pd: pds19,
vbat: bytes[14] | (bytes[15] << 8),
fitting: bytes[16],
fitting: bytes[16] & 0x1F,
scan_wave: SCAN_WAVE_KEY[scanWaveCode] || null,
run_state: bytes[17],
is_fault: bytes[17] === 0xFF,
checksum_ok: checksum19 === bytes[18],
raw_hex: bytesToHex(bytes)
}
@@ -326,11 +365,13 @@ function parseException(payload) {
// --- display helpers ---
// 掩码 = IO↔物理位置(与 REGION 常量一致)。注意:此处为硬编码中文(历史遗留,
// history/treatment-done 在用);新页面请改用 i18n common.regions.* 取标签。
function getRegionName(mask) {
var names = []
var bits = [
[0x01, '右区'], [0x02, '左区'], [0x04, '上区'],
[0x08, '中区'], [0x10, '下区'], [0x20, '左上区'], [0x40, '右上区']
[0x08, '中区'], [0x10, '下区']
]
for (var i = 0; i < bits.length; i++) {
if (mask & bits[i][0]) names.push(bits[i][1])
@@ -362,6 +403,7 @@ module.exports = {
TREAT_MODE: TREAT_MODE,
REGION: REGION,
REGION_NAMES: REGION_NAMES,
SCAN_WAVE_KEY: SCAN_WAVE_KEY,
CONTROL: CONTROL,
DEVICE_ERR: DEVICE_ERR,
+148 -114
查看文件
@@ -1,26 +1,26 @@
// Skin-tendency diagnosis — FRAMEWORK / placeholder implementation.
// Skin-tendency diagnosis — 按《扫描+护理完整流程.docx》7.1/7.2/7.3 +
// 《协议简述-添加扫描时光色.docx》+ 果果 2026-07 定案实现。
//
// STATUS: the diagnosis 依据 is NOT yet calibrated (客户也认为"还只是概念").
// This module defines the full data pipeline so the report UI + storage work end
// to end today, but the thresholds and the PD->region mapping are PLACEHOLDERS to
// be replaced after real-device calibration. It degrades gracefully when only
// partial scan data (currently single-wavelength red) is available.
// 核心链路:28 组 PD(4 波长×7 路) → 按 PD_REGION_MAP 聚合成 5 区 →
// 每波长算 5 区平均当基准 → 吸收度 NR = 本区/基准 − 1 →
// 每区取 4 个 NR 的最大者(argmax),超过阈值 TH 才判定问题 → 该波长即该区治疗光色。
//
// Two things here need hardware/calibration confirmation before this is "real":
// 1) PD_REGION_MAP — which of the 7 PDs feed which facial region (docs disagree).
// 2) levels thresholds — normalized-absorption cutoffs per severity level.
// Both can be overridden at runtime by the server-side diagnosis_config, so tuning
// after calibration does NOT require an app release.
// 极性(已由固件批注版文档坐实,新版协议简述再次确认"0x0FFF表示最低光照"):
// PD ADC 值越大 = 反射光越弱 = 皮肤吸收越多。故 NR = zone/avg − 1(吸收多→NR 高)。
// config.polarity = 'direct' 可切回"值大=光强"的旧假设(备用开关,标定时救急)。
//
// PD↔区域映射(果果转达):左=PD1 上=PD2 中=PD3/6/7 下=PD4 右=PD5(方位与实测 IO 表一致)。
// 仍待定:3 路 PD 区的聚合——文档 7.1 自相矛盾(几何平均 vs 取最小),按更细的几何平均+MAD剔异常实现。
// 所有阈值/亮度/映射均可被服务端 diagnosis_config 覆盖,标定后免发版调参。
// Problem type -> recommended care wavelength (IR=1, R=2, UV=3, Y=4).
// 问题类型 -> 治疗波长编码(下发命令用:IR=1, R=2, UV=3, Y=4)。
var PROBLEM_WAVELENGTH = { aging: 2, acne: 3, pigment: 4, deep: 1 }
// Scanned wavelength code -> the problem it reveals (inverse of the above).
var WAVELENGTH_PROBLEM = { 1: 'deep', 2: 'aging', 3: 'acne', 4: 'pigment' }
// Dictionary wave-key -> wavelength code.
// 波长 key -> 揭示的问题类型。
var WAVE_PROBLEM = { red: 'aging', uv: 'acne', yellow: 'pigment', ir: 'deep' }
// 波长 key -> 下发命令编码。
var WAVE_KEY_CODE = { red: 2, uv: 3, yellow: 4, ir: 1 }
// 5 regions in the app's neutral convention (right/left/top/middle/bottom),
// matching treatment-setup.js masks.
// 5 区 = IO↔物理位置(果果 2026-07-28 实测):右=IO1(0x01) 左=IO2(0x02) 上=IO3(0x04) 中=IO4(0x08) 下=IO5(0x10)。
var REGION_DEFS = [
{ key: 'right', mask: 0x01 },
{ key: 'left', mask: 0x02 },
@@ -29,102 +29,136 @@ var REGION_DEFS = [
{ key: 'bottom', mask: 0x10 }
]
// PLACEHOLDER PD->region map. Flow doc: 7 PDs = 1 special region (3 PDs) + 4 regions
// (1 PD each). The exact assignment is UNCONFIRMED — replace after hardware confirms
// the PD physical layout. Each region lists the PD index(es) that feed its signal.
var PD_REGION_MAP = {
right: [0], left: [1], top: [2], middle: [3, 5, 6], bottom: [4]
}
var MAX_ADC = 4095
var DEFAULT_CONFIG = {
calibrated: false,
levels: { low: 0.15, mid: 0.35, high: 0.55 },
polarity: 'inverted', // inverted=值大吸收多(已确认) | direct=旧假设备用
th: 0.10, // 判定阈值(文档建议初始值,需临床标定)
severity: { low: 0.05, mid: 0.15, high: 0.30 }, // 轻/中/重分级,仅报告展示
brightness: 204, // 治疗强度 80%(果果定案),仅用于推荐方案下发
// PD↔区域映射(果果 2026-07-28 确认):左=PD1 上=PD2 中=PD3/6/7 下=PD4 右=PD5(下标 0 基)。
pd_region_map: { right: [4], left: [0], top: [1], middle: [2, 5, 6], bottom: [3] },
problem_wavelength: PROBLEM_WAVELENGTH
}
function _avg(arr) {
if (!arr || !arr.length) return 0
var s = 0
for (var i = 0; i < arr.length; i++) s += arr[i]
return s / arr.length
function _median(arr) {
var s = arr.slice().sort(function (a, b) { return a - b })
var m = Math.floor(s.length / 2)
return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2
}
// Normalized absorption in [0,1]: the more the light is absorbed (lower reflected PD
// relative to the底噪 baseline), the stronger the tendency signal.
function _absorption(pdValue, baseline) {
if (!baseline || baseline <= 0) return 0
var a = (baseline - pdValue) / baseline
if (a < 0) a = 0
if (a > 1) a = 1
return a
// 区域有效值:1 路直接用;≥3 路按 7.1 节"几何平均 + 剔奇异值"(防黑痣/毛发单点失真)。
// 剔异常用 MAD(中位数绝对偏差)而非文档字面的 3σ:n=3 时单个离群点会把标准差同步撑大,
// 3σ 判据永不触发(审计实证 [900,9000,905] 不剔);MAD 阈值 4.45×MAD ≈ 3σ 等效(3×1.4826)。
function _aggregate(vals) {
if (!vals.length) return 0
if (vals.length === 1) return vals[0]
var kept = vals
if (vals.length >= 3) {
var med = _median(vals)
var devs = vals.map(function (v) { return Math.abs(v - med) })
var mad = _median(devs)
var thr = 4.45 * mad
var filtered = vals.filter(function (v) { return Math.abs(v - med) <= thr })
if (filtered.length >= 2) kept = filtered
}
var logSum = 0
for (var i = 0; i < kept.length; i++) {
if (kept[i] <= 0) return 0 // 有无效 0 值时该区数据不可信
logSum += Math.log(kept[i])
}
return Math.exp(logSum / kept.length)
}
function _levelOf(score, levels) {
if (score >= levels.high) return 3
if (score >= levels.mid) return 2
if (score >= levels.low) return 1
function _severityLevel(nr, severity) {
if (nr > severity.high) return 3
if (nr > severity.mid) return 2
if (nr > severity.low) return 1
return 0
}
// scanData: {
// device_id, scanned_at,
// region_mask, // which regions were scanned (default 0x1F)
// noise: [7], // per-PD 底噪 baseline (optional; defaults MAX_ADC)
// waves: { red:[7], uv:[7], yellow:[7], ir:[7] } // any subset; each = 7 PD values
// region_mask, // 本次扫描选中的区域(默认 0x1F)
// waves: { red:[7], ir:[7], uv:[7], yellow:[7] } // 任意子集;每项 = 7 路 PD ADC
// }
function analyze(scanData, config) {
config = config || DEFAULT_CONFIG
var levels = config.levels || DEFAULT_CONFIG.levels
var th = config.th !== undefined ? config.th : DEFAULT_CONFIG.th
var severity = config.severity || DEFAULT_CONFIG.severity
var brightness = config.brightness || DEFAULT_CONFIG.brightness
var pdMap = config.pd_region_map || DEFAULT_CONFIG.pd_region_map
var problemWave = config.problem_wavelength || PROBLEM_WAVELENGTH
var inverted = config.polarity !== 'direct'
scanData = scanData || {}
var waves = scanData.waves || {}
var noise = scanData.noise
var scannedMask = scanData.region_mask || 0x1F
// 1) 聚合:每波长 × 每选中区 → 区域有效值
var zone = {} // zone[waveKey][regionKey] = 有效值
var included = [] // 参与本次扫描的区域定义
var r, def
for (r = 0; r < REGION_DEFS.length; r++) {
if ((scannedMask & REGION_DEFS[r].mask) !== 0) included.push(REGION_DEFS[r])
}
for (var wk in waves) {
if (!waves.hasOwnProperty(wk) || !WAVE_PROBLEM[wk]) continue
var pdArr = waves[wk]
if (!pdArr || !pdArr.length) continue
zone[wk] = {}
for (r = 0; r < included.length; r++) {
def = included[r]
var idxs = pdMap[def.key] || []
var vals = []
for (var k = 0; k < idxs.length; k++) {
var v = pdArr[idxs[k]]
if (v !== undefined && v !== null && v > 0) vals.push(v)
}
if (vals.length) zone[wk][def.key] = _aggregate(vals)
}
}
// 2) 每波长的基准 = 该波长下各区有效值的平均(7.1Avg_PD_X_AllZones
var avg = {}
for (wk in zone) {
if (!zone.hasOwnProperty(wk)) continue
var sum = 0
var n = 0
for (r = 0; r < included.length; r++) {
var zv = zone[wk][included[r].key]
if (zv !== undefined) { sum += zv; n++ }
}
if (n > 0) avg[wk] = sum / n
}
// 3) 吸收度 NR + 每区 argmax 判定
var regions = []
var overallAcc = {}
for (var r = 0; r < REGION_DEFS.length; r++) {
var def = REGION_DEFS[r]
if ((scannedMask & def.mask) === 0) continue
var pdIdx = PD_REGION_MAP[def.key] || []
var problems = []
for (var wk in waves) {
if (!waves.hasOwnProperty(wk)) continue
var code = WAVE_KEY_CODE[wk]
var problemType = WAVELENGTH_PROBLEM[code]
if (!problemType) continue
var pdVals = []
var baseVals = []
for (var k = 0; k < pdIdx.length; k++) {
var idx = pdIdx[k]
if (waves[wk][idx] !== undefined) pdVals.push(waves[wk][idx])
baseVals.push(noise && noise[idx] !== undefined ? noise[idx] : MAX_ADC)
}
if (!pdVals.length) continue
var score = _absorption(_avg(pdVals), _avg(baseVals))
var level = _levelOf(score, levels)
if (level > 0) {
problems.push({ type: problemType, level: level, score: Math.round(score * 100) / 100 })
if (!overallAcc[problemType] || level > overallAcc[problemType]) {
overallAcc[problemType] = level
}
}
for (r = 0; r < included.length; r++) {
def = included[r]
var nrs = [] // 该区所有可算波长的 {wave, nr}
for (wk in zone) {
if (!zone.hasOwnProperty(wk)) continue
if (zone[wk][def.key] === undefined || !avg[wk]) continue
var ratio = zone[wk][def.key] / avg[wk]
var nr = inverted ? (ratio - 1) : (1 - ratio)
nrs.push({ wave: wk, nr: Math.round(nr * 1000) / 1000 })
}
nrs.sort(function (a, b) { return b.nr - a.nr })
var top = nrs.length ? nrs[0] : null
var hasProblem = !!(top && top.nr > th)
var problemType = hasProblem ? WAVE_PROBLEM[top.wave] : null
var level = hasProblem ? Math.max(1, _severityLevel(top.nr, severity)) : 0
if (problemType && (!overallAcc[problemType] || level > overallAcc[problemType])) {
overallAcc[problemType] = level
}
problems.sort(function (a, b) { return (b.level - a.level) || (b.score - a.score) })
var top = problems.length ? problems[0] : null
regions.push({
region: def.key,
mask: def.mask,
top_problem: top ? top.type : null,
level: top ? top.level : 0,
problems: problems
top_problem: problemType,
wave: hasProblem ? top.wave : null,
level: level,
score: top ? top.nr : 0,
nrs: nrs // 全量吸收度,供标定期回看
})
}
@@ -134,23 +168,22 @@ function analyze(scanData, config) {
}
overall.sort(function (a, b) { return b.level - a.level })
// Recommendation: care each region-with-a-top-problem using that problem's wavelength.
// One BLE command carries one wavelength, so plan entries are grouped by wavelength.
var planByWave = {}
var recommendMask = 0
for (var i = 0; i < regions.length; i++) {
var reg = regions[i]
if (!reg.top_problem) continue
var wl = problemWave[reg.top_problem]
if (!wl) continue
planByWave[wl] = (planByWave[wl] || 0) | reg.mask
recommendMask |= reg.mask
}
// 4) 推荐方案:每个问题区一条(区独立、可不同色),一条 BLE 命令即可全部下发。
var recommendPlan = []
for (var w in planByWave) {
if (!planByWave.hasOwnProperty(w)) continue
var code2 = parseInt(w, 10)
recommendPlan.push({ wavelength: code2, mask: planByWave[w], label_key: WAVELENGTH_PROBLEM[code2] })
var recommendMask = 0
for (r = 0; r < regions.length; r++) {
var reg = regions[r]
if (!reg.top_problem || !reg.wave) continue
recommendPlan.push({
region: reg.region,
mask: reg.mask,
wave: reg.wave,
wavelength: WAVE_KEY_CODE[reg.wave],
label_key: reg.top_problem,
level: reg.level,
brightness: brightness
})
recommendMask |= reg.mask
}
return {
@@ -165,30 +198,30 @@ function analyze(scanData, config) {
}
}
// Adapt the current (single-wavelength red) auto-scan result into scanData, so the
// pipeline works today. pdAvg = 7 averaged PD values under red light.
function fromRedScan(pdAvg, regionMask, deviceId, scannedAt, noise) {
// 把 auto-scan 按波长分桶后的平均值组装成 scanData
// buckets: { red:[7], ir:[7], uv:[7], yellow:[7] } 任意子集(旧固件无波长标识时只有 red)。
function buildScanData(buckets, regionMask, deviceId, scannedAt) {
return {
device_id: deviceId || null,
scanned_at: scannedAt || 0,
region_mask: regionMask || 0x1F,
noise: noise || null,
waves: { red: (pdAvg || []).slice(0, 7) }
waves: buckets || {}
}
}
// Deterministic mock report for UI development / demo when there is no device data.
// 无设备数据时的演示报告(开发者工具 mock)。
// 数值按已确认极性编造:值大=吸收多 → 左区红光偏高(光老化)、中区紫外偏高(痘痘油脂)。
function mockReport() {
return analyze({
device_id: 'MOCK',
scanned_at: 0,
region_mask: 0x1F,
noise: [4000, 4000, 4000, 4000, 4000, 4000, 4000],
waves: {
red: [3500, 3600, 1900, 3400, 3450, 3500, 3500],
uv: [3700, 3750, 3600, 1700, 3700, 1800, 1900],
yellow: [3500, 3550, 3400, 3450, 2300, 3500, 3520],
ir: [3600, 3600, 3550, 3580, 3560, 3600, 3600]
// 下标: 0=PD1左 1=PD2上 2=PD3中 3=PD4下 4=PD5右 5=PD6中 6=PD7中
red: [1350, 920, 900, 910, 905, 890, 940],
uv: [2050, 2020, 2600, 2010, 2080, 2560, 2620],
yellow: [1500, 1520, 1490, 1505, 1495, 1530, 1510],
ir: [1800, 1790, 1805, 1795, 1800, 1815, 1790]
}
}, DEFAULT_CONFIG)
}
@@ -196,9 +229,10 @@ function mockReport() {
module.exports = {
DEFAULT_CONFIG: DEFAULT_CONFIG,
PROBLEM_WAVELENGTH: PROBLEM_WAVELENGTH,
WAVELENGTH_PROBLEM: WAVELENGTH_PROBLEM,
WAVE_PROBLEM: WAVE_PROBLEM,
WAVE_KEY_CODE: WAVE_KEY_CODE,
REGION_DEFS: REGION_DEFS,
analyze: analyze,
fromRedScan: fromRedScan,
buildScanData: buildScanData,
mockReport: mockReport
}
@@ -0,0 +1,30 @@
-- 迁移:扫描报告存储 + 诊断配置种子(对应小程序 commit 6b91ebe 的诊断链路上线)
-- 幂等:可重复执行。只做两件事,不碰其他表/账号。
-- 执行方式见 WorkLog: products/jw-beauty/2026-07-28-生产DB迁移指引.md
-- 1) 扫描报告表(Phase 1 已定义,生产一直未建)
CREATE TABLE IF NOT EXISTS scan_reports (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id BIGINT UNSIGNED NOT NULL,
device_id VARCHAR(32) NULL,
scanned_at DATETIME NULL,
regions JSON NULL COMMENT 'array of per-region analysis',
overall JSON NULL COMMENT 'array of overall tendencies',
recommend_mask INT NOT NULL DEFAULT 0 COMMENT 'bitmask of regions recommended for care',
recommend_plan JSON NULL COMMENT 'array of {region, mask, wave, wavelength, label_key, level, brightness}',
raw_pd JSON NULL COMMENT 'raw PD samples for the calibration dataset (may be partial)',
calibrated TINYINT NOT NULL DEFAULT 0 COMMENT 'whether thresholds were calibrated',
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY idx_scan_reports_user_created (user_id, created_at),
KEY idx_scan_reports_device_created (device_id, created_at),
CONSTRAINT fk_scan_reports_user FOREIGN KEY (user_id) REFERENCES users (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- 2) 诊断配置种子(2026-07-28 新结构:极性/阈值/亮度/PD映射全部热调)
-- pd_region_map 已由固件确认(2026-07-28):左=PD1 中上=PD2 中=PD3/6/7 中下=PD4 右=PD50基下标)
-- ON DUPLICATE KEY UPDATE 会覆盖已有的 diagnosis_config——当前生产从未配置过该键,
-- 若执行前发现已有人工调过的值(见指引文档的核查步骤),先备份再执行。
INSERT INTO system_settings (setting_key, setting_value) VALUES
('diagnosis_config', '{"calibrated": false, "note": "阈值为待标定初始值(文档建议值);polarity=inverted 与 pd_region_map(左PD1/中上PD2/中PD3,6,7/中下PD4/右PD5) 均已由固件确认(2026-07-28)", "polarity": "inverted", "th": 0.10, "severity": {"low": 0.05, "mid": 0.15, "high": 0.30}, "brightness": 204, "pd_region_map": {"left": [0], "top": [1], "middle": [2, 5, 6], "bottom": [3], "right": [4]}, "problem_wavelength": {"aging": 2, "acne": 3, "pigment": 4, "deep": 1}}')
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value);
+1 -1
查看文件
@@ -204,4 +204,4 @@ INSERT IGNORE INTO system_settings (setting_key, setting_value) VALUES
('enable_binding', 'true'),
('enable_free_mode', 'true'),
('maintenance_mode', 'false'),
('diagnosis_config', '{"calibrated": false, "note": "占位阈值,待真机标定后调整", "levels": {"low": 0.15, "mid": 0.35, "high": 0.55}, "problem_wavelength": {"aging": 2, "acne": 3, "pigment": 4, "deep": 1}}');
('diagnosis_config', '{"calibrated": false, "note": "阈值为待标定初始值(文档建议值);polarity=inverted 与 pd_region_map(左PD1/中上PD2/中PD3,6,7/中下PD4/右PD5) 均已由固件确认(2026-07-28)", "polarity": "inverted", "th": 0.10, "severity": {"low": 0.05, "mid": 0.15, "high": 0.30}, "brightness": 204, "pd_region_map": {"left": [0], "top": [1], "middle": [2, 5, 6], "bottom": [3], "right": [4]}, "problem_wavelength": {"aging": 2, "acne": 3, "pigment": 4, "deep": 1}}');