|
@@ -1,8 +1,5 @@
|
|
|
-const {
|
|
|
- getBasic,
|
|
|
- getData,
|
|
|
- postData
|
|
|
-} = require('../../api/intell')
|
|
|
+const {getBasic,getData,postData,} = require('../../api/intell')
|
|
|
+const {getDevice, getloop} = require('../../api/device')
|
|
|
const enloop = require('../../utils/loop')
|
|
|
// pages/loop/loop.js
|
|
|
Page({
|
|
@@ -72,12 +69,14 @@ Page({
|
|
|
deviceKey: '',
|
|
|
num: 0, //记录回路数量
|
|
|
play: 0, //新老设备的页面切换
|
|
|
- timeValue: ['00:00', '00:00'],
|
|
|
- endTimeValue: ['00:00', '00:00'],
|
|
|
- lightstartTime: '00:00',
|
|
|
- lightendTime: '00:00',
|
|
|
+ //新设备数据
|
|
|
+ timeValue: ['00:00', '00:00','00:00','00:00','00:00','00:00'],
|
|
|
weather: ['晴天', '雨天', '阴天', '黑夜'],
|
|
|
- wIndex: 0
|
|
|
+ wIndex: 0,
|
|
|
+ newcolor:["#888888","#888888","#888888"],
|
|
|
+ newfont:["#cccccc","#cccccc","#cccccc"],
|
|
|
+ newSwitch:[false,false,false],
|
|
|
+ newSwitchstate:["","",""],
|
|
|
},
|
|
|
//分组下拉
|
|
|
changegroup: function (e) {
|
|
@@ -1716,7 +1715,7 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
//时间调控
|
|
|
- //时控开关选择器
|
|
|
+ //时控开关选择器(1-4旧设备,5-6新设备)
|
|
|
Controltime1: function () {
|
|
|
var obtain1 = this.data.state
|
|
|
obtain1[0] = !obtain1[0]
|
|
@@ -1793,6 +1792,25 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+ Controltime5:function(){
|
|
|
+ console.log(2131131)
|
|
|
+ let newSwitch = this.data.newSwitch
|
|
|
+ let newcolor = this.data.newcolor
|
|
|
+ let newfont = this.data.newfont
|
|
|
+ let newSwitchstate =this.data.newSwitchstate
|
|
|
+ newSwitch[0] = !newSwitch[0]
|
|
|
+ if(newSwitch[0] == true){
|
|
|
+ newcolor[0] = "blue"
|
|
|
+ newfont[0] = "white"
|
|
|
+ newSwitchstate[0] = "time"
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ newcolor[0] = "#888888"
|
|
|
+ newfont[0] = "#cccccc"
|
|
|
+ newSwitchstate[0] = ""
|
|
|
+ }
|
|
|
+ that.setData({newSwitch:newSwitch,newcolor:newcolor,newfont,newfont,newSwitchstate:newSwitchstate})
|
|
|
+ },
|
|
|
//固定与经纬的切换
|
|
|
change1: function () {
|
|
|
var change1 = this.data.fixed1
|
|
@@ -1842,34 +1860,56 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- //显示改变后的时间的值
|
|
|
+ //显示改变后的时间的值(1-4旧设备,5-10新设备)
|
|
|
bindTimeChange1: function (e) {
|
|
|
- var time1 = this.data.time
|
|
|
- time1[0] = e.detail.value
|
|
|
- this.setData({
|
|
|
- time: time1
|
|
|
- })
|
|
|
+ let time = this.data.time
|
|
|
+ time[0] = e.detail.value
|
|
|
+ this.setData({time: time})
|
|
|
},
|
|
|
bindTimeChange2: function (e) {
|
|
|
- var time2 = this.data.time
|
|
|
- time2[1] = e.detail.value
|
|
|
- this.setData({
|
|
|
- time: time2
|
|
|
- })
|
|
|
+ let time = this.data.time
|
|
|
+ time[1] = e.detail.value
|
|
|
+ this.setData({time: time})
|
|
|
},
|
|
|
bindTimeChange3: function (e) {
|
|
|
- var time3 = this.data.time
|
|
|
- time3[2] = e.detail.value
|
|
|
- this.setData({
|
|
|
- time: time3
|
|
|
- })
|
|
|
+ let time = this.data.time
|
|
|
+ time[2] = e.detail.value
|
|
|
+ this.setData({time: time})
|
|
|
},
|
|
|
bindTimeChange4: function (e) {
|
|
|
- var time4 = this.data.time
|
|
|
- time4[3] = e.detail.value
|
|
|
- this.setData({
|
|
|
- time: time4
|
|
|
- })
|
|
|
+ let time = this.data.time
|
|
|
+ time[3] = e.detail.value
|
|
|
+ this.setData({time: time})
|
|
|
+ },
|
|
|
+ bindTimeChange5:function(e){
|
|
|
+ let time = this.data.timeValue
|
|
|
+ time[0] = e.detail.value
|
|
|
+ this.setData({timeValue:time})
|
|
|
+ },
|
|
|
+ bindTimeChange6:function(e){
|
|
|
+ let time = this.data.timeValue
|
|
|
+ time[1] = e.detail.value
|
|
|
+ this.setData({timeValue:time})
|
|
|
+ },
|
|
|
+ bindTimeChange7:function(e){
|
|
|
+ let time = this.data.timeValue
|
|
|
+ time[2] = e.detail.value
|
|
|
+ this.setData({timeValue:time})
|
|
|
+ },
|
|
|
+ bindTimeChange8:function(e){
|
|
|
+ let time = this.data.timeValue
|
|
|
+ time[3] = e.detail.value
|
|
|
+ this.setData({timeValue:time})
|
|
|
+ },
|
|
|
+ bindTimeChange9:function(e){
|
|
|
+ let time = this.data.timeValue
|
|
|
+ time[4] = e.detail.value
|
|
|
+ this.setData({timeValue:time})
|
|
|
+ },
|
|
|
+ bindTimeChange10:function(e){
|
|
|
+ let time = this.data.timeValue
|
|
|
+ time[5] = e.detail.value
|
|
|
+ this.setData({timeValue:time})
|
|
|
},
|
|
|
//日期调控(图片切换)
|
|
|
setbuty0: function () {
|
|
@@ -3137,9 +3177,7 @@ Page({
|
|
|
wx.getSystemInfo({
|
|
|
success: function (res) {
|
|
|
if (res.model == 'iPad' || res.model == 'iPad Pro 10.5-inch' || res.model == 'iPad Pro 12.9-inch') {
|
|
|
- that.setData({
|
|
|
- zoom: 1
|
|
|
- })
|
|
|
+ that.setData({zoom: 1})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -3152,9 +3190,7 @@ Page({
|
|
|
groupName: groupName.groups
|
|
|
})
|
|
|
} else {
|
|
|
- that.setData({
|
|
|
- groupName: groupName.groups
|
|
|
- })
|
|
|
+ that.setData({groupName: groupName.groups})
|
|
|
}
|
|
|
//设备下拉
|
|
|
var deviceName = enloop.Devicedrop(that.data.groupName, that.data.groupIndex)
|
|
@@ -3169,35 +3205,168 @@ Page({
|
|
|
deviceName: deviceName.device
|
|
|
})
|
|
|
} else {
|
|
|
- that.setData({
|
|
|
- deviceName: deviceName.device
|
|
|
- })
|
|
|
+ that.setData({deviceName: deviceName.device})
|
|
|
}
|
|
|
//获取设备信息
|
|
|
var currentGroup = that.data.groupName[that.data.groupIndex]
|
|
|
var currentDevice = that.data.deviceName[that.data.deviceIndex]
|
|
|
var message = enloop.deviceMessage(currentGroup, currentDevice)
|
|
|
- console.log(message)
|
|
|
- getBasic(message[1], message[2]).then(res => {
|
|
|
- if (res.data.data.online == true) {
|
|
|
- that.setData({
|
|
|
- status: '在线'
|
|
|
- })
|
|
|
- } else {
|
|
|
- that.setData({
|
|
|
- status: '离线'
|
|
|
+ if(message.modules == 0){
|
|
|
+ getBasic(message.deviceId, message.deviceKey).then(res => {
|
|
|
+ if (res.data.data.online == true) {
|
|
|
+ that.setData({status: '在线'})
|
|
|
+ } else {
|
|
|
+ that.setData({status: '离线'})
|
|
|
+ }
|
|
|
+ getData(message.deviceId, message.deviceKey).then(ever => {
|
|
|
+ let {data} = ever.data
|
|
|
+ let loopnum = message.loopnum
|
|
|
+ var Summary = enloop.deviceinfo(data,loopnum,that.data.arr,that.data.brr,that.data.time,that.data.state,
|
|
|
+ that.data.state1,that.data.fixed1,that.data.fixed2,that.data.fixed3,
|
|
|
+ that.data.fixed4,that.data.address,that.data.radio1,that.data.radio2,
|
|
|
+ that.data.radio3,that.data.index,that.data.indexs)
|
|
|
+ that.setData({
|
|
|
+ crr:Summary.crr,arr:Summary.arr,brr:Summary.brr,fixed1:Summary.fixed1,
|
|
|
+ fixed2:Summary.fixed2,fixed3:Summary.fixed3,fixed4:Summary.fixed4,
|
|
|
+ index:Summary.index,indexs:Summary.indexs,radio1:Summary.radio1,radio2:Summary.radio2,
|
|
|
+ radio3:Summary.radio3,recorddate:Summary.recorddate,state:Summary.state,
|
|
|
+ state1:Summary.state1,time:Summary.time,address:Summary.address,play:0
|
|
|
+ })
|
|
|
+ //监视开关状态(改变颜色,调整功能)
|
|
|
+ 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;
|
|
|
+ }
|
|
|
})
|
|
|
- }
|
|
|
- getData(message[1], message[2]).then(ever => {
|
|
|
- let {data} = ever.data
|
|
|
- var Summary = enloop.deviceinfo(data,that.data.arr,that.data.brr,that.data.time,that.data.state,
|
|
|
- that.data.state1,that.data.fixed1,that.data.fixed2,that.data.fixed3,
|
|
|
- that.data.fixed4,that.data.address,that.data.radio1,that.data.radio2,
|
|
|
- that.data.radio3,that.data.index,that.data.indexs)
|
|
|
- console.log(Summary)
|
|
|
-
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //新设备在线状态
|
|
|
+ getDevice(message.Device,message.id).then(nrg => {
|
|
|
+ if(nrg.data.code == 0){
|
|
|
+ var nrg = nrg.data.data
|
|
|
+ if(nrg[0].status == 1){
|
|
|
+ that.setData({status:'在线'})
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ that.setData({status:'离线'})
|
|
|
+ }
|
|
|
+ getloop(message.Device).then(suc =>{
|
|
|
+ if(suc.data.code == 0){
|
|
|
+ that.setData({crr:message.loopnum,play:1})
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ console.log('获取新设备回路参数失败')
|
|
|
+ wx.showModal({
|
|
|
+ title:'错误',
|
|
|
+ content:suc.data.msg,
|
|
|
+ showCancel:false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ console.log('新设备获取信息失败')
|
|
|
+ wx.showModal({
|
|
|
+ title:'错误',
|
|
|
+ content:nrg.data.msg,
|
|
|
+ showCancel:false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|