important-area-focus.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <div class="important-area-focus">
  3. <div class="left">
  4. <template v-for="(item, index) in videoData">
  5. <div class="list-item" :class="{active: currentInfo.areaType === item.areaType}" @click="currentInfo = item">
  6. {{item.areaName}}
  7. </div>
  8. </template>
  9. </div>
  10. <div class="right">
  11. <!-- <template v-if="test.flvUrl">-->
  12. <!-- <div style="display: flex;">-->
  13. <!-- <FlvVideo :url="test.flvUrl"/>-->
  14. <!-- <FlvVideo :url="test.flvUrlProxy"/>-->
  15. <!-- </div>-->
  16. <!-- </template>-->
  17. <div class="right-title">{{ currentInfo.areaName }}</div>
  18. <div class="right-content">
  19. <!-- <FlvVideo class="flv-video" :url="`ws://10.110.31.81/odae-video/live/b5355c42-a313-4798-8d1b-4631b71286fa/1TMyt2IzM7UDBM_aq7bYkOdi-9GkCBoDSrZPidJ1JAA/rtmp.live.flv`"/>-->
  20. <template v-if="switchArea">
  21. <template v-for="(item, index) in currentInfo.viseoRecords?.filter((v, i) => i < 8)">
  22. <div class="video-item">
  23. <div class="video-item-title">{{item.name}}</div>
  24. <FlvVideo v-if="item.flvUrl" class="flv-video" :url="item.flvUrl"/>
  25. </div>
  26. </template>
  27. </template>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script lang="ts">
  33. import {
  34. defineComponent,
  35. ref,
  36. nextTick,
  37. onMounted,
  38. watch,
  39. computed,
  40. ComponentInternalInstance,
  41. reactive,
  42. toRefs,
  43. getCurrentInstance
  44. } from 'vue'
  45. import {useStore} from 'vuex'
  46. import axios from "axios";
  47. import {ElMessage, ElMessageBox} from "element-plus";
  48. import FlvVideo from "./flv-video.vue";
  49. export default defineComponent({
  50. name: 'App',
  51. components: {FlvVideo},
  52. setup() {
  53. const store = useStore()
  54. const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
  55. const state = reactive({
  56. videoData: [],
  57. secret: '035c73f7-bb6b-4889-a715-d9eb2d1925cc',
  58. currentInfo: {},
  59. switchArea: false,
  60. });
  61. // @ts-ignore
  62. const cC = window.cusConfig
  63. watch(() => state.videoData, (n) => {
  64. state.currentInfo = n?.[0] || {}
  65. })
  66. watch(() => state.currentInfo, (n: any) => {
  67. n?.viseoRecords.filter((v: any, i: number) => i < 8).forEach((v: any) => {
  68. getStream(v)
  69. })
  70. state.switchArea = false
  71. setTimeout(() => {
  72. state.switchArea = true
  73. }, 100)
  74. })
  75. const getStream = (obj: any) => {
  76. let url_1 = `/${store.state.app.apiProxy.tesApi}/index/api/addFFmpegSource?`
  77. const streamId = obj.hlsUrl.substring(obj.hlsUrl.indexOf('/live/') + 6)
  78. obj.flvUrl = `ws://10.110.31.81/odae-video/live/${streamId}/${cC.video.source}.live.flv`
  79. // const params = {
  80. // 'secret': state.secret,
  81. // 'src_url': `${obj.hlsUrl}/${cC.video.source}`,
  82. // 'dst_url': `rtmp://127.0.0.1/live/${streamId}`,
  83. // 'timeout_ms': 10000,
  84. // 'enable_hls': 0,
  85. // 'enable_mp4': 0
  86. // }
  87. // Object.entries(params).forEach(([k, v], i) => {
  88. // if (i > 0) {
  89. // url_1 += '&'
  90. // }
  91. // url_1 += `${k}=${v}`
  92. // })
  93. // axios.get(url_1).then(res => {
  94. // if (res.status === 200 && res.data?.code === 0 && res.data.data?.key) {
  95. // let url_2 = `/${store.state.app.apiProxy.tesApi}/index/api/getMediaList?`
  96. // const params = {
  97. // 'secret': state.secret,
  98. // 'stream': streamId,
  99. // }
  100. // Object.entries(params).forEach(([k, v], i) => {
  101. // if (i > 0) {
  102. // url_2 += '&'
  103. // }
  104. // url_2 += `${k}=${v}`
  105. // })
  106. // axios.get(url_2).then(res => {
  107. // if (res.status === 200 && res.data?.code === 0) {
  108. // obj.flvUrl = `ws://10.110.31.81/odae-video/live/${streamId}/${cC.video.source}.live.flv`
  109. // obj.flvUrlProxy = `ws://${location.host}/${store.state.app.apiProxy.tesApi}/live/${streamId}/${cC.video.source}.live.flv`
  110. // }
  111. // })
  112. // }
  113. // }).catch(() => {})
  114. }
  115. onMounted(() => {
  116. window.addEventListener("message", function (event) {
  117. const result = event.data;
  118. if (result.videoData) {
  119. state.videoData = result.videoData
  120. }
  121. });
  122. window.parent.postMessage({
  123. from: window.name,
  124. variable: "videoIframeLoading",
  125. value: true,
  126. }, "*")
  127. // const arr: any = []
  128. // state.videoData.forEach(p => {
  129. // p.viseoRecords.forEach(v => {
  130. // arr.push(v)
  131. // })
  132. // })
  133. // state.test = arr[0]
  134. // getStream(state.test)
  135. })
  136. return {
  137. ...toRefs(state),
  138. }
  139. }
  140. })
  141. </script>
  142. <style lang="scss" scoped>
  143. .important-area-focus {
  144. height: 360px;
  145. display: flex;
  146. line-height: 1;
  147. .left {
  148. width: 174px;
  149. height: 100%;
  150. margin-right: 10px;
  151. display: flex;
  152. flex-direction: column;
  153. overflow-y: auto;
  154. .list-item {
  155. width: 100%;
  156. min-height: 42px;
  157. padding: 10px 10px;
  158. box-sizing: border-box;
  159. cursor: pointer;
  160. background-image: url("./img/video_bg.png");
  161. background-repeat: no-repeat;
  162. background-size: 100% 100%;
  163. font-size: 20px;
  164. font-family: FZLanTingHeiS-DB-GB;
  165. font-weight: 400;
  166. color: #FFFFFF;
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. margin-top: 10px;
  171. &:first-child {
  172. margin-top: 0;
  173. }
  174. &.active {
  175. background-image: url("./img/video_bg_active.png");
  176. }
  177. }
  178. }
  179. .right {
  180. box-sizing: border-box;
  181. width: 960px;
  182. padding: 12px;
  183. height: 100%;
  184. border: 1px solid #3573FC;
  185. background: linear-gradient(90deg, rgba(0, 100, 241, 0.3) 0%, rgba(27, 36, 68, 0.3) 100%);
  186. display: flex;
  187. flex-direction: column;
  188. .right-title {
  189. box-sizing: border-box;
  190. padding-left: 14px;
  191. margin-top: 4px;
  192. width: 100%;
  193. border-bottom: 2px solid #062548;
  194. font-size: 24px;
  195. font-family: Adobe Heiti Std;
  196. font-weight: normal;
  197. color: #E2EBF1;
  198. padding-bottom: 15px;
  199. }
  200. .right-content {
  201. margin-top: 9px;
  202. display: grid;
  203. flex: 1;
  204. grid-template-columns: repeat(4, 1fr);
  205. column-gap: 7px;
  206. row-gap: 20px;
  207. .video-item {
  208. width: 222px;
  209. height: 128px;
  210. background: rgba(28, 45, 65, 0);
  211. border: 2px solid rgba(18, 87, 201, 0.4);
  212. border-radius: 4px;
  213. position: relative;
  214. .video-item-title {
  215. position: absolute;
  216. align-items: center;
  217. width: 100%;
  218. height: 24px;
  219. background: #000000;
  220. opacity: 0.8;
  221. border-radius: 2px;
  222. font-size: 12px;
  223. font-family: SimHei;
  224. font-weight: 400;
  225. color: #FEFEFE;
  226. padding: 0 6px;
  227. box-sizing: border-box;
  228. overflow: hidden;
  229. text-overflow: ellipsis;
  230. white-space: nowrap;
  231. line-height: 24px;
  232. z-index: 2;
  233. }
  234. .flv-video {
  235. width: 100%;
  236. height: 100%;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. </style>