diff --git a/public/components/property/cameraControlInfo/cameraControlInfo.html b/public/components/property/cameraControlInfo/cameraControlInfo.html new file mode 100644 index 000000000..2dec30afc --- /dev/null +++ b/public/components/property/cameraControlInfo/cameraControlInfo.html @@ -0,0 +1,34 @@ +
+
+
+
+
+
+

摄像头信息

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/public/components/property/cameraControlInfo/cameraControlInfo.js b/public/components/property/cameraControlInfo/cameraControlInfo.js new file mode 100644 index 000000000..8f6503047 --- /dev/null +++ b/public/components/property/cameraControlInfo/cameraControlInfo.js @@ -0,0 +1,40 @@ +/** + 入驻小区 + **/ +(function (vc) { + vc.extends({ + data: { + cameraControlInfo: { + machineCode: '', + machineVersion: '', + machineName: '', + machineTypeCd: '', + machineIp: '', + machineMac: '', + machineId: '' + } + }, + _initMethod: function () { + }, + _initEvent: function () { + vc.on('cameraControlInfo', 'notify', function (_data) { + $that.refreshCameraControlInfo(); + vc.copyObject(_data._machine, $that.cameraControlInfo); + }); + + }, + methods: { + refreshCameraControlInfo: function () { + vc.component.cameraControlInfo = { + machineCode: '', + machineVersion: '', + machineName: '', + machineTypeCd: '', + machineIp: '', + machineMac: '', + machineId: '' + } + } + } + }); +})(window.vc); \ No newline at end of file diff --git a/public/components/property/cameraControlVideo/cameraControlVideo.html b/public/components/property/cameraControlVideo/cameraControlVideo.html new file mode 100644 index 000000000..09bb7ed91 --- /dev/null +++ b/public/components/property/cameraControlVideo/cameraControlVideo.html @@ -0,0 +1,30 @@ +
+
+ +
+ +
+
+
+ +
+
+
+ +
+ +
+
+ +
+ + +
\ No newline at end of file diff --git a/public/components/property/cameraControlVideo/cameraControlVideo.js b/public/components/property/cameraControlVideo/cameraControlVideo.js new file mode 100644 index 000000000..80802805e --- /dev/null +++ b/public/components/property/cameraControlVideo/cameraControlVideo.js @@ -0,0 +1,155 @@ +/** + 入驻小区 + **/ +(function (vc) { + var DEFAULT_PAGE = 1; + var DEFAULT_ROWS = 1; + vc.extends({ + data: { + cameraControlVideoInfo: { + paId: '', + inMachineId: '', + outMachineId: '', + machines: [], + showType:'606', + outMachines: [] + + } + }, + _initMethod: function () { + $that._initShowType($that.cameraControlVideoInfo.showType); + + }, + _initEvent: function () { + vc.on('cameraControlVideo', 'notify', function (param) { + }) + vc.on('pagination', 'page_event', function (_currentPage) { + vc.component._listMachines(_currentPage, DEFAULT_ROWS); + }); + vc.on('cameraControlInfo', 'page_event', function (_currentPage) { + vc.component._listMachines(_currentPage, DEFAULT_ROWS); + }); + }, + methods: { + _listMachines: function (_page, _rows) { + let param = { + params: { + page: _page, + row: _rows, + machineTypeCd: '9998', + communityId: vc.getCurrentCommunity().communityId + } + } + //发送get请求 + vc.http.get('machineManage', + 'list', + param, + function (json, res) { + let _machineManageInfo = JSON.parse(json); + $that.cameraControlVideoInfo.machines = _machineManageInfo.machines; + let _machine = $that.cameraControlVideoInfo.machines[0]; + vc.emit('pagination', 'init', { + total: _machineManageInfo.records, + currentPage: _page + }); + vc.emit('cameraControlInfo', 'notify', { + _machine + }); + }, function (errInfo, error) { + console.log('请求失败处理'); + } + ); + }, + _swatchVedio: function () { + //创建一个socket实例 + let wsUrl = ""; + let _enterMachineId = $that.cameraControlVideoInfo.inMachineId; + vc.emit('parkingAreaControl', 'notify', { + inMachineId: _enterMachineId + }); + $that.cameraControlVideoInfo.inMachines.forEach((item) => { + if (item.machineId == _enterMachineId) { + wsUrl = item.machineIp; + if (item.machineVersion.indexOf('300') > -1) { + wsUrl += "/ws.flv" + } else { + wsUrl += "/ws" + } + } + }); + + wsUrl = wsUrl.replace(':8131', ':9080'); + let _protocol = window.location.protocol; + if (_protocol.startsWith('https')) { + wsUrl = + "wss://" + wsUrl; + } else { + wsUrl = + "ws://" + wsUrl; + } + let image = document.getElementById("receiver1"); + if (wsUrl.endsWith(".flv")) { + image = document.getElementById("receiver1Div"); + let jessibuca = new Jessibuca({ + container: image, + videoBuffer: 0.2, + isResize: false, + }); + jessibuca.onLoad = function () { + this.play(wsUrl); + }; + return; + } + let receiver_socket = new WebSocket(wsUrl); + // 监听消息 + receiver_socket.onmessage = function (data) { + let reader = new FileReader(); + reader.onload = function (evt) { + if (evt.target.readyState == FileReader.DONE) { + let url = evt.target.result; + image.src = "data:image/png;" + url; + } + }; + reader.readAsDataURL(data.data); + }; + }, + openFullscreen: function (e) { + var parents = $(e.target).parent().parent(); + + // $('#' + parents[0].id).height(650); + // $('#' + parents[0].id).width(400); + // $('#'+ parents[0].id).toggle(function () { + // $('#' + parents[0].id).height($('#' + parents[0].id).height() + 600); + // }, function () { + // $('#' + parents[0].id).height($('#' + parents[0].id).height() - 100); + // }) + }, + _openCameraControlInfoVideo: function (_machine) { + vc.emit('cameraControlInfo', 'notify', { + _machine + }); + }, + _initShowType: function(_typeCd){ + if(_typeCd == '606'){ + DEFAULT_ROWS=1; + $("div[name='showName']").attr('class','col-md-12'); + } + if(_typeCd == '607'){ + DEFAULT_ROWS=4; + $("div[name='showName']").attr('class','col-md-6'); + } + if(_typeCd == '608'){ + DEFAULT_ROWS=9; + $("div[name='showName']").attr('class','col-md-4'); + } + if(_typeCd == '609'){ + DEFAULT_ROWS=16; + $("div[name='showName']").attr('class','col-md-3'); + } + $that._listMachines(DEFAULT_PAGE, DEFAULT_ROWS); + + } + + } + }); +})(window.vc); \ No newline at end of file diff --git a/public/components/property/parkingAreaControlVideo/parkingAreaControlVideo.html b/public/components/property/parkingAreaControlVideo/parkingAreaControlVideo.html index 63ea99752..dc5b8601b 100644 --- a/public/components/property/parkingAreaControlVideo/parkingAreaControlVideo.html +++ b/public/components/property/parkingAreaControlVideo/parkingAreaControlVideo.html @@ -66,12 +66,12 @@
- +
- +
diff --git a/public/img/init.jpg b/public/img/init.jpg new file mode 100644 index 000000000..e9788ea58 Binary files /dev/null and b/public/img/init.jpg differ diff --git a/public/pages/property/videoControl/videoControl.html b/public/pages/property/videoControl/videoControl.html new file mode 100644 index 000000000..8da639438 --- /dev/null +++ b/public/pages/property/videoControl/videoControl.html @@ -0,0 +1,9 @@ +
+
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/public/pages/property/videoControl/videoControl.js b/public/pages/property/videoControl/videoControl.js new file mode 100644 index 000000000..ae2eb9086 --- /dev/null +++ b/public/pages/property/videoControl/videoControl.js @@ -0,0 +1,140 @@ +/** + 入驻小区 + **/ +(function (vc) { + vc.extends({ + data: { + parkingAreaControlInfo: { + _currentTab: 'parkingAreaControlCarInout', + paId: '', + inMachineId: '', + outMachineId: '', + + } + }, + _initMethod: function () { + $that.parkingAreaControlInfo.paId = vc.getParam('paId'); + $that._initParkingAreaWs(); + vc.emit('parkingAreaControlVideo', 'notify', { + paId: $that.parkingAreaControlInfo.paId + }); + }, + _initEvent: function () { + vc.on('parkingAreaControl', 'notify', function (_param) { + vc.copyObject(_param, $that.parkingAreaControlInfo); + }) + }, + methods: { + changeTab: function (_tab) { + $that.parkingAreaControlInfo._currentTab = _tab; + vc.emit(_tab, 'switch', { + paId: $that.parkingAreaControlInfo.paId + }) + }, + _initParkingAreaWs: function () { + let clientId = vc.uuid(); + let heartCheck = { + timeout: 30000, // 9分钟发一次心跳,比server端设置的连接时间稍微小一点,在接近断开的情况下以通信的方式去重置连接时间。 + serverTimeoutObj: null, + pingTime: new Date().getTime(), + reset: function () { + clearTimeout(this.serverTimeoutObj); + return this; + }, + start: function () { + let self = this; + this.serverTimeoutObj = setInterval(function () { + if (websocket.readyState == 1) { + console.log("连接状态,发送消息保持连接"); + let _pingTime = new Date().getTime(); + //保护,以防 异常 + if (_pingTime - self.pingTime < 15 * 1000) { + return; + } + websocket.send("{'cmd':'ping'}"); + self.pingTime = _pingTime; + + heartCheck.reset().start(); // 如果获取到消息,说明连接是正常的,重置心跳检测 + } else { + console.log("断开状态,尝试重连"); + $that._initParkingAreaWs(); + } + }, this.timeout) + } + } + + let _protocol = window.location.protocol; + let url = ''; + if (_protocol.startsWith('https')) { + url = + "wss://" + window.location.host + "/ws/parkingArea/" + + $that.parkingAreaControlInfo.paId + "/" + clientId; + } else { + // url = + // "ws://" + window.location.host + "/ws/parkingArea/" + + // $that.parkingAreaControlInfo.paId + "/" + clientId; + url = + "ws://demo.homecommunity.cn:9011/ws/parkingArea/" + + $that.parkingAreaControlInfo.paId + "/" + clientId; + } + + + if ("WebSocket" in window) { + websocket = new WebSocket(url); + } else if ("MozWebSocket" in window) { + websocket = new MozWebSocket(url); + } else { + websocket = new SockJS(url); + } + + //连接发生错误的回调方法 + websocket.onerror = function (_err) { + console.log("初始化失败", _err); + this.$notify.error({ + title: "错误", + message: "连接失败,请检查网络" + }); + }; + + //连接成功建立的回调方法 + websocket.onopen = function () { + heartCheck.reset().start(); + console.log("ws初始化成功"); + }; + + //接收到消息的回调方法 + websocket.onmessage = function (event) { + heartCheck.reset().start(); + console.log("event", event); + let _data = event.data; + try { + _data = JSON.parse(_data); + } catch (err) { + return; + } + + vc.emit('parkingAreaControlCarInout', 'notify', { + data: _data, + parkingAreaControl: $that.parkingAreaControlInfo + }); + vc.emit('parkingAreaControlFee', 'notify', _data); + }; + + //连接关闭的回调方法 + websocket.onclose = function () { + console.log("初始化失败"); + //$that._initParkingAreaWs(); + this.$notify.error({ + title: "错误", + message: "连接关闭,请刷新浏览器" + }); + }; + + //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。 + window.onbeforeunload = function () { + websocket.close(); + }; + } + } + }); +})(window.vc); \ No newline at end of file