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
这个提交包含在:
@@ -14,7 +14,8 @@ Page({
|
||||
bleState: 'disconnected',
|
||||
hasDevice: false,
|
||||
deviceInfo: null,
|
||||
devMode: false
|
||||
devMode: false,
|
||||
loading: true
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
@@ -47,9 +48,9 @@ Page({
|
||||
return
|
||||
}
|
||||
|
||||
self.setData({ connected: ble.isConnected() })
|
||||
self.setData({ connected: ble.isConnected(), loading: true })
|
||||
|
||||
api.getDevices().then(function (data) {
|
||||
var p1 = api.getDevices().then(function (data) {
|
||||
var devices = data.devices || []
|
||||
self.setData({ hasDevice: devices.length > 0 })
|
||||
if (devices.length > 0) {
|
||||
@@ -59,14 +60,22 @@ Page({
|
||||
deviceInfo: devices[0]
|
||||
})
|
||||
}
|
||||
}).catch(function () {})
|
||||
}).catch(function (err) {
|
||||
console.error('getDevices failed', err)
|
||||
})
|
||||
|
||||
api.getSubscription().then(function (sub) {
|
||||
var p2 = api.getSubscription().then(function (sub) {
|
||||
self.setData({
|
||||
subscription: sub,
|
||||
subRemaining: sub.remaining_days || 0
|
||||
})
|
||||
}).catch(function () {})
|
||||
}).catch(function (err) {
|
||||
console.error('getSubscription failed', err)
|
||||
})
|
||||
|
||||
Promise.all([p1, p2]).then(function () {
|
||||
self.setData({ loading: false })
|
||||
})
|
||||
},
|
||||
|
||||
onBleStatus: function (status) {
|
||||
@@ -88,7 +97,9 @@ Page({
|
||||
},
|
||||
onConnected: function () {
|
||||
self.setData({ connected: true, bleState: 'connected' })
|
||||
ble.queryStatus().catch(function () {})
|
||||
ble.queryStatus().catch(function (err) {
|
||||
console.error('queryStatus failed', err)
|
||||
})
|
||||
},
|
||||
onError: function (err) {
|
||||
self.setData({ connected: false, bleState: 'error' })
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<view class="page">
|
||||
<view class="page-content" wx:if="{{!hasDevice}}">
|
||||
<view class="loading-container" wx:if="{{loading}}">
|
||||
<view class="loading-spinner"></view>
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
|
||||
<view class="page-content" wx:if="{{!loading && !hasDevice}}">
|
||||
<view class="empty-device">
|
||||
<text class="empty-icon">📱</text>
|
||||
<view class="empty-text">还没有绑定设备</view>
|
||||
@@ -11,12 +16,13 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="page-content" wx:if="{{hasDevice}}">
|
||||
<view class="page-content" wx:if="{{!loading && hasDevice}}">
|
||||
<view class="device-card">
|
||||
<view class="device-icon">💆</view>
|
||||
<view class="device-name">{{deviceName || '我的光面膜'}}</view>
|
||||
<text class="status-badge status-badge-green" wx:if="{{connected}}">已连接</text>
|
||||
<text class="status-badge" style="background:#ccc;" wx:else>未连接</text>
|
||||
<button class="btn-secondary btn-sm" bindtap="onConnectBle" wx:if="{{hasDevice && !connected}}">重新连接</button>
|
||||
<view class="device-battery" wx:if="{{connected}}">
|
||||
<text>🔋</text>
|
||||
<text>电量 {{battery}}%</text>
|
||||
|
||||
@@ -42,3 +42,30 @@
|
||||
color: #999;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 200rpx 0;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border: 6rpx solid #f0f0f0;
|
||||
border-top-color: #E6508C;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
margin-top: 20rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户