- 新协议《协议简述-添加扫描时光色》落地: 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键
144 行
4.5 KiB
JavaScript
144 行
4.5 KiB
JavaScript
var ble = require('../../services/ble')
|
|
var i18n = require('../../i18n/index')
|
|
|
|
// Manual care page: user directly picks a care function (-> single light
|
|
// wavelength), regions and duration, then starts — skipping the smart scan.
|
|
//
|
|
// Care function -> wavelength (protocol WAVELENGTH: IR=1, R=2, UV=3, Y=4).
|
|
// SINGLE light per session: buildVendorCommand only lights one wavelength.
|
|
// FUTURE EXTENSION: a composite/multi-light care mode would require the vendor
|
|
// command builder to accept several wavelengths at once — not implemented here.
|
|
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,
|
|
functions: [
|
|
{ id: 'rejuvenate', wavelength: 2, wl: 'red', color: '#E8503A' },
|
|
{ id: 'acne', wavelength: 3, wl: 'uv', color: '#7C4DFF' },
|
|
{ id: 'eventone', wavelength: 4, wl: 'yellow', color: '#F5B841' },
|
|
{ id: 'revitalize', wavelength: 1, wl: 'infrared', color: '#8B2E3C' }
|
|
],
|
|
selectedFunctionId: 'rejuvenate',
|
|
selectedWavelength: 2,
|
|
// 掩码 = IO 纵列布局(与 treatment-setup 一致):左=0x01 中上=0x02 中=0x04 中下=0x08 右=0x10
|
|
regions: [
|
|
{ key: 'left', mask: 0x01, checked: true },
|
|
{ key: 'top', mask: 0x02, checked: true },
|
|
{ key: 'middle', mask: 0x04, checked: true },
|
|
{ key: 'bottom', mask: 0x08, checked: true },
|
|
{ key: 'right', mask: 0x10, checked: true }
|
|
],
|
|
// safety: a single session must NOT exceed 10 minutes (hardware caps at 10).
|
|
durations: [5, 10],
|
|
selectedMinutes: 10,
|
|
durationOptions: [],
|
|
submitting: false,
|
|
error: ''
|
|
},
|
|
|
|
onLoad: function () {
|
|
var app = getApp()
|
|
if (app && app.globalData && app.globalData.statusBarHeight) {
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
|
|
}
|
|
},
|
|
|
|
onShow: function () {
|
|
i18n.bind(this)
|
|
this.refreshDurationOptions()
|
|
},
|
|
|
|
// Duration labels carry a dynamic number, which WXML cannot substitute, so
|
|
// build the final strings in JS. Re-run on every onShow to follow locale.
|
|
refreshDurationOptions: function () {
|
|
var options = this.data.durations.map(function (min) {
|
|
return { min: min, label: i18n.t('manual.durationUnit', { min: min }) }
|
|
})
|
|
this.setData({ durationOptions: options })
|
|
},
|
|
|
|
onBack: function () {
|
|
wx.navigateBack({
|
|
fail: function () {
|
|
wx.reLaunch({ url: '/pages/index/index' })
|
|
}
|
|
})
|
|
},
|
|
|
|
onSelectFunction: function (e) {
|
|
var id = e.currentTarget.dataset.id
|
|
var funcs = this.data.functions
|
|
var wavelength = this.data.selectedWavelength
|
|
for (var i = 0; i < funcs.length; i++) {
|
|
if (funcs[i].id === id) {
|
|
wavelength = funcs[i].wavelength
|
|
break
|
|
}
|
|
}
|
|
this.setData({ selectedFunctionId: id, selectedWavelength: wavelength })
|
|
},
|
|
|
|
onToggleRegion: function (e) {
|
|
var idx = e.currentTarget.dataset.idx
|
|
var regions = this.data.regions
|
|
regions[idx].checked = !regions[idx].checked
|
|
this.setData({ regions: regions })
|
|
},
|
|
|
|
onSelectDuration: function (e) {
|
|
var min = parseInt(e.currentTarget.dataset.min, 10)
|
|
this.setData({ selectedMinutes: min })
|
|
},
|
|
|
|
onStart: function () {
|
|
var self = this
|
|
|
|
if (!ble.isConnected()) {
|
|
self.setData({ error: i18n.t('common.deviceNotConnected') })
|
|
return
|
|
}
|
|
|
|
var mask = 0
|
|
self.data.regions.forEach(function (r) {
|
|
if (r.checked) mask |= r.mask
|
|
})
|
|
|
|
if (mask === 0) {
|
|
wx.showToast({ title: i18n.t('manual.noRegionSelected'), icon: 'none' })
|
|
return
|
|
}
|
|
|
|
var wavelength = self.data.selectedWavelength
|
|
var durationMs = self.data.selectedMinutes * 60000
|
|
|
|
self.setData({ submitting: true, error: '' })
|
|
|
|
ble.setParams({
|
|
region_mask: mask,
|
|
wavelength: wavelength,
|
|
brightness: self.data.brightness,
|
|
duration_ms: durationMs,
|
|
mode: 0,
|
|
control: 0x02
|
|
}).then(function () {
|
|
return ble.startTreatment(mask)
|
|
}).then(function () {
|
|
self.setData({ submitting: false })
|
|
wx.redirectTo({
|
|
url: '/pages/treating/treating?regions=' + mask +
|
|
'&wavelength=' + wavelength +
|
|
'&duration=' + durationMs +
|
|
'&mode=0'
|
|
})
|
|
}).catch(function (err) {
|
|
self.setData({
|
|
submitting: false,
|
|
error: (err && err.error_msg) || i18n.t('manual.startFailed')
|
|
})
|
|
})
|
|
}
|
|
})
|