提交图
28 次代码提交
作者 SHA1 备注 提交日期
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
Guoguo 4466c53c7b feat(i18n): 剩余15页全量接入中英(登录/注册/扫码/绑定/佩戴/扫描/治疗/订阅/帮助等)
- 3 个并行 agent 各管 5 页,互不重叠命名空间
- 全 App 18 页均 i18n.bind,22 命名空间/400 键中英对齐
- 动态文案(时长/天数/价格/区域)JS 内 i18n.t 计算;区域标签复用 common.regions
2026-07-19 06:00:04 -07:00
Guoguo 8e11b2da10 fix: 报告 device_id 用 ble.getDeviceId()(修 P2 空归属)+手动入口接入 i18n(P3) 2026-07-18 20:25:57 -07:00
Guoguo f2ee086cc8 feat: 扫描报告页+手动选波长护理+光疗功效介绍页+诊断框架(占位阈值)
- services/diagnosis.js: 诊断流水线框架,阈值/PD映射为占位待标定,支持单波长降级
- auto-scan: 扫描完成改为出报告让用户选择护理(替代原自动开始治疗)
- 新增 scan-report/manual-treatment/light-info 三页,全部接入 i18n
- api.js: 新增 report/diagnosis-config 接口(对接后端契约)
2026-07-18 20:17:09 -07:00
Guoguo dae50a74fd fix: remove scan duration hint text from auto-scan page 2026-07-02 06:05:29 -07:00
Guoguo 784af52b7a fix: require seenRunState1 before judging fitting failure, prevent initial frame false trigger 2026-07-01 05:34:05 -07:00
Guoguo 515153f134 feat: auto-scan 3-phase state machine with proper PD collection timing
- Phase 1 (waiting_fit): after sending control=0x01, wait for fitting=1
- Phase 2 (collecting): once fitting=1 AND run_state=1, start PD accumulation
- Phase 3 (done): run_state 1→0, calculate averages, auto-send treatment
- Check start-collecting in BOTH fitting and run_state handlers
- fitting=0 + run_state 1→0 = fitting failure, prompt retry
- Timeout 3 minutes (was 30s), auto-start treatment on completion
2026-06-29 05:36:12 -07:00
Guoguo 74591d4da2 fix: audit fixes — dedupe run_state logs, stop device on scan exit
- Only log run_state when value changes (avoid flooding console)
- Send stopTreatment on unload if scan is in progress (stop device LEDs)
2026-06-29 04:02:16 -07:00
Guoguo f5cd882986 feat: redesign auto-scan as detection page with manual trigger and PD averaging
- Add "start detection" button (not auto-start on page load)
- Send control=0x01 only when user clicks button
- Accumulate PD values across all ADC frames during scan
- Monitor run_state: wait for 0x01→0x00 transition as completion signal
- Calculate PD averages on completion
- Send treatment command (control=0x02) on "next" with calculated params
- TODO: plug in full NR diagnosis algorithm when PD→region mapping confirmed
2026-06-29 03:58:40 -07:00
Guoguo 52f3ef971b fix: auto-scan onNext goes directly to treating instead of looping back to setup 2026-06-24 19:38:16 -07:00
Guoguo 4c674e5c23 fix: address audit findings — fitting trigger, race guards, state conflicts
wear-check:
- Send weak pulse light (brightness=26) to trigger FFE4 fitting report
- Timeout degrades to pass (backward compat with 17-byte firmware)
- Sync _resolved flag prevents double-resolve

treating:
- Only treat run_state=0x00 as completion after seeing run_state=0x02
  (prevents false completion on startup)
- Sync _finishing flag replaces async data.completed for race prevention
- onStatus preserves paused state during fitting loss (|| fittingLost)
- Remove dead _fittingTimer reference from onUnload

