Kaynağa Gözat

添加2路86开关扫码的

sixian 1 yıl önce
ebeveyn
işleme
eff726633b
3 değiştirilmiş dosya ile 53 ekleme ve 8 silme
  1. 50 5
      pages/scene/scene.js
  2. 2 2
      pages/scene/scene.wxss
  3. 1 1
      project.private.config.json

+ 50 - 5
pages/scene/scene.js

@@ -143,7 +143,7 @@ Page({
                   var a = wx.getStorageSync('group')
                   a.push({id:res.data.data.id,groupName:ever.content,devices:[]})
                   wx.setStorageSync('group', a)
-                } 
+                }
                 else{
                   var b = wx.getStorageSync('group')
                   b.push({id:res.data.data.id,groupName:ever.content,devices:[]})
@@ -165,7 +165,7 @@ Page({
                 })
               }
             })
-          }    
+          }
         }
       }
     })
@@ -196,7 +196,7 @@ Page({
                   Group[i].groupName = Group[i].groupName.slice(0,9) + '....'
                   }
               }
-              that.setData({array: Group}) 
+              that.setData({array: Group})
             }
             else{
               wx.showModal({
@@ -320,6 +320,51 @@ Page({
             }
           })
         }
+        //dsx添加的设备
+        else if( res.result.substring(0,2) == 86 ){
+          let ID = res.result
+          let SN = res.result
+          //添加设备
+          postDevice({groupId:Idindex,deviceSn:SN,deviceId:ID,module:1,deviceName:SN}).then(add =>{
+            if(add.data.code == 0){
+              //查询设备
+              getDevice(add.data.data.id,Idindex).then(get =>{
+                var Get = get.data.data
+                console.log(Get)
+                switch(Get.status){
+                  case 0:
+                    Get.status = '离线'
+                  break
+                  case 1:
+                    Get.status = '在线'
+                  break
+                }
+                if(group[index].devices != null){
+                  group[index].devices.push(Get)
+                }
+                else{
+                  group[index].devices = []
+                  group[index].devices.push(Get)
+                }
+                wx.setStorageSync('group', group)
+                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) + '....'
+                  }
+                }
+                that.setData({array: Group})
+              })
+            }
+            else{
+              wx.showModal({
+                title:'提示',
+                content:add.data.msg,
+                showCancel:false
+              })
+            }
+          })
+        }
         else{
           var arr = res.result.split(' ');
           var a = arr[0]//设备id
@@ -419,7 +464,7 @@ Page({
                 showCancel:false
               })
             }
-          })  
+          })
         }
       }
     })
@@ -677,4 +722,4 @@ Page({
   onShareAppMessage() {
 
   }
-})
+})

+ 2 - 2
pages/scene/scene.wxss

@@ -25,7 +25,7 @@ page{
   position: absolute;
   display: flex;
   align-items:center;
-  justify-content:center; 
+  justify-content:center;
   left: 40%;
   top: 15%;
   background-color: cornflowerblue;
@@ -116,7 +116,7 @@ page{
 
 .develops-2{
   position: absolute;
-  left: 28%;
+  left: 50%;
   top: 20%;
   font-size: calc(100vw * 14/375);
 }

+ 1 - 1
project.private.config.json

@@ -1,7 +1,7 @@
 {
   "projectname": "weixin",
   "setting": {
-    "compileHotReLoad": false,
+    "compileHotReLoad": true,
     "bigPackageSizeSupport": true,
     "urlCheck": true
   },