فهرست منبع

主页,列表

hxz 2 سال پیش
والد
کامیت
c3f42a343d
13فایلهای تغییر یافته به همراه251 افزوده شده و 155 حذف شده
  1. 1 1
      api/device.js
  2. 1 3
      app.js
  3. 1 1
      https/env.js
  4. 1 1
      https/request.js
  5. 43 47
      pages/control/control.js
  6. 0 4
      pages/control/control.wxml
  7. 13 23
      pages/loop/loop.js
  8. 35 2
      pages/loop/loop.wxml
  9. 75 4
      pages/loop/loop.wxss
  10. 78 67
      pages/scene/scene.js
  11. 2 1
      pages/sign/sign.js
  12. 1 1
      project.private.config.json
  13. 0 0
      utils/loop.js

+ 1 - 1
api/device.js

@@ -13,5 +13,5 @@ module.exports = {
   //控制回路开关
   //控制回路开关
   loopSwitch:(params) => request('/devices/operation','POST',params),
   loopSwitch:(params) => request('/devices/operation','POST',params),
   //获取回路的开关状态
   //获取回路的开关状态
-  loopSwitchstate:(Device,relayid) => request('/devices/relays/status?device_id='+ Device + '&relay_ids=' + relayid,'GET')
+  loopSwitchstate:(Device,relayid) => request('/devices/relays/status?id='+ Device + '&relay_ids=' + relayid,'GET')
 }
 }

+ 1 - 3
app.js

@@ -13,9 +13,7 @@ App({
     let currentTime = wx.getStorageSync('currentTime')//过期时间
     let currentTime = wx.getStorageSync('currentTime')//过期时间
     if(token != ''){
     if(token != ''){
       if(parseInt(Time - time)/1000 < currentTime){
       if(parseInt(Time - time)/1000 < currentTime){
-        wx.switchTab({
-          url: 'pages/scene/scene',
-        })
+        wx.switchTab({url: 'pages/scene/scene'})
       }
       }
       else{
       else{
         
         

+ 1 - 1
https/env.js

@@ -5,7 +5,7 @@ module.exports = {
   },
   },
   // 添加设备和分组
   // 添加设备和分组
   prod:{
   prod:{
-    baseUrl:'http://110.40.223.170:8120/api/minigrogram/lightcontrol'
+    baseUrl:'https://cloud.long-chi.com/api/minigrogram/lightcontrol'
   },
   },
   //获取设备具体信息
   //获取设备具体信息
   intell:{
   intell:{

+ 1 - 1
https/request.js

@@ -2,7 +2,7 @@ const { baseUrl } = require('./env').prod
 module.exports = {
 module.exports = {
     request : function(url, type , data = {}){
     request : function(url, type , data = {}){
     let fullUrl = `${baseUrl}${url}`
     let fullUrl = `${baseUrl}${url}`
-    let token = wx.getStorageSync('token') ? wx.getStorageSync('token')  : ''
+    let token = wx.getStorageSync('token')
     return new Promise((resolve,reject)=>{
     return new Promise((resolve,reject)=>{
       wx.request({url: fullUrl,method:type,data,header: {'content-type': 'application/json','Authorization': token},
       wx.request({url: fullUrl,method:type,data,header: {'content-type': 'application/json','Authorization': token},
         success(res){resolve(res)},
         success(res){resolve(res)},

+ 43 - 47
pages/control/control.js

@@ -59,7 +59,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R1_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R1_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"1",operation:1})
+        control.newSwitch({deviceId:id,relayId:1,operation:1})
       }
       }
     }
     }
     else if (opens == 2 && loops >= 2) {
     else if (opens == 2 && loops >= 2) {
@@ -67,7 +67,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R2_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R2_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"2",operation:1})
+        control.newSwitch({deviceId:id,relayId:2,operation:1})
       }
       }
     }
     }
     else if (opens == 3 && loops >= 3) {
     else if (opens == 3 && loops >= 3) {
@@ -75,7 +75,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R3_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R3_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"3",operation:1})
+        control.newSwitch({deviceId:id,relayId:3,operation:1})
       }
       }
     }
     }
     else if (opens == 4 && loops >= 4) {
     else if (opens == 4 && loops >= 4) {
@@ -83,7 +83,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R4_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R4_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"4",operation:1})
+        control.newSwitch({deviceId:id,relayId:4,operation:1})
       }
       }
     }
     }
     else if (opens == 5 && loops >= "5") {
     else if (opens == 5 && loops >= "5") {
@@ -91,7 +91,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R5_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R5_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"5",operation:1})
+        control.newSwitch({deviceId:id,relayId:5,operation:1})
       }
       }
     }
     }
     else if (opens == 6 && loops >= "6") {
     else if (opens == 6 && loops >= "6") {
@@ -99,7 +99,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R6_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R6_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"6",operation:1})
+        control.newSwitch({deviceId:id,relayId:6,operation:1})
       }
       }
     }
     }
     else if (opens == 7 && loops >= "7") {
     else if (opens == 7 && loops >= "7") {
@@ -107,7 +107,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R7_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R7_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"7",operation:1})
+        control.newSwitch({deviceId:id,relayId:7,operation:1})
       }
       }
     }
     }
     else if (opens == 8 && loops >= "8") {
     else if (opens == 8 && loops >= "8") {
@@ -115,7 +115,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R8_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R8_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"8",operation:1})
+        control.newSwitch({deviceId:id,relayId:8,operation:1})
       }
       }
     }
     }
     else if (opens == 9 && loops >= "9") {
     else if (opens == 9 && loops >= "9") {
@@ -123,7 +123,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R9_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R9_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"9",operation:1})
+        control.newSwitch({deviceId:id,relayId:9,operation:1})
       }
       }
     }
     }
     else if (opens == 10 && loops >= "10") {
     else if (opens == 10 && loops >= "10") {
@@ -131,7 +131,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R10_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R10_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"10",operation:1})
+        control.newSwitch({deviceId:id,relayId:10,operation:1})
       }
       }
     }
     }
     else if (opens == 11 && loops >= "11") {
     else if (opens == 11 && loops >= "11") {
@@ -139,7 +139,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R11_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R11_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"11",operation:1})
+        control.newSwitch({deviceId:id,relayId:11,operation:1})
       }
       }
     }
     }
     else if (opens == 12 && loops >= "12") {
     else if (opens == 12 && loops >= "12") {
@@ -147,7 +147,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R12_RelayStatus':13,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{ 'R12_RelayStatus':13,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"12",operation:1})
+        control.newSwitch({deviceId:id,relayId:12,operation:1})
       }
       }
     }
     }
     setTimeout(function(){
     setTimeout(function(){
@@ -226,7 +226,7 @@ Page({
           that.setData({lamp:wx.getStorageSync('lamp')})
           that.setData({lamp:wx.getStorageSync('lamp')})
         },500)
         },500)
       }
       }
