|
@@ -84,12 +84,17 @@ Page({
|
|
|
newcolor: ["#888888", "#888888", "#888888"],
|
|
|
newfont: ["#cccccc", "#cccccc", "#cccccc"],
|
|
|
newSwitch: [false, false, false],
|
|
|
- newSwitchstate: ["", "", ""],
|
|
|
+ newSwitchstate: ["", "", "",""],
|
|
|
equipment: 0, //记录当前设备的id
|
|
|
subset:0,//记录当前分组的id
|
|
|
},
|
|
|
//分组下拉
|
|
|
changegroup: function (e) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '刷新中',
|
|
|
+ icon: 'loading',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
var that = this
|
|
|
that.setData({
|
|
|
groupIndex: e.detail.value
|
|
@@ -102,11 +107,6 @@ Page({
|
|
|
for (let i = 0; i < group.length; i++) {
|
|
|
if (group[i].groupName == groupName) {
|
|
|
if (group[i].devices != null && group[i].devices.length != 0) {
|
|
|
- wx.showToast({
|
|
|
- title: '刷新中',
|
|
|
- icon: 'loading',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
for (let j = 0; j < group[i].devices.length; j++) {
|
|
|
deviceName.push(group[i].devices[j].deviceName)
|
|
|
}
|
|
@@ -126,7 +126,7 @@ Page({
|
|
|
that.setData({
|
|
|
play: 0,
|
|
|
deviceKey:Message.deviceKey,
|
|
|
- deviceid:Message.deviceid
|
|
|
+ deviceId:Message.deviceId
|
|
|
})
|
|
|
getBasic(Message.deviceId, Message.deviceKey).then(res => {
|
|
|
if (res.data.data.online == true) {
|
|
@@ -436,7 +436,7 @@ Page({
|
|
|
that.setData({
|
|
|
play: 0,
|
|
|
deviceKey:Message.deviceKey,
|
|
|
- deviceid:Message.deviceid
|
|
|
+ deviceId:Message.deviceId
|
|
|
})
|
|
|
getBasic(Message.deviceId, Message.deviceKey).then(res => {
|
|
|
if (res.data.data.online == true) {
|
|
@@ -716,12 +716,502 @@ Page({
|
|
|
},
|
|
|
//回路调控
|
|
|
bindPickerChange3: function (e) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '刷新中',
|
|
|
+ icon: 'loading',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
var that = this
|
|
|
var play = that.data.play
|
|
|
- that.setData({indexes: e.detail.value})
|
|
|
+ var indexes = parseInt(e.detail.value)
|
|
|
+ that.setData({indexes: indexes})
|
|
|
//旧设备
|
|
|
if(play == 0){
|
|
|
-
|
|
|
+ getData(that.data.deviceId,that.data.deviceKey).then(res => {
|
|
|
+ var {data} = res.data
|
|
|
+ var Indexes = that.data.indexes
|
|
|
+ Indexes = Indexes + 1
|
|
|
+ var crr = that.data.crr.length
|
|
|
+ if (Indexes == crr) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //以下为回路
|
|
|
+ for (let i = 1; i < data.length; i++) {
|
|
|
+ //时控一开时间
|
|
|
+ if (data[i].id == "R" + Indexes + "_DayOpenTime1") {
|
|
|
+ var timeopen1 = data[i].current_value
|
|
|
+ }
|
|
|
+ //时控一关时间
|
|
|
+ else if (data[i].id == "R" + Indexes + "_DayCloseTime1") {
|
|
|
+ var timeshut1 = data[i].current_value
|
|
|
+ }
|
|
|
+ //时控二开时间
|
|
|
+ else if (data[i].id == "R" + Indexes + "_DayOpenTime2") {
|
|
|
+ var timeopen2 = data[i].current_value
|
|
|
+ }
|
|
|
+ //时控二关时间
|
|
|
+ else if (data[i].id == "R" + Indexes + "_DayCloseTime2") {
|
|
|
+ var timeshut2 = data[i].current_value
|
|
|
+ }
|
|
|
+ //日期调控
|
|
|
+ else if (data[i].id == "R" + Indexes + "_Week") {
|
|
|
+ var weeks = data[i].current_value
|
|
|
+ that.setData({
|
|
|
+ recorddate: weeks
|
|
|
+ })
|
|
|
+ weeks = parseInt(weeks)
|
|
|
+ weeks = weeks.toString(2)
|
|
|
+ weeks = weeks + ''
|
|
|
+ if (weeks != '0') {
|
|
|
+ weeks = weeks.slice(1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //功能一
|
|
|
+ else if (data[i].id == "R" + Indexes + "_FunctionStatus1") {
|
|
|
+ var Function1 = data[i].current_value
|
|
|
+ var par = parseInt(Function1)
|
|
|
+ par = par.toString(2)
|
|
|
+ par = par + ''
|
|
|
+ switch (par.length) {
|
|
|
+ case 1:
|
|
|
+ par = '00000' + par
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ par = '0000' + par
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ par = '000' + par
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ par = '00' + par
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ par = '0' + par
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ par = par
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //功能二
|
|
|
+ else if (data[i].id == "R" + Indexes + "_FunctionStatus2") {
|
|
|
+ var Function2 = data[i].current_value
|
|
|
+ var qur = parseInt(Function2)
|
|
|
+ qur = qur.toString(2)
|
|
|
+ qur = qur + ''
|
|
|
+ switch (qur.length) {
|
|
|
+ case 1:
|
|
|
+ qur = '000' + qur
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ qur = '00' + qur
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ qur = '0' + qur
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ qur = qur
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //报警
|
|
|
+ else if (data[i].id == "R" + Indexes + "_RelayStatus") {
|
|
|
+ var police = data[i].current_value
|
|
|
+ }
|
|
|
+ //光控开
|
|
|
+ else if (data[i].id == "R" + Indexes + "_LcOn") {
|
|
|
+ var Lightcontrolopen = data[i].current_value
|
|
|
+ var trr = that.data.arr
|
|
|
+ for (let i = 0; i < 100; i++) {
|
|
|
+ trr[i] = i
|
|
|
+ }
|
|
|
+ Lightcontrolopen = parseInt(Lightcontrolopen)
|
|
|
+ that.setData({
|
|
|
+ arr: trr,
|
|
|
+ index: Lightcontrolopen
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //光控关
|
|
|
+ else if (data[i].id == "R" + Indexes + "_LcOff") {
|
|
|
+ var Lightcontrolshut = data[i].current_value
|
|
|
+ var prr = that.data.brr
|
|
|
+ for (let j = 0; j < 100; j++) {
|
|
|
+ prr[j] = j
|
|
|
+ }
|
|
|
+ Lightcontrolshut = parseInt(Lightcontrolshut)
|
|
|
+ that.setData({
|
|
|
+ brr: prr,
|
|
|
+ indexs: Lightcontrolshut
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //时控一开时间
|
|
|
+ var timeOpen1
|
|
|
+ switch (timeopen1.length) {
|
|
|
+ case 1:
|
|
|
+ timeOpen1 = '00' + ':' + '0' + timeopen1.substring(0, 1)
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ timeOpen1 = '00' + ':' + timeopen1.substring(0, 2)
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ var timeOpen1 = '0' + timeopen1.substring(0, 1) + ':' + timeopen1.substring(1, 3)
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ var timeOpen1 = timeopen1.substring(0, 2) + ':' + timeopen1.substring(2, 4)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //时控一关时间
|
|
|
+ var timeShut1
|
|
|
+ switch (timeshut1.length) {
|
|
|
+ case 1:
|
|
|
+ timeShut1 = '00' + ':' + '0' + timeshut1.substring(0, 1)
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ timeShut1 = '00' + ':' + timeshut1.substring(0, 2)
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ var timeShut1 = '0' + timeshut1.substring(0, 1) + ':' + timeshut1.substring(1, 3)
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ var timeShut1 = timeshut1.substring(0, 2) + ':' + timeshut1.substring(2, 4)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //时控二开时间
|
|
|
+ var timeOpen2
|
|
|
+ switch (timeopen2.length) {
|
|
|
+ case 1:
|
|
|
+ timeOpen2 = '00' + ':' + '0' + timeopen2.substring(0, 1)
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ timeOpen2 = '00' + ':' + timeopen2.substring(0, 2)
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ var timeOpen2 = '0' + timeopen2.substring(0, 1) + ':' + timeopen2.substring(1, 3)
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ var timeOpen2 = timeopen2.substring(0, 2) + ':' + timeopen2.substring(2, 4)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //时控二关时间
|
|
|
+ var timeShut2
|
|
|
+ switch (timeshut2.length) {
|
|
|
+ case 1:
|
|
|
+ timeShut2 = '00' + ':' + '0' + timeshut2.substring(0, 1)
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ timeShut2 = '00' + ':' + timeshut2.substring(0, 2)
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ var timeShut2 = '0' + timeshut2.substring(0, 1) + ':' + timeshut2.substring(1, 3)
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ var timeShut2 = timeshut2.substring(0, 2) + ':' + timeshut2.substring(2, 4)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //功能1
|
|
|
+ for (var i = 0; i < par.length; i++) {
|
|
|
+ var engry = that.data.state
|
|
|
+ switch (par.substring(i, i + 1)) {
|
|
|
+ case "0":
|
|
|
+ switch (i) {
|
|
|
+ case 0:
|
|
|
+ engry[3] = false
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ engry[2] = false
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ that.setData({
|
|
|
+ fixed2: "固定"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ that.setData({
|
|
|
+ fixed1: "固定"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ engry[1] = false
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ engry[0] = false
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ switch (i) {
|
|
|
+ case 0:
|
|
|
+ engry[3] = true
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ engry[2] = true
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ that.setData({
|
|
|
+ fixed2: "经纬"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ that.setData({
|
|
|
+ fixed1: "经纬"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ engry[1] = true
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ engry[0] = true
|
|
|
+ that.setData({
|
|
|
+ state: engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //功能2
|
|
|
+ for (let j = 0; j < qur.length; j++) {
|
|
|
+ var Engry = that.data.state1
|
|
|
+ switch (qur.substring(j, j + 1)) {
|
|
|
+ case "0":
|
|
|
+ switch (j) {
|
|
|
+ case 0:
|
|
|
+ that.setData({
|
|
|
+ fixed4: "固定"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ that.setData({
|
|
|
+ fixed3: "固定"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ Engry[1] = false
|
|
|
+ that.setData({
|
|
|
+ state1: Engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ Engry[0] = false
|
|
|
+ that.setData({
|
|
|
+ state1: Engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ switch (j) {
|
|
|
+ case 0:
|
|
|
+ that.setData({
|
|
|
+ fixed4: "经纬"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ that.setData({
|
|
|
+ fixed3: "经纬"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ Engry[1] = true
|
|
|
+ that.setData({
|
|
|
+ state1: Engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ Engry[0] = true
|
|
|
+ that.setData({
|
|
|
+ state1: Engry
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //日期调控
|
|
|
+ var controladdress = that.data.address
|
|
|
+ if (weeks == '0') {
|
|
|
+ for (let x = 0; x < 7; x++) {
|
|
|
+ controladdress[x] = "/image/false.png"
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ address: controladdress,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < weeks.length; i++) {
|
|
|
+ switch (weeks.substring(i, i + 1)) {
|
|
|
+ case '0':
|
|
|
+ controladdress[weeks.length - i - 1] = "/image/false.png"
|
|
|
+ that.setData({
|
|
|
+ address: controladdress,
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case '1':
|
|
|
+ controladdress[weeks.length - i - 1] = "/image/true.png"
|
|
|
+ that.setData({
|
|
|
+ address: controladdress,
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //报警状态
|
|
|
+ police = parseInt(police)
|
|
|
+ police = police.toString(2)
|
|
|
+ switch (police.length) {
|
|
|
+ case 1:
|
|
|
+ police = '000' + police
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ police = '00' + police
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ police = '0' + police
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ police = police
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (police.substring(1, 2) == '0' && police.substring(0, 1) == '0') {
|
|
|
+ that.setData({
|
|
|
+ radio1: true
|
|
|
+ })
|
|
|
+ } else if (police.substring(1, 2) == '1' && police.substring(0, 1) == '0') {
|
|
|
+ that.setData({
|
|
|
+ radio2: true
|
|
|
+ })
|
|
|
+ } else if (police.substring(1, 2) == '0' && police.substring(0, 1) == '1') {
|
|
|
+ that.setData({
|
|
|
+ radio3: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ var time = that.data.time
|
|
|
+ time[0] = timeOpen1
|
|
|
+ time[1] = timeShut1
|
|
|
+ time[2] = timeOpen2
|
|
|
+ time[3] = timeShut2
|
|
|
+ that.setData({
|
|
|
+ time: time
|
|
|
+ })
|
|
|
+ switch (that.data.state[0]) {
|
|
|
+ case true:
|
|
|
+ that.setData({
|
|
|
+ type1: "time",
|
|
|
+ timecontrolcolor1: "blue",
|
|
|
+ fontcolor1: "white",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ that.setData({
|
|
|
+ type1: "",
|
|
|
+ timecontrolcolor1: "#888888",
|
|
|
+ fontcolor1: "#cccccc",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (that.data.state[1]) {
|
|
|
+ case true:
|
|
|
+ that.setData({
|
|
|
+ type2: "time",
|
|
|
+ timecontrolcolor2: "blue",
|
|
|
+ fontcolor2: "white",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ that.setData({
|
|
|
+ type2: "",
|
|
|
+ timecontrolcolor2: "#888888",
|
|
|
+ fontcolor2: "#cccccc",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (that.data.state1[0]) {
|
|
|
+ case true:
|
|
|
+ that.setData({
|
|
|
+ type3: "time",
|
|
|
+ timecontrolcolor3: "blue",
|
|
|
+ fontcolor3: "white",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ that.setData({
|
|
|
+ type3: "",
|
|
|
+ timecontrolcolor3: "#888888",
|
|
|
+ fontcolor3: "#cccccc",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (that.data.state1[1]) {
|
|
|
+ case true:
|
|
|
+ that.setData({
|
|
|
+ type4: "time",
|
|
|
+ timecontrolcolor4: "blue",
|
|
|
+ fontcolor4: "white",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ that.setData({
|
|
|
+ type4: "",
|
|
|
+ timecontrolcolor4: "#888888",
|
|
|
+ fontcolor4: "#cccccc",
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (that.data.state[2]) {
|
|
|
+ case true:
|
|
|
+ that.setData({
|
|
|
+ Lightcontrolcolor1: "blue",
|
|
|
+ fontcolor5: "white",
|
|
|
+ select1: "selector"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ that.setData({
|
|
|
+ Lightcontrolcolor1: "#888888",
|
|
|
+ fontcolor5: "#cccccc",
|
|
|
+ select1: ""
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch (that.data.state[3]) {
|
|
|
+ case true:
|
|
|
+ that.setData({
|
|
|
+ Lightcontrolcolor2: "blue",
|
|
|
+ fontcolor6: "white",
|
|
|
+ select2: "selector"
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ that.setData({
|
|
|
+ Lightcontrolcolor2: "#888888",
|
|
|
+ fontcolor6: "#cccccc",
|
|
|
+ select2: ""
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
}
|
|
|
//新设备
|
|
|
else{
|
|
@@ -740,11 +1230,13 @@ Page({
|
|
|
//光控开启条件(天气)
|
|
|
for (let q = 0; q < weather.length; q++) {
|
|
|
if (Suc.lightControlCondition == weather[q]) {
|
|
|
- that.setData({wIndex: q})
|
|
|
+ that.setData({
|
|
|
+ wIndex: q
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
//时控1
|
|
|
- if (Suc.timeCondition1Switch = 1) {
|
|
|
+ if (Suc.timeCondition1Switch == 1) {
|
|
|
newSwitch[0] = true
|
|
|
newSwitchstate[0] = 'time'
|
|
|
} else {
|
|
@@ -754,7 +1246,7 @@ Page({
|
|
|
timeValue[0] = Suc.timeCondition1OnTime
|
|
|
timeValue[1] = Suc.timeCondition1OffTime
|
|
|
//时控2
|
|
|
- if (Suc.timeCondition2Switch = 1) {
|
|
|
+ if (Suc.timeCondition2Switch == 1) {
|
|
|
newSwitch[1] = true
|
|
|
newSwitchstate[1] = 'time'
|
|
|
} else {
|
|
@@ -764,12 +1256,14 @@ Page({
|
|
|
timeValue[2] = Suc.timeCondition2OnTime
|
|
|
timeValue[3] = Suc.timeCondition2OffTime
|
|
|
//光控
|
|
|
- if (Suc.lightControlSwitch = 1) {
|
|
|
+ if (Suc.lightControlSwitch == 1) {
|
|
|
newSwitch[2] = true
|
|
|
newSwitchstate[2] = 'time'
|
|
|
+ newSwitchstate[3] = 'selector'
|
|
|
} else {
|
|
|
newSwitch[2] = false
|
|
|
newSwitchstate[2] = ''
|
|
|
+ newSwitchstate[3] = ''
|
|
|
}
|
|
|
timeValue[4] = Suc.lightControlStart
|
|
|
timeValue[5] = Suc.lightControlEnd
|
|
@@ -967,10 +1461,12 @@ Page({
|
|
|
newcolor[2] = "blue"
|
|
|
newfont[2] = "white"
|
|
|
newSwitchstate[2] = "time"
|
|
|
+ newSwitchstate[3] = "selector"
|
|
|
} else {
|
|
|
newcolor[2] = "#888888"
|
|
|
newfont[2] = "#cccccc"
|
|
|
newSwitchstate[2] = ""
|
|
|
+ newSwitchstate[3] = ""
|
|
|
}
|
|
|
this.setData({
|
|
|
newSwitch: newSwitch,
|
|
@@ -1029,7 +1525,7 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- //显示改变后的时间的值(1-4旧设备,5-10新设备)
|
|
|
+ //显示改变后的时间的值(1-4旧设备,5-11新设备)
|
|
|
bindTimeChange1: function (e) {
|
|
|
let time = this.data.time
|
|
|
time[0] = e.detail.value
|
|
@@ -1100,6 +1596,11 @@ Page({
|
|
|
timeValue: time
|
|
|
})
|
|
|
},
|
|
|
+ bindweatherChange11:function(e){
|
|
|
+ this.setData({
|
|
|
+ wIndex: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
//日期调控(图片切换)
|
|
|
setbuty0: function () {
|
|
|
var that = this
|
|
@@ -1509,11 +2010,10 @@ Page({
|
|
|
for (let i = 0; i < suc.length; i++) {
|
|
|
if (index == i) {
|
|
|
let Suc = suc[i]
|
|
|
- console.log(Suc)
|
|
|
var newSwitch = that.data.newSwitch
|
|
|
var timeValue = that.data.timeValue
|
|
|
//时控1
|
|
|
- if (Suc.timeCondition1Switch = 1) {
|
|
|
+ if (Suc.timeCondition1Switch == 1) {
|
|
|
newSwitch[0] = true
|
|
|
} else {
|
|
|
newSwitch[0] = false
|
|
@@ -1521,7 +2021,7 @@ Page({
|
|
|
timeValue[0] = Suc.timeCondition1OnTime
|
|
|
timeValue[1] = Suc.timeCondition1OffTime
|
|
|
//时控2
|
|
|
- if (Suc.timeCondition2Switch = 1) {
|
|
|
+ if (Suc.timeCondition2Switch == 1) {
|
|
|
newSwitch[1] = true
|
|
|
} else {
|
|
|
newSwitch[1] = false
|
|
@@ -1529,7 +2029,7 @@ Page({
|
|
|
timeValue[2] = Suc.timeCondition2OnTime
|
|
|
timeValue[3] = Suc.timeCondition2OffTime
|
|
|
//光控
|
|
|
- if (Suc.lightControlSwitch = 1) {
|
|
|
+ if (Suc.lightControlSwitch == 1) {
|
|
|
newSwitch[2] = true
|
|
|
} else {
|
|
|
newSwitch[2] = false
|
|
@@ -1610,6 +2110,11 @@ Page({
|
|
|
},
|
|
|
//存储数据
|
|
|
Storedata: function () {
|
|
|
+ wx.showToast({
|
|
|
+ title: '存储数据中',
|
|
|
+ icon: 'loading',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
var that = this
|
|
|
var play = that.data.play
|
|
|
//旧设备
|
|
@@ -1864,15 +2369,9 @@ Page({
|
|
|
[LcOff]: Lightcontroloff,
|
|
|
[RelayStatus]: jude,
|
|
|
}
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object),
|
|
|
- success: function (res) {}
|
|
|
- })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object)).then(res => {
|
|
|
+ console.log(res.data)
|
|
|
+ })
|
|
|
} else {
|
|
|
var object1 = {
|
|
|
"Reflash": 11,
|
|
@@ -1978,70 +2477,30 @@ Page({
|
|
|
"R8_LcOff": Lightcontroloff, //光控关
|
|
|
"R8_RelayStatus": jude, //开关状态
|
|
|
}
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object1),
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object2),
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object3),
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object4),
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object5),
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object6),
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object7),
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: 'https://api.heclouds.com/cmds?device_id=' + that.data.deviceId,
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- "api-key": that.data.deviceKey
|
|
|
- },
|
|
|
- data: JSON.stringify(object8),
|
|
|
- })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object1)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object2)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object3)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object4)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object5)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object6)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object7)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ postData(that.data.deviceId,that.data.deviceKey,JSON.stringify(object8)).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
wx.showModal({
|
|
@@ -2053,40 +2512,59 @@ Page({
|
|
|
}
|
|
|
//新设备
|
|
|
else {
|
|
|
- var timeValues = that.data.timeValue //时间
|
|
|
- var crrs = that.data.crr //回路名称集合
|
|
|
- var Crrindex = that.data.indexes //回路下标
|
|
|
- var equipment = that.data.equipment //设备id
|
|
|
- var newSwitch = that.data.newSwitch //设备开关
|
|
|
- //开启条件(天气)
|
|
|
- var weather = that.data.weather
|
|
|
- var wIndex = that.data.wIndex
|
|
|
- postloop({
|
|
|
- "deviceId": equipment,
|
|
|
- "relays": [{
|
|
|
- "relayId": Crrindex,
|
|
|
- "name": crrs[Crrindex],
|
|
|
- "timeCondition1Switch": newSwitch[0],
|
|
|
- "timeCondition1OnTime": timeValues[0],
|
|
|
- "timeCondition1OffTime": timeValues[1],
|
|
|
- "timeCondition2Switch": newSwitch[1],
|
|
|
- "timeCondition2OnTime": timeValues[2],
|
|
|
- "timeCondition2OffTime": timeValues[3],
|
|
|
- "lightControlSwitch": newSwitch[2],
|
|
|
- "lightControlStart": timeValues[4],
|
|
|
- "lightControlEnd": timeValues[5],
|
|
|
- "lightControlCondition": weather[wIndex],
|
|
|
- "status": null
|
|
|
- }]
|
|
|
- }).then(upload => {
|
|
|
- if (upload.data.code != 0) {
|
|
|
- wx.showModal({
|
|
|
- title: '错误',
|
|
|
- content: upload.data.msg,
|
|
|
- showCancel: false
|
|
|
- })
|
|
|
+ if (that.data.status == "在线") {
|
|
|
+ var timeValues = that.data.timeValue //时间
|
|
|
+ var crrs = that.data.crr //回路名称集合
|
|
|
+ var Crrindex = that.data.indexes //回路下标
|
|
|
+ Crrindex = Crrindex + 1
|
|
|
+ var equipment = that.data.equipment //设备id
|
|
|
+ var newSwitch = that.data.newSwitch //设备开关
|
|
|
+ for(let x = 0;x < newSwitch.length; x++){
|
|
|
+ if(newSwitch[x] == true){
|
|
|
+ newSwitch[x] = 1
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ newSwitch[x] = 0
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ //开启条件(天气)
|
|
|
+ var weather = that.data.weather
|
|
|
+ var wIndex = that.data.wIndex
|
|
|
+ var postobject = {
|
|
|
+ "deviceId": equipment,
|
|
|
+ "relays": [{
|
|
|
+ "relayId": Crrindex,
|
|
|
+ "name": crrs[Crrindex - 1],
|
|
|
+ "timeCondition1Switch": newSwitch[0],
|
|
|
+ "timeCondition1OnTime": timeValues[0],
|
|
|
+ "timeCondition1OffTime": timeValues[1],
|
|
|
+ "timeCondition2Switch": newSwitch[1],
|
|
|
+ "timeCondition2OnTime": timeValues[2],
|
|
|
+ "timeCondition2OffTime": timeValues[3],
|
|
|
+ "lightControlSwitch": newSwitch[2],
|
|
|
+ "lightControlStart": timeValues[4],
|
|
|
+ "lightControlEnd": timeValues[5],
|
|
|
+ "lightControlCondition": weather[wIndex],
|
|
|
+ "status": null
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ postloop(postobject).then(upload => {
|
|
|
+ if (upload.data.code != 0) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '错误',
|
|
|
+ content: upload.data.msg,
|
|
|
+ showCancel: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '存储数据失败,请检查设备是否在线或者刷新页面',
|
|
|
+ showCancel: false,
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
@@ -2166,7 +2644,7 @@ Page({
|
|
|
that.setData({
|
|
|
play: 0,
|
|
|
deviceKey:message.deviceKey,
|
|
|
- deviceid:message.deviceid
|
|
|
+ deviceId:message.deviceId
|
|
|
})
|
|
|
getBasic(message.deviceId, message.deviceKey).then(res => {
|
|
|
if (res.data.data.online == true) {
|
|
@@ -2345,7 +2823,7 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
//时控1
|
|
|
- if (Suc.timeCondition1Switch = 1) {
|
|
|
+ if (Suc.timeCondition1Switch == 1) {
|
|
|
newSwitch[0] = true
|
|
|
newSwitchstate[0] = 'time'
|
|
|
} else {
|
|
@@ -2355,7 +2833,7 @@ Page({
|
|
|
timeValue[0] = Suc.timeCondition1OnTime
|
|
|
timeValue[1] = Suc.timeCondition1OffTime
|
|
|
//时控2
|
|
|
- if (Suc.timeCondition2Switch = 1) {
|
|
|
+ if (Suc.timeCondition2Switch == 1) {
|
|
|
newSwitch[1] = true
|
|
|
newSwitchstate[1] = 'time'
|
|
|
} else {
|
|
@@ -2365,12 +2843,14 @@ Page({
|
|
|
timeValue[2] = Suc.timeCondition2OnTime
|
|
|
timeValue[3] = Suc.timeCondition2OffTime
|
|
|
//光控
|
|
|
- if (Suc.lightControlSwitch = 1) {
|
|
|
+ if (Suc.lightControlSwitch == 1) {
|
|
|
newSwitch[2] = true
|
|
|
newSwitchstate[2] = 'time'
|
|
|
+ newSwitchstate[3] = 'selector'
|
|
|
} else {
|
|
|
newSwitch[2] = false
|
|
|
newSwitchstate[2] = ''
|
|
|
+ newSwitchstate[3] = ''
|
|
|
}
|
|
|
timeValue[4] = Suc.lightControlStart
|
|
|
timeValue[5] = Suc.lightControlEnd
|