xzw 4 years ago
parent
commit
55944175d3
2 changed files with 27 additions and 4 deletions
  1. 24 2
      js/main_2020_show.js
  2. 3 2
      js/showHardware.js

+ 24 - 2
js/main_2020_show.js

@@ -24,9 +24,9 @@ $("#hotPannel .close").on('click',()=>{
      
 })
 
-$("#hotPannel input.mui-switch").on('change',()=>{
+$("#hotPannel input.mui-switch").on('change',(e)=>{
     var ifOn = $('#hotPannel input.mui-switch').is(':checked');
-    window.changeDeviceStatus(window.hotNeedUpdatePannel)
+    window.changeDeviceStatus(window.hotNeedUpdatePannel, ifOn)
 })
 
 hardwareTypes = null
@@ -15613,6 +15613,28 @@ window.Modernizr = function(n, e, t) {
                 });
 
                
+               $.ajax({//获取设备状态
+                  method: "GET",
+                  headers: {
+                    "Content-Type": "application/json",
+                  },
+                  dataType: "json",
+                  contentType: "application/json",
+                  url: `/api/device/getParam/${hardware.id}/${hardware.code}`, 
+                  success: (data)=> {
+                        console.log(data)  
+                        if (data.code === 0) {
+                            var info = data.data.find(device=>device.id==hardware.id)
+                        }
+                    }
+                })
+               
+               
+               
+               
+               
+               
+               
                 return true 
                 
             }else{

+ 3 - 2
js/showHardware.js

@@ -104,8 +104,9 @@ $(function () {
     });
   };
 
-  window.changeDeviceStatus = function (item) {
+  window.changeDeviceStatus = function (item, on) {
     console.log(item);
+    var paramValue = on?1:0
     let tmp = item.infoAttribute.hardware
     $.ajax({
       method: "GET",
@@ -114,7 +115,7 @@ $(function () {
       },
       dataType: "json",
       contentType: "application/json",
-      url: url + `/api/device/control/${tmp.id}/${tmp.deviceCode}/${paramValue}/03`,
+      url: url + `/api/device/control/${tmp.id}/${tmp.code}/${paramValue}/03`,
       success: function (data) {
         if (data.code === 0) {
           resolve({