|
@@ -1,5 +1,5 @@
|
|
|
const {postData} = require('../api/intell')
|
|
|
-const {putDevice} = require('../api/device')
|
|
|
+const {putDevice,loopSwitch,loopSwitchstate} = require('../api/device')
|
|
|
function getlooplist(){
|
|
|
var group = wx.getStorageSync('group')
|
|
|
//获取分组下拉
|
|
@@ -47,7 +47,7 @@ function getlooplist(){
|
|
|
|
|
|
return [groups,groupsIndex,device,deviceIndex,loopnum,deviceId,deviceKey]
|
|
|
}
|
|
|
-//回路开/关
|
|
|
+//回路开/关(旧设备)
|
|
|
function Switch(deviceId,deviceKey,Rel){
|
|
|
postData(deviceId,deviceKey,Rel).then(res => {
|
|
|
if(res.data.errno == 10){
|
|
@@ -59,7 +59,7 @@ function Switch(deviceId,deviceKey,Rel){
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-//回路开/关读取
|
|
|
+//回路开/关读取(旧设备)
|
|
|
function switchReal(police,lamp,index){
|
|
|
switch(police.length){
|
|
|
case 1:
|
|
@@ -83,7 +83,43 @@ function switchReal(police,lamp,index){
|
|
|
}
|
|
|
return lamp
|
|
|
}
|
|
|
+//回路开/关(新设备)
|
|
|
+function newSwitch(swit){
|
|
|
+ loopSwitch(swit).then(res =>{
|
|
|
+ if(res.data.code != 0){
|
|
|
+ wx.showModal({
|
|
|
+ title:'错误',
|
|
|
+ content:res.data.msg,
|
|
|
+ showCancel:false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
+//回路开/关读取(新设备)
|
|
|
+function newswitchReal(Device,relayid){
|
|
|
+ loopSwitchstate(Device,relayid).then(res=>{
|
|
|
+ if(res.data.code == 0){
|
|
|
+ var relay = res.data.data
|
|
|
+ if(relay[0].status == 1){
|
|
|
+ let ever = 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp1.png'
|
|
|
+ console.log(ever)
|
|
|
+ return ever
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ let ever = 'https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png'
|
|
|
+ return ever
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ wx.showModal({
|
|
|
+ title:'错误',
|
|
|
+ content:res.data.msg,
|
|
|
+ showCancel:false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
//回路名称调整(未解决)
|
|
|
function loopname(deviceid,groupid,loop,loops,slice,groupName,deviceName,group,content){
|
|
|
if(content == ''){
|
|
@@ -177,9 +213,33 @@ function droplist(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//刷新主页界面的显示
|
|
|
+function Refresh(){
|
|
|
+ //重置状态
|
|
|
+ let loopName = []//回路名称
|
|
|
+ let loopIcon = []//回路图标
|
|
|
+ let switchState = []//开关状态
|
|
|
+ let size = []//字体大小
|
|
|
+ let fontColor = []//字体颜色
|
|
|
+ for(let p = 0;p < 12;p++){
|
|
|
+ loopName.push('回路' + (p+1))
|
|
|
+ loopIcon.push('')
|
|
|
+ switchState.push('https://cloud.long-chi.com/resource/miniprogram-lightcontrol/image/lamp.png')
|
|
|
+ size.push('calc(100vw * 16/375)')
|
|
|
+ fontColor.push('#d5dbdf')
|
|
|
+ }
|
|
|
+ let combination = [loopName,loopIcon,switchState,size,fontColor]
|
|
|
+ return combination
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
module.exports = {
|
|
|
getlooplist:getlooplist,
|
|
|
Switch:Switch,
|
|
|
switchReal:switchReal,
|
|
|
loopname:loopname,
|
|
|
+ Refresh:Refresh,
|
|
|
+ newSwitch:newSwitch,
|
|
|
+ newswitchReal:newswitchReal
|
|
|
}
|