YYC
2023-05-06 8e92b167650c011cfd38096524e6877268ae65b1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
var url = null;
var videoData = null;
var playData =null;
var data = {
    "interfaceId": "5604",
    "tokenAuth": "",
    "sign": "10003",
    "outId": "10003",
    "reqDateTime": new Date(),
    "data": {
        "deptId": ""
    }
};
var data1 = {
    "interfaceId": "5605",
    "tokenAuth": "",
    "sign": "10003",
    "outId": "10003",
    "reqDateTime": new Date(),
    "data": {
        "id": "",
        "playType": ""
    }
};
 
function init() {
 
    var user = JSON.parse(localStorage.getItem('user'));
    var selectDeptId = JSON.parse(localStorage.getItem('selectDeptId'));
    data.tokenAuth = user.tokenAuth;
    data1.tokenAuth = user.tokenAuth;
    data.data.deptId = selectDeptId;
    url = user.url + "/api-phone/v35/gateway";
 
    getVideoList();
 
}
 
function getVideoList() {
    //发送请求获取视频设备
    mui.ajax(url, {
        type: "POST",
        dataType: "json",
        crossDomain: true,
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify(data),
        success: function(result) {
            if (result.code == "0000") {
                videoData = result.data;
                console.log(JSON.stringify(videoData))
                renderVideo();
            } else {
                renderVideo();
                mui.alert(result.msg, '提示', ["确定"], function() {}, "div");
                
            }
        },
        error: function() {
            renderVideo();
            mui.alert('系统繁忙,请重试!', '提示', ["确定"], function() {}, "div");
        }
    })
}
 
//渲染视频监控设备
function renderVideo() {
    var html = '';
    if (videoData) {
        var videoList = videoData.data;
        if (videoList && videoList.length > 0) {
            $.each(videoList, function(index, item) {
                if (index % 3 == 0) {
                    html +=
                    '<li><a onclick="getVideo('+item.id,item.playType+')" class="con" style="background-image: url(images/icons/g-i15.png);">';
                }
                if (index % 3 == 1) {
                    html +=
                    '<li><a onclick="getVideo('+item.id,item.playType+')" class="con" style="background-image: url(images/icons/g-i16.png);">';
                }
                if (index % 3 == 2) {
                    html +=
                    '<li><a onclick="getVideo('+item.id,item.playType+')" class="con" style="background-image: url(images/icons/g-i17.png);">';
                }
                if (item.type = '02') {
                    html +=
                        '<div class="left"><div class="icon"><img src="images/icons/g-i13.png" alt=""></div><div class="name">' +
                        item.name + ' (球机)</div></div>';
                }
                if (item.type == '01') {
                    html +=
                        '<div class="left"><div class="icon"><img src="images/icons/g-i14.png" alt=""></div><div class="name">' +
                        item.name + ' (枪机)</div></div>';
                }
 
                html += '<div class="right"><span class="mui-icon  mui-icon-forward"></span></div></a></li>';
            })
        } else {
            html += '<li><a class="con" style="background-image: url(images/icons/g-i15.png);"><span>暂无相关设备</span></a></li>';
        }
    }else{
        html += '<li><a class="con" style="background-image: url(images/icons/g-i15.png);"><span>暂无相关设备</span></a></li>';
    }
    $("#recordList").html(html);
}
 
 
function getVideo(cameraId,playType){
    data1.data.id = cameraId;
    data1.data.playType = playType;
    
    //发送请求获取视频设备
    mui.ajax(url, {
        type: "POST",
        dataType: "json",
        crossDomain: true,
        contentType: "application/json;charset=utf-8",
        data: JSON.stringify(data1),
        success: function(result) {
            if (result.code == "0000") {
                playData = result.data;
                console.log(JSON.stringify(playData))
                toVideo(playData.playAddr);
            } else {
                toVideo('');
                mui.alert(result.msg, '提示', ["确定"], function() {}, "div");
            }
        },
        error: function() {
            toVideo('');
            mui.alert('系统繁忙,请重试!', '提示', ["确定"], function() {}, "div");
        }
    })
}
 
function toVideo(playAddr){
    var html = '';
    html += '<video src="'+playAddr+'" poster="images/pos1.png" class="video" webkit-playsinline="true" playsinline="true" controls></video>'
    $("#toVideo").html(html);
}
 
mui('.mui-scroll-wrapper').scroll({
    indicators: false, //是否显示滚动条
    deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
    bounce: false, //是否启用回弹
    deceleration: 0.0005 //flick 减速系数,系数越大,滚动速度越慢,滚动距离越小,默认值0.0006
});