|
@@ -9,8 +9,8 @@ import strings from '../../utils/strings.js';
|
|
|
import store from '../../utils/store.js';
|
|
|
import route_constant from '../../utils/route_constant.js';
|
|
|
import route_util from '../../utils/route_util.js';
|
|
|
-import lexinUtil from '../../utils/lexin/util.js';
|
|
|
-import lexinJump from '../../utils/lexin/jump.js';
|
|
|
+import lexin_util from '../../utils/lexin/util.js';
|
|
|
+import lexin_jump from '../../utils/lexin/jump.js';
|
|
|
import {
|
|
|
BtHelper
|
|
|
} from '../../devices/bt_helper.js';
|
|
@@ -284,7 +284,7 @@ Page({
|
|
|
|
|
|
var deviceId = deviceList[deviceListSelect].deviceId;
|
|
|
// 接收设备当前播放状态
|
|
|
- var deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
+ var deviceMacId = lexin_util.getDeviceMacId(deviceId);
|
|
|
const obj = {
|
|
|
DstDeviceName: deviceMacId
|
|
|
}
|
|
@@ -395,12 +395,12 @@ Page({
|
|
|
// 取消订阅
|
|
|
var deviceMacId = that.data.deviceMacId;
|
|
|
if (!strings.isEmpty(deviceMacId)) {
|
|
|
- var pubResponse = lexinUtil.getResponseByDeviceMacId(deviceMacId);
|
|
|
+ var pubResponse = lexin_util.getResponseByDeviceMacId(deviceMacId);
|
|
|
app.unsubscribe(pubResponse);
|
|
|
};
|
|
|
|
|
|
var deviceId = device.deviceId;
|
|
|
- deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
+ deviceMacId = lexin_util.getDeviceMacId(deviceId);
|
|
|
that.setData({
|
|
|
deviceListSelect: index,
|
|
|
deviceMacId: deviceMacId,
|
|
@@ -441,7 +441,7 @@ Page({
|
|
|
deviceList: deviceList,
|
|
|
});
|
|
|
|
|
|
- var deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
+ var deviceMacId = lexin_util.getDeviceMacId(deviceId);
|
|
|
const obj = {
|
|
|
DstDeviceName: deviceMacId
|
|
|
};
|
|
@@ -511,7 +511,7 @@ Page({
|
|
|
"is_debug": app.globalData.is_debug
|
|
|
};
|
|
|
|
|
|
- var deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
+ var deviceMacId = lexin_util.getDeviceMacId(deviceId);
|
|
|
app.PubMsg({
|
|
|
type: "play",
|
|
|
DstDeviceName: deviceMacId,
|
|
@@ -608,7 +608,7 @@ Page({
|
|
|
if (deviceList[deviceListSelect].connectType == 3) {
|
|
|
var deviceMacId = that.data.deviceMacId;
|
|
|
if (!strings.isEmpty(deviceMacId)) {
|
|
|
- var pubResponse = lexinUtil.getResponseByDeviceMacId(deviceMacId);
|
|
|
+ var pubResponse = lexin_util.getResponseByDeviceMacId(deviceMacId);
|
|
|
app.unsubscribe(pubResponse);
|
|
|
that.setData({
|
|
|
actionIndex: null,
|
|
@@ -781,7 +781,7 @@ Page({
|
|
|
|
|
|
var deviceId = deviceList[index].deviceId;
|
|
|
// 取消订阅
|
|
|
- var pubResponse = lexinUtil.getResponseByDeviceId(deviceId);
|
|
|
+ var pubResponse = lexin_util.getResponseByDeviceId(deviceId);
|
|
|
app.unsubscribe(pubResponse);
|
|
|
if (onlyCancel) {
|
|
|
return;
|
|
@@ -886,115 +886,26 @@ Page({
|
|
|
that.subscribeDevicesStatus();
|
|
|
},
|
|
|
|
|
|
- ///更新列表排序
|
|
|
- updateDeviceList(deviceList, isInit, closeAllBlue) {
|
|
|
+ /// 手机关闭蓝牙,所有蓝牙设备离线
|
|
|
+ closeBlueResetOffline(isInit, closeAllBlue) {
|
|
|
var that = this;
|
|
|
- if (strings.isEmpty(deviceList)) {
|
|
|
- deviceList = that.data.deviceList;
|
|
|
- }
|
|
|
-
|
|
|
- if (deviceList.length <= 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- var finalList = [];
|
|
|
- if (isInit) {
|
|
|
- deviceList[0].state = "offline";
|
|
|
- }
|
|
|
+ var deviceList = that.data.deviceList;
|
|
|
+ updateDeviceList(deviceList, isInit, closeAllBlue);
|
|
|
+ },
|
|
|
|
|
|
- /// 让所有蓝牙设备离线
|
|
|
- if (closeAllBlue) {
|
|
|
- deviceList.forEach(element => {
|
|
|
- if (element.connectType != 3) {
|
|
|
- element.state = "offline";
|
|
|
- }
|
|
|
+ /// 更新列表排序
|
|
|
+ updateDeviceList(deviceList, isInit, closeAllBlue) {
|
|
|
+ var finalList = store.updateDeviceList(deviceList, isInit, closeAllBlue);
|
|
|
+ if (!strings.isEmpty(deviceList) || !strings.isEmpty(finalList)) {
|
|
|
+ that.setData({
|
|
|
+ deviceList: finalList,
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
- var isFirstOnline = false;
|
|
|
- if (deviceList[0].state == "online") {
|
|
|
- isFirstOnline = true;
|
|
|
- finalList.push(deviceList[0]);
|
|
|
- }
|
|
|
-
|
|
|
- ///区分在线和离线
|
|
|
- for (var i = isFirstOnline ? 1 : 0; i < deviceList.length; i++) {
|
|
|
- if (isInit) {
|
|
|
- deviceList[i].state = "offline";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var onLineList = [];
|
|
|
- var onNoLineList = [];
|
|
|
- ///添加在线的
|
|
|
- for (var i = isFirstOnline ? 1 : 0; i < deviceList.length; i++) {
|
|
|
- var device = deviceList[i];
|
|
|
- if (device.state == "online") {
|
|
|
- onLineList.push(device)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ///添加离线的
|
|
|
- for (var i = isFirstOnline ? 1 : 0; i < deviceList.length; i++) {
|
|
|
- var device = deviceList[i];
|
|
|
- if (device.state != "online") {
|
|
|
- onNoLineList.push(device)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 区分在线wifi和蓝牙 wifi在前 离线在后
|
|
|
- var onLineWifiList = [];
|
|
|
- var onLineBlueList = [];
|
|
|
- ///添加在线wifi
|
|
|
- onLineList.forEach(element => {
|
|
|
- if (element.connectType == 3) {
|
|
|
- onLineWifiList.push(element);
|
|
|
- }
|
|
|
- });
|
|
|
- ///添加在线蓝牙
|
|
|
- onLineList.forEach(element => {
|
|
|
- if (element.connectType != 3) {
|
|
|
- onLineBlueList.push(element)
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- finalList = finalList.concat(onLineWifiList);
|
|
|
- finalList = finalList.concat(onLineBlueList);
|
|
|
-
|
|
|
- ///只需要蓝牙和wifi在线的
|
|
|
- let mDeviceList = []
|
|
|
- mDeviceList = mDeviceList.concat(onLineWifiList);
|
|
|
- mDeviceList = mDeviceList.concat(onLineBlueList);
|
|
|
- getApp().globalData.mDeviceList = mDeviceList;
|
|
|
-
|
|
|
- ///区分离线wifi和蓝牙 wifi在前 离线在后
|
|
|
- var onNoLineWifiList = [];
|
|
|
- var onNoLineBlueList = [];
|
|
|
- ///添加离线wifi
|
|
|
- onNoLineList.forEach(element => {
|
|
|
- if (element.connectType == 3) {
|
|
|
- onNoLineWifiList.push(element)
|
|
|
- }
|
|
|
- });
|
|
|
- ///添加离线蓝牙
|
|
|
- onNoLineList.forEach(element => {
|
|
|
- if (element.connectType != 3) {
|
|
|
- onNoLineBlueList.push(element)
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- finalList = finalList.concat(onNoLineWifiList);
|
|
|
- finalList = finalList.concat(onNoLineBlueList);
|
|
|
-
|
|
|
- store.setStore("deviceList", finalList);
|
|
|
- that.setData({
|
|
|
- deviceList: finalList
|
|
|
- });
|
|
|
},
|
|
|
|
|
|
// 关于我们
|
|
|
jumpToAboutUs() {
|
|
|
- lexinJump.toAboutUs();
|
|
|
+ lexin_jump.toAboutUs();
|
|
|
},
|
|
|
|
|
|
///******************************* 可折叠 ********************************************///
|