From af1e1837484389269a6eaffcce666eca8a66471c Mon Sep 17 00:00:00 2001 From: java110 <928255095@qq.com> Date: Tue, 2 Aug 2022 15:42:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=91=E6=8E=A7=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=20=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addMonitorMachine/addMonitorMachine.html | 6 + .../editMonitorMachine.html | 6 + .../viewCameraVideo/viewCameraVideo.html | 21 +++ .../viewCameraVideo/viewCameraVideo.js | 129 ++++++++++++++++++ public/index.html | 2 + .../monitorMachineManage.html | 9 ++ .../monitorMachineManage.js | 3 + public/video.html | 4 +- 8 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 public/components/property/viewCameraVideo/viewCameraVideo.html create mode 100644 public/components/property/viewCameraVideo/viewCameraVideo.js diff --git a/public/components/property/addMonitorMachine/addMonitorMachine.html b/public/components/property/addMonitorMachine/addMonitorMachine.html index e92e7bacd..c5a92032d 100644 --- a/public/components/property/addMonitorMachine/addMonitorMachine.html +++ b/public/components/property/addMonitorMachine/addMonitorMachine.html @@ -26,6 +26,12 @@ +
+ +
+ +
+
diff --git a/public/components/property/editMonitorMachine/editMonitorMachine.html b/public/components/property/editMonitorMachine/editMonitorMachine.html index 53d2e4360..c8799957e 100644 --- a/public/components/property/editMonitorMachine/editMonitorMachine.html +++ b/public/components/property/editMonitorMachine/editMonitorMachine.html @@ -26,6 +26,12 @@ +
+ +
+ +
+
diff --git a/public/components/property/viewCameraVideo/viewCameraVideo.html b/public/components/property/viewCameraVideo/viewCameraVideo.html new file mode 100644 index 000000000..d02a46904 --- /dev/null +++ b/public/components/property/viewCameraVideo/viewCameraVideo.html @@ -0,0 +1,21 @@ +
+ +
\ No newline at end of file diff --git a/public/components/property/viewCameraVideo/viewCameraVideo.js b/public/components/property/viewCameraVideo/viewCameraVideo.js new file mode 100644 index 000000000..aba96aefb --- /dev/null +++ b/public/components/property/viewCameraVideo/viewCameraVideo.js @@ -0,0 +1,129 @@ +/** + 入驻小区 + **/ +(function(vc) { + var DEFAULT_PAGE = 1; + var DEFAULT_ROWS = 1; + vc.extends({ + data: { + viewCameraVideoInfo: { + machineId: '', + machine: {}, + timer: {}, + sdk: {} + } + }, + _initMethod: function() {}, + _initEvent: function() { + vc.on('viewCameraVideo', 'openCameraVideoModal', function(_machine) { + clearInterval($that.viewCameraVideoInfo.timer); + $that.viewCameraVideoInfo.machineId = _machine.machineId; + $('#viewCameraVideoModel').modal('show'); + $that._listViewCameraVideoMachines(); + $that._initMachineVideo(); + }); + }, + methods: { + _listViewCameraVideoMachines: function() { + let param = { + params: { + page: 1, + row: 1, + machineId: $that.viewCameraVideoInfo.machineId, + communityId: vc.getCurrentCommunity().communityId + } + } + //发送get请求 + vc.http.get('machineManage', + 'list', + param, + function(json, res) { + let _machineManageInfo = JSON.parse(json); + $that.viewCameraVideoInfo.machine = _machineManageInfo.machines[0]; + $that.applyViewCamera($that.viewCameraVideoInfo.machine); + }, + function(errInfo, error) { + console.log('请求失败处理'); + } + ); + }, + _initMachineVideo: function() { + timer = setInterval(function() { + $that.heartbeatCamera(); + }, 1000 * 30) + }, + _playVideo: function(_videoId, url) { + $('#viewCameraVideo').show(); + //let sdk = null; // Global handler to do cleanup when replaying. + $that.viewCameraVideoInfo.sdk = new SrsRtcPlayerAsync(); + $('#viewCameraVideo').prop('srcObject', $that.viewCameraVideoInfo.sdk.stream); + $that.viewCameraVideoInfo.sdk.play(url).then(function(session) {}).catch(function(reason) { + $that.viewCameraVideoInfo.sdk.close(); + $('#viewCameraVideo').hide(); + console.error(reason); + }); + }, + applyViewCamera: function(_machine) { + let data = { + machineId: _machine.machineId, + communityId: vc.getCurrentCommunity().communityId, + } + vc.http.apiPost( + '/machine.playCamera', + JSON.stringify(data), { + emulateJSON: true + }, + function(json, res) { + //vm.menus = vm.refreshMenuActive(JSON.parse(json),0); + let _json = JSON.parse(json); + if (_json.code == 0) { + $that._playVideo(_machine.machineId, _json.data.address); + _machine.callId = _json.data.callId + return; + } + vc.toast(_json.msg); + }, + function(errInfo, error) { + console.log('请求失败处理'); + vc.message(json); + + }); + }, + heartbeatCamera: function() { + let _machine = $that.viewCameraVideoInfo.machine; + if (!_machine) { + return; + } + + let _callIds = _machine.callId; + + if (!_callIds) { + return; + } + let data = { + callIds: _callIds, + communityId: vc.getCurrentCommunity().communityId, + machineId: _machine.machineId + } + vc.http.apiPost( + '/machine.heartbeatCamera', + JSON.stringify(data), { + emulateJSON: true + }, + function(json, res) { + //vm.menus = vm.refreshMenuActive(JSON.parse(json),0); + let _json = JSON.parse(json); + if (_json.code == -3) { // 摄像头 未推流 重新播放推流 + $that.viewCameras(); + } + }, + function(errInfo, error) {}); + }, + _closeViewCameraVideo: function() { + clearInterval($that.viewCameraVideoInfo.timer); + $that.viewCameraVideoInfo.sdk.close(); + $('#viewCameraVideoModel').modal('hide'); + } + } + }); +})(window.vc); \ No newline at end of file diff --git a/public/index.html b/public/index.html index 511e36934..3dd92e1cd 100644 --- a/public/index.html +++ b/public/index.html @@ -52,6 +52,8 @@ + + diff --git a/public/pages/property/monitorMachineManage/monitorMachineManage.html b/public/pages/property/monitorMachineManage/monitorMachineManage.html index 2ac57c77a..bf6389ea7 100644 --- a/public/pages/property/monitorMachineManage/monitorMachineManage.html +++ b/public/pages/property/monitorMachineManage/monitorMachineManage.html @@ -59,6 +59,9 @@ + + + @@ -80,6 +83,7 @@ {{machine.machineName}} {{machine.machineCode}} {{machine.machineVersion}} + {{machine.machineIp}} {{machine.stateName}} {{machine.heartbeatTime}} @@ -91,6 +95,10 @@ + + + @@ -112,4 +120,5 @@ + \ No newline at end of file diff --git a/public/pages/property/monitorMachineManage/monitorMachineManage.js b/public/pages/property/monitorMachineManage/monitorMachineManage.js index 22f2fcb3d..b51c13321 100644 --- a/public/pages/property/monitorMachineManage/monitorMachineManage.js +++ b/public/pages/property/monitorMachineManage/monitorMachineManage.js @@ -133,6 +133,9 @@ }); _call(); }, 'MONITOR'); + }, + _openViewVideoModel: function(_machine) { + vc.emit('viewCameraVideo', 'openCameraVideoModal', _machine); } } }); diff --git a/public/video.html b/public/video.html index 0eeb5a0a9..36abbe328 100644 --- a/public/video.html +++ b/public/video.html @@ -58,12 +58,10 @@ +
- -
-