let passWay = localStorage.getItem("passWay"); let form, layer, table, laydate; // 统一视频编码18位、统一视频前端编码、统一设备协议编码、视频通道 let tCode, twCode, tdCode; let ty_code = 'to-1'; let nrUvpVideoObj; let openClose = false; let dataTypeParam = 1; let uapJsUrl = 'http://11.158.0.129:80/videoComponent/v2.0.0/uvp.js?jjsp_token=' + token; let dataObj = {}, puid, id; let cameraList = []; function setParams(params) { dataObj = JSON.parse(params); cameraList = dataObj.dataList; if (cameraList && cameraList.length > 0) { puid = cameraList[0].puid || ''; tCode = cameraList[0].tcode || ''; id = dataObj.id || ''; setBallsSelect(cameraList); } /* if (puid == null && tCode == null) { puid = '9'; } */ tCodeParam = tCode; //动态加载js if (ty_code == passWay) { $("#videoPlayer").css("display", "none"); passWay = ty_code; uaplogin(); //初始化登录获取token video(id, puid, tCodeParam); } else { video(id, puid, tCodeParam); } // 页面加载自动获取焦点 $('#startTime').focus(); puidParam = puid; localStorage.setItem("esc", 'esc') layui.use(['form', 'layer', 'table', 'laydate', 'util'], function () { form = layui.form; layer = layui.layer; table = layui.table; laydate = layui.laydate; util = layui.util; laydate.render({ elem: '#startTime', //指定元素 元素选择器 type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒) trigger: 'click', max: Date.parse(new Date()), format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss btns: ['clear', 'now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定 done: function (value, date) { //时间回调 } }); $('#startTime').val(getNowTime()) pages(); //按钮点击事件 util.event('lay-active', { photoLocal: function () { screenshot(); } }); // 切换播放视频 form.on('select(chooseBall)', function (data) { console.log(data); let strArr = data.value.split('@@'); video(id, strArr[0], strArr[1]); puid = strArr[0]; queryBallOnlineRecord(); }); }) } function onloadJs(url, callback) { var script = document.createElement('script'); // script.type = 'text/javascript'; // 异步加载 // script.async = true; // 设置脚本的来源 script.src = url; // 监听脚本加载完成的事件 script.onload = function () { console.log("Script loaded and ready to use."); if (callback) callback(); }; // 错误处理 script.onerror = function () { console.error("Error loading script: " + url); }; // 将脚本添加到文档中 document.head.appendChild(script); } //此处开始进行视频切换 function video(id, puid, tCodeParam) { console.log(id, puid, tCodeParam) //如果是统一视频 if (ty_code == passWay) { puidParam = tCodeParam; try { let url = playVideoUrl('fly', 'h264', 'main', tCodeParam); console.log("video_token====", video_token); $("#tyCode").html(tCodeParam); //初始化加载 var ip = video_ip; var token = video_token; var port = video_port; nrUvpVideoObj = new UVPVideoObj({ id: 'windowbox', ip, port, token, ak, callback: onEventNotify, winNum: 1 }); // nrUvpVideoObj.uvpVideoPlay({ winNum: 1, codeType: 1, devCode: tCodeParam, devName: '球机在线视频', }) videoObject.devCode = tCodeParam; playControl(); playControl2(); } catch (e) { } } else { if (cameraList && cameraList.length > 0) { for (var i = 0; i < cameraList.length; i++) { if (cameraList[i].puid == puid) { $("#tyCode").html(cameraList[i].tCode || ''); } } } try { puidParam = puid; initVideo(); setTimeout(function () { videoObject.devCode = puid; playVideo(1, videoObject.devCode) }, 1000); } catch (e) { } } } /*查询球机当日上线记录*/ function queryBallOnlineRecord() { pages(); } // 球机当日上线记录 function pages() { let params = { createDay: $('#startTime').val(), puId: puid } $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, url: dataUrl + "proteam/pot/todayTask/getBallTimeList?token=" + token, data: params, type: 'POST', async: false, success: function (result) { if (result.code === 200) { if (result.data) { initBallOnlineRecordTable(result.data) } } else if (result.code === 500) { layer.alert(result.msg, { icon: 2 }) } else if (result.code === 401) { logout(1); } }, error: function () { } }); } /*初始化球机当日上线记录表格*/ function initBallOnlineRecordTable(dataList) { table.render({ elem: "#ballOnlineRecordTable", id: "ballOnlineRecordTable", height: "full-485", data: dataList, cols: [ [ { field: "upTime", title: "开机时间", unresize: true, width: 120, align: "center", }, { field: "downTime", title: "关机时间", unresize: true, width: 120, align: "center", }, { field: "hours", title: "在线时长", unresize: true, width: 120, align: "center", } ], ], done: function (res, curr, count) { table.resize("ballOnlineRecordTable"); count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block"); count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto"); }, }); } // 多球机下拉选 function setBallsSelect(list) { let html = '
'; html += '' html += '
' $('#record').after(html); layui.form.render(); } // 关闭页面 function closePage(type) { // 关闭远程督查页面清空esc localStorage.removeItem('esc'); let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 parent.layer.close(index); //再执行关闭 }