-    },2000)
+    },3000)
   },
   },
   //回路关
   //回路关
   Shut(e){
   Shut(e){
@@ -244,7 +244,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R1_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R1_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"1",operation:0})
+        control.newSwitch({deviceId:id,relayId:1,operation:0})
       }
       }
     }
     }
     else if (shuts == 2 && loops >= 2) {
     else if (shuts == 2 && loops >= 2) {
@@ -252,7 +252,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R2_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R2_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"2",operation:0})
+        control.newSwitch({deviceId:id,relayId:2,operation:0})
       }
       }
     }
     }
     else if (shuts == 3 && loops >= 3) {
     else if (shuts == 3 && loops >= 3) {
@@ -260,7 +260,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R3_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R3_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"3",operation:0})
+        control.newSwitch({deviceId:id,relayId:3,operation:0})
       }
       }
     }
     }
     else if (shuts == 4 && loops >= 4) {
     else if (shuts == 4 && loops >= 4) {
@@ -268,7 +268,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R4_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R4_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"4",operation:0})
+        control.newSwitch({deviceId:id,relayId:4,operation:0})
       }
       }
     }
     }
     else if (shuts == 5 && loops >= 5) {
     else if (shuts == 5 && loops >= 5) {
@@ -276,7 +276,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R5_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R5_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"5",operation:0})
+        control.newSwitch({deviceId:id,relayId:5,operation:0})
       }
       }
     }
     }
     else if (shuts == 6 && loops >= 6) {
     else if (shuts == 6 && loops >= 6) {
@@ -284,7 +284,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R6_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R6_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"6",operation:0})
+        control.newSwitch({deviceId:id,relayId:6,operation:0})
       }
       }
     }
     }
     else if (shuts == 7 && loops >= 7) {
     else if (shuts == 7 && loops >= 7) {
@@ -292,7 +292,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R7_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R7_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"7",operation:0})
+        control.newSwitch({deviceId:id,relayId:7,operation:0})
       }
       }
     }
     }
     else if (shuts == 8 && loops >= 8) {
     else if (shuts == 8 && loops >= 8) {
@@ -300,7 +300,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R8_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R8_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"8",operation:0})
+        control.newSwitch({deviceId:id,relayId:8,operation:0})
       }
       }
     }
     }
     else if (shuts == 9 && loops >= 9) {
     else if (shuts == 9 && loops >= 9) {
@@ -308,7 +308,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R9_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R9_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"9",operation:0})
+        control.newSwitch({deviceId:id,relayId:9,operation:0})
       }
       }
     }
     }
     else if (shuts == 10 && loops >= 10) {
     else if (shuts == 10 && loops >= 10) {
@@ -316,7 +316,7 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R10_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R10_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"10",operation:0})
+        control.newSwitch({deviceId:id,relayId:10,operation:0})
       }
       }
     }
     }
     else if (shuts == 11 && loops >= 11) {
     else if (shuts == 11 && loops >= 11) {
@@ -324,15 +324,15 @@ Page({
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R11_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R11_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"11",operation:0})
+        control.newSwitch({deviceId:id,relayId:11,operation:0})
       }
       }
     }
     }
