Browse Source

[FE]首页直播组件

chenxr3 4 years ago
parent
commit
18d7e66b9e

+ 6 - 0
security-protection-platform/src/api/dashboard/index.js

@ -21,5 +21,11 @@ const api = {
21 21
      return resp.data
22 22
    })
23 23
  }
24
  // 直播流
25
  // queryMonitorSceneTerminalRel () {
26
  //   return $default.get('/sp/monitorSceneTerminal/queryMonitorSceneTerminalRel', {monitorSceneId:2}).then(resp => {
27
  //     return resp.data
28
  //   })
29
  // }
24 30
}
25 31
export default api

+ 118 - 91
security-protection-platform/src/modules/dashboard/index.vue

@ -9,46 +9,28 @@
9 9
    </div>
10 10
    <div class="body">
11 11
      <div class="body-left">
12
        <div :style="`height:260px`" class="body-left-item">
12
        <div :style="`height:34%`" class="body-left-item">
13 13
          <div :style="`background-image: url(${titleImgBg})`" class="title">
14 14
            <span class="title-span">出勤统计</span>
15 15
          </div>
16
          <div id="doughnut" style="height: 100%"></div>
16
          <div id="doughnut" style="height: 100%;width: 100%"></div>
17 17
        </div>
18
        <div :style="`height:260px;margin-top: 24px;`" class="body-left-item">
18
        <div :style="`height:34%;margin-top: 3%;`" class="body-left-item">
19 19
          <div :style="`background-image: url(${titleImgBg})`" class="title">
20 20
            <span class="title-span">告警分析</span>
21 21
          </div>
22
          <div id="bar" style="height: 100%"></div>
22
          <div id="bar" style="height: 100%;width: 100%"></div>
23 23
        </div>
24
        <div :style="`height:220px;margin-top: 24px;`" class="body-left-item">
24
        <div :style="`height:29%;margin-top: 3%;`" class="body-left-item">
25 25
          <div :style="`background-image: url(${titleImgBg})`" class="title">
26 26
            <span class="title-span">近24h告警</span>
27 27
          </div>
28 28
          <div class="top4">
29
            <t-row :gutter="2" align="center" class="top4-row">
29
            <t-row v-for="(item,index) in topData" :gutter="2" align="center" class="top4-row">
30 30
              <t-col span="6">
31
                <div :style="`background-image: url(${polygon})`" class="polygon">1</div>
32
                &nbsp;&nbsp;{{ topData[0].name }}</t-col>
33
              <t-col span="2" offset="4">{{ topData[0].value }}个</t-col>
34
            </t-row>
35
            <t-row :gutter="2" align="center" class="top4-row">
36
              <t-col span="6">
37
                <div :style="`background-image: url(${polygon})`" class="polygon">2</div>
38
                &nbsp;&nbsp;{{ topData[1].name }}</t-col>
39
              <t-col span="2" offset="4">{{ topData[1].value }}个</t-col>
40
            </t-row>
41
            <t-row :gutter="2" align="center" class="top4-row">
42
              <t-col span="6">
43
                <div :style="`background-image: url(${polygon})`" class="polygon">3</div>
44
                &nbsp;&nbsp;{{ topData[2].name }}</t-col>
45
              <t-col span="2" offset="4">{{ topData[2].value }}个</t-col>
46
            </t-row>
47
            <t-row :gutter="2" align="center" class="top4-row">
48
              <t-col span="6">
49
                <div :style="`background-image: url(${polygon})`" class="polygon">4</div>
50
                &nbsp;&nbsp;{{ topData[3].name }}</t-col>
51
              <t-col span="2" offset="4">{{ topData[3].value }}个</t-col>
31
                <div :style="`background-image: url(${polygon})`" class="polygon">{{ index + 1 }}</div>
32
                &nbsp;&nbsp;{{ item.name }}</t-col>
33
              <t-col span="2" offset="4">{{ item.value }}个</t-col>
52 34
            </t-row>
53 35
          </div>
54 36
        </div>
@ -57,15 +39,24 @@
57 39
        <div :style="`background-image: url(${titleImgBg})`" class="title" style="width: 370px;">
58 40
          <span class="title-span">重点区域监控</span>
59 41
        </div>
60
        <video-player ref="videoPlayer" :options="videoOptions" class="vjs-custom-skin videoPlayer" :playsinline="true"></video-player>
61
62
<!--        <img src="@/assets/images/indexT1.png" style="width: 730px;height: 730px;padding-left: 20px;padding-top: 10px;">-->
42
        <video-player ref="videoPlayer" :options="videoOptions" :playsinline="true" class="vjs-custom-skin videoPlayer"></video-player>
43
        <div class="videoPlayers">
44
          <div v-for="(item,index) in videoOptionsList" class="videoPlayer-sm" @click="videoSwitchover(item)">
45
            <video-player ref="videoPlayer"
46
                          :options="item.options"
47
                          :playsinline="true"
48
                          :style="`padding: 0 2.5% 2.5% 2%;border-radius: 5px;border: ${1-index}px solid #009bf3;`"