auto-scan:
- Sync _completed flag in _scanComplete prevents double-build
2026-06-22 06:28:25 -07:00
Guoguo f4e74e9460 feat: auto-scan receives 4 sequential ADC sets for multi-spectrum scan
Firmware does R→UV→Y→IR sequential scan autonomously. Miniprogram
now listens for 4 consecutive ADC notifications, storing each as a
separate spectrum group. Also listens for run_state=IDLE as scan
completion signal. Displays all 4 spectrum groups with PD1-PD7 bars.
Stores full scan data in globalData.lastScanData for diagnosis phase.
2026-06-22 06:20:53 -07:00
Guoguo 36f12e098e feat: upgrade FFE1 command to 34 bytes with control byte
Per 协议简述(3): Byte33 is now control instruction (0=IDLE, 1=scan,
2=treat), Byte34 is XOR checksum. Backward compat with 33-byte
read-back preserved. All command sites updated with correct control:
- auto-scan: control=0x01 (scan mode)
- treatment-setup: control=0x02 (treat mode)
- stopTreatment: control=0x00 (IDLE)
2026-06-12 09:00:01 -07:00
Guoguo edf45690c3 fix: address audit findings for Phase 1 scan
- Extract _cleanup() to properly unregister ADC listener + clear timers
- ADC callback unregisters itself on first receive (prevent duplicates)
- setParams failure now stops scanning and clears all state
- Timeout handler unregisters ADC listener
- Add BLE connection check before scan
- SCAN_TIMEOUT 8s → 12s (must exceed hold_time 10s)
- Pre-compute barWidth in JS instead of float math in WXML
- Error only shows when scanning is false
2026-06-10 08:18:54 -07:00
Guoguo 0ffa67da65 feat: implement MVP Phase 1 — full-area scan with ADC data collection
- Send scan command: all 5 regions LED on, brightness 128
- Listen for ADC notify (17 bytes) instead of broken queryStatus
- Parse and display PD1-PD7 values with visual bars
- Show VBAT/battery info
- Store scan PD data in globalData for Phase 3 smart adjustment
- 8s timeout fallback, stop LED on page unload
2026-06-10 08:16:17 -07:00
Guoguo 44935c4bf3 fix: correct region mapping (swap left/right, swap middle/bottom) and auto-scan proceeds on timeout
Region name mapping corrected to match actual hardware IO positions:
- 0x01: 左区→右区, 0x02: 右区→左区
- 0x08: 下区→中区, 0x10: 中区→下区
Auto-scan no longer shows timeout error, proceeds to next step instead.
2026-06-05 23:37:03 -07:00
Guoguo 29ff1c015b fix: replace facial/medical terms with neutral position labels
Region names: 左脸→左区, 右脸→右区, 额头→上区, 下巴→下区,
鼻唇→中区, 左眼→左上区, 右眼→右上区, 全脸→全区域.
Replace 面部/面罩 with 设备 in wear-check and auto-scan pages.
2026-05-31 23:39:06 -07:00
Guoguo aff8c2d9b5 fix: remove all medical device terms from user-facing text
Replace '光子美容仪' with '智美'/'智能面膜'/'我的设备' throughout.
Replace '护理' with '使用' in all UI text.
Replace '皮肤' with '检测'/'智能' where applicable.
Replace 🌸 with 💎 for brand identity.
Internal code (variable names, API paths, file names) unchanged.
2026-05-29 01:34:54 -07:00
Guoguo f0fdb285b5 chore: remove all mock/debug code for production release
Miniprogram:
- ENV switched to 'prod' (disables __DEV__ flag)
- Deleted mock.js and test-ble-frame.js
- Removed mockBind/mockPurchase from api.js
- Removed all debug UI panels and onMock* handlers from 6 pages
- Removed mock purchase fallback in subscribe-plans
- Removed SIMPLE PERIPHERAL dev board from BLE scan

Server:
- Removed /device/mock-bind route
- Removed /subscription/mock-purchase route
- Removed dev_openid fallback in wechat.js
- Removed mockBind() from binding.dao.js
- Removed mock fallback in purchase endpoint
- NODE_ENV default changed to 'production'

