feat: add loading animation on reconnect button, 5s timeout
这个提交包含在:
@@ -4,7 +4,8 @@ Page({
|
||||
data: {
|
||||
statusBarHeight: 44,
|
||||
battery: 0,
|
||||
connected: false
|
||||
connected: false,
|
||||
reconnecting: false
|
||||
},
|
||||
|
||||
onBack: function () {
|
||||
@@ -37,29 +38,32 @@ Page({
|
||||
|
||||
onRetry: function () {
|
||||
var self = this
|
||||
if (self.data.reconnecting) return
|
||||
if (ble.isConnected()) {
|
||||
self.setData({ connected: true })
|
||||
return
|
||||
}
|
||||
self.setData({ connected: false })
|
||||
self.setData({ connected: false, reconnecting: true })
|
||||
ble.disconnect()
|
||||
setTimeout(function () {
|
||||
ble.startScan({
|
||||
onFound: function () {},
|
||||
onConnected: function () {
|
||||
clearTimeout(self._reconnectTimer)
|
||||
self.setData({ connected: true })
|
||||
self.setData({ connected: true, reconnecting: false })
|
||||
wx.showToast({ title: '连接成功', icon: 'success' })
|
||||
},
|
||||
onError: function (err) {
|
||||
clearTimeout(self._reconnectTimer)
|
||||
self.setData({ reconnecting: false })
|
||||
wx.showToast({ title: err.msg || '连接失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
self._reconnectTimer = setTimeout(function () {
|
||||
ble.stopScan()
|
||||
self.setData({ reconnecting: false })
|
||||
wx.showToast({ title: '搜索超时', icon: 'none' })
|
||||
}, 15000)
|
||||
}, 5000)
|
||||
}, 500)
|
||||
},
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户