|
@@ -9,6 +9,7 @@ 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 {
|
|
|
BtHelper
|
|
|
} from '../../devices/bt_helper.js';
|
|
@@ -79,8 +80,8 @@ Page({
|
|
|
|
|
|
onHomeShow() {
|
|
|
var that = this;
|
|
|
- var autoConnected = that.data.autoConnected;
|
|
|
- var deviceListSelect = that.data.deviceListSelect;
|
|
|
+ // var autoConnected = that.data.autoConnected;
|
|
|
+ // var deviceListSelect = that.data.deviceListSelect;
|
|
|
// if (!autoConnected && deviceListSelect == null) {
|
|
|
// that.actionDevice(0);
|
|
|
// }
|
|
@@ -184,7 +185,7 @@ Page({
|
|
|
|
|
|
// 回调
|
|
|
mqttCallback(type, option) {
|
|
|
- // console.log("gadsfadsfadsfa==888===" + type);
|
|
|
+ console.log("gadsfadsfadsfa==888===" + type);
|
|
|
var that = this;
|
|
|
let payloads = null;
|
|
|
if (option && option.payload) {
|
|
@@ -282,7 +283,7 @@ Page({
|
|
|
|
|
|
var deviceId = deviceList[deviceListSelect].deviceId;
|
|
|
// 接收设备当前播放状态
|
|
|
- var deviceMacId = that.getDeviceMacId(deviceId);
|
|
|
+ var deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
const obj = {
|
|
|
DstDeviceName: deviceMacId
|
|
|
}
|
|
@@ -351,7 +352,6 @@ Page({
|
|
|
deviceList = that.data.deviceList;
|
|
|
///当前没有连接设备,则去连接第一个wifi设备
|
|
|
var deviceListSelect = that.data.deviceListSelect;
|
|
|
- console.log("gadsfqwerqwerq====" + deviceListSelect);
|
|
|
if (deviceListSelect === null) {
|
|
|
for (var i = 0; i < deviceList.length; i++) {
|
|
|
if (deviceList[i].state === "online" && deviceList[i].connectType == 3) {
|
|
@@ -393,13 +393,13 @@ Page({
|
|
|
|
|
|
// 取消订阅
|
|
|
var deviceMacId = that.data.deviceMacId;
|
|
|
- if (deviceMacId !== null) {
|
|
|
- var pubResponse = that.getUserPubResponse(deviceMacId);
|
|
|
+ if (!strings.isEmpty(deviceMacId)) {
|
|
|
+ var pubResponse = lexinUtil.getResponseByDeviceMacId(deviceMacId);
|
|
|
app.unsubscribe(pubResponse);
|
|
|
};
|
|
|
|
|
|
var deviceId = device.deviceId;
|
|
|
- deviceMacId = that.getDeviceMacId(deviceId);
|
|
|
+ deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
that.setData({
|
|
|
deviceListSelect: index,
|
|
|
deviceMacId: deviceMacId,
|
|
@@ -440,14 +440,15 @@ Page({
|
|
|
deviceList: deviceList,
|
|
|
});
|
|
|
|
|
|
- var deviceMacId = that.getDeviceMacId(deviceId);
|
|
|
- /// /AIrSMArT_7cdfa1fd3af0/user/pub_response
|
|
|
- var pubResponse = that.getUserPubResponse(deviceMacId);
|
|
|
- app.subscribe(pubResponse);
|
|
|
-
|
|
|
+ var deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
const obj = {
|
|
|
DstDeviceName: deviceMacId
|
|
|
};
|
|
|
+
|
|
|
+ /// /AIrSMArT_7cdfa1fd3af0/user/pub_response
|
|
|
+ var pubResponse = thalexinUtilt.getResponseByDeviceMacId(deviceMacId);
|
|
|
+ app.subscribe(pubResponse);
|
|
|
+
|
|
|
app.PubMsg({
|
|
|
type: "get_dev_info",
|
|
|
...obj
|
|
@@ -509,7 +510,7 @@ Page({
|
|
|
"is_debug": app.globalData.is_debug
|
|
|
};
|
|
|
|
|
|
- var deviceMacId = that.getDeviceMacId(deviceId);
|
|
|
+ var deviceMacId = lexinUtil.getDeviceMacId(deviceId);
|
|
|
app.PubMsg({
|
|
|
type: "play",
|
|
|
DstDeviceName: deviceMacId,
|
|
@@ -517,14 +518,6 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- getDeviceMacId(deviceId) {
|
|
|
- return `AIrSMArT_${deviceId.split("BLUFI_")[1]}`
|
|
|
- },
|
|
|
-
|
|
|
- getUserPubResponse(deviceMacId) {
|
|
|
- return `/${deviceMacId}/user/pub_response`;
|
|
|
- },
|
|
|
-
|
|
|
getchannelData(clientType) {
|
|
|
var that = this;
|
|
|
var deviceList = that.data.deviceList;
|
|
@@ -620,8 +613,8 @@ Page({
|
|
|
var deviceList = that.data.deviceList;
|
|
|
if (deviceList[deviceListSelect].connectType == 3) {
|
|
|
var deviceMacId = that.data.deviceMacId;
|
|
|
- if (deviceMacId !== null) {
|
|
|
- var pubResponse = that.getUserPubResponse(deviceMacId);
|
|
|
+ if (!strings.isEmpty(deviceMacId)) {
|
|
|
+ var pubResponse = lexinUtil.getResponseByDeviceMacId(deviceMacId);
|
|
|
app.unsubscribe(pubResponse);
|
|
|
that.setData({
|
|
|
actionIndex: null,
|
|
@@ -696,7 +689,7 @@ Page({
|
|
|
};
|
|
|
|
|
|
var device = deviceList[deviceListSelect];
|
|
|
- console.log("gasdfqwerqwewqrqr====" + JSON.stringify(device));
|
|
|
+ console.log("gadsfadsfadsfa==999===" + JSON.stringify(device));
|
|
|
wx.navigateTo({
|
|
|
url: './../deviceWake/deviceWake?deviceId=' + device.deviceId + "&clientType=" + device.ProdModel,
|
|
|
});
|
|
@@ -794,8 +787,7 @@ Page({
|
|
|
|
|
|
var deviceId = deviceList[index].deviceId;
|
|
|
// 取消订阅
|
|
|
- var deviceMacId = that.getDeviceMacId(deviceId);
|
|
|
- var pubResponse = that.getUserPubResponse(deviceMacId);
|
|
|
+ var pubResponse = lexinUtil.getResponseByDeviceId(deviceId);
|
|
|
app.unsubscribe(pubResponse);
|
|
|
if (onlyCancel) {
|
|
|
return;
|