newSubVideoComponent.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="newSubVideoComponent">
  3. <p class="null-data-list-p" v-if="!dataList[0]">暂无数据</p>
  4. <div class="sub-video-max-big-box" v-if="dataList[0]">
  5. <div class="sub-video-big-box" v-for="(item,index) in dataList" :key="index">
  6. <div class="sub-video-box">
  7. <p class="sub-name-p">{{item.roomNum?item.subName+'('+item.roomNum+')':item.subName}}</p>
  8. <mpegts-video :videoProps="item.videoData" ref="mpegtsRef" ></mpegts-video>
  9. <!--<H5PlayerVideo class="sub-video-box" :videoProps="item.videoData"></H5PlayerVideo>-->
  10. </div>
  11. <div class="sensor-max-box">
  12. <div class="sensor-box" v-for="(minItem,minIndex) in item.sensorList" :key="minIndex">
  13. <div class="img-box">
  14. <svg-icon v-if="minItem.icon" class="svg-img" :icon-class="minItem.icon"/>
  15. </div>
  16. <div class="text-box">
  17. <p>{{minItem.deviceName}}</p>
  18. <p>{{minItem.deviceValue?minItem.deviceValue:'-'}}{{minItem.unit}}</p>
  19. </div>
  20. </div>
  21. <p class="null-sensor-p" v-if="!item.sensorList">该实验室未配置传感器</p>
  22. </div>
  23. </div>
  24. </div>
  25. <!--<fullH5PlayerVideo v-if="fullVideoType" :fullVideoProps="fullVideoProps"></fullH5PlayerVideo>-->
  26. </div>
  27. </template>
  28. <script>
  29. import H5PlayerVideo from '@/components/H5PlayerVideo/H5PlayerVideo.vue'
  30. import fullH5PlayerVideo from '@/components/fullH5PlayerVideo/fullH5PlayerVideo.vue'
  31. import mpegtsVideo from '@/components/mpegtsVideo/mpegtsVideo.vue'
  32. import {
  33. laboratorySubRelInfoSelectInfoAndSensor,
  34. iotCameraFindByCondition
  35. } from '@/api/index'
  36. export default {
  37. name: 'newSubVideoComponent',
  38. components: {
  39. H5PlayerVideo,
  40. fullH5PlayerVideo,
  41. mpegtsVideo,
  42. },
  43. data() {
  44. return {
  45. timer: null,//定时器
  46. dataList: [],
  47. //请求参数
  48. queryParams: {
  49. page: 1,
  50. pageSize: 2,
  51. deptId: !localStorage.getItem('deptId')?'':localStorage.getItem('deptId'),
  52. },
  53. total: 0,//总数
  54. videoList: [],
  55. //全屏视频参数
  56. fullVideoProps:{},
  57. fullVideoType:false,
  58. }
  59. },
  60. created() {
  61. },
  62. mounted() {
  63. this.initialize()
  64. this.timerPlay()
  65. },
  66. methods: {
  67. //父类方法-用于全屏窗口切换
  68. fullScreenWindowSwitch(data){
  69. let self = this;
  70. for(let i=0;i<self.$refs.mpegtsRef.length;i++){
  71. if(data.cameraIndexCode != self.$refs.mpegtsRef[i].videoData.cameraIndexCode){
  72. if(data.type){
  73. self.$refs.mpegtsRef[i].stopVideo();
  74. }else{
  75. self.$refs.mpegtsRef[i].playVideo();
  76. }
  77. }
  78. }
  79. },
  80. //初始化
  81. initialize() {
  82. let obj = JSON.parse(JSON.stringify(this.queryParams))
  83. if(!obj.deptId){
  84. obj.buildId = localStorage.getItem('buildId');
  85. }
  86. laboratorySubRelInfoSelectInfoAndSensor(obj).then((res) => {
  87. if (res.data.records[0]) {
  88. res.data.records.forEach((bigItem)=>{
  89. if(bigItem.sensorList){
  90. bigItem.sensorList.forEach((item)=>{
  91. item.icon = item.icon?localStorage.getItem('fileBrowseEnvironment')+item.icon:null;
  92. })
  93. }
  94. })
  95. this.$set(this, 'total', res.data.total)
  96. this.getSubVideo(res.data.records)
  97. } else {
  98. this.$set(this, 'dataList', [])
  99. }
  100. })
  101. },
  102. // 定时器
  103. timerPlay() {
  104. let self = this
  105. clearInterval(this.timer)
  106. this.timer = setInterval(function() {
  107. let num = self.accMul(self.queryParams.page,self.queryParams.pageSize);
  108. if(num<self.total){
  109. self.$set(self.queryParams,'page',self.queryParams.page+1);
  110. }else{
  111. self.$set(self.queryParams,'page',1);
  112. }
  113. self.laboratorySubRelInfoSelectInfoAndSensor();
  114. }, 1000 * 20)
  115. },
  116. laboratorySubRelInfoSelectInfoAndSensor() {
  117. laboratorySubRelInfoSelectInfoAndSensor(this.queryParams).then((res) => {
  118. if (res.data.records[0]) {
  119. this.getSubVideo(res.data.records)
  120. } else {
  121. this.$set(this, 'dataList', [])
  122. }
  123. })
  124. },
  125. getSubVideo(list) {
  126. this.$set(this,'videoList',[]);
  127. let sub1 = {}
  128. let sub2 = {}
  129. if (list[0]) {
  130. sub1 = {
  131. subId: list[0].subId,
  132. subName: list[0].subName,
  133. roomNum: list[0].roomNum,
  134. sensorList: list[0].sensorList,
  135. videoData:{
  136. width: 355, //(宽度:非必传-默认600)
  137. height: 200 //(高度:非必传-默认338)
  138. }
  139. }
  140. }
  141. if (list[1]) {
  142. sub2 = {
  143. subId: list[1].subId,
  144. subName: list[1].subName,
  145. roomNum: list[1].roomNum,
  146. sensorList: list[1].sensorList,
  147. videoData:{
  148. width: 355, //(宽度:非必传-默认600)
  149. height: 200 //(高度:非必传-默认338)
  150. }
  151. }
  152. }
  153. if (list[1]) {
  154. Promise.all([
  155. this.videoInitialize(sub1),
  156. this.videoInitialize(sub2)
  157. ]).then((result) => {
  158. this.$set(this, 'dataList', this.videoList)
  159. console.log('dataList2',this.dataList)
  160. }).catch((error) => {
  161. })
  162. } else {
  163. Promise.all([
  164. this.videoInitialize(sub1)
  165. ]).then((result) => {
  166. this.$set(this, 'dataList', this.videoList)
  167. console.log('dataList1',this.dataList)
  168. }).catch((error) => {
  169. })
  170. }
  171. },
  172. videoInitialize(data) {
  173. let obj = {
  174. page: '1',
  175. pageSize: '10',
  176. buildId: '',
  177. floorId: '',
  178. passageway: '',
  179. subIds: [data.subId],
  180. protocol: window.location.href.indexOf('https') !== -1 ? 'wss' : 'ws',
  181. streamType: 1,
  182. source: 1
  183. }
  184. iotCameraFindByCondition(obj).then(response => {
  185. if(response.data.records[0]){
  186. let newData = JSON.parse(JSON.stringify(data));
  187. newData.videoData.url = response.data.records[0].streamUrl;
  188. newData.videoData.cameraIndexCode = response.data.records[0].deviceNo;
  189. this.videoList.push(newData);
  190. }else{
  191. let newData = JSON.parse(JSON.stringify(data));
  192. newData.videoData.url = null;
  193. newData.videoData.cameraIndexCode = null;
  194. this.videoList.push(newData);
  195. }
  196. })
  197. },
  198. accMul(arg1, arg2) {
  199. var m = 0, s1 = arg1.toString(), s2 = arg2.toString()
  200. try {
  201. m += s1.split('.')[1].length
  202. } catch (e) {
  203. }
  204. try {
  205. m += s2.split('.')[1].length
  206. } catch (e) {
  207. }
  208. return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
  209. },
  210. //全屏开启-关闭轮播
  211. stopTime(cameraIndexCode){
  212. this.$set(this,'fullVideoProps',{cameraIndexCode:cameraIndexCode});
  213. this.$set(this,'fullVideoType',true);
  214. },
  215. //全屏关闭-开启轮播
  216. outFullScreen(){
  217. let self = this;
  218. this.$set(this,'fullVideoType',false);
  219. this.$set(this,'fullVideoProps',{});
  220. },
  221. },
  222. beforeDestroy() {
  223. clearInterval(this.timer)
  224. }
  225. }
  226. </script>
  227. <style scoped lang="scss">
  228. * {
  229. margin: 0;
  230. padding: 0;
  231. }
  232. .newSubVideoComponent {
  233. width: 680px;
  234. height: 500px;
  235. .sub-video-max-big-box {
  236. width: 680px;
  237. height: 500px;
  238. .sub-video-big-box:nth-child(2){
  239. margin-top:20px;
  240. }
  241. .sub-video-big-box {
  242. width: 680px;
  243. height: 230px;
  244. display: flex;
  245. .sub-video-box {
  246. width: 355px;
  247. height: 230px;
  248. .sub-name-p {
  249. height: 30px;
  250. line-height: 30px;
  251. font-size: 12px;
  252. color: #FFFFFF;
  253. padding-left: 10px;
  254. background-color: rgba(0, 0, 0, 0.6);
  255. margin-right: 1px;
  256. }
  257. .sub-video-box {
  258. width: 355px;
  259. height: 200px;
  260. }
  261. }
  262. .sensor-max-box {
  263. overflow: hidden;
  264. margin-left: 20px;
  265. .sensor-box {
  266. background-color: #073F55;
  267. height: 105px;
  268. width: 300px;
  269. margin-bottom: 20px;
  270. border-radius: 10px;
  271. display: flex;
  272. .img-box {
  273. width: 99px;
  274. height: 85px;
  275. margin: 10px 20px 0 19px;
  276. background: url("../assets/ZDimages/emergencyManagement/icon_yjsj_zc.png") no-repeat;
  277. background-size: 100%;
  278. .svg-img {
  279. display: block;
  280. width: 24px;
  281. height: 24px;
  282. margin: 37px 0 0 37px;
  283. color: #24D1F9;
  284. }
  285. }
  286. .text-box {
  287. p {
  288. color: #fff;
  289. font-size: 14px;
  290. line-height: 24px;
  291. height: 24px;
  292. overflow: hidden;
  293. }
  294. p:nth-child(1) {
  295. margin-top: 28px;
  296. }
  297. p:nth-child(2) {
  298. }
  299. }
  300. }
  301. .null-sensor-p{
  302. width:300px;
  303. text-align: center;
  304. color:#dedede;
  305. font-size:14px;
  306. line-height:230px;
  307. }
  308. }
  309. }
  310. }
  311. .null-data-list-p {
  312. line-height: 500px;
  313. text-align: center;
  314. width: 100%;
  315. color: #dedede;
  316. }
  317. }
  318. </style>