|
@@ -74,7 +74,7 @@ Page({
|
|
|
that.onBannerLoad();
|
|
|
},
|
|
|
|
|
|
- onShow() {},
|
|
|
+ onShow() { },
|
|
|
|
|
|
onLoginLoad() {
|
|
|
var that = this;
|
|
@@ -157,7 +157,7 @@ Page({
|
|
|
///监听蓝牙设备
|
|
|
BtHelper.getInstance().initBluetoothAdapter();
|
|
|
BtHelper.getInstance().getBluetoothDevices();
|
|
|
- BtHelper.getInstance().startScan(null, null, function (res) {});
|
|
|
+ BtHelper.getInstance().startScan(null, null, function (res) { });
|
|
|
var isFirst = true;
|
|
|
console.log("开始监听蓝牙设备");
|
|
|
that.startBleTimer(isFirst, true);
|
|
@@ -233,7 +233,21 @@ Page({
|
|
|
console.log("自动连接成功", isConnected)
|
|
|
if (isConnected) {
|
|
|
device.state = 'online';
|
|
|
- that.updateDeviceList(device);
|
|
|
+ let hasDev = that.data.deviceList.find(item => {
|
|
|
+ return item.deviceId === device.deviceId;
|
|
|
+ })
|
|
|
+
|
|
|
+ let hasOnline = that.data.deviceList.find(item => {
|
|
|
+ return item.state === 'online';
|
|
|
+ })
|
|
|
+
|
|
|
+ if (hasDev && hasOnline) {
|
|
|
+ // 有设备&&有在线的设备, 直接更新
|
|
|
+ hasDev.state = 'online';
|
|
|
+ that.updateDeviceList(that.data.deviceList, false, false);
|
|
|
+ } else {
|
|
|
+ that.addBlueDevice(device);
|
|
|
+ }
|
|
|
that.stopIntervalId1();
|
|
|
} else {
|
|
|
device.state = 'offline';
|
|
@@ -266,7 +280,7 @@ Page({
|
|
|
case "connect":
|
|
|
constant.lexinSubscribe.subscribeAllDevice();
|
|
|
break;
|
|
|
- ///再走有在线
|
|
|
+ ///再走有在线
|
|
|
case "message_onoffline":
|
|
|
constant.lexinConnect.searchOnlineDevice(payloads, function (list) {
|
|
|
that.updateDeviceList(list, false, false);
|
|
@@ -329,7 +343,7 @@ Page({
|
|
|
break;
|
|
|
default:
|
|
|
}
|
|
|
- } catch (e) {}
|
|
|
+ } catch (e) { }
|
|
|
},
|
|
|
|
|
|
///去连接设备数据
|