feat: init project with miniprogram, cloud functions and admin console

这个提交包含在:
Guoguo
2026-04-22 21:24:20 +08:00
当前提交 a84e37a6e2
修改 106 个文件,包含 5902 行新增0 行删除
@@ -0,0 +1,102 @@
var ble = require('../../services/ble')
Page({
data: {
regions: [
{ name: '左脸颊', mask: 0x01, checked: true },
{ name: '右脸颊', mask: 0x02, checked: true },
{ name: '额头', mask: 0x04, checked: true },
{ name: '下巴', mask: 0x08, checked: true },
{ name: '鼻部', mask: 0x10, checked: true },
{ name: '左眼周', mask: 0x20, checked: false },
{ name: '右眼周', mask: 0x40, checked: false }
],
wavelengthOptions: [
{ name: '红光 630nm', value: 2, desc: '抗衰修复' },
{ name: '红外 850nm', value: 1, desc: '深层修复' },
{ name: '紫光 405nm', value: 3, desc: '祛痘消炎' },
{ name: '黄光 590nm', value: 4, desc: '提亮肤色' }
],
selectedWavelength: 2,
brightness: 200,
durationOptions: [
{ label: '5分钟', value: 300000 },
{ label: '10分钟', value: 600000 },
{ label: '15分钟', value: 900000 },
{ label: '20分钟', value: 1200000 }
],
selectedDuration: 600000,
modeOptions: [
{ name: '普通模式', value: 0 },
{ name: '智能模式', value: 1 }
],
selectedMode: 0,
submitting: false,
error: ''
},
onToggleRegion: function (e) {
var idx = e.currentTarget.dataset.idx
var regions = this.data.regions
regions[idx].checked = !regions[idx].checked
this.setData({ regions: regions })
},
onSelectAll: function () {
var regions = this.data.regions.map(function (r) {
return Object.assign({}, r, { checked: true })
})
this.setData({ regions: regions })
},
onSelectWavelength: function (e) {
this.setData({ selectedWavelength: e.currentTarget.dataset.value })
},
onBrightnessChange: function (e) {
this.setData({ brightness: parseInt(e.detail.value) })
},
onSelectDuration: function (e) {
this.setData({ selectedDuration: e.currentTarget.dataset.value })
},
onSelectMode: function (e) {
this.setData({ selectedMode: e.currentTarget.dataset.value })
},
onStart: function () {
var self = this
var mask = 0
self.data.regions.forEach(function (r) {
if (r.checked) mask |= r.mask
})
if (mask === 0) {
wx.showToast({ title: '请至少选择一个区域', icon: 'none' })
return
}
self.setData({ submitting: true, error: '' })
ble.setParams({
region_mask: mask,
wavelength: self.data.selectedWavelength,
brightness: self.data.brightness,
duration_ms: self.data.selectedDuration,
mode: self.data.selectedMode
}).then(function () {
return ble.startTreatment(mask)
}).then(function () {
self.setData({ submitting: false })
wx.redirectTo({
url: '/pages/treating/treating?regions=' + mask +
'&wavelength=' + self.data.selectedWavelength +
'&duration=' + self.data.selectedDuration +
'&mode=' + self.data.selectedMode
})
}).catch(function (err) {
self.setData({ submitting: false, error: err.error_msg || '启动失败' })
})
}
})
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "护理设置"
}
@@ -0,0 +1,62 @@
<view class="container">
<view class="card">
<view class="section-title">护理区域</view>
<view class="region-grid">
<view wx:for="{{regions}}" wx:key="mask" class="region-item {{item.checked ? 'region-active' : ''}}"
bindtap="onToggleRegion" data-idx="{{index}}">
<text>{{item.name}}</text>
</view>
</view>
<view class="btn-select-all mt-10" bindtap="onSelectAll">全选</view>
</view>
<view class="card">
<view class="section-title">波长选择</view>
<view class="wavelength-list">
<view wx:for="{{wavelengthOptions}}" wx:key="value"
class="wavelength-item {{selectedWavelength === item.value ? 'wavelength-active' : ''}}"
bindtap="onSelectWavelength" data-value="{{item.value}}">
<text class="wavelength-name">{{item.name}}</text>
<text class="wavelength-desc">{{item.desc}}</text>
</view>
</view>
</view>
<view class="card">
<view class="section-title">亮度: {{brightness}}</view>
<slider min="0" max="255" value="{{brightness}}" bindchange="onBrightnessChange"
activeColor="#333333" block-size="20" />
</view>
<view class="card">
<view class="section-title">护理时长</view>
<view class="duration-list">
<view wx:for="{{durationOptions}}" wx:key="value"
class="duration-item {{selectedDuration === item.value ? 'duration-active' : ''}}"
bindtap="onSelectDuration" data-value="{{item.value}}">
{{item.label}}
</view>
</view>
</view>
<view class="card">
<view class="section-title">护理模式</view>
<view class="mode-list">
<view wx:for="{{modeOptions}}" wx:key="value"
class="mode-item {{selectedMode === item.value ? 'mode-active' : ''}}"
bindtap="onSelectMode" data-value="{{item.value}}">
{{item.name}}
</view>
</view>
</view>
<view wx:if="{{error}}" class="card">
<text class="text-error">{{error}}</text>
</view>
<view class="btn-area-fixed">
<view class="btn-primary" bindtap="onStart" disabled="{{submitting}}">
{{submitting ? '启动中...' : '开始护理'}}
</view>
</view>
</view>
@@ -0,0 +1,98 @@
.region-grid {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.region-item {
padding: 12rpx 24rpx;
border-radius: 8rpx;
background-color: #f0f0f0;
font-size: 26rpx;
color: #666666;
}
.region-active {
background-color: #333333;
color: #ffffff;
}
.btn-select-all {
font-size: 24rpx;
color: #333333;
text-align: right;
}
.wavelength-list {
display: flex;
flex-direction: column;
gap: 12rpx;
}
.wavelength-item {
padding: 20rpx;
border: 2rpx solid #eeeeee;
border-radius: 8rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.wavelength-active {
border-color: #333333;
background-color: #fafafa;
}
.wavelength-name {
font-size: 28rpx;
font-weight: 500;
}
.wavelength-desc {
font-size: 24rpx;
color: #999999;
}
.duration-list {
display: flex;
gap: 16rpx;
}
.duration-item {
flex: 1;
padding: 16rpx;
text-align: center;
border: 2rpx solid #eeeeee;
border-radius: 8rpx;
font-size: 26rpx;
}
.duration-active {
border-color: #333333;
background-color: #333333;
color: #ffffff;
}
.mode-list {
display: flex;
gap: 16rpx;
}
.mode-item {
flex: 1;
padding: 16rpx;
text-align: center;
border: 2rpx solid #eeeeee;
border-radius: 8rpx;
font-size: 26rpx;
}
.mode-active {
border-color: #333333;
background-color: #333333;
color: #ffffff;
}
.btn-area-fixed {
padding: 20rpx 0 40rpx;
}