xzw 4 years ago
parent
commit
56ce31af27
2 changed files with 193 additions and 96 deletions
  1. 191 94
      js/main_2020_show.js
  2. 2 2
      js/showHardware.js

+ 191 - 94
js/main_2020_show.js

@@ -60,13 +60,14 @@ deviceBtnBind($('#hotPannel .ac-con  .air-con [name="onoff"] .ac-btn').eq(0),  '
 deviceBtnBind($('#hotPannel .ac-con  .air-con [name="onoff"] .ac-btn').eq(1),  '07', '0')//fanState
 deviceBtnBind($('#hotPannel .ac-con  .air-con [name="onoff"] .ac-btn').eq(1),  '07', '0')//fanState
 
 
 
 
-var getAjax = function(url, success, errorString){
+var getAjax = function(url, data, success, errorString){
     $(".waiting").addClass('showloading')
     $(".waiting").addClass('showloading')
     $.ajax({//获取设备状态
     $.ajax({//获取设备状态
       method: "GET",
       method: "GET",
       headers: {
       headers: {
         "Content-Type": "application/json",
         "Content-Type": "application/json",
       },
       },
+      data : data,  
       dataType: "json",
       dataType: "json",
       contentType: "application/json",
       contentType: "application/json",
       url: url,
       url: url,
@@ -81,7 +82,7 @@ var getAjax = function(url, success, errorString){
     })
     })
 }
 }
 
 
-getAjax(g_Prefix+`/api/device/getType`, (data)=>{
+getAjax(g_Prefix+`/api/device/getType`, null, (data)=>{
     if (data.code === 0) { 
     if (data.code === 0) { 
         hardwareTypes = data.data 
         hardwareTypes = data.data 
     } else {
     } else {
@@ -94,7 +95,7 @@ window.getDeviceInfo = function(deviceId, callback){
     var userId = '77547f7af360c5d8e14932866b844d53' 
     var userId = '77547f7af360c5d8e14932866b844d53' 
     var url = `/api/device/list/${userId}` + (deviceId ? `?deviceId=${deviceId}` : '')
     var url = `/api/device/list/${userId}` + (deviceId ? `?deviceId=${deviceId}` : '')
     
     
-    getAjax(url, (data)=>{
+    getAjax(url, null, (data)=>{
         if(data.code == 0){
         if(data.code == 0){
             callback(data.data)
             callback(data.data)
         }
         }
@@ -15667,48 +15668,44 @@ window.Modernizr = function(n, e, t) {
             this.deviceStatus = status
             this.deviceStatus = status
         }
         }
         
         
-        hot.prototype.showPannel = function(o={}){
+        hot.prototype.showPannel = function(o={}) {
             var hardware = this.infoAttribute.hardware
             var hardware = this.infoAttribute.hardware
-            
-            if(hardware && hardware.id!=void 0){ 
+
+            if (hardware && hardware.id != void 0) {
                 //获取设备状态
                 //获取设备状态
                 $(".waiting").addClass('showloading')
                 $(".waiting").addClass('showloading')
                 getDeviceInfo(hardware.id, (data)=>{
                 getDeviceInfo(hardware.id, (data)=>{
                     this.setDeviceStatus(data[0].status == 2)
                     this.setDeviceStatus(data[0].status == 2)
-                    
-                    if(this.deviceStatus){//在线
-                    
-                        getAjax(`/api/device/getStatus/${hardware.code}`,  (data)=> {
-                            console.log(data)  
+
+                    if (this.deviceStatus) {
+                        //在线
+
+                        getAjax(`/api/device/getStatus/${hardware.code}`, null, (data)=>{
+                            console.log(data)
                             if (data.code === 0) {
                             if (data.code === 0) {
                                 data = data.data;
                                 data = data.data;
                                 var devType = hardwareTypes.find(type=>type.id == hardware.devTypeId).name
                                 var devType = hardwareTypes.find(type=>type.id == hardware.devTypeId).name
                                 $("#hotPannel>div").addClass("hide")
                                 $("#hotPannel>div").addClass("hide")
-                                
-                                
-                                if(devType == "灯控"){
+
+                                if (devType == "灯控") {
                                     $("#hotPannel>div[name='light']").removeClass("hide")
                                     $("#hotPannel>div[name='light']").removeClass("hide")
-                                    
+
                                     var ifOn = data.find(e=>e.paramCode == '02').paramValue == '1'
                                     var ifOn = data.find(e=>e.paramCode == '02').paramValue == '1'
                                     $("#hotPannel>div[name='light']  input").prop('checked', ifOn);
                                     $("#hotPannel>div[name='light']  input").prop('checked', ifOn);
-                                      
-                                      
-                                      
-                                }else if(devType == "温湿度"){
+
+                                } else if (devType == "温湿度") {
                                     $("#hotPannel>#temperature").removeClass("hide")
                                     $("#hotPannel>#temperature").removeClass("hide")
                                     this.temperature = parseInt(temperature)
                                     this.temperature = parseInt(temperature)
-                                    
+
                                     loadTemperature({
                                     loadTemperature({
-                                        id:"temperature",//dom Id
-                                        val:70 //度数    
+                                        id: "temperature",
+                                        //dom Id
+                                        val: 70//度数    
                                     })
                                     })
-                                    
-                                    
-                                    
-                                }else if(devType == "摄像头"){
-                                    $("#hotPannel>.m-con").removeClass("hide") 
-                                    
-                                    
+
+                                } else if (devType == "摄像头") {
+                                    $("#hotPannel>.m-con").removeClass("hide")
+
                                     /* "result": [
                                     /* "result": [
                                         {
                                         {
                                           "id": "97347887d0dbad459bca30118fe9fae2",
                                           "id": "97347887d0dbad459bca30118fe9fae2",
@@ -15775,9 +15772,7 @@ window.Modernizr = function(n, e, t) {
                                         
                                         
                                         
                                         
                                         */
                                         */
-                                    
-                                    
-                                    
+
                                     /* "code": 0,
                                     /* "code": 0,
                                       "data": {
                                       "data": {
                                         "external": {
                                         "external": {
@@ -15798,93 +15793,195 @@ window.Modernizr = function(n, e, t) {
                                         }
                                         }
                                       },
                                       },
                                       "msg": "操作成功" */
                                       "msg": "操作成功" */
-                                     getAjax(`/api/device/getLive/${hardware.code}`, (data2)=> {
-                                          if(data2.code == 0){
+                                    getAjax(`/api/device/getLive/${hardware.code}`, null, (data2)=>{
+                                        if (data2.code == 0) {
                                             loadMonitor({
                                             loadMonitor({
-                                                id:"monitor",
-                                                url:  data2.data.external.hls    //'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8'
-                                            }) 
-                                          }
-                                     },"获取视频地址失败" )
-                                      
-                                      
-                                    
-                                    
-                                    
-                                    
-                                    
-                                }else if(devType == "空调"){
-                                    $("#hotPannel>.ac-con").removeClass("hide")
+                                                id: "monitor",
+                                                url: data2.data.external.hls //'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8'
+                                            })
+                                        }
+                                    }
+                                    , "获取视频地址失败")
+
+                                    var getCalendar = function(year,month) {//回放
+                                       
+                                        if (month.toString().length == 1) {
+                                            month = "0" + month;
+                                        }
+                                        
+                                        
+                                        getAjax(`/api/device/camera/queryVideoList`, 
+                                            {
+                                                "channelId": hardware.code,
+                                                "time": year + '-' + month, //"2012-01" 
+                                                "type": "month"
+                                            } ,
+                                            (data2)=>{
+                                                if (data2.code == 0) { // [{date: "1", status: "2"}, {date: "2", status: "2"},
+                                                    data2.result
+                                                    
+                                                    var hasMonitorDays = data2.result.filter(e=>e.status == '1');
+                                                    hasMonitorDays = hasMonitorDays.map(e=>{return {startDate:year + month + e.date, id:e.date}})//有监控的日期 
+                                                    
+                                                    loadCalendar({
+                                                        data: hasMonitorDays,
+                                                        /* [{
+                                                            'startDate': "2021-5-18",//有监控的日期 
+                                                            id: '传对应的id'
+                                                        }], */ 
+                                                        cellCb: (item)=>{//点击日期时间
+                                                            console.log(item);
+                                                            if (1) {
+                                                                
+                                                                
+                                                                getAjax(`/api/device/camera/queryVideoList`, 
+                                                                    {
+                                                                        "channelId": hardware.code,
+                                                                        "time": year + '-' + month + day, //"2012-01" 
+                                                                        "type": "day"
+                                                                    }, 
+                                                                    (data3)=>{
+                                                                        if(data3.code == 0){
+                                                                            /* address: null
+                                                                            creationTime: null
+                                                                            deviceId: null
+                                                                            endTime: "2021-05-13 12:00:01"
+                                                                            filePath: null
+                                                                            fileSize: null
+                                                                            id: null
+                                                                            name: null
+                                                                            secrecy: null
+                                                                            startTime: "2021-05-13 11:00:08"
+                                                                            sumNum: null
+                                                                            type: null */
+                                                                            var timeList = data3.result;
+                                                                            
+                                                                            
+                                                                            /* channelId: "34020000001320010059"
+                                                                            endTime: "2021-05-13 13:00:01"
+                                                                            startTime: "2021-05-13 12:00:01" */
+                                                                            
+                                                                            getAjax(`/api/device/camera/playBack`, (data4)=>{
+                                                                                if (data4.code == 0) {
+                                                                                    loadMonitor({
+                                                                                        id: "monitor",
+                                                                                        url: data4.result.external.hls //'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8'
+                                                                                    })
+                                                                                }
+                                                                                
+                                                                            }, "获取视频地址失败")
+                                                                        }
+                                                                            
+                                                                            
+                                                                            
+                                                                    
+                                                                    }, '获取视频日历day失败'
+                                                                )
+                                                                
+                                                                 
+                                                            }
+                                                        }
+                                                        ,
+                                                        monthCb: (item)=>{
+                                                            console.log(item);
+                                                            getCalendar(item)
+
+                                                        }
+                                                      
+                                                    })
+                                            }
+                                        }
+                                        , "获取视频日历month失败")
+                                    }
+                                    var date = new Date(); 
+                                    getCalendar(date.getFullYear(), date.getMonth())
+
+
+
 
 
 
 
-                                 /* 摆叶位置	06	可读写	下拉框			{"1":"上","2":"下","3":"左","4":"右"}	-	编辑删除
+
+
+
+
+
+
+
+                                } else if (devType == "空调") {
+                                    $("#hotPannel>.ac-con").removeClass("hide")
+
+                                    /* 摆叶位置	06	可读写	下拉框			{"1":"上","2":"下","3":"左","4":"右"}	-	编辑删除
                                 3	温度	05	可读写	文本框				-	编辑删除
                                 3	温度	05	可读写	文本框				-	编辑删除
                                 4	开关机	02	可读写	下拉框			{"0":"关","1":"开"}	-	编辑删除
                                 4	开关机	02	可读写	下拉框			{"0":"关","1":"开"}	-	编辑删除
                                 5	风速	04	可读写	下拉框			{"1":"低风","2":"中风","3":"高风"}	-	编辑删除
                                 5	风速	04	可读写	下拉框			{"1":"低风","2":"中风","3":"高风"}	-	编辑删除
                                 6	摆叶状态	07	可读写	下拉框			{"0":"关","1":"开"}	-	编辑删除
                                 6	摆叶状态	07	可读写	下拉框			{"0":"关","1":"开"}	-	编辑删除
                                 7	模式	03	可读写	下拉框			{"0":"自动","1":"除湿","2":"冷风","3":"送风","4":"暖风"}	-	
                                 7	模式	03	可读写	下拉框			{"0":"自动","1":"除湿","2":"冷风","3":"送风","4":"暖风"}	-	
                                     */
                                     */
-                                    
-                                    
-                                    var ifOn = data.find(e=>e.paramCode == '02').paramValue == '1' 
-                                    var mode = data.find(e=>e.paramCode == '03').paramValue 
+
+                                    var ifOn = data.find(e=>e.paramCode == '02').paramValue == '1'
+                                    var mode = data.find(e=>e.paramCode == '03').paramValue
                                     var windSpeed = data.find(e=>e.paramCode == '04').paramValue
                                     var windSpeed = data.find(e=>e.paramCode == '04').paramValue
                                     var temperature = data.find(e=>e.paramCode == '05').paramValue
                                     var temperature = data.find(e=>e.paramCode == '05').paramValue
                                     var fanPos = data.find(e=>e.paramCode == '06').paramValue
                                     var fanPos = data.find(e=>e.paramCode == '06').paramValue
-                                    var fanState = data.find(e=>e.paramCode == '07').paramValue == '1' 
+                                    var fanState = data.find(e=>e.paramCode == '07').paramValue == '1'
                                     this.temperature = parseInt(temperature)
                                     this.temperature = parseInt(temperature)
-                                    
-                                    
-                                    loadAirConditioner({ 
-                                        id:"air-conditioner",
-                                        name : hardware.name,
-                                        val:parseInt(temperature),
-                                        min:16,
-                                        max:30,
-                                        type: mode == 0 ? '自动': mode == 1 ? '除湿': mode == 2 ? '冷风': mode == 3 ? '送风' : '暖风',//模式
-                                        ifOn,//开关机
-                                        windSpeed : windSpeed == 1 ? "低风" : windSpeed == 2 ? "中风" :  "高风",//风速
-                                        fanPos : fanPos == 1 ? "上" : fanPos == 2 ? "下" : fanPos == 3  ? "左" : "右",//摆叶位置
-                                        fanState,//摆叶状态,
-                                        
-                                    }) 
+
+                                    loadAirConditioner({
+                                        id: "air-conditioner",
+                                        name: hardware.name,
+                                        val: parseInt(temperature),
+                                        min: 16,
+                                        max: 30,
+                                        type: mode == 0 ? '自动' : mode == 1 ? '除湿' : mode == 2 ? '冷风' : mode == 3 ? '送风' : '暖风',
+                                        //模式
+                                        ifOn,
+                                        //开关机
+                                        windSpeed: windSpeed == 1 ? "低风" : windSpeed == 2 ? "中风" : "高风",
+                                        //风速
+                                        fanPos: fanPos == 1 ? "上" : fanPos == 2 ? "下" : fanPos == 3 ? "左" : "右",
+                                        //摆叶位置
+                                        fanState,
+                                        //摆叶状态,
+
+                                    })
                                 }
                                 }
-                                
-                                
-                                
-                                
-                                $("#hotPannel>div").css("display","block");
-                                $("#hotPannel .title").text(hardware.name); 
+
+                                $("#hotPannel>div").css("display", "block");
+                                $("#hotPannel .title").text(hardware.name);
                                 this.updatePannel()
                                 this.updatePannel()
                                 window.hotNeedUpdatePannel = this
                                 window.hotNeedUpdatePannel = this
-                                
-                                if(o.focus){
-                                    if(player.mode == 'panorama'){
+
+                                if (o.focus) {
+                                    if (player.mode == 'panorama') {
                                         this.examine(player)
                                         this.examine(player)
-                                    }else if(player.mode != 'transitioning'){
-                                        player.focusPoint({/* modelSize: size,  */aim: this.mesh.position})
-                                    } 
-                                } 
+                                    } else if (player.mode != 'transitioning') {
+                                        player.focusPoint({
+                                            /* modelSize: size,  */
+                                            aim: this.mesh.position
+                                        })
+                                    }
+                                }
                             } else {
                             } else {
-                                
                             }
                             }
-                        }, '获取数据失败')
-                        
-                
-                    }else{
+                        }
+                        , '获取数据失败')
+
+                    } else {
                         $(".waiting").removeClass('showloading')
                         $(".waiting").removeClass('showloading')
                         alert('该设备不在线')
                         alert('该设备不在线')
                     }
                     }
 
 
-                    
-                }) 
-               
-                return true 
-                
-            }else{
-                $("#hotPannel>div").css("display","");
+                }
+                )
+
+                return true
+
+            } else {
+                $("#hotPannel>div").css("display", "");
             }
             }
         }
         }
+        
+        
         hot.prototype.updatePannel = function(){
         hot.prototype.updatePannel = function(){
             var pos = math.getPos2d(this.position, player.camera, $("#player")[0]);
             var pos = math.getPos2d(this.position, player.camera, $("#player")[0]);
             if(pos.trueSide){
             if(pos.trueSide){

+ 2 - 2
js/showHardware.js

@@ -408,7 +408,7 @@ $(function () {
       });
       });
   }
   }
 
 
-  loadCalendar({
+  /* loadCalendar({
     data:[{
     data:[{
         'startDate': "2021-5-18",//有监控的日期
         'startDate': "2021-5-18",//有监控的日期
         id:'传对应的id'
         id:'传对应的id'
@@ -417,7 +417,7 @@ $(function () {
     cellCb: (item)=> {
     cellCb: (item)=> {
       console.log(item);
       console.log(item);
     }
     }
-  })
+  }) */
 
 
   /*loadMonitor({
   /*loadMonitor({
       id:"monitor",
       id:"monitor",