|
@@ -10,46 +10,59 @@
|
10
|
10
|
</div>
|
11
|
11
|
</div>
|
12
|
12
|
<div class="flex-part monitor-list">
|
13
|
|
- <div class="flex-part-0 monitor-item">
|
14
|
|
- <div class="monitor-play" data-position="100px" data-toggle="modal" data-target="#monitorModal">
|
15
|
|
- <i class="icon icon-play-circle"></i>
|
16
|
|
- </div>
|
17
|
|
- <h2>#1</h2>
|
18
|
|
- </div>
|
19
|
|
- <div class="flex-part-0 monitor-item">
|
20
|
|
- <div class="monitor-play" data-position="100px" data-toggle="modal" data-target="#monitorModal">
|
21
|
|
- <i class="icon icon-play-circle"></i>
|
22
|
|
- </div>
|
23
|
|
- <h2>大门</h2>
|
24
|
|
- </div>
|
25
|
|
- <div class="flex-part-0 monitor-item">
|
26
|
|
- <h2>厨房</h2>
|
27
|
|
- </div>
|
28
|
|
- <div class="flex-part-0 monitor-item">
|
29
|
|
- <h2>大厅</h2>
|
30
|
|
- </div>
|
31
|
|
- <div class="flex-part-0 monitor-item">
|
32
|
|
- <h2>门卫</h2>
|
33
|
|
- </div>
|
34
|
13
|
</div>
|
35
|
14
|
|
36
|
15
|
<script>
|
37
|
16
|
let player = null;
|
38
|
|
- function showMonitorModal() {
|
|
17
|
+ function showMonitorModal(dom) {
|
|
18
|
+ const url = dom.getAttribute('data-monitor-url');
|
|
19
|
+ if (!url) {
|
|
20
|
+ alert('未找到关联设备');
|
|
21
|
+ return;
|
|
22
|
+ };
|
|
23
|
+
|
39
|
24
|
const canvas = document.createElement('canvas');
|
40
|
25
|
canvas.id = "video-canvas";
|
41
|
26
|
document.querySelector("#monitorModal .modal-content").appendChild(canvas);
|
42
|
|
- const url = 'ws://192.168.89.147:8888/ws/rtsp://admin:abcd12345678@192.168.89.203';
|
43
|
|
- player = new JSMpeg.Player(url, { canvas: canvas, protocols: [] });
|
|
27
|
+ const ws = 'ws://192.168.89.147:8888/ws/' + url;
|
|
28
|
+ player = new JSMpeg.Player(ws, { canvas: canvas, protocols: [] });
|
44
|
29
|
}
|
45
|
30
|
|
46
|
31
|
function loadPage2() {
|
47
|
|
- $('#monitorModal').on('shown.zui.modal', function() {
|
48
|
|
- showMonitorModal()
|
49
|
|
- });
|
50
|
|
- $('#monitorModal').on('hide.zui.modal', function() {
|
51
|
|
- player.destroy();
|
52
|
|
- });
|
|
32
|
+
|
|
33
|
+ var monitroTpl = [
|
|
34
|
+ '<div class="flex-part-0 monitor-item">',
|
|
35
|
+ ' <div class="monitor-play" data-monitor-url="{url}" data-position="100px" data-toggle="modal" data-target="#monitorModal">',
|
|
36
|
+ ' <i class="icon icon-play-circle"></i>',
|
|
37
|
+ ' </div>',
|
|
38
|
+ ' <h2>{title}</h2>',
|
|
39
|
+ '</div>',
|
|
40
|
+ ].join('');
|
|
41
|
+
|
|
42
|
+ $.ajax({
|
|
43
|
+ url: TH_SERVER+'/monitor?pageNum=1&pageSize=20&status=1',
|
|
44
|
+ success: function (resp) {
|
|
45
|
+ if (resp.code != 1000) return;
|
|
46
|
+ var list = resp.data.records
|
|
47
|
+ if (list && list.length > 0) {
|
|
48
|
+ var html = list.map(function(item, index) {
|
|
49
|
+ var url = item.url || '';
|
|
50
|
+ var title = item.title || '';
|
|
51
|
+ return monitroTpl.replace('{url}', url).replace('{title}', title);
|
|
52
|
+ }).join('');
|
|
53
|
+
|
|
54
|
+ $('.monitor-list').children().remove();
|
|
55
|
+ $('.monitor-list').append(html);
|
|
56
|
+
|
|
57
|
+ $('#monitorModal').on('shown.zui.modal', function(e) {
|
|
58
|
+ showMonitorModal(e.relatedTarget)
|
|
59
|
+ });
|
|
60
|
+ $('#monitorModal').on('hide.zui.modal', function() {
|
|
61
|
+ player.destroy();
|
|
62
|
+ });
|
|
63
|
+ }
|
|
64
|
+ }
|
|
65
|
+ })
|
53
|
66
|
}
|
54
|
67
|
</script>
|
55
|
68
|
</div>
|