|
@@ -89,7 +89,7 @@ Page({
|
|
BtHelper.getInstance().initBluetoothAdapter();
|
|
BtHelper.getInstance().initBluetoothAdapter();
|
|
var l = store.getStore("deviceList");
|
|
var l = store.getStore("deviceList");
|
|
if (!strings.isEmpty(l)) {
|
|
if (!strings.isEmpty(l)) {
|
|
- that.updateDeviceList(l, true);
|
|
|
|
|
|
+ that.updateDeviceList(l, true, false);
|
|
}
|
|
}
|
|
|
|
|
|
///监听蓝牙设备
|
|
///监听蓝牙设备
|
|
@@ -153,7 +153,7 @@ Page({
|
|
}
|
|
}
|
|
|
|
|
|
if (isChanged) {
|
|
if (isChanged) {
|
|
- that.updateDeviceList(deviceList, false);
|
|
|
|
|
|
+ that.updateDeviceList(deviceList, false, false);
|
|
}
|
|
}
|
|
|
|
|
|
var autoConnected = that.data.autoConnected;
|
|
var autoConnected = that.data.autoConnected;
|
|
@@ -217,7 +217,7 @@ Page({
|
|
else if (payloads.type === "play" || payloads.type === "play_state") {
|
|
else if (payloads.type === "play" || payloads.type === "play_state") {
|
|
var deviceList = that.data.deviceList;
|
|
var deviceList = that.data.deviceList;
|
|
var deviceListSelect = that.data.deviceListSelect;
|
|
var deviceListSelect = that.data.deviceListSelect;
|
|
- if (deviceList.length <= deviceListSelect) {
|
|
|
|
|
|
+ if (deviceListSelect === null || deviceList.length <= deviceListSelect) {
|
|
return;
|
|
return;
|
|
};
|
|
};
|
|
|
|
|
|
@@ -274,7 +274,7 @@ Page({
|
|
}
|
|
}
|
|
///数据有更新
|
|
///数据有更新
|
|
if (isUpdate) {
|
|
if (isUpdate) {
|
|
- that.updateDeviceList(deviceList, false);
|
|
|
|
|
|
+ that.updateDeviceList(deviceList, false, false);
|
|
}
|
|
}
|
|
} else if (payloads.type === "battery" && payloads.other) {
|
|
} else if (payloads.type === "battery" && payloads.other) {
|
|
that.setData({
|
|
that.setData({
|
|
@@ -339,7 +339,7 @@ Page({
|
|
|
|
|
|
///数据有更新
|
|
///数据有更新
|
|
if (isUpdate) {
|
|
if (isUpdate) {
|
|
- that.updateDeviceList(deviceList, false);
|
|
|
|
|
|
+ that.updateDeviceList(deviceList, false, false);
|
|
}
|
|
}
|
|
|
|
|
|
deviceList = that.data.deviceList;
|
|
deviceList = that.data.deviceList;
|
|
@@ -396,7 +396,7 @@ Page({
|
|
};
|
|
};
|
|
|
|
|
|
that.setData({
|
|
that.setData({
|
|
- actionIndex: e.currentTarget.dataset.index
|
|
|
|
|
|
+ actionIndex: e.currentTarget.dataset.index,
|
|
});
|
|
});
|
|
|
|
|
|
var channelData = that.data.channelData;
|
|
var channelData = that.data.channelData;
|
|
@@ -475,6 +475,7 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 关于我们
|
|
goMeAbout() {
|
|
goMeAbout() {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: './../about/about',
|
|
url: './../about/about',
|
|
@@ -593,15 +594,20 @@ Page({
|
|
return;
|
|
return;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ ///限制蓝牙设备和不在线wifi设备
|
|
|
|
+ var device = deviceList[index];
|
|
|
|
+ if (device.connectType != 3 || device.state != "online") {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
// 取消订阅
|
|
// 取消订阅
|
|
var thisDeviceMac = that.data.thisDeviceMac;
|
|
var thisDeviceMac = that.data.thisDeviceMac;
|
|
if (thisDeviceMac !== null) {
|
|
if (thisDeviceMac !== null) {
|
|
app.unsubscribe(`/${thisDeviceMac}/user/pub_response`);
|
|
app.unsubscribe(`/${thisDeviceMac}/user/pub_response`);
|
|
};
|
|
};
|
|
|
|
|
|
- thisDeviceMac = `AIrSMArT_${that.data.deviceList[index].deviceId.split("BLUFI_")[1]}`;
|
|
|
|
|
|
+ thisDeviceMac = `AIrSMArT_${device.deviceId.split("BLUFI_")[1]}`;
|
|
that.setData({
|
|
that.setData({
|
|
- autoConnected: true,
|
|
|
|
deviceListSelect: index,
|
|
deviceListSelect: index,
|
|
thisDeviceMac: thisDeviceMac,
|
|
thisDeviceMac: thisDeviceMac,
|
|
});
|
|
});
|
|
@@ -650,7 +656,7 @@ Page({
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
-
|
|
|
|
|
|
+ // 去唤醒界面
|
|
goWake() {
|
|
goWake() {
|
|
var that = this;
|
|
var that = this;
|
|
var deviceList = that.data.deviceList;
|
|
var deviceList = that.data.deviceList;
|
|
@@ -807,8 +813,9 @@ Page({
|
|
});
|
|
});
|
|
|
|
|
|
///在线排序前面,wifi设备排序前面
|
|
///在线排序前面,wifi设备排序前面
|
|
- that.updateDeviceList(deviceList, false);
|
|
|
|
|
|
+ that.updateDeviceList(deviceList, false, false);
|
|
var indexPage = that.data.indexPage;
|
|
var indexPage = that.data.indexPage;
|
|
|
|
+ console.log("gadsfqwerqwerqrqr==ccc==");
|
|
if (indexPage != 0) {
|
|
if (indexPage != 0) {
|
|
that.setData({
|
|
that.setData({
|
|
indexPage: 0,
|
|
indexPage: 0,
|
|
@@ -841,13 +848,14 @@ Page({
|
|
deviceId: newDevice.deviceId,
|
|
deviceId: newDevice.deviceId,
|
|
name: "猫王小王子OTR-X",
|
|
name: "猫王小王子OTR-X",
|
|
state: "online",
|
|
state: "online",
|
|
- devName: "猫王小王子OTR-X",
|
|
|
|
|
|
+ devName: "",
|
|
|
|
+ // devName: "猫王小王子OTR-X",
|
|
mac: newDevice.deviceId,
|
|
mac: newDevice.deviceId,
|
|
image: "./../../img/min.png",
|
|
image: "./../../img/min.png",
|
|
});
|
|
});
|
|
|
|
|
|
///在线排序前面,wifi设备排序前面
|
|
///在线排序前面,wifi设备排序前面
|
|
- that.updateDeviceList(deviceList, false);
|
|
|
|
|
|
+ that.updateDeviceList(deviceList, false, false);
|
|
var indexPage = that.data.indexPage;
|
|
var indexPage = that.data.indexPage;
|
|
if (indexPage != 0) {
|
|
if (indexPage != 0) {
|
|
that.setData({
|
|
that.setData({
|
|
@@ -860,17 +868,30 @@ Page({
|
|
},
|
|
},
|
|
|
|
|
|
///更新列表排序
|
|
///更新列表排序
|
|
- updateDeviceList(deviceList, isInit) {
|
|
|
|
|
|
+ updateDeviceList(deviceList, isInit, closeAllBlue) {
|
|
|
|
+ var that = this;
|
|
|
|
+ if (strings.isEmpty(deviceList)) {
|
|
|
|
+ deviceList = that.data.deviceList;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (deviceList.length <= 0) {
|
|
if (deviceList.length <= 0) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- var that = this;
|
|
|
|
var finalList = [];
|
|
var finalList = [];
|
|
if (isInit) {
|
|
if (isInit) {
|
|
deviceList[0].state = "offline";
|
|
deviceList[0].state = "offline";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// 让所有蓝牙设备离线
|
|
|
|
+ if (closeAllBlue) {
|
|
|
|
+ deviceList.forEach(element => {
|
|
|
|
+ if (element.connectType != 3) {
|
|
|
|
+ element.state = "offline";
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
var isFirstOnline = false;
|
|
var isFirstOnline = false;
|
|
if (deviceList[0].state == "online") {
|
|
if (deviceList[0].state == "online") {
|
|
isFirstOnline = true;
|
|
isFirstOnline = true;
|