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 行删除
+38 -26
查看文件
@@ -1,4 +1,6 @@
var ble = require('../../services/ble')
var api = require('../../utils/api')
var diagnosis = require('../../services/diagnosis')
var SCAN_TIMEOUT = 180000
Page({
@@ -158,39 +160,49 @@ Page({
getApp().globalData.lastScanPdAvg = avg
console.log('[SCAN] PD平均值:', avg, '帧数:', count)
this._startTreatment()
this._buildAndGoReport(avg)
},
_startTreatment: function () {
// 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) {
var self = this
var app = getApp()
var mask = self.data.regions || 0x1F
var avg = self.data.pdAvg
var params = self._calculateTreatParams(mask, avg)
var deviceId = (app.globalData.connectedDevice && app.globalData.connectedDevice.device_id) || null
var scannedAt = Date.now()
console.log('[SCAN] 自动发送治疗命令:', JSON.stringify(params))
ble.setParams(params).then(function () {
return ble.startTreatment(mask)
}).then(function () {
wx.redirectTo({
url: '/pages/treating/treating?regions=' + mask +
'&wavelength=2&duration=600000&mode=1'
})
}).catch(function (err) {
self.setData({ error: err.error_msg || '启动治疗失败' })
})
},
function proceed(config) {
var scanData = diagnosis.fromRedScan(avg, mask, deviceId, scannedAt)
var report = diagnosis.analyze(scanData, config || diagnosis.DEFAULT_CONFIG)
app.globalData.lastScanReport = report
_calculateTreatParams: function (mask, pdAvg) {
// TODO: 接入完整诊断算法(NR 归一化吸收率 → 匹配光谱+强度)
// 需要 PD→区域映射确认后实现
return {
region_mask: mask,
wavelength: 2,
brightness: 200,
duration_ms: 600000,
mode: 1,
control: 0x02
// Best-effort persist (also seeds the calibration dataset via raw_pd); never blocks navigation.
api.saveReport({
device_id: report.device_id,
scanned_at: report.scanned_at,
regions: report.regions,
overall: report.overall,
recommend_mask: report.recommend_mask,
recommend_plan: report.recommend_plan,
raw_pd: report.raw_pd,
calibrated: report.calibrated
}).catch(function () {})
wx.redirectTo({ url: '/pages/scan-report/scan-report' })
}
api.getDiagnosisConfig().then(function (cfg) {
proceed(cfg && cfg.levels ? cfg : diagnosis.DEFAULT_CONFIG)
}).catch(function () {
proceed(diagnosis.DEFAULT_CONFIG)
})
},
onUnload: function () {
@@ -0,0 +1,34 @@
var i18n = require('../../i18n/index')
Page({
data: {
statusBarHeight: 44,
// Ordered list of lights; strings live in i18n under lightInfo.lights[key],
// colors are presentation-only and stay in JS.
lights: [
{ key: 'red', color: '#E8503A' },
{ key: 'uv', color: '#7C4DFF' },
{ key: 'yellow', color: '#F5B841' },
{ key: 'infrared', color: '#8B2E3C' }
],
// Parallel to i18n.lightInfo.modes (matched by index).
modeColors: ['#E8503A', '#7C4DFF', '#F5B841', '#8B2E3C', '#F08AA8']
},
onLoad: function () {
var app = getApp()
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
},
onShow: function () {
i18n.bind(this)
},
onBack: function () {
wx.navigateBack({
fail: function () {
wx.switchTab({ url: '/pages/profile/profile' })
}
})
}
})
@@ -0,0 +1,4 @@
{
"navigationStyle": "custom",
"navigationBarTitleText": "光疗功效介绍"
}
@@ -0,0 +1,40 @@
<view class="page">
<view class="page-header page-header-gradient" style="padding-top: {{statusBarHeight + 24}}px;">
<view class="nav-back nav-back-light" bindtap="onBack"> {{i18n.common.back}}</view>
<view class="page-header-title">{{i18n.lightInfo.navTitle}}</view>
<view class="page-header-subtitle">{{i18n.lightInfo.headerSubtitle}}</view>
</view>
<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-top">
<view class="swatch" style="background: {{item.color}};"></view>
<view class="light-head">
<view class="light-name">{{i18n.lightInfo.lights[item.key].name}}</view>
<view class="light-wave">{{i18n.lightInfo.lights[item.key].wavelength}}</view>
</view>
</view>
<view class="light-effect" style="color: {{item.color}};">{{i18n.lightInfo.lights[item.key].effect}}</view>
<view class="light-desc">{{i18n.lightInfo.lights[item.key].desc}}</view>
<view class="light-suits">
<text class="suits-label">{{i18n.lightInfo.suitsLabel}}</text>
<text class="suits-text">{{i18n.lightInfo.lights[item.key].suits}}</text>
</view>
</view>
<!-- 护理模式 -->
<view class="section-title section-title-gap">{{i18n.lightInfo.modesSectionTitle}}</view>
<view class="mode-grid">
<view class="mode-card" wx:for="{{i18n.lightInfo.modes}}" wx:for-item="mode" wx:key="name">
<view class="mode-dot" style="background: {{modeColors[index]}};"></view>
<view class="mode-name">{{mode.name}}</view>
<view class="mode-desc">{{mode.desc}}</view>
</view>
</view>
<!-- 免责声明 -->
<view class="disclaimer">{{i18n.lightInfo.disclaimer}}</view>
</view>
</view>
@@ -0,0 +1,125 @@
.section-title {
font-size: 30rpx;
font-weight: 600;
color: #333333;
margin-bottom: 24rpx;
}
.section-title-gap {
margin-top: 44rpx;
}
/* 光卡片 */
.light-card {
background: #ffffff;
border-radius: 24rpx;
padding: 32rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.04);
}
.light-card-top {
display: flex;
align-items: center;
gap: 24rpx;
margin-bottom: 20rpx;
}
.swatch {
width: 72rpx;
height: 72rpx;
border-radius: 50%;
flex-shrink: 0;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
}
.light-head {
display: flex;
flex-direction: column;
gap: 6rpx;
}
.light-name {
font-size: 32rpx;
font-weight: 600;
color: #333333;
}
.light-wave {
font-size: 24rpx;
color: #999999;
}
.light-effect {
font-size: 28rpx;
font-weight: 600;
margin-bottom: 12rpx;
}
.light-desc {
font-size: 26rpx;
color: #666666;
line-height: 1.6;
margin-bottom: 16rpx;
}
.light-suits {
font-size: 24rpx;
line-height: 1.5;
padding-top: 16rpx;
border-top: 2rpx solid #f2f2f2;
}
.suits-label {
color: #999999;
margin-right: 12rpx;
}
.suits-text {
color: #555555;
}
/* 护理模式 */
.mode-grid {
display: flex;
flex-wrap: wrap;
gap: 20rpx;
}
.mode-card {
width: calc(50% - 10rpx);
box-sizing: border-box;
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx 24rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.04);
}
.mode-dot {
width: 40rpx;
height: 40rpx;
border-radius: 50%;
margin-bottom: 16rpx;
}
.mode-name {
font-size: 28rpx;
font-weight: 600;
color: #333333;
margin-bottom: 8rpx;
}
.mode-desc {
font-size: 24rpx;
color: #888888;
line-height: 1.5;
}
/* 免责声明 */
.disclaimer {
margin-top: 44rpx;
font-size: 22rpx;
color: #aaaaaa;
line-height: 1.6;
text-align: center;
}
@@ -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;
}
@@ -0,0 +1,184 @@
var api = require('../../utils/api')
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' }
function pad2(n) { return (n < 10 ? '0' : '') + n }
function formatTime(ms) {
if (!ms) ms = Date.now()
var d = new Date(ms)
return d.getFullYear() + '-' + pad2(d.getMonth() + 1) + '-' + pad2(d.getDate()) +
' ' + pad2(d.getHours()) + ':' + pad2(d.getMinutes())
}
Page({
data: {
statusBarHeight: 44,
loading: true,
calibrated: true,
hasProblem: false,
scannedAtText: '',
overallList: [],
regionList: [],
recommendList: [],
starting: false,
error: ''
},
onLoad: function (options) {
var app = getApp()
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
this._options = options || {}
},
onShow: function () {
i18n.bind(this)
this._loadReport()
},
onBack: function () {
wx.navigateBack({ fail: function () { wx.reLaunch({ url: '/pages/index/index' }) } })
},
_loadReport: function () {
var self = this
var app = getApp()
var opts = self._options || {}
if (opts.report_id) {
self.setData({ loading: true })
api.getReport(opts.report_id).then(function (rep) {
self._render(self._normalize(rep))
}).catch(function () { self._fallback() })
return
}
if (app.globalData.lastScanReport) {
self._render(app.globalData.lastScanReport)
return
}
self.setData({ loading: true })
api.getLatestReport().then(function (rep) {
// Backend ok() coerces null -> {}, so treat an empty payload as "no report".
if (self._hasContent(rep)) self._render(self._normalize(rep))
else self._fallback()
}).catch(function () { self._fallback() })
},
_hasContent: function (rep) {
if (!rep) return false
return !!((rep.regions && rep.regions.length) ||
(rep.overall && rep.overall.length) ||
(rep.recommend_plan && rep.recommend_plan.length))
},
_fallback: function () {
// Preview/demo when no device data is available yet.
this._render(diagnosis.mockReport())
},
_normalize: function (rep) {
if (!rep) return diagnosis.mockReport()
var scannedAt = 0
if (typeof rep.scanned_at === 'number') scannedAt = rep.scanned_at
else if (rep.scanned_at) scannedAt = Date.parse(rep.scanned_at) || 0
return {
device_id: rep.device_id || null,
scanned_at: scannedAt,
regions: rep.regions || [],
overall: rep.overall || [],
recommend_mask: rep.recommend_mask || 0,
recommend_plan: rep.recommend_plan || [],
raw_pd: rep.raw_pd || {},
calibrated: !!rep.calibrated
}
},
_render: function (report) {
var d = i18n.getDict().report
var common = i18n.getDict().common
function levelLabel(l) {
if (l >= 3) return d.level.high
if (l === 2) return d.level.mid
if (l === 1) return d.level.low
return d.noProblem
}
var overallList = (report.overall || []).map(function (o) {
return { label: d.problems[o.type] || o.type, level: o.level, levelLabel: levelLabel(o.level) }
})
var regionList = (report.regions || []).map(function (r) {
return {
name: d.regionNames[r.region] || r.region,
level: r.level,
levelLabel: levelLabel(r.level),
problemLabel: r.top_problem ? (d.problems[r.top_problem] || r.top_problem) : d.noProblem,
hasProblem: !!r.top_problem
}
})
var defs = diagnosis.REGION_DEFS
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,
mask: p.mask
}
})
this._report = report
this.setData({
loading: false,
calibrated: !!report.calibrated,
hasProblem: overallList.length > 0,
scannedAtText: formatTime(report.scanned_at),
overallList: overallList,
regionList: regionList,
recommendList: recommendList,
error: ''
})
},
onStartRecommend: function () {
var self = this
var report = self._report || {}
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
self.setData({ starting: true, error: '' })
ble.setParams({
region_mask: mask, wavelength: wl, brightness: 140,
duration_ms: 600000, mode: 1, control: 0x02
}).then(function () {
return ble.startTreatment(mask)
}).then(function () {
wx.redirectTo({
url: '/pages/treating/treating?regions=' + mask +
'&wavelength=' + wl + '&duration=600000&mode=1'
})
}).catch(function (err) {
self.setData({ starting: false, error: (err && err.error_msg) || i18n.t('common.networkError') })
})
},
onManual: function () {
wx.redirectTo({ url: '/pages/manual-treatment/manual-treatment' })
}
})
@@ -0,0 +1,4 @@
{
"navigationStyle": "custom",
"navigationBarTitleText": "扫描报告"
}
@@ -0,0 +1,66 @@
<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"> {{i18n.common.back}}</view>
<view class="page-header-title">{{i18n.report.title}}</view>
<view class="page-header-subtitle">{{i18n.report.subtitle}}</view>
</view>
<view class="loading-container" wx:if="{{loading}}">
<view class="loading-spinner"></view>
<text class="loading-text">{{i18n.common.loading}}</text>
</view>
<view class="page-content" wx:if="{{!loading}}">
<view class="concept-banner" wx:if="{{!calibrated}}">
<text class="concept-icon">ⓘ</text>
<text class="concept-text">{{i18n.report.conceptNotice}}</text>
</view>
<view class="scan-time">{{i18n.report.scannedAt}}{{scannedAtText}}</view>
<!-- Overall -->
<view class="card">
<view class="card-title">{{i18n.report.overallTitle}}</view>
<view class="chip-row" wx:if="{{hasProblem}}">
<view class="chip chip-lv{{item.level}}" wx:for="{{overallList}}" wx:key="label">
<text class="chip-name">{{item.label}}</text>
<text class="chip-lv">{{item.levelLabel}}</text>
</view>
</view>
<view class="empty-hint" wx:else>{{i18n.report.noProblem}}</view>
</view>
<!-- Per-region -->
<view class="card">
<view class="card-title">{{i18n.report.regionTitle}}</view>
<view class="region-row" wx:for="{{regionList}}" wx:key="name">
<text class="region-name">{{item.name}}</text>
<view class="region-right">
<text class="region-problem {{item.hasProblem ? '' : 'region-problem-none'}}">{{item.problemLabel}}</text>
<text class="region-lv region-lv{{item.level}}" wx:if="{{item.hasProblem}}">{{item.levelLabel}}</text>
</view>
</view>
</view>
<!-- Recommendation -->
<view class="card" wx:if="{{recommendList.length > 0}}">
<view class="card-title">{{i18n.report.recommendTitle}}</view>
<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-meta">{{item.wavelengthLabel}} · {{item.regionsLabel}}</text>
</view>
</view>
</view>
<view class="error-text" wx:if="{{error}}">{{error}}</view>
<view class="actions">
<button class="btn-primary" bindtap="onStartRecommend" disabled="{{starting}}" loading="{{starting}}" wx:if="{{recommendList.length > 0}}">{{i18n.report.startTreatment}}</button>
<button class="btn-secondary" bindtap="onManual">{{i18n.report.manualInstead}}</button>
</view>
<view class="disclaimer">{{i18n.report.disclaimer}}</view>
</view>
</view>
@@ -0,0 +1,100 @@
.page {
min-height: 100vh;
background: #f5f5f5;
}
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
padding-top: 120rpx;
}
.loading-spinner {
width: 56rpx;
height: 56rpx;
border: 6rpx solid #eee;
border-top-color: #E8503A;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
.loading-text { margin-top: 20rpx; color: #999; font-size: 26rpx; }
@keyframes spin { to { transform: rotate(360deg); } }
.concept-banner {
display: flex;
align-items: center;
background: #FFF7E6;
border: 1rpx solid #FFE1A8;
border-radius: 14rpx;
padding: 18rpx 22rpx;
margin-bottom: 20rpx;
}
.concept-icon { color: #E8971A; margin-right: 12rpx; font-size: 30rpx; }
.concept-text { color: #A66908; font-size: 24rpx; line-height: 1.4; flex: 1; }
.scan-time { color: #999; font-size: 24rpx; margin: 0 6rpx 20rpx; }
.card {
background: #fff;
border-radius: 18rpx;
padding: 28rpx 26rpx;
margin-bottom: 22rpx;
box-shadow: 0 4rpx 18rpx rgba(0,0,0,0.04);
}
.card-title { font-size: 30rpx; font-weight: 600; color: #333; margin-bottom: 20rpx; }
.chip-row { display: flex; flex-wrap: wrap; }
.chip {
display: flex;
align-items: center;
border-radius: 999rpx;
padding: 10rpx 22rpx;
margin: 0 16rpx 16rpx 0;
background: #F3F4F6;
}
.chip-name { font-size: 26rpx; color: #333; }
.chip-lv { font-size: 22rpx; color: #fff; margin-left: 12rpx; padding: 2rpx 14rpx; border-radius: 999rpx; background: #bbb; }
.chip-lv1 .chip-lv { background: #6BBF59; }
.chip-lv2 .chip-lv { background: #F5B841; }
.chip-lv3 .chip-lv { background: #E8503A; }
.empty-hint { color: #999; font-size: 26rpx; }
.region-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.region-row:last-child { border-bottom: none; }
.region-name { font-size: 28rpx; color: #333; }
.region-right { display: flex; align-items: center; }
.region-problem { font-size: 26rpx; color: #555; margin-right: 14rpx; }
.region-problem-none { color: #aaa; }
.region-lv { font-size: 22rpx; color: #fff; padding: 2rpx 14rpx; border-radius: 999rpx; background: #bbb; }
.region-lv1 { background: #6BBF59; }
.region-lv2 { background: #F5B841; }
.region-lv3 { background: #E8503A; }
.rec-row { display: flex; align-items: flex-start; padding: 16rpx 0; }
.rec-dot {
width: 14rpx; height: 14rpx; border-radius: 50%;
background: #E8503A; margin-top: 12rpx; margin-right: 18rpx; flex-shrink: 0;
}
.rec-body { display: flex; flex-direction: column; }
.rec-label { font-size: 28rpx; color: #333; font-weight: 500; }
.rec-meta { font-size: 24rpx; color: #999; margin-top: 6rpx; }
.error-text { color: #E8503A; font-size: 26rpx; text-align: center; margin: 10rpx 0; }
.actions { margin-top: 12rpx; }
.actions .btn-primary, .actions .btn-secondary { margin-bottom: 20rpx; }
.disclaimer {
color: #b0b0b0;
font-size: 22rpx;
line-height: 1.5;
text-align: center;
margin: 20rpx 10rpx 40rpx;
}
@@ -25,6 +25,10 @@ Page({
})
},
onManual: function () {
wx.navigateTo({ url: '/pages/manual-treatment/manual-treatment' })
},
onLoad: function () {
var app = getApp()
this.setData({ statusBarHeight: app.globalData.statusBarHeight })
@@ -37,6 +37,8 @@
开始使用
</button>
<view class="manual-entry" bindtap="onManual" style="text-align:center;color:#E8503A;font-size:26rpx;margin-top:28rpx;">手动选择波长护理 </view>
<view class="error-text" wx:if="{{error}}">{{error}}</view>
</view>
</view>