文件
jw-beauty/miniprogram/pages/wear-check/wear-check.js
T
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

76 行
1.8 KiB
JavaScript

var ble = require('../../services/ble')
var config = require('../../config/env')
Page({
data: {
statusBarHeight: 44,
checking: false,
result: null,
error: '',
devMode: false,
battery: 0,
connected: false
},
onBack: function () {
wx.navigateBack({
fail: function () {
wx.reLaunch({ url: '/pages/index/index' })
}
})
},
onLoad: function () {
var app = getApp()
this.setData({ statusBarHeight: app.globalData.statusBarHeight, devMode: config.__DEV__ || false })
var device = app.globalData.currentDevice || {}
this.setData({
battery: device.battery || 0,
connected: ble.isConnected()
})
},
onShow: function () {
this.checkWearing()
},
checkWearing: function () {
var self = this
self.setData({ checking: true, result: null, error: '' })
if (this._onStatus) ble.off('status', this._onStatus)
this._onStatus = function (status) {
self.setData({ checking: false })
if (status.battery !== undefined) {
self.setData({ battery: status.battery, connected: true })
}
if (status.bind_status === 1) {
self.setData({ result: 'ok' })
} else {
self.setData({ result: 'fail', error: '请确认设备已正确佩戴' })
}
}
ble.on('status', this._onStatus)
ble.queryStatus().catch(function (err) {
self.setData({ checking: false, result: 'fail', error: err.error_msg || '查询失败' })
})
},
onUnload: function () {
if (this._onStatus) ble.off('status', this._onStatus)
},
onNext: function () {
wx.navigateTo({ url: '/pages/treatment-setup/treatment-setup' })
},
onRetry: function () {
this.checkWearing()
},
onMockWearOk: function () {
this.setData({ checking: false, result: 'ok' })
}
})