文件
jw-beauty/miniprogram/pages/wear-check/wear-check.js
T
Guoguo f85925ecd1 fix: correct page flow — wear-check before mode select, smart mode to auto-scan
- wear-check onNext → treatment-setup (was auto-scan)
- treatment-setup smart mode → auto-scan (was wear-check)
Flow: index → wear-check → treatment-setup → normal: treat / smart: auto-scan → treat
2026-06-29 05:28:05 -07:00

73 行
1.7 KiB
JavaScript

var ble = require('../../services/ble')
Page({
data: {
statusBarHeight: 44,
battery: 0,
connected: false,
regions: 0x1F
},
onBack: function () {
wx.navigateBack({
fail: function () {
wx.reLaunch({ url: '/pages/index/index' })
}
})
},
onLoad: function (options) {
var app = getApp()
this.setData({
statusBarHeight: app.globalData.statusBarHeight,
connected: ble.isConnected(),
regions: parseInt(options.regions) || 0x1F
})
var device = app.globalData.currentDevice || {}
this.setData({ battery: device.battery || 0 })
},
onNext: function () {
if (!ble.isConnected()) {
wx.showToast({ title: '设备未连接', icon: 'none' })
return
}
wx.redirectTo({
url: '/pages/treatment-setup/treatment-setup'
})
},
onRetry: function () {
var self = this
if (ble.isConnected()) {
self.setData({ connected: true })
return
}
self.setData({ connected: false })
ble.disconnect()
setTimeout(function () {
ble.startScan({
onFound: function () {},
onConnected: function () {
clearTimeout(self._reconnectTimer)
self.setData({ connected: true })
wx.showToast({ title: '连接成功', icon: 'success' })
},
onError: function (err) {
clearTimeout(self._reconnectTimer)
wx.showToast({ title: err.msg || '连接失败', icon: 'none' })
}
})
self._reconnectTimer = setTimeout(function () {
ble.stopScan()
wx.showToast({ title: '搜索超时', icon: 'none' })
}, 15000)
}, 500)
},
onUnload: function () {
clearTimeout(this._reconnectTimer)
ble.stopScan()
}
})