videoStats.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="videoStats panel-box risk-warning">
  3. <div class="corner-deco tl"></div><div class="corner-deco tr"></div>
  4. <div class="corner-deco bl"></div><div class="corner-deco br"></div>
  5. <div class="panel-title">实验室视频监控</div>
  6. <div class="video-content">
  7. <webRTC v-if="webRtcType" class="video-for-min-box"></webRTC>
  8. <mpegts-video class="video-for-min-box" :videoProps="item" v-for="(item,index) in mpegtsList" :key="'mpegts_'+index"></mpegts-video>
  9. <videoForMod class="video-for-min-box" v-for="(item,index) in modList" :key="'video_'+index" :deviceNo="item.deviceNo"></videoForMod>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import { getVideoList,laboratoryLabScreenScreenConfigGet,iotDeviceList } from '@/api/index'
  15. import videoForMod from '@/components/videoForMod/videoForMod.vue'
  16. import mpegtsVideo from '@/components/mpegtsVideo/mpegtsVideo.vue'
  17. import webRTC from './webRTC.vue'
  18. export default {
  19. name: 'videoStats',
  20. components: { videoForMod,mpegtsVideo,webRTC },
  21. data () {
  22. return {
  23. width:470,
  24. height:280,
  25. modList:[],
  26. mpegtsList:[
  27. {
  28. width: 470, //(宽度:非必传-默认600)
  29. height: 280, //(高度:非必传-默认338)
  30. url: 'https://192.168.166.11/zlmedia/gpfas/286fe8bdb0ad41f89323eaf6bd5d9f39-9ac65e490f8b43caa060e83938f47e53-29.live.flv',
  31. cameraIndexCode: 'mpegtsa',
  32. },
  33. {
  34. width: 470, //(宽度:非必传-默认600)
  35. height: 280, //(高度:非必传-默认338)
  36. url: 'https://192.168.166.11/zlmedia/gpfas/286fe8bdb0ad41f89323eaf6bd5d9f39-9ac65e490f8b43caa060e83938f47e53-29.live.flv',
  37. cameraIndexCode: 'mpegtsb',
  38. },
  39. ],
  40. pollTimer:null,
  41. page:1,
  42. webRtcType:false,
  43. }
  44. },
  45. created(){
  46. },
  47. mounted(){
  48. this.laboratoryLabScreenScreenConfigGet();
  49. this.pollTimer = setInterval(this.laboratoryLabScreenScreenConfigGet, 5 * 60 * 1000)
  50. // this.getVideoData();
  51. },
  52. methods:{
  53. //指定视频
  54. async iotDeviceList(){
  55. let obj = {
  56. page: this.page,
  57. pageSize: 4,
  58. typeKey: "camera",
  59. orderBy:"subject_id desc"
  60. };
  61. const res = await iotDeviceList(obj)
  62. if (res.code === 200) {
  63. this.$set(this,'modList',res.data.records);
  64. if(res.data.current<(res.data.pages-1)){
  65. this.page++
  66. }else{
  67. this.$set(this,'page',1);
  68. }
  69. }
  70. },
  71. async laboratoryLabScreenScreenConfigGet(){
  72. try {
  73. const res = await laboratoryLabScreenScreenConfigGet({ screenType: 2 })
  74. if (res.code === 200) {
  75. this.$set(this,'modList',[]);
  76. if(res.data.effective){
  77. this.$set(this,'webRtcType',true);
  78. this.$set(this,'page',1);
  79. let list = [];
  80. for(let i=0;i<res.data.items.length;i++){
  81. if(i<1){
  82. list.push(res.data.items[i])
  83. }
  84. }
  85. this.$set(this,'modList',list);
  86. console.log('modList',this.modList)
  87. }else{
  88. this.$set(this,'webRtcType',false);
  89. this.iotDeviceList();
  90. }
  91. }
  92. } catch (e) {
  93. }
  94. },
  95. //刷新视屏
  96. getVideoData(data) {
  97. let obj = {
  98. page: 1,
  99. pageSize: 4,
  100. passageway: '',
  101. protocol: window.location.href.indexOf('https') !== -1 ? 'wss' : 'ws',
  102. streamType: 1,
  103. source: 4,
  104. subIds: data,
  105. };
  106. this.$set(this, 'videoQueryParams', obj);
  107. this.$nextTick(() => {
  108. this.videoInitialize()
  109. })
  110. },
  111. async videoInitialize() {
  112. let self = this;
  113. self.$set(self, 'videoType', false);
  114. self.$set(self, 'videoList', []);
  115. try {
  116. // const res = await getVideoList(this.videoQueryParams)
  117. // 假数据开始
  118. let res = {
  119. data: {
  120. total: 100,
  121. records: [
  122. {streamUrl: '1', deviceNo: '1'},
  123. {streamUrl: '2', deviceNo: '2'},
  124. {streamUrl: '3', deviceNo: '3'},
  125. {streamUrl: '4', deviceNo: '4'},
  126. ],
  127. }
  128. };
  129. // 假数据结束
  130. let list = [];
  131. for(let i=0;i<res.data.records.length;i++){
  132. list.push(
  133. {
  134. width: self.width, //(宽度:非必传-默认600)
  135. height: self.height, //(高度:非必传-默认338)
  136. url: res.data.records[i].streamUrl,
  137. cameraIndexCode: res.data.records[i].deviceNo,
  138. }
  139. )
  140. }
  141. this.$set(this,'videoList',list)
  142. this.$nextTick(()=>{
  143. setTimeout(function(){
  144. self.$set(self, 'videoType', true);
  145. },1000);
  146. })
  147. } catch (e) {
  148. console.error('VideoGrid:', e)
  149. }
  150. },
  151. },
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. .videoStats{
  156. }
  157. .risk-warning {
  158. display: flex;
  159. flex-direction: column;
  160. }
  161. .video-content{
  162. padding: 0;
  163. position: relative;
  164. z-index: 2;
  165. flex: 1;
  166. min-height: 0;
  167. /*.videoForMod:nth-child(2){*/
  168. /*margin-left:10px;*/
  169. /*}*/
  170. /*.videoForMod:nth-child(3){*/
  171. /*margin-top:5px;*/
  172. /*}*/
  173. /*.videoForMod:nth-child(4){*/
  174. /*margin-top:5px;*/
  175. /*margin-left:10px;*/
  176. /*}*/
  177. .video-for-min-box{
  178. display: inline-block!important;
  179. overflow: hidden!important;
  180. border-radius:4px!important;
  181. height:280px!important;
  182. width:470px!important;
  183. }
  184. .video-for-min-box:nth-child(1){
  185. margin:0 10px 0 0!important;
  186. }
  187. .video-for-min-box:nth-child(2){
  188. }
  189. .video-for-min-box:nth-child(3){
  190. margin:10px 10px 0 0!important;
  191. }
  192. .video-for-min-box:nth-child(4){
  193. /*margin:10px 0 0 0!important;*/
  194. }
  195. }
  196. </style>