49
                          class="vjs-custom-skin videoPlayer">
50
            </video-player>
51
            <div style="color: white;text-align: center;">{{ item.name }}</div>
52
          </div>
53
        </div>
63 54
      </div>
64 55
      <div class="body-right">
65 56
        <div :style="`background-image: url(${titleImgBg})`" class="title" style="width: 330px;">
66 57
          <span class="title-span">人员进出识别</span>
67 58
        </div>
68
        <img src="@/assets/images/indexT2.png" style="width: 325px;height: 730px;padding-left: 15px;padding-top: 10px;">
59
        <img src="@/assets/images/indexT2.png" style="width: 95%;height: 95%;padding-left: 15px;padding-top: 10px;">
69 60
      </div>
70 61
    </div>
71 62
  </div>
@ -77,6 +68,7 @@ import titleImgBg from '@/assets/images/indexTitle.png'
77 68
import polygon from '@/assets/images/polygon.png'
78 69
import echarts from 'echarts'
79 70
import dasapi from '@/api/dashboard'
71
import sysapi from '@/api/system'
80 72
import 'video.js/dist/video-js.css'
81 73
import 'vue-video-player/src/custom-theme.css'
82 74
import { videoPlayer } from 'vue-video-player'
@ -121,6 +113,7 @@ export default {
121 113
    return {
122 114
      nowDate: new Date(),
123 115
      videoOptions: {},
116
      videoOptionsList: [],
124 117
      imgBg: imgBg,
125 118
      titleImgBg: titleImgBg,
126 119
      polygon: polygon,
@ -128,43 +121,14 @@ export default {
128 121
      population: 0,
129 122
      alarmDataX: [],
130 123
      alarmDataY: [],
131
      topData: [
132
        {name: '未戴安全帽', value: ''},
133
        {name: '人员聚集', value: ''},
134
        {name: '吸烟', value: ''},
135
        {name: '摔倒', value: ''}],
124
      topData: [],
136 125
      topData1: []
137 126
    }
138 127
  },
139 128
  computed: {
140 129
  },
141 130
  mounted () {
142
143
    this.videoOptions = {
144
      live: true,
145
      autoplay: true,
146
      fluid: true,
147
      notSupportedMessage: '暂时无法播放',
148
      controlBar: {
149
        timeDivider: true,
150
        durationDisplay: true,
151
        remainingTimeDisplay: false,
152
        fullscreenToggle: true // 全屏按钮
153
      },
154
      techOrder: ['flash'],
155
      flash: {
156
        hls: { withCredentials: false },
157
        swf: 'static/video-js.swf' // 引入静态文件swf
158
      },
159
      sources: [{ // 流配置,数组形式,会根据兼容顺序自动切换
160
        type: 'rtmp/mp4',
161
        src: 'rtmp://58.200.131.2:1935/livetv/hunantv' 
162
      }]
163
    }
164
165
166
167
131
    this.initVideo()
168 132
    setInterval(() => { // 当前时间
169 133
      this.nowDate = new Date()
170 134
    }, 1000)
@ -173,7 +137,58 @@ export default {
173 137
    this.init24Top()
174 138
  },
175 139
  methods: {
176
140
    initVideo() {
141
      sysapi.getTerminalRel(2).then(res => {
142
        this.videoOptions = {
143
          live: true,
144
          autoplay: true,
145
          fluid: false,
146
          height: document.documentElement.clientHeight * 0.60,
147
          notSupportedMessage: '暂时无法播放',
148
          controlBar: {
149
            timeDivider: false,
150
            durationDisplay: false,
151
            remainingTimeDisplay: false,
152
            fullscreenToggle: true // 全屏按钮
153
          },
154
          techOrder: ['flash'],
155
          flash: {
156
            hls: { withCredentials: false },
157
            swf: 'static/video-js.swf' // 引入静态文件swf
158
          },
159
          sources: [{ // 流配置,数组形式,会根据兼容顺序自动切换
160
            type: 'rtmp/mp4',
161
            src: res.data.data[0].videoUrl
162
          }]
163
        }
164
        this.videoOptionsList = []
165
        res.data.data.forEach(e => {
166
          this.videoOptionsList.push({
167
            options:{
168
              live: true,
169
              autoplay: true,
170
              fluid: false,
171
              height: document.documentElement.clientHeight * 0.15,
172
              notSupportedMessage: '暂时无法播放',
173
              controls: false,
174
              techOrder: ['flash'],
175
              flash: {
176
                hls: { withCredentials: false },
177
                swf: 'static/video-js.swf' // 引入静态文件swf
178
              },
179
              sources: [{ // 流配置,数组形式,会根据兼容顺序自动切换
180
                type: 'rtmp/mp4',
181
                src: e.videoUrl
182
              }]
183
            },
184
            name: e.resourceToolName
185
          })
186
        })
187
      })
188
    },
189
    videoSwitchover(itme){
190
      this.videoOptions.sources = itme.options.sources
191
    },
177 192
    gotoSystem() {
178 193
      this.$router.push({name:'videoSurveillance'})
179 194
    },
@ -205,11 +220,8 @@ export default {
205 220
      })
206 221
    },
207 222
    init24Top() {
208
      this.topData1 = dasapi.queryAlarmAnalysisTopList().then(res => {
209
        this.topData1 = res.data
210
        if (res.data.length>3){
211
          this.topData = this.topData1
212
        }
223
      this.topData = dasapi.queryAlarmAnalysisTopList().then(res => {
224
        this.topData = res.data
213 225
      })
214 226
    },
215 227
    initAttendanceData() {
@ -389,8 +401,7 @@ export default {
389 401
390 402
<style lang="scss">
391 403
.index{
392
  width: 1500px;
393
  height: 880px;
404
  height:100vh;
394 405
  background-color: #011d40;
395 406
  .time{
396 407
    width: 500px;
@ -399,15 +410,14 @@ export default {
399 410
    margin-top: -14px;
400 411
  }
401 412
  .goto{
402
    display:block;
403
    float:right;
413
    cursor: pointer;
404 414
    margin-top: -30px;
405
    width: 122px;
415
    width: 8%;
406 416
    height: 40px;
407 417
    border-radius: 5px;
408 418
    background-color: #011d40; /* 浏览器不支持的时候显示 */
409 419
    box-shadow: 0 0 30px -10px #009bf3 inset;
410
    margin-right: 10px;
420
    margin-left: 91%;
411 421
    align-items: center;
412 422
    text-align: center;
413 423
    padding-top: 6px;
@ -420,8 +430,7 @@ export default {
420 430
    display: flex;
421 431
    align-items: center;
422 432
    text-align: center;
423
    height: 45.1px;
424
    width: 1500px;
433
    height: 6%;
425 434
    overflow: hidden;
426 435
    position: relative;
427 436
    .top-logo{
@ -429,21 +438,21 @@ export default {
429 438
      top:50%;
430 439
      left:50%;
431 440
      transform: translate(-50%,-50%);
432
      height: 24px;
433
      width: 400px;
441
      height: 50%;
442
      width: 25%;
434 443
      vertical-align: middle
435 444
    }
436 445
  }
437 446
  .body{
438 447
    display: flex;
439
    width: 1500px;
440
    padding-top: 5px;
448
    height: 90%;
449
    padding-top: 1%;
441 450
    justify-content: space-around;
442 451
    .body-left{
443
      width: 340px;
444
      height: 788px;
452
      width: 23%;
453
      height: 96%;
445 454
      .body-left-item{
446
        width: 340px;
455
        width: 100%;
447 456
        border-radius: 5px;
448 457
        background-color: #011d40; /* 浏览器不支持的时候显示 */
449 458
        box-shadow: 0 0 30px -10px #009bf3 inset;
@ -452,7 +461,6 @@ export default {
452 461
          padding-right: 15px;
453 462
          color: #00d8f3;
454 463
          font-size: 15px;
455
          font-family: "Microsoft YaHei";
456 464
          height: 100%;
457 465
          .top4-row{
458 466
            border: 0 none;
@ -474,15 +482,15 @@ export default {
474 482
      }
475 483
    }
476 484
    .body-center{
477
      width: 750px;
478
      height: 788px;
485
      width: 50%;
486
      height: 96%;
479 487
      border-radius: 5px;
480 488
      background-color: #011d40; /* 浏览器不支持的时候显示 */
481 489
      box-shadow: 0 0 30px -10px #009bf3 inset;
482 490
    }
483 491
    .body-right{
484
      width: 340px;
485
      height: 788px;
492
      width: 23%;
493
      height: 96%;
486 494
      border-radius: 5px;
487 495
      background-color: #011d40; /* 浏览器不支持的时候显示 */
488 496
      box-shadow: 0 0 30px -10px #009bf3 inset;
@ -494,7 +502,7 @@ export default {
494 502
    align-items: center;
495 503
    text-align: center;
496 504
    height: 28px;
497
    width: 340px;
505
    width: 100%;
498 506
    margin: 0 auto;
499 507
    .title-span{
500 508
      height: 28px;
@ -511,7 +519,7 @@ export default {
511 519
    align-items: center;
512 520
    text-align: center;
513 521
    height: 28px;
514
    width: 350px;
522
    width: 47%;
515 523
    margin: 0 auto;
516 524
    .title-span{
517 525
      height: 28px;
@ -522,6 +530,25 @@ export default {
522 530
      margin: auto;
523 531
    }
524 532
  }
525
533
  .videoPlayer{
534
    width: 100%;
535
    padding: 1.5% 2.5% 0.5% 2.5%;
536
  }
537
  .videoPlayers{
538
    display: flex;
539
    width: 100%;
540
    height: 25%;
541
    padding: 0 2.5% 0.5% 2.5%;
542
    justify-content: space-around;
543
    .videoPlayer-sm{
544
      z-index:9999;
545
      cursor: pointer;
546
      width: 23%;
547
      height: 95%;
548
    }
549
  }
550
  .vjs-progress-control{
551
    visibility:hidden
552
  }
526 553
}
527 554
</style>