fix: wear-check reconnect scans and connects directly
- Retry button disconnects then re-scans for device (no page navigation) - Prevents duplicate scan with checking guard - Disconnect before scan with 500ms delay for adapter recovery - Clears reconnect timer on success/error/unload - Error text updated to guide user to retry button
这个提交包含在:
@@ -39,7 +39,7 @@ Page({
|
||||
self.setData({ checking: true, result: null, error: '' })
|
||||
|
||||
if (!ble.isConnected()) {
|
||||
self.setData({ checking: false, result: 'fail', error: '设备未连接,请返回重新连接' })
|
||||
self.setData({ checking: false, result: 'fail', error: '设备未连接,请点击重新连接' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ Page({
|
||||
|
||||
onUnload: function () {
|
||||
if (this._onStatus) ble.off('status', this._onStatus)
|
||||
clearTimeout(this._reconnectTimer)
|
||||
ble.stopScan()
|
||||
},
|
||||
|
||||
onNext: function () {
|
||||
@@ -77,11 +79,33 @@ Page({
|
||||
},
|
||||
|
||||
onRetry: function () {
|
||||
if (!ble.isConnected()) {
|
||||
wx.navigateBack()
|
||||
var self = this
|
||||
if (self.data.checking) return
|
||||
if (ble.isConnected()) {
|
||||
self.checkWearing()
|
||||
return
|
||||
}
|
||||
this.checkWearing()
|
||||
self.setData({ checking: true, result: null, error: '', connected: false })
|
||||
clearTimeout(self._reconnectTimer)
|
||||
ble.disconnect()
|
||||
setTimeout(function () {
|
||||
ble.startScan({
|
||||
onFound: function () {},
|
||||
onConnected: function () {
|
||||
clearTimeout(self._reconnectTimer)
|
||||
self.setData({ checking: false, connected: true })
|
||||
self.checkWearing()
|
||||
},
|
||||
onError: function (err) {
|
||||
clearTimeout(self._reconnectTimer)
|
||||
self.setData({ checking: false, result: 'fail', error: err.msg || '连接失败' })
|
||||
}
|
||||
})
|
||||
self._reconnectTimer = setTimeout(function () {
|
||||
ble.stopScan()
|
||||
self.setData({ checking: false, result: 'fail', error: '搜索超时,请确认设备已开机' })
|
||||
}, 15000)
|
||||
}, 500)
|
||||
},
|
||||
|
||||
onMockWearOk: function () {
|
||||
|
||||
在新工单中引用
屏蔽一个用户