feat: 扫描报告页+手动选波长护理+光疗功效介绍页+诊断框架(占位阈值)

- services/diagnosis.js: 诊断流水线框架,阈值/PD映射为占位待标定,支持单波长降级
- auto-scan: 扫描完成改为出报告让用户选择护理(替代原自动开始治疗)
- 新增 scan-report/manual-treatment/light-info 三页,全部接入 i18n
- api.js: 新增 report/diagnosis-config 接口(对接后端契约)
这个提交包含在:
Guoguo
2026-07-18 20:17:09 -07:00
父节点 d8eb6677c6
当前提交 f2ee086cc8
修改 19 个文件,包含 1270 行新增30 行删除
@@ -0,0 +1,143 @@
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,
// region mask mapping identical to treatment-setup: 右=0x01 左=0x02 上=0x04 中=0x08 下=0x10
regions: [
{ key: 'right', mask: 0x01, checked: true },
{ key: 'left', mask: 0x02, checked: true },
{ key: 'top', mask: 0x04, checked: true },
{ key: 'middle', mask: 0x08, checked: true },
{ key: 'bottom', 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')
})
})
}
})
@@ -0,0 +1,4 @@
{
"navigationStyle": "custom",
"navigationBarTitleText": "手动护理"
}
@@ -0,0 +1,58 @@
<view class="page">
<view class="page-header page-header-pink" style="padding-top: {{statusBarHeight + 24}}px;">
<view class="nav-back" bindtap="onBack"> {{i18n.common.back}}</view>
<view class="page-header-title">{{i18n.manual.navTitle}}</view>
<view class="page-header-subtitle">{{i18n.manual.navSubtitle}}</view>
</view>
<view class="page-content">
<view class="page-title">{{i18n.manual.functionTitle}}</view>
<view class="func-grid">
<view
wx:for="{{functions}}"
wx:key="id"
class="func-card {{selectedFunctionId === item.id ? 'active' : ''}}"
style="{{selectedFunctionId === item.id ? 'border-color:' + item.color + ';' : ''}}"
bindtap="onSelectFunction"
data-id="{{item.id}}">
<view class="func-dot" style="background: {{item.color}};"></view>
<view class="func-name">{{i18n.manual.functions[item.id].name}}</view>
<view class="func-wl" style="color: {{item.color}};">{{i18n.common.wavelengths[item.wl]}}</view>
<view class="func-benefit">{{i18n.manual.functions[item.id].benefit}}</view>
</view>
</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>
</view>
<view class="page-title section-title">{{i18n.manual.durationTitle}}</view>
<view class="segmented">
<view
wx:for="{{durationOptions}}"
wx:key="min"
class="segment {{selectedMinutes === item.min ? 'active' : ''}}"
bindtap="onSelectDuration"
data-min="{{item.min}}">
{{item.label}}
</view>
</view>
<view class="safety-tip">{{i18n.manual.safetyTip}}</view>
<button class="btn-primary" bindtap="onStart" disabled="{{submitting}}" loading="{{submitting}}">
{{submitting ? i18n.manual.starting : i18n.manual.start}}
</button>
<view class="error-text" wx:if="{{error}}">{{error}}</view>
</view>
</view>
@@ -0,0 +1,125 @@
.nav-back {
position: absolute;
left: 32rpx;
font-size: 30rpx;
color: #ffffff;
}
.section-title {
font-size: 28rpx;
margin-top: 40rpx;
}
/* care function cards */
.func-grid {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
}
.func-card {
width: calc(50% - 10rpx);
box-sizing: border-box;
padding: 28rpx 24rpx;
background: #ffffff;
border: 4rpx solid #e5e5e5;
border-radius: 24rpx;
}
.func-card.active {
background: #fdf2f8;
}
.func-dot {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
margin-bottom: 16rpx;
}
.func-name {
font-size: 30rpx;
font-weight: 600;
color: #333333;
margin-bottom: 6rpx;
}
.func-wl {
font-size: 24rpx;
margin-bottom: 10rpx;
}
.func-benefit {
font-size: 22rpx;
color: #999999;
line-height: 1.5;
}
/* region checkbox grid */
.region-grid {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
justify-content: center;
}
.region-chip {
min-width: 140rpx;
padding: 20rpx 0;
text-align: center;
border: 4rpx solid #e5e5e5;
border-radius: 16rpx;
font-size: 26rpx;
color: #999999;
flex: 1 1 26%;
}
.region-chip.active {
border-color: #E6508C;
background: rgba(230, 80, 140, 0.12);
color: #E6508C;
}
/* duration segmented control */
.segmented {
display: flex;
gap: 20rpx;
}
.segment {
flex: 1;
padding: 24rpx 0;
text-align: center;
border: 4rpx solid #e5e5e5;
border-radius: 16rpx;
font-size: 28rpx;
color: #666666;
}
.segment.active {
border-color: #E6508C;
background: #fdf2f8;
color: #E6508C;
font-weight: 600;
}
.safety-tip {
margin: 32rpx 0 24rpx;
padding: 20rpx 24rpx;
background: #fff7e6;
border-radius: 16rpx;
font-size: 24rpx;
color: #ad6800;
line-height: 1.6;
}
.error-text {
text-align: center;
color: #ff4d4f;
font-size: 26rpx;
margin-top: 16rpx;
}
.btn-primary::after {
border: none;
}