hxz 2 vuotta sitten
vanhempi
commit
10c1aa13a8
6 muutettua tiedostoa jossa 1586 lisäystä ja 1424 poistoa
  1. 747 755
      pages/control/control.js
  2. 117 55
      pages/loop/loop.js
  3. 721 557
      pages/system/system.js
  4. 1 1
      project.private.config.json
  5. 0 53
      utils/control.js
  6. 0 3
      utils/loop.js

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 747 - 755
pages/control/control.js


+ 117 - 55
pages/loop/loop.js

@@ -405,7 +405,8 @@ Page({
         } else {
           wx.setStorageSync('deviceName', '')
           that.setData({
-            status: '离线'
+            status: '离线',
+            deviceName:[]
           })
         }
       }
@@ -1805,44 +1806,66 @@ Page({
         }
       }
     })
-    if (wx.getStorageSync('group') != null) {
+    var group = wx.getStorageSync('group')
+    if (group != null && group.length != 0) {
       //分组下拉
-      var groupName = enloop.Groupdrop()
-      if (groupName.n != '') {
-        that.setData({
-          groupIndex: groupName.n,
-          groupName: groupName.groups
-        })
+      var group = wx.getStorageSync('group')
+      var groups = []
+      for (let i = 0; i < group.length; i++) {
+        groups.push(group[i].groupName)
+      }
+      that.setData({groupName:groups})
+      //改变分组下标
+      if (wx.getStorageSync('groupName') != '') {
+        let GroupName = groups
+        for (let n = 0; n < GroupName.length; n++) {
+          if (GroupName[n] == wx.getStorageSync('groupName')) {
+            that.setData({groupIndex:n})
+          }
+        }
       } else {
-        that.setData({
-          groupName: groupName.groups
-        })
+        wx.setStorageSync('groupName', groups[0])
       }
       //设备下拉
-      var deviceName = enloop.Devicedrop(that.data.groupName, that.data.groupIndex)
-      if (deviceName == '离线') {
-        that.setData({
-          status: '离线'
-        })
-      } else {
-        if (deviceName.m != '') {
-          that.setData({
-            deviceIndex: deviceName.m,
-            deviceName: deviceName.device
-          })
-        } else {
-          that.setData({
-            deviceName: deviceName.device
-          })
+      var device = []
+      var groupName  = that.data.groupName
+      var groupIndex = that.data.groupIndex
+      for (let j = 0; j < group.length; j++) {
+        if (groupName[groupIndex] == group[j].groupName) {
+          if (group[j].devices != null && group[j].devices.length != 0) {
+            for (let p = 0; p < group[j].devices.length; p++) {
+              device.push(group[j].devices[p].deviceName)
+            }
+            that.setData({deviceName:device})
+            //改变设备下标
+            if (wx.getStorageSync('deviceName') != '') {
+              for (let m = 0; m < device.length; m++) {
+                if (device[m] == wx.getStorageSync('deviceName')) {
+                  that.setData({deviceIndex:m})
+                }
+              }
+            } else {
+              wx.setStorageSync('deviceName', device[0])
+            }
+          } else {
+            that.setData({status:'离线',deviceName:[]})
+          }
         }
+      }
         //获取设备信息
         var currentGroup = that.data.groupName[that.data.groupIndex]
         var currentDevice = that.data.deviceName[that.data.deviceIndex]
         var message = enloop.deviceMessage(currentGroup, currentDevice)
+        that.setData({
+          equipment: message.Device,
+          subset:message.id
+        }) //记录当前的设备id和分组id
         //旧设备
         if (message.modules == 0) {
           that.setData({
-            play: 0
+            play: 0,
+            deviceKey:message.deviceKey,
+            deviceId:message.deviceId
           })
           getBasic(message.deviceId, message.deviceKey).then(res => {
             if (res.data.data.online == true) {
@@ -2010,27 +2033,45 @@ Page({
                       let Suc = suc[i]
                       var newSwitch = that.data.newSwitch
                       var timeValue = that.data.timeValue
+                      var newSwitchstate = that.data.newSwitchstate
+                      var weather = that.data.weather
+                      //光控开启条件(天气)
+                      for (let q = 0; q < weather.length; q++) {
+                        if (Suc.lightControlCondition == weather[q]) {
+                          that.setData({
+                            wIndex: q
+                          })
+                        }
+                      }
                       //时控1
                       if (Suc.timeCondition1Switch == 1) {
                         newSwitch[0] = true
+                        newSwitchstate[0] = 'time'
                       } else {
                         newSwitch[0] = false
+                        newSwitchstate[0] = ''
                       }
                       timeValue[0] = Suc.timeCondition1OnTime
                       timeValue[1] = Suc.timeCondition1OffTime
                       //时控2
                       if (Suc.timeCondition2Switch == 1) {
                         newSwitch[1] = true
+                        newSwitchstate[1] = 'time'
                       } else {
                         newSwitch[1] = false
+                        newSwitchstate[1] = ''
                       }
                       timeValue[2] = Suc.timeCondition2OnTime
                       timeValue[3] = Suc.timeCondition2OffTime
                       //光控
                       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
@@ -2044,7 +2085,7 @@ Page({
                         timeValue: timeValue,
                         newSwitch: newSwitch
                       })
-                      ///监视新设备开关状态
+                      //监视新设备开关状态
                       var newSwitchs = that.data.newSwitch
                       var newfonts = that.data.newfont
                       var newcolors = that.data.newcolor
@@ -2103,7 +2144,9 @@ Page({
             }
           })
         }
-      }
+    }
+    else{
+      that.setData({deviceName:[],groupName:[]})
     }
   },
   //存储数据
@@ -2600,36 +2643,52 @@ Page({
         }
       }
     })
-    if (wx.getStorageSync('group') != null) {
+    var group = wx.getStorageSync('group')
+    if (group != null && group.length != 0) {
       //分组下拉
-      var groupName = enloop.Groupdrop()
-      if (groupName.n != '') {
-        that.setData({
-          groupIndex: groupName.n,
-          groupName: groupName.groups
-        })
+      var group = wx.getStorageSync('group')
+      var groups = []
+      for (let i = 0; i < group.length; i++) {
+        groups.push(group[i].groupName)
+      }
+      that.setData({groupName:groups})
+      //改变分组下标
+      if (wx.getStorageSync('groupName') != '') {
+        let GroupName = groups
+        for (let n = 0; n < GroupName.length; n++) {
+          if (GroupName[n] == wx.getStorageSync('groupName')) {
+            that.setData({groupIndex:n})
+          }
+        }
       } else {
-        that.setData({
-          groupName: groupName.groups
-        })
+        wx.setStorageSync('groupName', groups[0])
       }
       //设备下拉
-      var deviceName = enloop.Devicedrop(that.data.groupName, that.data.groupIndex)
-      if (deviceName == '离线') {
-        that.setData({
-          status: '离线'
-        })
-      } else {
-        if (deviceName.m != '') {
-          that.setData({
-            deviceIndex: deviceName.m,
-            deviceName: deviceName.device
-          })
-        } else {
-          that.setData({
-            deviceName: deviceName.device
-          })
+      var device = []
+      var groupName  = that.data.groupName
+      var groupIndex = that.data.groupIndex
+      for (let j = 0; j < group.length; j++) {
+        if (groupName[groupIndex] == group[j].groupName) {
+          if (group[j].devices != null && group[j].devices.length != 0) {
+            for (let p = 0; p < group[j].devices.length; p++) {
+              device.push(group[j].devices[p].deviceName)
+            }
+            that.setData({deviceName:device})
+            //改变设备下标
+            if (wx.getStorageSync('deviceName') != '') {
+              for (let m = 0; m < device.length; m++) {
+                if (device[m] == wx.getStorageSync('deviceName')) {
+                  that.setData({deviceIndex:m})
+                }
+              }
+            } else {
+              wx.setStorageSync('deviceName', device[0])
+            }
+          } else {
+            that.setData({status:'离线',deviceName:[]})
+          }
         }
+      }
         //获取设备信息
         var currentGroup = that.data.groupName[that.data.groupIndex]
         var currentDevice = that.data.deviceName[that.data.deviceIndex]
@@ -2791,6 +2850,7 @@ Page({
           })
           //新设备在线状态
           getDevice(message.Device, message.id).then(nrg => {
+            console.log([message.Device,message.id])
             if (nrg.data.code == 0) {
               var nrg = nrg.data.data
               if (nrg[0].status == 1) {
@@ -2922,7 +2982,9 @@ Page({
             }
           })
         }
-      }
+    }
+    else{
+      that.setData({deviceName:[],groupName:[]})
     }
   },
 

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 721 - 557
pages/system/system.js


+ 1 - 1
project.private.config.json

@@ -6,5 +6,5 @@
     "urlCheck": true
   },
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-  "libVersion": "2.27.1"
+  "libVersion": "2.19.6"
 }

+ 0 - 53
utils/control.js

@@ -121,58 +121,7 @@ function newswitchReal(Device,relayid){
     }
   })
 }
-//回路名称调整(输入框)
-function loopname(){
-  wx.showModal({
-    title: '修改回路名称',
-    editable: true,
-    placeholderText: '请输入名称',
-    success:res =>{
-      if(res.confirm){
-        if (res.content == '') {
-          wx.showModal({
-            title: '提示',
-            content: '请输入名称',
-            showCancel: false
-          })
-        } else if (res.content.length > 10) {
-          wx.showModal({
-            title: '提示',
-            content: '回路名称不能大于10个字符',
-            showCancel: false
-          })
-        }
-        else{
-          return res.content
-        }
-      }
-    }
-  })
-}
 
-//回路名称调整(请求)
-function requesloopname(deviceid,groupid,slice){
-  putDevice({id: deviceid,groupId: groupid,circuits: slice}).then(res =>{
-    if(res.data.code == 0){
-      for (let i = 0; i < group.length; i++) {
-        if (groupName == group[i].groupName) {
-          for (let j = 0; j < group[i].devices.length; j++) {
-            if (deviceName == group[i].devices[j].deviceName) {
-              group[i].devices[j].circuits = slice
-            }
-          }
-        }
-      }
-    }
-    else{
-      wx.showModal({
-        title: '错误',
-        content: res.data.msg,
-        showCancel:false
-      })
-    }
-  })
-}
 
 //分组下拉和设备下拉的获取(主页界面)
 function droplist(){
@@ -247,9 +196,7 @@ module.exports = {
   getlooplist:getlooplist,
   Switch:Switch,
   switchReal:switchReal,
-  loopname:loopname,
   Refresh:Refresh,
   newSwitch:newSwitch,
   newswitchReal:newswitchReal,
-  requesloopname:requesloopname
 }

+ 0 - 3
utils/loop.js

@@ -16,9 +16,6 @@ function Groupdrop() {
     }
   } else {
     wx.setStorageSync('groupName', groups[0])
-    return {
-      groups
-    }
   }
 }