|
@@ -79,9 +79,13 @@ Page({
|
|
|
getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
|
|
|
if (res.data.errno == 0) {
|
|
|
if (res.data.data.online == true) {
|
|
|
- that.setData({ status: '在线' })
|
|
|
+ that.setData({
|
|
|
+ status: '在线'
|
|
|
+ })
|
|
|
} else {
|
|
|
- that.setData({ status: '离线' })
|
|
|
+ that.setData({
|
|
|
+ status: '离线'
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
wx.showModal({
|
|
@@ -390,9 +394,13 @@ Page({
|
|
|
getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
|
|
|
if (res.data.errno == 0) {
|
|
|
if (res.data.data.online == true) {
|
|
|
- that.setData({ status: '在线' })
|
|
|
+ that.setData({
|
|
|
+ status: '在线'
|
|
|
+ })
|
|
|
} else {
|
|
|
- that.setData({ status: '离线' })
|
|
|
+ that.setData({
|
|
|
+ status: '离线'
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
wx.showModal({
|
|
@@ -1406,9 +1414,13 @@ Page({
|
|
|
getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
|
|
|
if (res.data.errno == 0) {
|
|
|
if (res.data.data.online == true) {
|
|
|
- that.setData({ status: '在线' })
|
|
|
+ that.setData({
|
|
|
+ status: '在线'
|
|
|
+ })
|
|
|
} else {
|
|
|
- that.setData({ status: '离线' })
|
|
|
+ that.setData({
|
|
|
+ status: '离线'
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
wx.showModal({
|
|
@@ -1441,7 +1453,7 @@ Page({
|
|
|
for (let h = 0; h < 12; h++) {
|
|
|
lamp.push(
|
|
|
"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
|
|
|
- )
|
|
|
+ )
|
|
|
}
|
|
|
setTimeout(function() {
|
|
|
getData(that.data.deviceId, that.data.deviceKey).then(bind => {
|
|
@@ -1526,9 +1538,13 @@ Page({
|
|
|
getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
|
|
|
if (res.data.errno == 0) {
|
|
|
if (res.data.data.online == true) {
|
|
|
- that.setData({ status: '在线' })
|
|
|
+ that.setData({
|
|
|
+ status: '在线'
|
|
|
+ })
|
|
|
} else {
|
|
|
- that.setData({ status: '离线' })
|
|
|
+ that.setData({
|
|
|
+ status: '离线'
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
wx.showModal({
|
|
@@ -1561,7 +1577,7 @@ Page({
|
|
|
for (let h = 0; h < 12; h++) {
|
|
|
lamp.push(
|
|
|
"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
|
|
|
- )
|
|
|
+ )
|
|
|
}
|
|
|
setTimeout(function() {
|
|
|
getData(that.data.deviceId, that.data.deviceKey).then(bind => {
|
|
@@ -1711,7 +1727,7 @@ Page({
|
|
|
for (let h = 0; h < 12; h++) {
|
|
|
lamp.push(
|
|
|
"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
|
|
|
- )
|
|
|
+ )
|
|
|
}
|
|
|
//旧设备
|
|
|
if (moudule == 0) {
|
|
@@ -1754,228 +1770,228 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
getData(deviceId, deviceKey).then(
|
|
|
- ver => {
|
|
|
- if (ver.data.errno == 0) {
|
|
|
- let data = ver.data.data
|
|
|
- for (let i = 0; i < data
|
|
|
- .length; i++) {
|
|
|
- if (data[i].id ==
|
|
|
- "RelayCount") {
|
|
|
- var quantity =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- that.setData({
|
|
|
- loops: quantity
|
|
|
- })
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- "ManualStatus"
|
|
|
- ) {
|
|
|
- if (data[i]
|
|
|
- .current_value ==
|
|
|
- 0) {
|
|
|
- that.setData({
|
|
|
- Modecontrol: "自动"
|
|
|
- })
|
|
|
- } else {
|
|
|
+ ver => {
|
|
|
+ if (ver.data.errno == 0) {
|
|
|
+ let data = ver.data.data
|
|
|
+ for (let i = 0; i < data
|
|
|
+ .length; i++) {
|
|
|
+ if (data[i].id ==
|
|
|
+ "RelayCount") {
|
|
|
+ var quantity =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
that.setData({
|
|
|
- Modecontrol: "手动"
|
|
|
+ loops: quantity
|
|
|
})
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ "ManualStatus"
|
|
|
+ ) {
|
|
|
+ if (data[i]
|
|
|
+ .current_value ==
|
|
|
+ 0) {
|
|
|
+ that.setData({
|
|
|
+ Modecontrol: "自动"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.setData({
|
|
|
+ Modecontrol: "手动"
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //回路1
|
|
|
- else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R1_RelayStatus'
|
|
|
+ //回路1
|
|
|
+ else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R1_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 0)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R2_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 0)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R2_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 1)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R3_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 1)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R3_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 2)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R4_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 2)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R4_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 3)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R5_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 3)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R5_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 4)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R6_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 4)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R6_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 5)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R7_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 5)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R7_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 6)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R8_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 6)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R8_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 7)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R9_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 7)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R9_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 8)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R10_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 8)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R10_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 9)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R11_RelayStatus'
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 9)
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R11_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 10
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 10
|
|
|
)
|
|
|
- } else if (data[i]
|
|
|
- .id ==
|
|
|
- 'R12_RelayStatus'
|
|
|
+ } else if (data[i]
|
|
|
+ .id ==
|
|
|
+ 'R12_RelayStatus'
|
|
|
) {
|
|
|
- let police =
|
|
|
- data[i]
|
|
|
- .current_value
|
|
|
- var lamps =
|
|
|
- control
|
|
|
- .switchReal(
|
|
|
- police,
|
|
|
- lamp, 11
|
|
|
+ let police =
|
|
|
+ data[i]
|
|
|
+ .current_value
|
|
|
+ var lamps =
|
|
|
+ control
|
|
|
+ .switchReal(
|
|
|
+ police,
|
|
|
+ lamp, 11
|
|
|
+ )
|
|
|
+ }
|
|
|
+ wx.setStorageSync(
|
|
|
+ 'lamp',
|
|
|
+ lamps)
|
|
|
+ that.setData({
|
|
|
+ lamp: wx
|
|
|
+ .getStorageSync(
|
|
|
+ 'lamp'
|
|
|
)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ var Loop = that.data
|
|
|
+ .Loop
|
|
|
+ var color = that.data
|
|
|
+ .Color
|
|
|
+ var size = that.data
|
|
|
+ .Size
|
|
|
+ var Address = that.data
|
|
|
+ .address
|
|
|
+ var enloop = that.data
|
|
|
+ .loop
|
|
|
+ for (let i = 0; i <
|
|
|
+ quantity; i++) {
|
|
|
+ Loop[i] = enloop[i]
|
|
|
+ color[i] = "black"
|
|
|
+ size[i] =
|
|
|
+ "calc(100vw * 16/375)",
|
|
|
+ Address[i] =
|
|
|
+ "/image/modify.png"
|
|
|
}
|
|
|
- wx.setStorageSync(
|
|
|
- 'lamp',
|
|
|
- lamps)
|
|
|
that.setData({
|
|
|
- lamp: wx
|
|
|
- .getStorageSync(
|
|
|
- 'lamp'
|
|
|
- )
|
|
|
+ Color: color,
|
|
|
+ Size: size,
|
|
|
+ address: Address,
|
|
|
+ Loop: Loop
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showModal({
|
|
|
+ title: '错误',
|
|
|
+ content: ver
|
|
|
+ .data
|
|
|
+ .error,
|
|
|
+ showCancel: false
|
|
|
})
|
|
|
}
|
|
|
- var Loop = that.data
|
|
|
- .Loop
|
|
|
- var color = that.data
|
|
|
- .Color
|
|
|
- var size = that.data
|
|
|
- .Size
|
|
|
- var Address = that.data
|
|
|
- .address
|
|
|
- var enloop = that.data
|
|
|
- .loop
|
|
|
- for (let i = 0; i <
|
|
|
- quantity; i++) {
|
|
|
- Loop[i] = enloop[i]
|
|
|
- color[i] = "black"
|
|
|
- size[i] =
|
|
|
- "calc(100vw * 16/375)",
|
|
|
- Address[i] =
|
|
|
- "/image/modify.png"
|
|
|
- }
|
|
|
- that.setData({
|
|
|
- Color: color,
|
|
|
- Size: size,
|
|
|
- address: Address,
|
|
|
- Loop: Loop
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.showModal({
|
|
|
- title: '错误',
|
|
|
- content: ver
|
|
|
- .data
|
|
|
- .error,
|
|
|
- showCancel: false
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
} else {
|
|
|
wx.showModal({
|
|
|
title: '错误',
|
|
@@ -2365,7 +2381,9 @@ Page({
|
|
|
}, 2000)
|
|
|
} else if (res.data.errno == 10) {
|
|
|
setTimeout(function() {
|
|
|
- that.setData({ status: '离线' })
|
|
|
+ that.setData({
|
|
|
+ status: '离线'
|
|
|
+ })
|
|
|
}, 2000)
|
|
|
} else {
|
|
|
setTimeout(function() {
|
|
@@ -2421,7 +2439,8 @@ Page({
|
|
|
}
|
|
|
that.setData({
|
|
|
loop: loop
|
|
|
- })
|
|
|
+ })
|
|
|
+ console.log(id)
|
|
|
getloop(id).then(res => {
|
|
|
if (res.data.code == 0) {
|
|
|
let loopState = res.data.data
|
|
@@ -2487,9 +2506,13 @@ Page({
|
|
|
getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
|
|
|
if (res.data.errno == 0) {
|
|
|
if (res.data.data.online == true) {
|
|
|
- that.setData({ status: '在线' })
|
|
|
+ that.setData({
|
|
|
+ status: '在线'
|
|
|
+ })
|
|
|
} else {
|
|
|
- that.setData({ status: '离线' })
|
|
|
+ that.setData({
|
|
|
+ status: '离线'
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
wx.showModal({
|
|
@@ -2555,9 +2578,13 @@ Page({
|
|
|
getBasic(that.data.deviceId, that.data.deviceKey).then(res => {
|
|
|
if (res.data.errno == 0) {
|
|
|
if (res.data.data.online == true) {
|
|
|
- that.setData({ status: '在线' })
|
|
|
+ that.setData({
|
|
|
+ status: '在线'
|
|
|
+ })
|
|
|
} else {
|
|
|
- that.setData({ status: '离线' })
|
|
|
+ that.setData({
|
|
|
+ status: '离线'
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
wx.showModal({
|
|
@@ -2661,7 +2688,9 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- that.setData({ groupIndex: 0 })
|
|
|
+ that.setData({
|
|
|
+ groupIndex: 0
|
|
|
+ })
|
|
|
wx.setStorageSync('groupName', that.data.groupName[that.data.groupIndex])
|
|
|
}
|
|
|
//获取设备下拉
|
|
@@ -2688,7 +2717,9 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- that.setData({ deviceIndex: 0 })
|
|
|
+ that.setData({
|
|
|
+ deviceIndex: 0
|
|
|
+ })
|
|
|
wx.setStorageSync('deviceName', that.data.deviceName[that.data.deviceIndex])
|
|
|
}
|
|
|
//根据分组名和设备信息
|
|
@@ -2740,7 +2771,7 @@ Page({
|
|
|
for (let h = 0; h < 12; h++) {
|
|
|
lamp.push(
|
|
|
"https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png"
|
|
|
- )
|
|
|
+ )
|
|
|
}
|
|
|
//旧设备
|
|
|
if (moudule == 0) {
|
|
@@ -2920,7 +2951,7 @@ Page({
|
|
|
lamp: wx
|
|
|
.getStorageSync(
|
|
|
'lamp'
|
|
|
- )
|
|
|
+ )
|
|
|
})
|
|
|
}
|
|
|
var Loop = that.data.Loop
|
|
@@ -3021,8 +3052,8 @@ Page({
|
|
|
for (let n = 0; n < loopState.length; n++) {
|
|
|
Loop[n] = that.data.Loop[n]
|
|
|
color[n] = "black"
|
|
|
- size[n] = "calc(100vw * 16/375)",
|
|
|
- Address[n] = "/image/modify.png"
|
|
|
+ size[n] = "calc(100vw * 16/375)"
|
|
|
+ Address[n] = "/image/modify.png"
|
|
|
}
|
|
|
that.setData({
|
|
|
Color: color,
|
|
@@ -3040,7 +3071,7 @@ Page({
|
|
|
})
|
|
|
loopSwitchstate(id).then(ret => {
|
|
|
if (ret.data.code == 0) {
|
|
|
- var relay = ret.data.data
|
|
|
+ var relay = ret.data.data
|
|
|
for (let e = 0; e < relay.length; e++) {
|
|
|
if (relay[e].status == 1) {
|
|
|
lamp[e] =
|
|
@@ -3119,5 +3150,4 @@ Page({
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
}
|
|
|
-})
|
|
|
-
|
|
|
+})
|