|
@@ -246,6 +246,7 @@ Page({
|
|
var that = this;
|
|
var that = this;
|
|
console.log("gadsfadsfadsfa==777===" + JSON.stringify(payloads));
|
|
console.log("gadsfadsfadsfa==777===" + JSON.stringify(payloads));
|
|
|
|
|
|
|
|
+ ///是否更新过在线离线状态
|
|
var isUpdate = false;
|
|
var isUpdate = false;
|
|
var deviceList = that.data.deviceList;
|
|
var deviceList = that.data.deviceList;
|
|
if (!strings.isEmpty(deviceList)) {
|
|
if (!strings.isEmpty(deviceList)) {
|
|
@@ -276,23 +277,24 @@ Page({
|
|
}
|
|
}
|
|
|
|
|
|
///当前没有连接设备,则去连接第一个wifi设备
|
|
///当前没有连接设备,则去连接第一个wifi设备
|
|
- if (that.data.deviceListIndex === null) {
|
|
|
|
|
|
+ var deviceListIndex = that.data.deviceListIndex;
|
|
|
|
+ if (deviceListIndex === null) {
|
|
var list = that.data.deviceList;
|
|
var list = that.data.deviceList;
|
|
for (var i = 0; i < list.length; i++) {
|
|
for (var i = 0; i < list.length; i++) {
|
|
- if (list[i].state === "online" && list[i].ProdModel == "MW-2AX(WIFI-N)") {
|
|
|
|
|
|
+ if (list[i].state === "online" && list[i].connectType == 3) {
|
|
that.actionDevice(i);
|
|
that.actionDevice(i);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ // 当前播放设备离线
|
|
|
|
+ if (that.data.deviceList.length > deviceListIndex && that.data.deviceList[deviceListIndex].state !== "online") {
|
|
|
|
+ that.setData({
|
|
|
|
+ actionIndex: null,
|
|
|
|
+ deviceListIndex: null,
|
|
|
|
+ });
|
|
|
|
+ };
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 当前播放设备离线
|
|
|
|
- if (that.data.deviceListIndex !== null && that.data.deviceList[that.data.deviceListIndex].state !== "online") {
|
|
|
|
- that.setData({
|
|
|
|
- actionIndex: null,
|
|
|
|
- deviceListIndex: null,
|
|
|
|
- });
|
|
|
|
- };
|
|
|
|
},
|
|
},
|
|
|
|
|
|
// 订阅设备在线状态
|
|
// 订阅设备在线状态
|
|
@@ -320,6 +322,7 @@ Page({
|
|
};
|
|
};
|
|
|
|
|
|
let topic = `/AIrSMArT_${that.data.deviceList[that.data.deviceListIndex].name.split("BLUFI_")[1]}/user/pub_response`;
|
|
let topic = `/AIrSMArT_${that.data.deviceList[that.data.deviceListIndex].name.split("BLUFI_")[1]}/user/pub_response`;
|
|
|
|
+
|
|
app.subscribe(topic);
|
|
app.subscribe(topic);
|
|
const obj = {
|
|
const obj = {
|
|
DstDeviceName: that.getThisDeviceID()
|
|
DstDeviceName: that.getThisDeviceID()
|
|
@@ -418,12 +421,15 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- goChannel() {
|
|
|
|
|
|
+ ///去频道详情
|
|
|
|
+ onTapToChannel() {
|
|
var that = this;
|
|
var that = this;
|
|
- wx.setStorageSync("channelDeta", that.data.channelData[that.data.actionIndex]);
|
|
|
|
- wx.navigateTo({
|
|
|
|
- url: './../channelDetails/channelDetails'
|
|
|
|
- });
|
|
|
|
|
|
+ if (that.data.channelData.length > that.data.actionIndex) {
|
|
|
|
+ wx.setStorageSync("channelDeta", that.data.channelData[that.data.actionIndex]);
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: './../channelDetails/channelDetails'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
onUnload() {
|
|
onUnload() {
|
|
@@ -452,35 +458,35 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- goMeLogin() {
|
|
|
|
|
|
+ onTapLogin() {
|
|
var that = this;
|
|
var that = this;
|
|
|
|
+ ///退出登录
|
|
if (that.data.isLogin) {
|
|
if (that.data.isLogin) {
|
|
- // 退出登录
|
|
|
|
- wx.removeStorage({
|
|
|
|
- key: 'userInfo',
|
|
|
|
- success(res) {
|
|
|
|
- var nickName = "未登录";
|
|
|
|
- var greeting = that.getGreetBuNickName(nickName);
|
|
|
|
-
|
|
|
|
- that.setData({
|
|
|
|
- isLogin: false,
|
|
|
|
- greeting: greeting,
|
|
|
|
- nickName: nickName,
|
|
|
|
- userPic: "./../../img/head_pic.png",
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- wx.removeStorage({
|
|
|
|
- key: 'token',
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- // 登录
|
|
|
|
|
|
+ that.logOut();
|
|
|
|
+ }
|
|
|
|
+ // 登录
|
|
|
|
+ else {
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: './../login/login',
|
|
url: './../login/login',
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ ///退出登录
|
|
|
|
+ logOut() {
|
|
|
|
+ var that = this;
|
|
|
|
+ wx.removeStorageSync('userInfo');
|
|
|
|
+ wx.removeStorageSync('token');
|
|
|
|
+ var nickName = "未登录";
|
|
|
|
+ var greeting = that.getGreetBuNickName(nickName);
|
|
|
|
+ that.setData({
|
|
|
|
+ isLogin: false,
|
|
|
|
+ greeting: greeting,
|
|
|
|
+ nickName: nickName,
|
|
|
|
+ userPic: "./../../img/head_pic.png",
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
addDevice() {
|
|
addDevice() {
|
|
var that = this;
|
|
var that = this;
|
|
if (!that.data.isLogin) {
|
|
if (!that.data.isLogin) {
|
|
@@ -532,11 +538,14 @@ Page({
|
|
} else {
|
|
} else {
|
|
route_util.jumpParam('/pages/deviceDetail/detail', JSON.stringify(item))
|
|
route_util.jumpParam('/pages/deviceDetail/detail', JSON.stringify(item))
|
|
}
|
|
}
|
|
-
|
|
|
|
},
|
|
},
|
|
|
|
|
|
actionDevice(index) {
|
|
actionDevice(index) {
|
|
var that = this;
|
|
var that = this;
|
|
|
|
+ if (that.data.deviceList.length <= index) {
|
|
|
|
+ return;
|
|
|
|
+ };
|
|
|
|
+
|
|
const device = that.data.deviceList[index];
|
|
const device = that.data.deviceList[index];
|
|
if (device.state !== "online") {
|
|
if (device.state !== "online") {
|
|
return;
|
|
return;
|