index.vue
10.8 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
<template>
<div class="manage-container clerk-wrapper">
<el-row class="manage-content">
<el-col :span="5" class="treeMenu">
<el-row class="manage-head-wrapper">
<el-col :xs="22" :sm="22">
<div class="manage-select-box">
<el-input v-model="filterText" class="search-inp" :placeholder="$t('pholder.Site')" clearable/>
</div>
<el-button type="primary" class="search-btn" plain @click="searchFun">{{$t('button.search')}}</el-button>
</el-col>
</el-row>
<!-- class="filter-tree" :filter-node-method="filterNode" -->
<el-tree :data="tableData" class="tree" :style="{height:tableHeight+'px'}" ref="tree" default-expand-all :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</el-col>
<el-col :span="19" class="personInfo">
<div v-show="platform==1" class="video-box" :style="{height:tableHeight+'px'}" v-loading="loading">
<canvas id="canvasVideo" style="background: black;width:100%;height:100%"></canvas>
</div>
<div v-show="platform==2" class="videoBox" :style="{height:tableHeight+'px'}" v-loading="loading">
<div id="my-video" style="background: black;width:100%;height:100%"></div>
<div class="btns">
<el-button type="text" class="scaleBtn" icon="el-icon-plus" @mousedown.native='setControl(8)' @mouseup.native='stopControl(8)'></el-button>
<el-button type="text" class="scaleBtn" icon="el-icon-minus" @mousedown.native='setControl(9)' @mouseup.native='stopControl(9)'></el-button>
</div>
</div>
</el-col>
</el-row>
</div>
</template>
<script>
import * as Cookies from 'js-cookie'
import EZUIKit from 'ezuikit-js'
import SLPlayer from '../../../../static/js/slplayer'
export default {
data() {
return {
currObj:'',
radio1:'高清',
tableData: [],
loading: true,
queryForm:{},
defaultProps: {
children: 'children',
label: 'name',
},
platform:'',
palyUrl:'',
player:'',
playerIndex:0,
playerM3u8:'',
playerM3u8Index:0,
playerEz:'',
filterText:''
};
},
computed: {
tableHeight() {
const windowInnerHeight = window.innerHeight;
return windowInnerHeight - windowInnerHeight * 0.24;
}
},
mounted() {
this.getTableData()
},
beforeDestroy() {
if(this.player){
this.player.stop()
}
},
watch: {
// filterText(val) {
// this.$refs.tree.filter(val);
// }
},
methods: {
getTableData(){
this.tableData = []
this.$api.videoShopTourReport.getGateGroup({accountId:this.$cookie.get('accountId')}).then(res => {
let result = res.data;
if(result.code==200){
this.tableData = this.recursionDeal([result.data])
}
})
},
recursionDeal(data){
let that = this
data.forEach(item=>{
item.children = []
if(item.malls && item.malls.length>0){
item.malls.forEach(item1=>{
if(item1.patrolGates){
item1.patrolGates.forEach(item2=>{
item2.type = 'gate'
})
item1.children = item1.patrolGates
}
})
item.children.push.apply(item.children,item.malls);
}
if(item.subGroups && item.subGroups.length>0){
item.children.push.apply(item.children,item.subGroups);
that.recursionDeal(item.subGroups)
}
})
return data
},
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
setControl(val){
let parmas = {
'platform':this.currObj.platform,
'deviceSerial':this.currObj.deviceSerial,
'channelNo':this.currObj.channelNo,
'direction':val,
'speed':1
}
this.$api.videoShopTourReport.ptzStart(parmas).then(data => {
let result = data.data
if(result.code !=200){
this.$message({
message: '调整失败',
type: 'error'
});
}
})
},
stopControl(val){
let parmas = {
'platform':this.currObj.platform,
'deviceSerial':this.currObj.deviceSerial,
'channelNo':this.currObj.channelNo,
'direction':val
}
this.$api.videoShopTourReport.ptzStop(parmas).then(data => {
let result = data.data
if(result.code !=200){
this.$message({
message: '调整失败',
type: 'error'
});
}
})
},
playerVideo(atoken){
this.$nextTick(()=>{
// 拾联视频
if(this.platform==1){
if(this.playerEz){
let canvasVideo = document.getElementById('my-video')
canvasVideo.innerHTML = ''
}
if(this.playerIndex>0){
// 暂停上次播放并重新开始新的视频
this.player.stop();
setTimeout(()=>{
this.player.start(this.palyUrl)
},100)
}else{
this.createPlayer(this.palyUrl);
}
}else{
// 萤石云视频
// 清除拾联视频
if(this.player){
this.player.stop();
}
// 开始萤石云视频
if(this.playerEz){
let canvasVideo = document.getElementById('my-video')
canvasVideo.innerHTML = ''
}
if(this.currObj.presetId != undefined){
let moveParmas = {
platform:this.currObj.platform,
deviceSerial:this.currObj.deviceSerial,
channelNo:this.currObj.channelNo,
index:this.currObj.presetId
}
this.$api.videoShopTourReport.getPresetMove(moveParmas).then(data => {
console.log(data.data)
})
}
// 开始萤石云视频
this.playerEz = new EZUIKit.EZUIKitPlayer({
id: "my-video", // 视频容器ID
accessToken: atoken,
url: this.palyUrl,
template: 'theme',//simple - 极简版;standard-标准版;security - 安防版(预览回放);voice-语音版;
autoplay: true,
footer: ['hd','fullScreen'],
width: document.getElementById('my-video').offsetWidth - 20,
height:this.tableHeight - 50,
});
setTimeout(()=>{
this.playerEz.play()
},500)
}
})
},
handleNodeClick(data) {
if(data.type != 'gate'){
return false;
}
this.platform = data.platform;
let parmas = {
id:data.id
}
if(this.platform==2){
parmas.protocol=1
}
let presetId = data.presetId
this.$api.videoShopTourReport.getLiveInfo(parmas).then(res => {
let result = res.data;
if(result.code==200){
this.currObj = {
presetId:presetId,
...result.data
}
this.palyUrl= result.data.liveAddress;
this.playerVideo(result.data.accessToken)
}
})
},
createPlayer(row) {
this.playerIndex ++ ;
let that = this;
that.Module = {
/* ************************************ */
// 定义视频画布
canvas: document.getElementById("canvasVideo"),
/* ************************************ */
// 设置相应的事件回调
onStart: function () {
console.log("onStart...")
},
onEnd: function () {
console.log("onEnd...")
},
onError: function (code, err) {
alert('error: ', code, err)
console.log('error: ', code, err);
},
onVideoStart: function () {
console.log('onVideoStart。。。');
},
// 录像回放中返回时间刻度
onPlayTime: function (ts) {
if(ts==0) return;
var date = new Date(ts * 1000);//如果date为10位不需要乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
var timestamp = Y + M + D + h + m + s;
}
}
SLPlayer(that.Module).then(function (obj) {
that.loading = false
that.player = obj;
setTimeout(()=>{
that.player.start(row)
},1000)
});
},
searchFun(){
if(this.filterText){
let tabelParams = {
accountId: this.$cookie.get('accountId'),
mallName:this.filterText
};
this.$api.videoShopTourReport.filterGateGroup(tabelParams, null, true).then(data => {
this.tableData = [];
var result = data.data;
result.data.forEach(item=>{
if(item.patrolGates && item.patrolGates.length>0){
item.patrolGates.forEach(item2=>{
item2.type = 'gate'
})
item.children = item.patrolGates
}
})
this.tableData = result.data;
})
}else{
this.getTableData()
}
}
}
};
</script>
<style scoped lang="less">
.manage-select-box .el-select {
width: 200px;
}
.manage-container{
height: 100%;
}
.manage-content{
height: calc(100% - 100px);
}
.videoBox{
position: relative;
}
.btns{
position: absolute;
right: 15px;
bottom: 70px;
.scaleBtn{
padding: 0;
width: 20px;
height: 20px;
display: block;
background-color: #fff;
color: #000;
margin: 0 0 10px 0;
}
}
.personInfo{
padding: 20px;
}
.tree{
overflow: auto;
}
.treeMenu {
padding-right: 5px;
border-right: 3px solid #f0f3f9;
height: 100%;
.treePage {
padding: 2px 0;
position: fixed;
bottom: 15px;
/deep/.el-pagination__jump{
line-height: 22px;
margin-left: 0;
}
}
.btn-box{
margin-bottom: 10px;
}
}
</style>