|
@@ -41,7 +41,6 @@ Page({
|
|
|
MenuButtonheight: app.globalData.MenuButtonheight,
|
|
|
MenuButtonTop: app.globalData.MenuButtonTop,
|
|
|
actionIndex: null,
|
|
|
- isShowDevicelist: false,
|
|
|
luoma: ["Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", " Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ", "Ⅺ", "Ⅻ"],
|
|
|
channelData: [],
|
|
|
deviceList: [],
|
|
@@ -49,7 +48,6 @@ Page({
|
|
|
showLogin: false,
|
|
|
isOneLoading: true,
|
|
|
uid: null,
|
|
|
- showDelete: false,
|
|
|
isSetWake: false,
|
|
|
thisDeviceMac: null,
|
|
|
battery: 4, // 0≤电量<20,0格
|
|
@@ -376,6 +374,7 @@ Page({
|
|
|
_this.subscribeDevicesStatus();
|
|
|
},
|
|
|
|
|
|
+ // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online","ProdModel":"MW-2AX(WIFI-N)","devName":"猫王小王子OTR-X"}]
|
|
|
online(payloads) {
|
|
|
// 设置在线状态
|
|
|
_this.data.deviceList.map((v, index) => {
|
|
@@ -383,6 +382,7 @@ Page({
|
|
|
_this.data.deviceList[index].state = payloads.state;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
_this.setData({
|
|
|
deviceList: _this.data.deviceList,
|
|
|
});
|
|
@@ -449,12 +449,6 @@ Page({
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- isShowDevicelistFun() {
|
|
|
- this.setData({
|
|
|
- isShowDevicelist: !_this.data.isShowDevicelist
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
actionMusic(e) {
|
|
|
if (e.currentTarget.dataset.index === this.data.actionIndex) {
|
|
|
return;
|
|
@@ -520,24 +514,6 @@ Page({
|
|
|
return `AIrSMArT_${this.data.deviceList[this.data.deviceListIndex].name.split("BLUFI_")[1]}`
|
|
|
},
|
|
|
|
|
|
- goLogin() {
|
|
|
- wx.navigateTo({
|
|
|
- url: './../login/login',
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- goDeviceConnect() {
|
|
|
- routeUtil.jump(route_constant.deviceList)
|
|
|
- this.setData({
|
|
|
- isShowDevicelist: false
|
|
|
- })
|
|
|
- return;
|
|
|
- wx.navigateTo({
|
|
|
- url: './../deviceConnect0/deviceConnect0',
|
|
|
- });
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
getchannelData(clientType) {
|
|
|
let _this = this;
|
|
|
if (this.data.deviceListIndex === null) {
|
|
@@ -590,73 +566,69 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- showDelete() {
|
|
|
- // wx.navigateTo({
|
|
|
- // url: './../deviceRoter3/deviceRoter3',
|
|
|
- // })
|
|
|
- this.setData({
|
|
|
- showDelete: !this.data.showDelete
|
|
|
- });
|
|
|
- },
|
|
|
deleteDevice(e) {
|
|
|
-
|
|
|
- const id = this.data.deviceList[e.currentTarget.dataset.index].deviceId;
|
|
|
- let name = _this.data.deviceListIndex !== null ? this.data.deviceList[_this.data.deviceListIndex].name : null;
|
|
|
- const deviceList = this.data.deviceList.filter((v, i) => {
|
|
|
- return id !== v.deviceId
|
|
|
- });
|
|
|
- // 取消订阅
|
|
|
- app.unsubscribe(`/AIrSMArT_${_this.data.deviceList[e.currentTarget.dataset.index].name.split("BLUFI_")[1]}/user/pub_response`);
|
|
|
-
|
|
|
- wx.setStorage({
|
|
|
- key: "devicelist",
|
|
|
- data: JSON.stringify(deviceList),
|
|
|
- success() {
|
|
|
-
|
|
|
- _this.setData({
|
|
|
- deviceList,
|
|
|
- thisDeviceMac: null
|
|
|
- });
|
|
|
-
|
|
|
- // 当前没有设备
|
|
|
- if (deviceList.length === 0) {
|
|
|
- _this.setData({
|
|
|
- showDelete: false,
|
|
|
- actionIndex: null,
|
|
|
- deviceListIndex: null,
|
|
|
- isShowDevicelist: false,
|
|
|
+ wx.showModal({
|
|
|
+ title: '确定删除?',
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ const id = this.data.deviceList[e.currentTarget.dataset.index].deviceId;
|
|
|
+ let name = _this.data.deviceListIndex !== null ? this.data.deviceList[_this.data.deviceListIndex].name : null;
|
|
|
+ const deviceList = this.data.deviceList.filter((v, i) => {
|
|
|
+ return id !== v.deviceId
|
|
|
});
|
|
|
- }
|
|
|
+ // 取消订阅
|
|
|
+ app.unsubscribe(`/AIrSMArT_${_this.data.deviceList[e.currentTarget.dataset.index].name.split("BLUFI_")[1]}/user/pub_response`);
|
|
|
+
|
|
|
+ wx.setStorage({
|
|
|
+ key: "devicelist",
|
|
|
+ data: JSON.stringify(deviceList),
|
|
|
+ success() {
|
|
|
|
|
|
- if (_this.data.deviceListIndex === null) {
|
|
|
- return
|
|
|
- };
|
|
|
- if (e.currentTarget.dataset.index === _this.data.deviceListIndex) {
|
|
|
- let index_ = null;
|
|
|
- deviceList.map((v, index) => {
|
|
|
- if (v.state === "online" && index_ === null) {
|
|
|
- index_ = index;
|
|
|
- }
|
|
|
- });
|
|
|
- if (index_ !== null) {
|
|
|
- _this.actionDevice(index_);
|
|
|
- } else {
|
|
|
- _this.setData({
|
|
|
- actionIndex: null,
|
|
|
- deviceListIndex: null,
|
|
|
- });
|
|
|
- };
|
|
|
- } else {
|
|
|
- deviceList.map((v, index) => {
|
|
|
- if (v.name === name) {
|
|
|
_this.setData({
|
|
|
- deviceListIndex: index,
|
|
|
+ deviceList,
|
|
|
+ thisDeviceMac: null
|
|
|
});
|
|
|
+
|
|
|
+ // 当前没有设备
|
|
|
+ if (deviceList.length === 0) {
|
|
|
+ _this.setData({
|
|
|
+ actionIndex: null,
|
|
|
+ deviceListIndex: null,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_this.data.deviceListIndex === null) {
|
|
|
+ return
|
|
|
+ };
|
|
|
+ if (e.currentTarget.dataset.index === _this.data.deviceListIndex) {
|
|
|
+ let index_ = null;
|
|
|
+ deviceList.map((v, index) => {
|
|
|
+ if (v.state === "online" && index_ === null) {
|
|
|
+ index_ = index;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (index_ !== null) {
|
|
|
+ _this.actionDevice(index_);
|
|
|
+ } else {
|
|
|
+ _this.setData({
|
|
|
+ actionIndex: null,
|
|
|
+ deviceListIndex: null,
|
|
|
+ });
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ deviceList.map((v, index) => {
|
|
|
+ if (v.name === name) {
|
|
|
+ _this.setData({
|
|
|
+ deviceListIndex: index,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
},
|
|
|
goWake() {
|
|
@@ -742,4 +714,29 @@ Page({
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ addDevice() {
|
|
|
+ var that = this;
|
|
|
+ var showLogin = that.data.showLogin;
|
|
|
+ if (!showLogin) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: './../login/login'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deviceList && deviceList.length === 0) {
|
|
|
+ that.goDeviceConnect();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ goDeviceConnect() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: './../deviceConnect0/deviceConnect0',
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ onTapIem() {},
|
|
|
+
|
|
|
})
|