var _shipSn = localStorage.getItem("shipSn"); var _pageStart = 0, callBac = null, allCarm = []; var _ajaxNum = 0, infoBac = null, allNvr = {}; // 初始化设备列表 function infoAjax(_id,_cb, num){ if(num == 0){ infoBac = _cb; allNvr = {}; _ajaxNum = 0; } $.ajax({ url: "https://open.ys7.com/api/lapp/device/info", type: "POST", traditional: true, dataType: "json", async: true, //同步请求 data: { deviceSerial:_id[_ajaxNum], accessToken:accTok }, headers: { "Content-Type": "application/x-www-form-urlencoded" }, error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(result) { if(result.code==200){ allNvr[result.data.deviceSerial] = result.data.status; if((_id.length - 1)>_ajaxNum){ _ajaxNum += 1; infoAjax(_id,function df(){}, _ajaxNum) }else{ infoBac(allNvr); } }else if(result.code==10002){ alert("登录已失效,请重新登录!"); localStorage.removeItem("_yz_TT"); localStorage.removeItem("_yz_TU"); top.location.href= staticUrl+"/Login.html"; } } }); } function infoAjaxLi(_cb){ $.ajax({ url: "https://open.ys7.com/api/lapp/device/list", type: "POST", traditional: true, dataType: "json", async: true, //同步请求 data: { pageStart:0, pageSize: 50, accessToken:accTok }, headers: { "Content-Type": "application/x-www-form-urlencoded" }, error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(result) { if(result.code == 200&&result.data.length){ _cb(result.data); }else{ _cb([]); } } }); } function SBAjax(_data,callback,num){ if(num == 0){ callBac = callback; allCarm = []; _pageStart = 0; } $.ajax({ url: "https://open.ys7.com/api/lapp/device/camera/list", type: "POST", traditional: true, dataType: "json", async: true, //同步请求 data: { deviceSerial:_data[_pageStart] , accessToken:accTok }, headers: { "Content-Type": "application/x-www-form-urlencoded" }, error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(result) { if(result.code==200){ allCarm = [...allCarm,...result.data]; if((_data.length - 1)>_pageStart){ _pageStart += 1; SBAjax(_data,function df(){},_pageStart) }else{ callBac(allCarm); } }else if(result.code==10002){ alert("登录已失效,请重新登录!"); localStorage.removeItem("_yz_TT"); localStorage.removeItem("_yz_TU"); top.location.href= staticUrl+"/Login.html"; } } }); } // 请求直播路径 function getLive(callback){ if(_playSn == null){ return; } if(_Player != null){ _Player.pause(); _Player.unload(); _Player.detachMediaElement(); _Player.destroy(); _Player = null; } $.ajax({ url: "https://open.ys7.com/api/lapp/v2/live/address/get", type: "POST", traditional: true, contentType: 'application/x-www-form-urlencoded', dataType: "json", async: false, //同步请求 data: { accessToken: accTok, deviceSerial: _playSn, channelNo: _playNo, protocol: 4, quality: _quality == "height"?1:2 }, error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(res) { if(res.code==200){ callback(res.data.url); // 设备网络状态不佳或设备已离线! } } }) } // 请求报警列表 function initAjax(_num){ if(prodSn[_shipSn].enn != ""){ yzkj.load("load1"); let _keyt = prodSn[_shipSn].enn; setTimeout(()=>{ $.ajax({ url:"https://www.enstation.vip:9443/receive", type: "GET", traditional: true, dataType: "json", async: false, headers:{ "Authorization": "ZDhlNjhjOTAwM2EyJWd6eXolaWUldXNlciV6aF9DTg==", "Content-Type": "application/json;charset=UTF-8" }, data:{ user: _keyt, msgType: ajaxType, enddate: _newTime[1], startdate: _newTime[0], pageNum:_num - 1, pageSize: 12, }, error: function(XMLHttpRequest, textStatus, errorThrown) { }, success: function(res) { if(res.success&&res.data.length){ setHtml(res.data); $("#pageTxt").text(_num); $("#allPgage").text(Math.ceil(res.total/12)); $("#allNum").text(res.total); $(".nodata").hide(); }else{ $("#pageTxt").text(_num); $("#allPgage").text(0); $("#allNum").text(0); $(".nodata").show(); setHtml([]); } yzkj.closeLoad("load1"); } }) },100) }else{ $("#pageTxt").text(1); $("#allPgage").text(0); $("#allNum").text(0); $(".nodata").show(); setHtml([]) } } function changePage(_key){ let allPage = parseInt($("#allPgage").text()); let _pagenum = parseInt($("#pageTxt").text()); if(_key=="first"){ if(_pagenum == 1){ ShowLoading("已经是第一页了!",1); return; }else{ _pagenum=1 } }else if(_key=="last"){ if(_pagenum == allPage){ ShowLoading("已经是最后一页了!",1); return; }else{ _pagenum=allPage; } }else{ if(parseInt(_key)==-1&&_pagenum==1){ ShowLoading("已经是第一页了!",1); return; }else if(parseInt(_key)==1&&_pagenum==allPage){ ShowLoading("已经是最后一页了!",1); return; }else{ _pagenum+=parseInt(_key); } } $("#pageTxt").text(_pagenum); initAjax(_pagenum); } $(document).on("click",".detailli img",function(){ let imgs = list[$(this).data("id")].imgs; let index = 0; var loadVideo = `
1 / 1
`; $(document.body).append(loadVideo); $(".indtxt span[name='index']").text(index+1); $(".indtxt span[name='all']").text(imgs.length); $(document).on("click",".imgbig .icon-left",function(){ if(index==0){ index = imgs.length - 1; }else{ index -= 1; } $(".imgbig img").attr("src",imgs[index]); $(".indtxt span[name='index']").text(index+1); }) $(document).on("click",".imgbig .icon-right",function(){ if(index==(imgs.length - 1)){ index = 0; }else{ index += 1; } $(".imgbig img").attr("src",imgs[index]); $(".indtxt span[name='index']").text(index+1); }) }) function imgerrorfun(){ var img=event.srcElement; let str=img.src; img.src="../imgs/imgerr.png"; } // 按时间查询 function seachLi(){ let _sta = $(".startDate").val(); let _end = $(".endDate").val(); if(_sta==""&&_end==""){ ShowLoading("至少选择一个时间段查询!",1); }else{ _sta = _sta==""?"2021-01-01":_sta; _end = _end==""?getTime(new Date())[0]:_end; _newTime =[_sta,_end]; initAjax(1); } } function handleError(e){ // console.log('捕获到错误',e) } function handleSuccess(){ // console.log("播放成功回调函数,此处可执行播放成功后续动作"); }