index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <el-row class="mainBox">
  3. <el-col v-for="(item,ind) in footerList" :key="ind">
  4. <!-- <img src="../../../assets/image-af/signal.png" alt="" class="signal"> -->
  5. <!-- <img src="../../../assets/image-af/electric.png" alt="" class="electric"> -->
  6. <span class="signal">{{item.signal}}</span>
  7. <span class="electric">{{item.battery}}</span>
  8. <span class="boxName">{{item.deviceName}}</span>
  9. <el-row class="contentInfo fontBox">
  10. <el-col v-html="item.status"></el-col>
  11. </el-row>
  12. </el-col>
  13. <el-col>
  14. <!-- <img src="../../../assets/image-af/test1.png" alt="" class="videoBox"> -->
  15. <video id="myVideo" class="video-js videoBox" controls preload="auto" data-setup='{}' style='width: 100%;height: 100%' v-if="resList[0]">
  16. <source id="source" :src="resList[0] && resList[0].url || ''" type="application/x-mpegURL"/>
  17. </video>
  18. <img src="../../../assets/image-af/red.png" alt="" class="redImage" v-else>
  19. </el-col>
  20. <el-col>
  21. <video id="myVideo2" class="video-js videoBox" controls preload="auto" data-setup='{}' style='width: 100%;height: 100%' v-if="resList[1]">
  22. <source id="source" :src="resList[1] && resList[1].url || ''" type="application/x-mpegURL"/>
  23. </video>
  24. <img src="../../../assets/image-af/red.png" alt="" class="redImage" v-else>
  25. </el-col>
  26. </el-row>
  27. </template>
  28. <script>
  29. import videojs from 'video.js'
  30. import 'video.js/dist/video-js.css'
  31. import 'videojs-contrib-hls'
  32. export default {
  33. props:['footerList'],
  34. data(){
  35. return{
  36. myVideo:null,
  37. myVideo2:null,
  38. resList:[]
  39. }
  40. },
  41. mounted(){
  42. this.getData()
  43. },
  44. methods:{
  45. videoPlay(){
  46. // videojs 简单使用
  47. if(this.resList[0]){
  48. this.myVideo = videojs('myVideo', {
  49. bigPlayButton: false,
  50. textTrackDisplay: false,
  51. posterImage: false,
  52. errorDisplay: false,
  53. })
  54. console.log(this.myVideo)
  55. this.myVideo.play()// 视频播放
  56. }
  57. if(this.resList[1]){
  58. this.myVideo2 = videojs('myVideo2', {
  59. bigPlayButton: false,
  60. textTrackDisplay: false,
  61. posterImage: false,
  62. errorDisplay: false,
  63. })
  64. this.myVideo2.play()// 视频播放
  65. }
  66. },
  67. async getData(){
  68. let res = await this.$axios.get('/AFTop/querySystemUrl?'+this.$qs.stringify({
  69. type: 1
  70. }))
  71. if(res.success){
  72. this.resList = res.data.slice(0,2)
  73. this.$nextTick(()=>{
  74. this.videoPlay()
  75. })
  76. }
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .mainBox{
  83. display: flex;
  84. justify-content: space-between;
  85. &>.el-col{
  86. width: 10.5%;
  87. height: 100%;
  88. background: url('../../../assets/image-af/bg2.png') no-repeat;
  89. background-size: 100% 100%;
  90. position: relative;
  91. font-size: 16px;
  92. display: flex;
  93. flex-direction: column;
  94. justify-content: center;
  95. align-items: center;
  96. .signal{
  97. position: absolute;
  98. left: 15px;
  99. top: 15px;
  100. width: 16px;
  101. height: 16px;
  102. }
  103. .electric{
  104. position: absolute;
  105. right: 15px;
  106. top: 15px;
  107. width: 23px;
  108. height: 14px;
  109. }
  110. .boxName{
  111. position: absolute;
  112. bottom: 10px;
  113. text-align: center;
  114. left: 0;
  115. right: 0;
  116. }
  117. .contentInfo{
  118. text-align: center;
  119. font-size: 22px;
  120. font-weight: 700;
  121. color: #24FF00;
  122. }
  123. .fontBox{
  124. font-size: 18px;
  125. }
  126. .videoBox{
  127. width: 100%;
  128. height: 100%;
  129. }
  130. .redImage{
  131. position: absolute;
  132. left: 0;
  133. right: 0;
  134. bottom: 0;
  135. top: 0;
  136. margin: auto;
  137. width: 100%;
  138. height: 100%;
  139. background: #ff000042;
  140. }
  141. }
  142. }
  143. </style>