Admin:
- ENV switched to 'prod'

All mock code preserved in 'test' branch for future development use.
2026-05-20 07:19:26 -07:00
Guoguo 92416261ee feat: production readiness — feature gaps + config hardening
Miniprogram:
- Add BLE reconnect button on home page when disconnected
- Add loading states to index, profile, subscribe-plans pages
- Add profile editing (avatar + nickname) with COS upload
- Enable pull-to-refresh on history page
- Fix auto-scan self.options → self.data inconsistency
- Add console.error to silent catch blocks
- Gate 'Simple Peripheral' BLE scan behind __DEV__ flag
- Add production config comment to env.js

Admin console:
- Add empty state '暂无数据' to all 5 list views
- Replace plain text plan input with select dropdown
- Add type="date" to record date filters
- Add production config comment

Server:
- CORS origin restricted in production (env CORS_ORIGIN)
- DB pool size configurable via DB_POOL_SIZE env var
- .env.example updated with WeChat Pay + production fields
2026-05-15 09:07:41 -07:00
Guoguo 031678c03f feat: complete feature gaps across all modules
Server:
- Add settings-cache with 60s TTL for feature toggle checks
- Enforce maintenance_mode on login, enable_binding on device bind

Admin console:
- Remove dead "发送通知" button from user detail
- Firmware check calls real API and compares versions

Miniprogram:
- Wear-check: dynamic battery/connected from BLE state
- Login: hide non-functional phone auth button
- Treating: show actual selected regions instead of hardcoded "全脸"
- Index: display subscription status with tap to manage
- Auto-scan: show "待检测" instead of "--" for PD data
- Agreements: tap shows "内容建设中" modal
2026-05-02 08:48:26 -07:00
Guoguo c5f6033ccf fix: improve UX and fix admin console display issues
Miniprogram:
- Add back buttons to all custom-nav pages
- Add debug/mock buttons (BLE connect, wear check, treatment)
  controlled by __DEV__ flag (hidden in prod)

Admin console:
- Fix log page using nonexistent fields (operator_type, target_type)
  now correctly reads admin_id/user_id/action/detail from API
- Fix subscription date fields (started_at→start_time, expired_at→expire_time)
- Wire up subscription detail/extend/renew action buttons
- Wire up device detail "查看完整日志" button
- Add "创建订阅" button to subscription toolbar
- Fix subscription status mapping (2=expired, 3=cancelled)

Docs:
- Add detailed architecture docs for server, miniprogram, admin console
2026-04-28 18:32:26 -07:00
Guoguo b80e872600 fix: comprehensive security, quality and consistency fixes
Server:
- Block startup with default JWT secrets in production
- Make subscription verify admin-only (no payment integration yet)
- Add device ownership validation on command/result, event, treatment/sync
- Remove admin token from request body fallback
- Add pageParams boundary protection (pageSize capped at 100)
- Fix COS getObjectUrl to use callback-based Promise
- Add settings key whitelist matching frontend fields
- Add user existence check before subscription creation
- Fix firmware always returning has_update:true
- Replace hardcoded trial subscription with actual DB query
- Extract shared utilities (limitClause, toMysqlDate, formatDate)

Miniprogram:
- Replace fake PD random data with placeholder
- Mark client-timer treatment completions with source field
- Disable mock.js
- Fix BLE listener leaks (save refs, cleanup in onUnload)
- Fix ble.off clearing all listeners (pass specific callback)
- Add BLE disconnect detection via onBLEConnectionStateChange
- Fix subscription status type consistency (number not string)
- Fix scan callback accumulation in ble.js
- Fix history stats accumulation across pages
- Fix subscribe-success/treatment-done hardcoded values
- Fix profile subscription view logic
- Replace purchase flow with admin-contact modal
- Add error logging in command-sync report