-    else if (shuts == 12 && loops >= "12") {
+    else if (shuts == 12 && loops >= 12) {
       if(moudule == 0){
       if(moudule == 0){
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R12_RelayStatus':12,'Reflash':3})
         control.Switch(that.data.deviceId,that.data.deviceKey,{'R12_RelayStatus':12,'Reflash':3})
       }
       }
       else{
       else{
-        control.newSwitch({deviceId:id,relayIds:"12",operation:0})
+        control.newSwitch({deviceId:id,relayId:12,operation:0})
       }
       }
     }
     }
     setTimeout(function(){
     setTimeout(function(){
@@ -342,40 +342,40 @@ Page({
           if(bind.data.errno == 0){
           if(bind.data.errno == 0){
             for(let r1 = 0;r1 < Bind.length;r1++){         
             for(let r1 = 0;r1 < Bind.length;r1++){         
               if(Bind[r1].id == 'R1_RelayStatus'){
               if(Bind[r1].id == 'R1_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,0)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,0)
               }
               }
               else if(Bind[r1].id == 'R2_RelayStatus'){
               else if(Bind[r1].id == 'R2_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,1)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,1)
               }
               }
               else if(Bind[r1].id == 'R3_RelayStatus'){
               else if(Bind[r1].id == 'R3_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,2)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,2)
               }
               }
               else if(Bind[r1].id == 'R4_RelayStatus'){
               else if(Bind[r1].id == 'R4_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,3)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,3)
               }
               }
               else if(Bind[r1].id == 'R5_RelayStatus'){
               else if(Bind[r1].id == 'R5_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,4)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,4)
               }
               }
               else if(Bind[r1].id == 'R6_RelayStatus'){
               else if(Bind[r1].id == 'R6_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,5)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,5)
               }
               }
               else if(Bind[r1].id == 'R7_RelayStatus'){
               else if(Bind[r1].id == 'R7_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,6)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,6)
               }
               }
               else if(Bind[r1].id == 'R8_RelayStatus'){
               else if(Bind[r1].id == 'R8_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,7)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,7)
               }
               }
               else if(Bind[r1].id == 'R9_RelayStatus'){
               else if(Bind[r1].id == 'R9_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,8)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,8)
               }
               }
               else if(Bind[r1].id == 'R10_RelayStatus'){
               else if(Bind[r1].id == 'R10_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,9)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,9)
               }
               }
               else if(Bind[r1].id == 'R11_RelayStatus'){
               else if(Bind[r1].id == 'R11_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,10)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,10)
               }
               }
               else if(Bind[r1].id == 'R12_RelayStatus'){
               else if(Bind[r1].id == 'R12_RelayStatus'){
-                var switchReal = control.SwitchReal(Bind[r1].current_value,lamp,11)
+                var switchReal = control.switchReal(Bind[r1].current_value,lamp,11)
               }
               }
             }
             }
             wx.setStorageSync('lamp',switchReal)
             wx.setStorageSync('lamp',switchReal)
@@ -408,7 +408,7 @@ Page({
           that.setData({lamp:wx.getStorageSync('lamp')})
           that.setData({lamp:wx.getStorageSync('lamp')})
         },500)
         },500)
       }
       }
-    },2000)
+    },3000)
   },
   },
   //回路名称调整
   //回路名称调整
   loopname(e){
   loopname(e){
@@ -1182,7 +1182,6 @@ Page({
     'R5_RelayStatus':12,'R6_RelayStatus':12,'R7_RelayStatus':12,'R8_RelayStatus':12,'R9_RelayStatus':12,
     'R5_RelayStatus':12,'R6_RelayStatus':12,'R7_RelayStatus':12,'R8_RelayStatus':12,'R9_RelayStatus':12,
     'R10_RelayStatus':12,'R11_RelayStatus':12,'R12_RelayStatus':12,'Reflash':3}
     'R10_RelayStatus':12,'R11_RelayStatus':12,'R12_RelayStatus':12,'Reflash':3}
     postData(that.data.deviceId,that.data.deviceKey,obj).then(res => {
     postData(that.data.deviceId,that.data.deviceKey,obj).then(res => {
-      console.log(res)
       if(res.data.errno == 0){
       if(res.data.errno == 0){
         wx.setStorageSync('lamp', [])
         wx.setStorageSync('lamp', [])
         var lamp = wx.getStorageSync('lamp')
         var lamp = wx.getStorageSync('lamp')
@@ -1525,7 +1524,6 @@ Page({
           }
           }
         }
         }
         else{
         else{
-          console.log('主页分组下拉到没有设备的工程')
           wx.showModal({
           wx.showModal({
             title:'提示',
             title:'提示',
             content:'工程中不存在设备',
             content:'工程中不存在设备',
@@ -1814,7 +1812,6 @@ Page({
     var deviceId = that.data.deviceId
     var deviceId = that.data.deviceId
     var deviceKey = that.data.deviceKey
     var deviceKey = that.data.deviceKey
     postData(deviceId,deviceKey,{'ManualStatus':1,'Reflash':3}).then(res => {
     postData(deviceId,deviceKey,{'ManualStatus':1,'Reflash':3}).then(res => {
-      console.log(res.data)
       if(res.data.errno == 0){
       if(res.data.errno == 0){
         that.setData({Modecontrol:'手动'})
         that.setData({Modecontrol:'手动'})
       }
       }
@@ -1888,7 +1885,6 @@ Page({
         }
         }
       }
       }
       else{
       else{
-        console.log('添加分组下标')
         wx.setStorageSync('groupName',that.data.groupName[that.data.groupIndex])
         wx.setStorageSync('groupName',that.data.groupName[that.data.groupIndex])
       }
       }
       //获取设备下拉
       //获取设备下拉
@@ -2146,9 +2142,9 @@ Page({
                   })
                   })
                 }
                 }
               })
               })
-              loopSwitchstate(id,'1,2,3,4,5,6,7,8').then(res=>{
-                if(res.data.code == 0){
-                  var relay = res.data.data
+              loopSwitchstate(id,'1,2,3,4,5,6,7,8').then(ret=>{
+                if(ret.data.code == 0){
+                  var relay = ret.data.data
                   for(let e = 0;e < relay.length;e++){
                   for(let e = 0;e < relay.length;e++){
                     if(relay[e].status == 1){
                     if(relay[e].status == 1){
                       lamp[e] = 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp1.png'
                       lamp[e] = 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp1.png'
@@ -2164,7 +2160,7 @@ Page({
                 else{
                 else{
                   wx.showModal({
                   wx.showModal({
                     title:'错误',
                     title:'错误',
-                    content:res.data.msg,
+                    content:ret.data.msg,
                     showCancel:false
                     showCancel:false
                   })
                   })
                 }
                 }

+ 0 - 4
pages/control/control.wxml

@@ -133,8 +133,4 @@
     <button style="width: 17%;top: 15%;" class="loop-install-3" bindtap="Fullopen">全开</button>
     <button style="width: 17%;top: 15%;" class="loop-install-3" bindtap="Fullopen">全开</button>
     <button style="width: 17%;top: 15%;" class="loop-install-4" bindtap="Allclosed">全关</button>
     <button style="width: 17%;top: 15%;" class="loop-install-4" bindtap="Allclosed">全关</button>
   </view>
   </view>
-  <view class="loop-1" wx:if="{{play == 1 ? true : false}}">
-    <button style="width: 17%;top: 15%;" class="loop-install-3" bindtap="Fullopen">全开</button>
-    <button style="width: 17%;top: 15%;" class="loop-install-4" bindtap="Allclosed">全关</button>
-  </view>
 </view>
 </view>

+ 13 - 23
pages/loop/loop.js

@@ -64,8 +64,13 @@ Page({
     deviceId:'',
     deviceId:'',
     deviceKey:'',
     deviceKey:'',
     num:0,//记录回路数量
     num:0,//记录回路数量
-    play:1,//新老设备的页面切换
-    timeValue:'00:00',
+    play:0,//新老设备的页面切换
+    timeValue:['00:00','00:00'],
+    endTimeValue:['00:00','00:00'],
+    lightstartTime:'00:00',
+    lightendTime:'00:00',
+    weather:['晴天','雨天','阴天','黑夜'],
+    wIndex:0
   },
   },
   //分组下拉
   //分组下拉
   changegroup:function(e){
   changegroup:function(e){
@@ -2928,9 +2933,7 @@ Page({
     wx.getSystemInfo({
     wx.getSystemInfo({
       success:function(res){
       success:function(res){
         if(res.model == 'iPad' || res.model == 'iPad Pro 10.5-inch' || res.model == 'iPad Pro 12.9-inch'){
         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})
         }
         }
       }
       }
     })
     })
@@ -2941,17 +2944,13 @@ Page({
      for(let i = 0;i < group.length;i++){
      for(let i = 0;i < group.length;i++){
        groups.push(group[i].groupName)
        groups.push(group[i].groupName)
      }
      }
-     that.setData({
-       groupName:groups
-     })
+     that.setData({groupName:groups})
     //改变分组下标
     //改变分组下标
     if(wx.getStorageSync('groupName') != ''){
     if(wx.getStorageSync('groupName') != ''){
       let GroupName = that.data.groupName
       let GroupName = that.data.groupName
       for(let n = 0;n < GroupName.length;n++){
       for(let n = 0;n < GroupName.length;n++){
         if(GroupName[n] == wx.getStorageSync('groupName')){
         if(GroupName[n] == wx.getStorageSync('groupName')){
-          that.setData({
-            groupIndex:n
-          })
+          that.setData({groupIndex:n})
         }
         }
       }
       }
     }
     }
@@ -2969,9 +2968,7 @@ Page({
             var DeviceName = that.data.deviceName
             var DeviceName = that.data.deviceName
             for(let m = 0;m < DeviceName.length;m++){
             for(let m = 0;m < DeviceName.length;m++){
               if(DeviceName[m] == wx.getStorageSync('deviceName')){
               if(DeviceName[m] == wx.getStorageSync('deviceName')){
-                that.setData({
-                  deviceIndex:m
-                })
+                that.setData({deviceIndex:m})
               }
               }
             }
             }
            }
            }
@@ -3044,9 +3041,6 @@ Page({
                         weeks = parseInt(weeks)
                         weeks = parseInt(weeks)
                         weeks = weeks.toString(2)
                         weeks = weeks.toString(2)
                         weeks = weeks + ''
                         weeks = weeks + ''
-                        if(weeks != '0'){
-                          weeks = weeks.slice(1)
-                        }
                       }
                       }
                       //功能1
                       //功能1
                       else if(data[i].id == "R1_FunctionStatus1"){
                       else if(data[i].id == "R1_FunctionStatus1"){
@@ -3290,18 +3284,14 @@ Page({
                       for(let x = 0;x < weeks.length; x++){
                       for(let x = 0;x < weeks.length; x++){
                         controladdress[x] = "/image/false.png"
                         controladdress[x] = "/image/false.png"
                       }
                       }
-                      that.setData({
-                        address:controladdress,
-                      })
+                      that.setData({address:controladdress})
                     }
                     }
                     else{
                     else{
                       for(let i = 0;i < weeks.length;i++){
                       for(let i = 0;i < weeks.length;i++){
                         switch (weeks.substring(i,i+1)) {
                         switch (weeks.substring(i,i+1)) {
                           case '0':
                           case '0':
                             controladdress[weeks.length-i-1] = "/image/false.png"
                             controladdress[weeks.length-i-1] = "/image/false.png"
-                            that.setData({
-                              address:controladdress,
-                            })
+                            that.setData({address:controladdress})
                           break;
                           break;
                           case '1':
                           case '1':
                             controladdress[weeks.length-i-1] = "/image/true.png"
                             controladdress[weeks.length-i-1] = "/image/true.png"

+ 35 - 2
pages/loop/loop.wxml

@@ -23,6 +23,7 @@
     </view>
     </view>
   </picker>
   </picker>
 </view>
 </view>
+<!-- 旧设备 -->
 <view class="subject" wx:if="{{play == 0 ? true : false}}">
 <view class="subject" wx:if="{{play == 0 ? true : false}}">
    <!-- 时控一 -->
    <!-- 时控一 -->
   <view class="Time-control">
   <view class="Time-control">
@@ -114,6 +115,7 @@
     </view>
     </view>
   </view>
   </view>
 </view>
 </view>
+<!-- 旧设备刷新存储数据 -->
 <view class="Refresh" wx:if="{{play == 0 ? true : false}}">
 <view class="Refresh" wx:if="{{play == 0 ? true : false}}">
   <button class="Refresh-1" style="width: 28%" bindtap="RefreshPage">刷新页面</button>
   <button class="Refresh-1" style="width: 28%" bindtap="RefreshPage">刷新页面</button>
   <button class="Refresh-2" style="width: 28%" bindtap="Storedata">存储数据</button>
   <button class="Refresh-2" style="width: 28%" bindtap="Storedata">存储数据</button>
@@ -128,17 +130,48 @@
     <switch></switch>
     <switch></switch>
     <text style="left: 40%;">开启时间</text>
     <text style="left: 40%;">开启时间</text>
     <text style="left: 75%;">关闭时间</text>
     <text style="left: 75%;">关闭时间</text>
-    <picker mode="time" start="00:00" end="23:59" value="{{timeValue}}">
-        <view class="startTime">{{timeValue}}</view>
+    <picker mode="time" start="00:00" end="23:59" value="{{timeValue[0]}}">
+        <view class="startTime">{{timeValue[0]}}</view>
+    </picker>
+    <picker mode="time" start="00:00" end="23:59" value="{{endTimeValue[0]}}">
+        <view class="endTime">{{endTimeValue[0]}}</view>
     </picker>
     </picker>
   </view>
   </view>
   <!-- 时控2 -->
   <!-- 时控2 -->
   <view class="newtime2">
   <view class="newtime2">
+    <text style="left: 2%;top: 8%;">时</text>
+    <text style="left: 2%;top: 32%;">控</text>
+    <text style="left: 2%;top: 57%;">二</text>
     <switch></switch>
     <switch></switch>
+    <text style="left: 40%;">开启时间</text>
+    <text style="left: 75%;">关闭时间</text>
+    <picker mode="time" start="00:00" end="23:59" value="{{timeValue[1]}}">
+        <view class="startTime">{{timeValue[1]}}</view>
+    </picker>
+    <picker mode="time" start="00:00" end="23:59" value="{{endTimeValue[1]}}">
+        <view class="endTime">{{endTimeValue[1]}}</view>
+    </picker>
   </view>
   </view>
   <!-- 光控 -->
   <!-- 光控 -->
   <view class="newlight">
   <view class="newlight">
+    <text style="top:2%;letter-spacing:20px">光控</text>
     <switch></switch>
     <switch></switch>
+    <picker mode="time" start="00:00" end="23:59" value="{{lightstartTime}}">
+        <view class="lightstartTime">{{lightstartTime}}</view>
+    </picker>
+    <text style="left: 44%;">至</text>
+    <picker mode="time" start="00:00" end="23:59" value="{{lightendTime}}">
+        <view class="lightendTime">{{lightendTime}}</view>
+    </picker>
+    <picker mode="selector" range="{{weather}}" value="{{wIndex}}" >
+      <view class="weather">{{weather[wIndex]}}</view>
+    </picker>
+    <text style="bottom:7%;letter-spacing:10px">(生效时间)</text>
   </view>
   </view>
 </view>
 </view>
+<!-- 新设备刷新存储数据 -->
+<view class="Refresh" wx:if="{{play == 1 ? true : false}}">
+  <button class="Refresh-1" style="width: 28%">刷新页面</button>
+  <button class="Refresh-2" style="width: 28%">存储数据</button>
+</view>
 
 

+ 75 - 4
pages/loop/loop.wxss

@@ -247,14 +247,29 @@ page{
 .startTime{
 .startTime{
   position: absolute;
   position: absolute;
   left: 40%;
   left: 40%;
-  top: 40%;
-  background-color: blue;
+  top: 35%;
+  background-color: rgb(33, 111, 156);
   width: 20%;
   width: 20%;
   height: 30%;
   height: 30%;
   border-radius: 10px;
   border-radius: 10px;
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;
   justify-content: center;
   justify-content: center;
+  font-size: calc(100vw * 16/375);
+}
+
+.endTime{
+  position: absolute;
+  left: 74%;
+  top: 35%;
+  background-color: rgb(33, 111, 156);
+  width: 20%;
+  height: 30%;
+  border-radius: 10px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  font-size: calc(100vw * 16/375);
 }
 }
 
 
 .newtime1 text{
 .newtime1 text{
@@ -274,22 +289,78 @@ page{
   position: relative;
   position: relative;
 }
 }
 
 
+.newtime2 text{
+  font-size: calc(100vw * 18/375);
+  font-weight: 550;
+  position: absolute;
+  top: 2%;
+}
+
 .newtime2 switch{
 .newtime2 switch{
   position: absolute;
   position: absolute;
-  left: 2%;
+  left: 12%;
 }
 }
 /* 新设备光控 */
 /* 新设备光控 */
 .newlight{
 .newlight{
   background-color: cornflowerblue;
   background-color: cornflowerblue;
   width: 100%;
   width: 100%;
-  height: 25%;
+  height: 30%;
   margin-top: 1%;
   margin-top: 1%;
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;
+  justify-content: center;
   position: relative;
   position: relative;
 }
 }
 
 
 .newlight switch{
 .newlight switch{
   position: absolute;
   position: absolute;
   left: 2%;
   left: 2%;
+}
+
+.newlight text{
+  font-size: calc(100vw * 18/375);
+  font-weight: 550;
+  position: absolute;
+}
+
+.lightstartTime{
+  position: absolute;
+  left: 22%;
+  top:35%;
+  background-color: rgb(33, 111, 156);
+  width: 20%;
+  height: 30%;
+  border-radius: 10px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  font-size: calc(100vw * 16/375);
+}
+
+.lightendTime{
+  position: absolute;
+  left: 52%;
+  top:35%;
+  background-color: rgb(33, 111, 156);
+  width: 20%;
+  height: 30%;
+  border-radius: 10px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  font-size: calc(100vw * 16/375);
+}
+
+.weather{
+  position: absolute;
+  left: 78%;
+  top:35%;
+  background-color: rgb(33, 111, 156);
+  width: 20%;
+  height: 30%;
+  border-radius: 10px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  font-size: calc(100vw * 16/375);
 }
 }

+ 78 - 67
pages/scene/scene.js

@@ -33,75 +33,84 @@ Page({
       duration: 2000
       duration: 2000
     })
     })
     var that = this
     var that = this
-    let token = wx.getStorageSync('token')
-    wx.request({
-      url: 'https://cloud.long-chi.com/api/minigrogram/lightcontrol/groups',
-      method:'GET',
-      header:{'Content-Type': 'application/json',
-      'Authorization': token},
-      success:res =>{
-        console.log('刷新成功' + res.data.msg)
-        if(res.data.code == 200){
-          var data = res.data.data
-          if(data != null){
-            for(let i = 0;i <data.length;i++){
-              if(data[i].devices != null){
-                for(let j = 0;j < data[i].devices.length;j++){
+    getGroup().then(res => {
+      console.log(wx.getStorageSync('token'))
+      if(res.data.code == 0){
+        var data = res.data.data
+        console.log(data)
+        if(data != null){
+          for(let i = 0;i <data.length;i++){
+            if(data[i].devices != null){
+              for(let j = 0;j < data[i].devices.length;j++){
+                if(data[i].devices[j].module == 0){
                   let id = data[i].devices[j].deviceId
                   let id = data[i].devices[j].deviceId
                   let key = data[i].devices[j].deviceKey
                   let key = data[i].devices[j].deviceKey
-                  console.log('id为' + id)
-                  console.log('key为' + key)
-                  wx.request({
-                    url: 'https://api.heclouds.com/devices/' + id,
-                    method:'GET',
-                    header:{"api-key": key},
-                    success:(res) =>{
-                      console.log(res.data.data.online)
-                      if (res.data.data.online == true) {
+                  getBasic(id,key).then(ever =>{
+                    if(ever.data.errno == 0){
+                      if(ever.data.data.online == true){
                         data[i].devices[j].status = '在线'
                         data[i].devices[j].status = '在线'
                       }
                       }
                       else{
                       else{
                         data[i].devices[j].status = '离线'
                         data[i].devices[j].status = '离线'
                       }
                       }
                       wx.setStorageSync('group',data)
                       wx.setStorageSync('group',data)
-                      var group = wx.getStorageSync('group')
-                      for(let i = 0;i < group.length;i++){
-                        if(group[i].groupName.length > 10){
-                          group[i].groupName = group[i].groupName.slice(0,9) + '....'
+                      let tgroups = wx.getStorageSync('group')
+                      for(let i = 0;i < tgroups.length;i++){
+                        if(tgroups[i].groupName.length > 10){
+                          tgroups[i].groupName = tgroups[i].groupName.slice(0,9) + '....'
                         }
                         }
                       }
                       }
-                      that.setData({
-                        array:group,
+                      that.setData({array:tgroups})
+                    }
+                    else{
+                      wx.showModal({
+                        title:'错误',
+                        content:ever.data.error,
+                        showCancel:false
                       })
                       })
                     }
                     }
                   })
                   })
                 }
                 }
-              }
-              else {
-                wx.setStorageSync('group',data)
-                var group = wx.getStorageSync('group')
-                for(let i = 0;i < group.length;i++){
-                  if(group[i].groupName.length > 10){
-                    group[i].groupName = group[i].groupName.slice(0,9) + '....'
+                else{
+                  let status = data[i].devices[j].status
+                  switch(status){
+                    case 0:
+                      data[i].devices[j].status = '离线'
+                    break;
+                    case 1:
+                      data[i].devices[j].status = '在线'
+                    break
                   }
                   }
+                  wx.setStorageSync('group',data)
+                  let tgroups = wx.getStorageSync('group')
+                  for(let i = 0;i < tgroups.length;i++){
+                    if(tgroups[i].groupName.length > 10){
+                      tgroups[i].groupName = tgroups[i].groupName.slice(0,9) + '....'
+                    }
+                  }
+                  that.setData({array:tgroups})
+                }
+              }
+            }
+            else{
+              wx.setStorageSync('group',data)
+              let group = wx.getStorageSync('group')
+              for(let i = 0;i < group.length;i++){
+                if(group[i].groupName.length > 10){
+                  group[i].groupName = group[i].groupName.slice(0,9) + '....'
                 }
                 }
-                that.setData({
-                  array:group,
-                })
               }
               }
+              that.setData({array:group})
             }
             }
           }
           }
         }
         }
-        else{
-          wx.showModal({
-            title:'提示',
-            content:res.data.msg,
-            showCancel:false
-          })
-        }
-      },
-      fail:(bug) =>{
-        console.log(bug)
+      }
+      else{
+        wx.showModal({
+          title:'错误',
+          content:res.data.msg,
+          showCancel:false
+        })
       }
       }
     })
     })
   },
   },
@@ -130,7 +139,6 @@ Page({
             })
             })
           }
           }
           else{
           else{
-            console.log('添加分组')
             postGroup({groupName:ever.content}).then((res)=>{
             postGroup({groupName:ever.content}).then((res)=>{
               if(res.data.code == 0){
               if(res.data.code == 0){
                 if(wx.getStorageSync('group') == ''){
                 if(wx.getStorageSync('group') == ''){
@@ -208,7 +216,6 @@ Page({
   //修改分组名称
   //修改分组名称
   ShowChanges:function(e){
   ShowChanges:function(e){
     var that = this
     var that = this
-    console.log('缓存的分组名称为' + wx.getStorageSync('groupName'))
     wx.showModal({
     wx.showModal({
       title:'修改工程名称',
       title:'修改工程名称',
       editable:true,
       editable:true,
@@ -234,7 +241,6 @@ Page({
           }
           }
           else{
           else{
             putGroup({id:Idindex,groupName:res.content}).then(ever=>{
             putGroup({id:Idindex,groupName:res.content}).then(ever=>{
-              console.log(ever)
               if (ever.data.code == 0) {
               if (ever.data.code == 0) {
                 if(groupName == wx.getStorageSync('groupName')){
                 if(groupName == wx.getStorageSync('groupName')){
                   wx.setStorageSync('groupName',res.content)
                   wx.setStorageSync('groupName',res.content)
@@ -282,7 +288,6 @@ Page({
             if(add.data.code == 0){
             if(add.data.code == 0){
               //查询设备
               //查询设备
               getDevice(add.data.data.id,Idindex).then(get =>{
               getDevice(add.data.data.id,Idindex).then(get =>{
-                console.log(get.data.data)
                 var Get = get.data.data
                 var Get = get.data.data
                 switch(Get[0].status){
                 switch(Get[0].status){
                   case 0:
                   case 0:
@@ -405,7 +410,6 @@ Page({
   //修改设备名称
   //修改设备名称
   modifyequipmentname:function(e){
   modifyequipmentname:function(e){
     var that = this
     var that = this
-    console.log('缓存的设备名称为' + wx.getStorageSync('deviceName'))
     var key = e.currentTarget.dataset.indexdel
     var key = e.currentTarget.dataset.indexdel
     var group = wx.getStorageSync('group')
     var group = wx.getStorageSync('group')
     var deviceId = group[key[0]].devices[key[1]].id
     var deviceId = group[key[0]].devices[key[1]].id
@@ -434,7 +438,6 @@ Page({
           }
           }
           else{
           else{
             putDevice({deviceName:res.content,id:deviceId,groupId:groupId}).then(ever=>{
             putDevice({deviceName:res.content,id:deviceId,groupId:groupId}).then(ever=>{
-              console.log('修改设备名称' + ever.data.msg)
               if(ever.data.code == 0){
               if(ever.data.code == 0){
                 if(groupName == wx.getStorageSync('groupName') && deviceName == wx.getStorageSync('deviceName')){
                 if(groupName == wx.getStorageSync('groupName') && deviceName == wx.getStorageSync('deviceName')){
                   wx.setStorageSync('deviceName',res.content)
                   wx.setStorageSync('deviceName',res.content)
@@ -534,7 +537,6 @@ Page({
     getGroup().then(res => {
     getGroup().then(res => {
       if(res.data.code == 0){
       if(res.data.code == 0){
         var data = res.data.data
         var data = res.data.data
-        console.log(data)
         if(data != null){
         if(data != null){
           for(let i = 0;i <data.length;i++){
           for(let i = 0;i <data.length;i++){
             if(data[i].devices != null){
             if(data[i].devices != null){
@@ -543,20 +545,29 @@ Page({
                   let id = data[i].devices[j].deviceId
                   let id = data[i].devices[j].deviceId
                   let key = data[i].devices[j].deviceKey
                   let key = data[i].devices[j].deviceKey
                   getBasic(id,key).then(ever =>{
                   getBasic(id,key).then(ever =>{
-                    if(ever.data.data.online == true){
-                      data[i].devices[j].status = '在线'
+                    if(ever.data.errno == 0){
+                      if(ever.data.data.online == true){
+                        data[i].devices[j].status = '在线'
+                      }
+                      else{
+                        data[i].devices[j].status = '离线'
+                      }
+                      wx.setStorageSync('group',data)
+                      let tgroups = wx.getStorageSync('group')
+                      for(let i = 0;i < tgroups.length;i++){
+                        if(tgroups[i].groupName.length > 10){
+                          tgroups[i].groupName = tgroups[i].groupName.slice(0,9) + '....'
+                        }
+                      }
+                      that.setData({array:tgroups})
                     }
                     }
                     else{
                     else{
-                      data[i].devices[j].status = '离线'
-                    }
-                    wx.setStorageSync('group',data)
-                    let tgroups = wx.getStorageSync('group')
-                    for(let i = 0;i < tgroups.length;i++){
-                      if(tgroups[i].groupName.length > 10){
-                        tgroups[i].groupName = tgroups[i].groupName.slice(0,9) + '....'
-                      }
+                      wx.showModal({
+                        title:'错误',
+                        content:ever.data.error,
+                        showCancel:false
+                      })
                     }
                     }
-                    that.setData({array:tgroups})
                   })
                   })
                 }
                 }
                 else{
                 else{

+ 2 - 1
pages/sign/sign.js

@@ -29,8 +29,9 @@ Page({
           data:{code:e.code},
           data:{code:e.code},
           header:{"Content-Type": "application/json"},
           header:{"Content-Type": "application/json"},
           success:function(res){
           success:function(res){
-            if(res.data.code == 200){
+            if(res.data.code == 0){
               let time = new Date()
               let time = new Date()
+              console.log(res.data.data.access_token)
               wx.setStorageSync('time',time) //登录时间
               wx.setStorageSync('time',time) //登录时间
               wx.setStorageSync('currentTime', res.data.data.expires_in)//过期时间
               wx.setStorageSync('currentTime', res.data.data.expires_in)//过期时间
               wx.setStorageSync('token', res.data.data.access_token)
               wx.setStorageSync('token', res.data.data.access_token)

+ 1 - 1
project.private.config.json

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

+ 0 - 0
utils/loop.js