比较提交
10
次代码提交
44935c4bf3
...
8a4f9382e4
| 作者 | SHA1 | 提交日期 | |
|---|---|---|---|
|
|
8a4f9382e4 | ||
|
|
36f12e098e | ||
|
|
69621fd2b6 | ||
|
|
7270b593ae | ||
|
|
b4d677a9b4 | ||
|
|
fa44f4f5ad | ||
|
|
340837c700 | ||
|
|
edf45690c3 | ||
|
|
0ffa67da65 | ||
|
|
c9799a5fc1 |
+1
-1
@@ -10,7 +10,7 @@ admin-console/dist/
|
||||
docs/reference/小程序及后台管理软件开发资料/
|
||||
软件系统说明.docx
|
||||
*.docx
|
||||
!docs/protocols/协议简述.docx
|
||||
!docs/protocols/*.docx
|
||||
cloud/sql/
|
||||
certs/
|
||||
*.pem
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>智美 - 管理后台</title>
|
||||
<title>LumiFlow - 管理后台</title>
|
||||
<!--preload-links-->
|
||||
<!--app-context-->
|
||||
</head>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="admin-layout">
|
||||
<view class="sidebar">
|
||||
<view class="sidebar-logo">💎 智美</view>
|
||||
<view class="sidebar-logo">💎 LumiFlow</view>
|
||||
<view class="sidebar-sub">管理后台</view>
|
||||
<view class="sidebar-menu">
|
||||
<view
|
||||
@@ -54,7 +54,7 @@ export default {
|
||||
computed: {
|
||||
pageTitle() {
|
||||
var item = this.menuItems.find(m => m.view === this.currentPage)
|
||||
return item ? item.icon + ' ' + item.label : '智美管理后台'
|
||||
return item ? item.icon + ' ' + item.label : 'LumiFlow 管理后台'
|
||||
},
|
||||
adminName() {
|
||||
var store = useUserStore()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "智美后台",
|
||||
"name": "LumiFlow 后台",
|
||||
"appid": "__UNI__HOXADMIN",
|
||||
"description": "Hox beauty device admin console",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": "100",
|
||||
"h5": {
|
||||
"title": "智美后台",
|
||||
"title": "LumiFlow 后台",
|
||||
"router": {
|
||||
"mode": "hash",
|
||||
"base": "/admin/"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "智美后台",
|
||||
"navigationBarTitleText": "LumiFlow 后台",
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"backgroundColor": "#f5f5f5"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view class="login-page">
|
||||
<view class="login-card">
|
||||
<view class="login-logo">💎</view>
|
||||
<view class="login-title">智美</view>
|
||||
<view class="login-title">LumiFlow</view>
|
||||
<view class="login-subtitle">管理后台</view>
|
||||
|
||||
<view class="form-group">
|
||||
@@ -32,7 +32,7 @@
|
||||
登 录
|
||||
</button>
|
||||
|
||||
<view class="login-footer">© 2026 智美管理后台</view>
|
||||
<view class="login-footer">© 2026 LumiFlow</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
二进制文件未显示。
二进制文件未显示。
二进制文件未显示。
二进制文件未显示。
二进制文件未显示。
二进制文件未显示。
二进制文件未显示。
+1
-1
@@ -21,7 +21,7 @@
|
||||
],
|
||||
"window": {
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"navigationBarTitleText": "智美",
|
||||
"navigationBarTitleText": "LumiFlow",
|
||||
"navigationBarTextStyle": "black",
|
||||
"backgroundColor": "#f5f5f5"
|
||||
},
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
var ble = require('../../services/ble')
|
||||
var SCAN_BRIGHTNESS = 128
|
||||
var SCAN_TIMEOUT = 12000
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
scanning: true,
|
||||
scanProgress: 0,
|
||||
regions: 0x7F,
|
||||
regionData: [],
|
||||
timeout: false,
|
||||
regions: 0x1F,
|
||||
pdValues: [],
|
||||
pdRaw: [],
|
||||
vbat: 0,
|
||||
battery: 0,
|
||||
error: ''
|
||||
},
|
||||
|
||||
@@ -22,72 +27,100 @@ Page({
|
||||
var app = getApp()
|
||||
this.setData({
|
||||
statusBarHeight: app.globalData.statusBarHeight,
|
||||
regions: parseInt(options.regions) || 0x7F
|
||||
regions: parseInt(options.regions) || 0x1F
|
||||
})
|
||||
this.startScan()
|
||||
},
|
||||
|
||||
startScan: function () {
|
||||
var self = this
|
||||
self.setData({ scanning: true, scanProgress: 0, timeout: false })
|
||||
|
||||
this._progressTimer = setInterval(function () {
|
||||
var p = self.data.scanProgress + 2
|
||||
if (p > 98) p = 98
|
||||
self.setData({ scanProgress: p })
|
||||
}, 100)
|
||||
|
||||
this._onStatus = function (status) {
|
||||
if (status.mode_state === 0x01) {
|
||||
self.setData({ scanProgress: 50 })
|
||||
} else if (status.mode_state === 0x04 || status.mode_state === 0x00) {
|
||||
clearInterval(self._progressTimer)
|
||||
self.setData({ scanning: false, scanProgress: 100 })
|
||||
var names = ble.getRegionName(status.region_mask || 0x7F)
|
||||
self.setData({ regionData: self.parseScanResults(names) })
|
||||
}
|
||||
}
|
||||
ble.on('status', this._onStatus)
|
||||
|
||||
ble.queryStatus().catch(function () {})
|
||||
|
||||
setTimeout(function () {
|
||||
clearInterval(self._progressTimer)
|
||||
if (!self.data.scanning) return
|
||||
self.setData({ scanning: false, scanProgress: 100 })
|
||||
var names = ble.getRegionName(self.data.regions || 0x7F)
|
||||
self.setData({ regionData: self.parseScanResults(names) })
|
||||
}, 5000)
|
||||
_cleanup: function () {
|
||||
if (this._progressTimer) { clearInterval(this._progressTimer); this._progressTimer = null }
|
||||
if (this._timeoutTimer) { clearTimeout(this._timeoutTimer); this._timeoutTimer = null }
|
||||
if (this._onAdc) { ble.off('adc', this._onAdc); this._onAdc = null }
|
||||
},
|
||||
|
||||
parseScanResults: function (regions) {
|
||||
return regions.map(function (name) {
|
||||
return { region: name, pd: '待检测' }
|
||||
startScan: function () {
|
||||
var self = this
|
||||
|
||||
if (!ble.isConnected()) {
|
||||
self.setData({ scanning: false, error: '设备未连接,请先连接设备' })
|
||||
return
|
||||
}
|
||||
|
||||
self.setData({ scanning: true, scanProgress: 0, error: '', pdValues: [] })
|
||||
|
||||
this._progressTimer = setInterval(function () {
|
||||
var p = self.data.scanProgress + 1
|
||||
if (p > 90) p = 90
|
||||
self.setData({ scanProgress: p })
|
||||
}, 80)
|
||||
|
||||
this._onAdc = function (data) {
|
||||
console.log('[SCAN] 收到ADC数据:', JSON.stringify(data))
|
||||
self._cleanup()
|
||||
self.setData({ scanning: false, scanProgress: 100 })
|
||||
self._handleAdcData(data)
|
||||
}
|
||||
ble.on('adc', this._onAdc)
|
||||
|
||||
console.log('[SCAN] 下发扫描指令: 全域亮度', SCAN_BRIGHTNESS)
|
||||
ble.setParams({
|
||||
region_mask: 0x1F,
|
||||
wavelength: 2,
|
||||
brightness: SCAN_BRIGHTNESS,
|
||||
hold_time: 10,
|
||||
control: 0x01
|
||||
}).then(function () {
|
||||
console.log('[SCAN] 扫描指令发送成功,等待ADC回传...')
|
||||
}).catch(function (err) {
|
||||
console.error('[SCAN] 扫描指令发送失败:', err)
|
||||
self._cleanup()
|
||||
self.setData({ scanning: false, scanProgress: 0, error: '扫描指令发送失败' })
|
||||
})
|
||||
|
||||
this._timeoutTimer = setTimeout(function () {
|
||||
if (!self.data.scanning) return
|
||||
console.log('[SCAN] 等待ADC超时,使用默认值')
|
||||
self._cleanup()
|
||||
self.setData({ scanning: false, scanProgress: 100 })
|
||||
self._handleAdcData(null)
|
||||
}, SCAN_TIMEOUT)
|
||||
},
|
||||
|
||||
_handleAdcData: function (data) {
|
||||
var regionNames = ['右区(IO1)', '左区(IO2)', '上区(IO3)', '中区(IO4)', '下区(IO5)']
|
||||
var pdValues = []
|
||||
|
||||
if (data && data.pd && data.pd.length >= 7) {
|
||||
this.setData({ pdRaw: data.pd, vbat: data.vbat || 0, battery: data.battery || 0 })
|
||||
for (var i = 0; i < 5; i++) {
|
||||
var barW = Math.min(100, Math.round(data.pd[i] / 40.95))
|
||||
pdValues.push({ region: regionNames[i], pd: data.pd[i], pdText: String(data.pd[i]), barWidth: barW })
|
||||
}
|
||||
pdValues.push({ region: 'PD6', pd: data.pd[5], pdText: String(data.pd[5]), barWidth: Math.min(100, Math.round(data.pd[5] / 40.95)) })
|
||||
pdValues.push({ region: 'PD7', pd: data.pd[6], pdText: String(data.pd[6]), barWidth: Math.min(100, Math.round(data.pd[6] / 40.95)) })
|
||||
|
||||
getApp().globalData.lastScanPd = data.pd
|
||||
getApp().globalData.lastScanVbat = data.vbat
|
||||
} else {
|
||||
for (var j = 0; j < 5; j++) {
|
||||
pdValues.push({ region: regionNames[j], pd: 0, pdText: '未采集', barWidth: 0 })
|
||||
}
|
||||
}
|
||||
|
||||
this.setData({ pdValues: pdValues })
|
||||
},
|
||||
|
||||
onUnload: function () {
|
||||
if (this._progressTimer) clearInterval(this._progressTimer)
|
||||
if (this._onStatus) ble.off('status', this._onStatus)
|
||||
this._cleanup()
|
||||
ble.stopTreatment().catch(function () {})
|
||||
},
|
||||
|
||||
onNext: function () {
|
||||
var mask = this.data.regions || 0x7F
|
||||
ble.setParams({
|
||||
region_mask: mask,
|
||||
wavelength: 2,
|
||||
brightness: 200,
|
||||
duration_ms: 600000,
|
||||
mode: 1
|
||||
}).then(function () {
|
||||
return ble.startTreatment(mask)
|
||||
}).then(function () {
|
||||
var mask = this.data.regions || 0x1F
|
||||
var pdRaw = this.data.pdRaw
|
||||
var pdParam = pdRaw.length > 0 ? '&pd=' + encodeURIComponent(JSON.stringify(pdRaw)) : ''
|
||||
wx.redirectTo({
|
||||
url: '/pages/treating/treating?regions=' + mask + '&wavelength=2&duration=600000&mode=1'
|
||||
url: '/pages/treatment-setup/treatment-setup?regions=' + mask + pdParam
|
||||
})
|
||||
}).catch(function (err) {
|
||||
wx.showToast({ title: err.error_msg || '启动失败', icon: 'none' })
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,30 +1,39 @@
|
||||
<view class="page">
|
||||
<view class="page-header page-header-pink" style="padding-top: {{statusBarHeight + 24}}px;">
|
||||
<view class="nav-back" bindtap="onBack">‹ 返回</view>
|
||||
<view class="page-header-title">自动扫描</view>
|
||||
<view class="page-header-subtitle">正在识别区域...</view>
|
||||
<view class="page-header-title">区域扫描</view>
|
||||
<view class="page-header-subtitle">{{scanning ? '正在采集数据...' : '扫描完成'}}</view>
|
||||
</view>
|
||||
|
||||
<view class="page-content">
|
||||
<view class="page-title">自动扫描区域</view>
|
||||
|
||||
<view class="scan-container">
|
||||
<view class="scan-container" wx:if="{{scanning}}">
|
||||
<view class="face-outline">
|
||||
<view class="scan-line"></view>
|
||||
</view>
|
||||
<view class="scan-progress-bar">
|
||||
<view class="scan-progress-fill" style="width: {{scanProgress}}%"></view>
|
||||
</view>
|
||||
<view class="scan-status">全域LED已开启,亮度 128,等待PD数据回传...</view>
|
||||
</view>
|
||||
|
||||
<view class="scan-hint">请正确佩戴设备</view>
|
||||
<view class="scan-hint" style="font-size:24rpx;color:#999;margin-top:8rpx;">连接设备后可获取检测数据</view>
|
||||
|
||||
<view class="scan-progress" wx:if="{{scanning}}">
|
||||
正在扫描... <text class="highlight">{{regionData.length || 3}}</text> 个区域
|
||||
<view class="scan-result" wx:if="{{!scanning && pdValues.length > 0}}">
|
||||
<view class="result-title">PD 采集结果</view>
|
||||
<view class="pd-list">
|
||||
<view class="pd-item" wx:for="{{pdValues}}" wx:key="region">
|
||||
<view class="pd-region">{{item.region}}</view>
|
||||
<view class="pd-value {{item.pd > 0 ? '' : 'pd-empty'}}">{{item.pdText}}</view>
|
||||
<view class="pd-bar-bg" wx:if="{{item.pd > 0}}">
|
||||
<view class="pd-bar-fill" style="width: {{item.barWidth}}%"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="vbat-info" wx:if="{{vbat > 0}}">
|
||||
电池电压: {{vbat}}mV ({{battery}}%)
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="detected-tags" wx:if="{{regionData.length > 0}}">
|
||||
<text class="detected-tag" wx:for="{{regionData}}" wx:key="region">{{item.region}}</text>
|
||||
</view>
|
||||
<view class="scan-error" wx:if="{{!scanning && error}}">{{error}}</view>
|
||||
|
||||
<button class="btn-primary mt-30" wx:if="{{!scanning}}" bindtap="onNext">设置参数</button>
|
||||
<button class="btn-primary mt-30" wx:if="{{!scanning}}" bindtap="onNext">下一步</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
.scan-container {
|
||||
position: relative;
|
||||
width: 320rpx;
|
||||
height: 400rpx;
|
||||
margin: 40rpx auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.face-outline {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
width: 320rpx;
|
||||
height: 400rpx;
|
||||
border: 6rpx solid #e5e5e5;
|
||||
border-radius: 50% 50% 45% 45%;
|
||||
position: relative;
|
||||
@@ -29,49 +29,103 @@
|
||||
100% { top: calc(100% - 6rpx); opacity: 0.5; }
|
||||
}
|
||||
|
||||
.scan-hint {
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #666666;
|
||||
margin-bottom: 24rpx;
|
||||
.scan-progress-bar {
|
||||
width: 80%;
|
||||
height: 8rpx;
|
||||
background: #f0f0f0;
|
||||
border-radius: 4rpx;
|
||||
margin-top: 30rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.scan-progress {
|
||||
text-align: center;
|
||||
background: #f0f9ff;
|
||||
padding: 16rpx 28rpx;
|
||||
border-radius: 24rpx;
|
||||
font-size: 26rpx;
|
||||
color: #006699;
|
||||
width: fit-content;
|
||||
margin: 0 auto;
|
||||
.scan-progress-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #E6508C, #DCB982);
|
||||
border-radius: 4rpx;
|
||||
transition: width 0.3s;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
color: #E6508C;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detected-tags {
|
||||
text-align: center;
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.detected-tag {
|
||||
background: #fdf2f8;
|
||||
border: 2rpx solid #E6508C;
|
||||
color: #E6508C;
|
||||
padding: 10rpx 24rpx;
|
||||
border-radius: 24rpx;
|
||||
.scan-status {
|
||||
font-size: 24rpx;
|
||||
display: inline-block;
|
||||
margin: 6rpx;
|
||||
animation: tagPulse 1s ease-in-out;
|
||||
color: #999;
|
||||
margin-top: 16rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@keyframes tagPulse {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.05); }
|
||||
.scan-result {
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 24rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.result-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.pd-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.pd-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.pd-region {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
width: 160rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pd-value {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #E6508C;
|
||||
width: 100rpx;
|
||||
flex-shrink: 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.pd-empty {
|
||||
color: #ccc;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.pd-bar-bg {
|
||||
flex: 1;
|
||||
height: 16rpx;
|
||||
background: #f5f5f5;
|
||||
border-radius: 8rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.pd-bar-fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #E6508C, #DCB982);
|
||||
border-radius: 8rpx;
|
||||
min-width: 4rpx;
|
||||
}
|
||||
|
||||
.vbat-info {
|
||||
margin-top: 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.scan-error {
|
||||
text-align: center;
|
||||
color: #ff4d4f;
|
||||
font-size: 26rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.btn-primary::after {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<view class="found-card" wx:if="{{state === 'binding'}}">
|
||||
<view class="found-icon">💆</view>
|
||||
<view class="found-name">智能面膜-{{deviceId}}</view>
|
||||
<view class="found-name">LumiFlow-{{deviceId}}</view>
|
||||
<text class="status-badge status-badge-green">正在配对...</text>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<view class="page">
|
||||
<view class="page-header page-header-pink" style="padding-top: {{statusBarHeight + 24}}px;">
|
||||
<view class="page-header-title">智美</view>
|
||||
<view class="page-header-title">LumiFlow</view>
|
||||
<view class="page-header-subtitle">微信登录</view>
|
||||
</view>
|
||||
|
||||
<view class="page-content">
|
||||
<view class="welcome-text">欢迎使用智美</view>
|
||||
<view class="welcome-text">欢迎使用LumiFlow</view>
|
||||
|
||||
<view class="flower-area">
|
||||
<text class="flower">💎</text>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
<view class="logout-btn" bindtap="onLogout">退出登录</view>
|
||||
|
||||
<view class="version-text">v0.1.5</view>
|
||||
<view class="version-text">v0.1.6</view>
|
||||
</view>
|
||||
|
||||
<!-- Edit profile modal -->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<view class="page">
|
||||
<view class="page-header page-header-pink" style="padding-top: {{statusBarHeight + 24}}px;">
|
||||
<view class="page-header-title">智美</view>
|
||||
<view class="page-header-title">LumiFlow</view>
|
||||
<view class="page-header-subtitle">完善个人资料</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -90,7 +90,8 @@ Page({
|
||||
wavelength: 2,
|
||||
brightness: 200,
|
||||
duration_ms: self.data.fixedDurationMs,
|
||||
mode: self.data.selectedMode
|
||||
mode: self.data.selectedMode,
|
||||
control: 0x02
|
||||
}).then(function () {
|
||||
return ble.startTreatment(mask)
|
||||
}).then(function () {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<view class="device-row-icon">💆</view>
|
||||
<view class="device-row-info">
|
||||
<view class="device-row-name">
|
||||
智能面膜
|
||||
LumiFlow
|
||||
<text class="status-badge status-badge-green" wx:if="{{connected}}">已连接</text>
|
||||
<text class="status-badge" style="background:#ccc;" wx:else>未连接</text>
|
||||
</view>
|
||||
|
||||
@@ -181,12 +181,13 @@ function startTreatment(regionMask) {
|
||||
|
||||
function stopTreatment() {
|
||||
if (protocol.PROTOCOL_MODE === 'vendor_33') {
|
||||
return writeRawCommand(protocol.buildVendorCommand33({
|
||||
return writeRawCommand(protocol.buildVendorCommand({
|
||||
region_mask: 0,
|
||||
wavelength: protocol.WAVELENGTH.R,
|
||||
brightness: 0,
|
||||
current_gain: 0,
|
||||
hold_time: 0
|
||||
hold_time: 0,
|
||||
control: protocol.CONTROL.IDLE
|
||||
}))
|
||||
}
|
||||
return writeCommandWithRetry(protocol.CMD.STOP, [])
|
||||
|
||||
@@ -98,8 +98,14 @@ function handleValueChange(res) {
|
||||
console.warn('[BLE] ADC checksum mismatch, dropping')
|
||||
return
|
||||
}
|
||||
emit('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct })
|
||||
emit('adc', { pd: parsed.pd, vbat: vbatMv, battery: batteryPct, fitting: parsed.fitting, run_state: parsed.run_state })
|
||||
emit('battery', { battery: batteryPct, vbat: vbatMv })
|
||||
if (parsed.fitting !== -1) {
|
||||
emit('fitting', { fitting: parsed.fitting })
|
||||
}
|
||||
if (parsed.run_state !== -1) {
|
||||
emit('run_state', { run_state: parsed.run_state })
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ module.exports = {
|
||||
WAVELENGTH: protocol.WAVELENGTH,
|
||||
TREAT_MODE: protocol.TREAT_MODE,
|
||||
REGION: protocol.REGION,
|
||||
CONTROL: protocol.CONTROL,
|
||||
DEVICE_ERR: protocol.DEVICE_ERR,
|
||||
|
||||
// Connection
|
||||
@@ -41,6 +42,7 @@ module.exports = {
|
||||
PROTOCOL_MODE: protocol.PROTOCOL_MODE,
|
||||
buildFrame: protocol.buildFrame,
|
||||
parseFrame: protocol.parseFrame,
|
||||
buildVendorCommand: protocol.buildVendorCommand,
|
||||
buildVendorCommand33: protocol.buildVendorCommand33,
|
||||
parseVendorStatus: protocol.parseVendorStatus,
|
||||
parseStatusReport: protocol.parseStatusReport,
|
||||
|
||||
@@ -155,9 +155,19 @@ function bytesToHex(bytes) {
|
||||
return hex.toUpperCase()
|
||||
}
|
||||
|
||||
// --- vendor 33-byte command protocol ---
|
||||
// --- vendor 34-byte command protocol ---
|
||||
// Byte1-30: IO1~IO5 (6B each: R, IR, UV, Y, GainH, GainL)
|
||||
// Byte31-32: hold time (seconds, big-endian)
|
||||
// Byte33: control (0=IDLE, 1=scan, 2=treat)
|
||||
// Byte34: XOR checksum of Byte1-33
|
||||
|
||||
function buildVendorCommand33(options) {
|
||||
var CONTROL = {
|
||||
IDLE: 0x00,
|
||||
SCAN: 0x01,
|
||||
TREAT: 0x02
|
||||
}
|
||||
|
||||
function buildVendorCommand(options) {
|
||||
options = options || {}
|
||||
var regionMask = options.region_mask || REGION.FULL_FACE
|
||||
var wavelength = options.wavelength || WAVELENGTH.R
|
||||
@@ -165,6 +175,7 @@ function buildVendorCommand33(options) {
|
||||
var gain = clampUInt16(options.current_gain === undefined ? brightness : 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,
|
||||
@@ -190,15 +201,38 @@ function buildVendorCommand33(options) {
|
||||
}
|
||||
|
||||
bytes.push((holdSeconds >> 8) & 0xFF, holdSeconds & 0xFF)
|
||||
bytes.push(control & 0xFF)
|
||||
bytes.push(xorChecksum(bytes))
|
||||
return bytes
|
||||
}
|
||||
|
||||
// deprecated: alias kept for backward compat, actually outputs 34 bytes
|
||||
function buildVendorCommand33(options) {
|
||||
return buildVendorCommand(options)
|
||||
}
|
||||
|
||||
function parseVendorStatus(buffer) {
|
||||
var bytes = bufferToBytes(buffer)
|
||||
if (bytes.length === 1) {
|
||||
return { type: 'heartbeat', heartbeat: bytes[0], is_heartbeat: true, raw_hex: bytesToHex(bytes) }
|
||||
}
|
||||
if (bytes.length === 19) {
|
||||
var checksum19 = xorChecksum(bytes.slice(0, 18))
|
||||
var pds19 = []
|
||||
for (var p = 0; p < 7; p++) {
|
||||
pds19.push(bytes[p * 2] | (bytes[p * 2 + 1] << 8))
|
||||
}
|
||||
return {
|
||||
type: 'adc',
|
||||
is_heartbeat: false,
|
||||
pd: pds19,
|
||||
vbat: bytes[14] | (bytes[15] << 8),
|
||||
fitting: bytes[16],
|
||||
run_state: bytes[17],
|
||||
checksum_ok: checksum19 === bytes[18],
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
}
|
||||
if (bytes.length === 17) {
|
||||
var checksum = xorChecksum(bytes.slice(0, 16))
|
||||
var pds = []
|
||||
@@ -210,10 +244,34 @@ function parseVendorStatus(buffer) {
|
||||
is_heartbeat: false,
|
||||
pd: pds,
|
||||
vbat: bytes[14] | (bytes[15] << 8),
|
||||
fitting: -1,
|
||||
run_state: -1,
|
||||
checksum_ok: checksum === bytes[16],
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
}
|
||||
if (bytes.length === 34) {
|
||||
var ios34 = []
|
||||
for (var j = 0; j < 5; j++) {
|
||||
var off34 = j * 6
|
||||
ios34.push({
|
||||
red: bytes[off34], infrared: bytes[off34 + 1],
|
||||
uv: bytes[off34 + 2], warm_yellow: bytes[off34 + 3],
|
||||
gain: (bytes[off34 + 4] << 8) | bytes[off34 + 5]
|
||||
})
|
||||
}
|
||||
var expected34 = xorChecksum(bytes.slice(0, 33))
|
||||
return {
|
||||
type: 'params',
|
||||
is_heartbeat: false,
|
||||
ios: ios34,
|
||||
hold_time: (bytes[30] << 8) | bytes[31],
|
||||
control: bytes[32],
|
||||
checksum: bytes[33],
|
||||
checksum_ok: expected34 === bytes[33],
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
}
|
||||
if (bytes.length === 33) {
|
||||
var ios = []
|
||||
for (var i = 0; i < 5; i++) {
|
||||
@@ -224,12 +282,15 @@ function parseVendorStatus(buffer) {
|
||||
gain: (bytes[off + 4] << 8) | bytes[off + 5]
|
||||
})
|
||||
}
|
||||
var expected33 = xorChecksum(bytes.slice(0, 32))
|
||||
return {
|
||||
type: 'params',
|
||||
is_heartbeat: false,
|
||||
ios: ios,
|
||||
hold_time: (bytes[30] << 8) | bytes[31],
|
||||
control: -1,
|
||||
checksum: bytes[32],
|
||||
checksum_ok: expected33 === bytes[32],
|
||||
raw_hex: bytesToHex(bytes)
|
||||
}
|
||||
}
|
||||
@@ -345,6 +406,7 @@ module.exports = {
|
||||
TREAT_MODE: TREAT_MODE,
|
||||
REGION: REGION,
|
||||
REGION_NAMES: REGION_NAMES,
|
||||
CONTROL: CONTROL,
|
||||
DEVICE_ERR: DEVICE_ERR,
|
||||
|
||||
bufferToBytes: bufferToBytes,
|
||||
@@ -354,6 +416,7 @@ module.exports = {
|
||||
bytesToUint32: bytesToUint32,
|
||||
hexToBytes: hexToBytes,
|
||||
bytesToHex: bytesToHex,
|
||||
buildVendorCommand: buildVendorCommand,
|
||||
buildVendorCommand33: buildVendorCommand33,
|
||||
|
||||
buildFrame: buildFrame,
|
||||
|
||||
@@ -16,7 +16,10 @@ function execute(command) {
|
||||
wavelength: payload.wavelength,
|
||||
brightness: payload.brightness,
|
||||
duration_ms: payload.duration_ms,
|
||||
mode: payload.mode
|
||||
mode: payload.mode,
|
||||
control: payload.control,
|
||||
current_gain: payload.current_gain,
|
||||
hold_time: payload.hold_time
|
||||
})
|
||||
case ble.CMD.START:
|
||||
return ble.startTreatment(payload.region_mask)
|
||||
|
||||
@@ -89,7 +89,7 @@ async function create(device) {
|
||||
device_id: device.device_id,
|
||||
product_id: device.product_id || 'HOX_LIGHT_MASK',
|
||||
device_secret: device.device_secret || '',
|
||||
device_name: device.device_name || '智能面膜',
|
||||
device_name: device.device_name || 'LumiFlow',
|
||||
firmware_version: device.firmware_version || '1.0.0'
|
||||
}
|
||||
)
|
||||
@@ -111,7 +111,7 @@ async function createBatch(deviceIds) {
|
||||
device_id: deviceId,
|
||||
product_id: 'HOX_LIGHT_MASK',
|
||||
device_secret: '',
|
||||
device_name: '智能面膜',
|
||||
device_name: 'LumiFlow',
|
||||
firmware_version: '1.0.0'
|
||||
})
|
||||
created++
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ async function createPrepayOrder({ openid, orderId, amountFen, description }) {
|
||||
const body = {
|
||||
appid: config.wxpay.appid || config.wechat.appid,
|
||||
mchid: config.wxpay.mchId,
|
||||
description: description || '智能面膜订阅',
|
||||
description: description || 'LumiFlow 订阅',
|
||||
out_trade_no: orderId,
|
||||
notify_url: config.wxpay.notifyUrl,
|
||||
amount: { total: amountFen, currency: 'CNY' },
|
||||
|
||||
@@ -92,7 +92,7 @@ router.post('/devices', requireAdmin, wrap(async (req, res) => {
|
||||
device_id: deviceId,
|
||||
product_id: req.body.product_id || 'HOX_LIGHT_MASK',
|
||||
device_secret: req.body.device_secret || '',
|
||||
device_name: req.body.device_name || '智能面膜',
|
||||
device_name: req.body.device_name || 'LumiFlow',
|
||||
firmware_version: req.body.firmware_version || '1.0.0'
|
||||
})
|
||||
await logDao.write({ admin_id: req.admin.admin_id, action: 'admin_device_create', detail: '预生成产品码: ' + deviceId, ip: req.ip })
|
||||
|
||||
@@ -68,7 +68,7 @@ router.post('/subscription/purchase', requireUser, wrap(async (req, res) => {
|
||||
openid: req.user.openid,
|
||||
orderId,
|
||||
amountFen,
|
||||
description: '智能面膜-' + (plan === 'yearly' ? '年卡' : '月卡')
|
||||
description: 'LumiFlow-' + (plan === 'yearly' ? '年卡' : '月卡')
|
||||
})
|
||||
|
||||
await paymentOrderDao.markPrepay(orderId, prepayId)
|
||||
|
||||
在新工单中引用
屏蔽一个用户