Admin console:
- Fix AdminLayout logout (require->import, logout->clearToken)
- Remove all mock data from production request.js
- Replace dashboard fake data with real API calls
- Replace monthly_revenue with subscription_count
- Fix subscription stats fallback (|| -> ??)
- Add token expiry tracking (7 days)
- Unify device status map and subscription status text
- Fix user page record link navigation
- Fix subscription createForm.user_id type handling
- Add error feedback in all empty catch blocks
- Remove unused remember checkbox and uview-plus dependency
- Extract common CSS to shared stylesheet (-900 lines)
- Extract formatDate to shared utils/format.js
- Show real admin name in layout header
2026-04-28 08:46:59 -07:00
Guoguo 444c91c0b0 refactor: migrate to Tencent Cloud backend 2026-04-28 22:56:47 +08:00
Guoguo 52cb1f72dc fix: resolve header overlap on Dynamic Island iPhones
- app.js 通过 wx.getSystemInfoSync 获取 statusBarHeight 存入 globalData
- 所有12个自定义导航页面的 JS 读取 statusBarHeight
- WXML 通过 style="padding-top: {{statusBarHeight + 24}}px" 动态适配
- 普通手机和灵动岛手机都能正确显示
2026-04-24 22:20:10 +08:00
Guoguo 5064cf119d fix(ui): polish miniprogram and admin console details
小程序修复:
- 首页/我的/记录页移除自定义头部,使用原生导航栏
- tabBar '护理记录' 改为 '记录'
- 智能模式跳转auto-scan页面(不再跳过)
- 扫码区域尺寸 300→360rpx,图标 100→120rpx
- 护理中倒计时 120→144rpx
- 完成页图标 120→140rpx
- 完成页时长格式 '10分0秒' → '10分钟'
- 蓝牙连接 '连接中' → '点击连接'
- 订阅套餐默认选中年卡
- 订阅成功页改为动态数据(非硬编码)
- 我的页增加退出登录按钮
- 护理记录日期支持'今天/昨天'相对格式
- 扫描进度居中
- 锁定模式图标加灰度滤镜

管理后台修复:
- 所有页面移除重复页面标题
- 仪表盘统计卡片改为垂直布局
- 快捷操作图标统一粉色+箭头
- 设备管理搜索placeholder和库存badge修正
- 用户管理头像、次后缀、月卡/试用badge颜色修正
- 订阅管理stat背景改白色、过期改红色、tab切换修复
- 护理记录模式badge修正
- 操作日志改为平铺列表
- 系统设置开关改绿色、表单改水平布局
- 全局背景色 #f5f5f5 → #f0f2f5
2026-04-23 01:18:50 +08:00
Guoguo aa4b215c8b feat(ui): redesign all miniprogram pages
- 全局样式改为粉色(#E6508C)/金色(#DCB982)/绿色(#52c41a)配色
- 所有非tab页使用自定义导航栏,带彩色头部+标题+副标题
- login页: 粉色头部+🌸图标+微信授权登录
- scan页: 粉色头部+虚线扫码框+手动输入按钮
- ble-connect页: 蓝牙提示+搜索中/已发现设备卡片
- bind-success页: 绿色头部+成功图标+7天试用提示卡
- wear-check页: 设备信息行+佩戴指引卡片
- index首页: 粉色设备卡片+开始护理/设备管理按钮
- treatment-setup页: 模式选择+面部地图选区域
- auto-scan页: 面部轮廓+扫描线动画+检测标签
- treating页: 蓝色头部+大倒计时+渐变进度条+放松提示
- treatment-done页: 绿色头部+统计卡片+已记录提示
- subscribe-prompt页: 普通/智能模式对比+试用提示+金色订阅按钮
- subscribe-plans页: 金色头部+服务卡片+月卡/年卡选择
- subscribe-success页: 绿色头部+订阅详情卡+金色按钮
- profile页: 渐变头部+用户行+订阅卡+菜单列表
- history页: 粉色统计行+模式标签记录列表
2026-04-22 21:40:55 +08:00
Guoguo a84e37a6e2 feat: init project with miniprogram, cloud functions and admin console 2026-04-22 21:24:20 +08:00