home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="container">
  3. <div class="header">
  4. <img :src="headImg" alt="" />
  5. </div>
  6. <el-container>
  7. <Left></Left>
  8. <right></right>
  9. <div ref="linedomRef" style="width:1px;height:1px;position: absolute;z-index: 228;background:#ccc;">
  10. </div>
  11. </el-container>
  12. <div ref="popoverRef" id="popoverRef" class="modelInfo" >
  13. <div class="model-detail" >
  14. <div v-for="item in classDeviceInfo" >
  15. <div class="list">
  16. {{ item[0].value }}
  17. </div>
  18. <div v-for="item2 in item" class="listtitle">
  19. <span style="color: #fff;margin-left: 5px; font-weight: 700;padding-left: 8px; "> {{ item2.name }} :</span>
  20. <span v-if="item2.value!='在线'" style=" font-family: 100; margin-left: 5px;color: #ffffffeb;">{{ item2.value }}</span>
  21. <span v-else style=" font-family: 100; margin-left: 5px;color: #10C383;">{{ item2.value }}</span>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <!-- 视频播放弹框 -->
  27. <el-dialog class="videoDialog" v-model="videoDialog" :title="titleDialog" width="60%" align="center" top="4%">
  28. <videoPlay v-bind="videoData" @play="onPlay" />
  29. </el-dialog>
  30. </div>
  31. </template>
  32. <script>
  33. import { reactive, onMounted, ref, toRefs, onBeforeUnmount, getCurrentInstance, nextTick } from 'vue';
  34. import { ElScrollbar, ElPagination, ElDialog, ElCarousel, ElCarouselItem, ElMessage } from "element-plus";
  35. import "vue3-video-play/dist/style.css";
  36. import { addResponseEventListener } from "../webrtcVideo.js";
  37. import { videoPlay } from "vue3-video-play";
  38. import CircleProgress from './CircleProgress.vue';
  39. import Left from './left.vue'
  40. import Right from './right.vue'
  41. import Login from './Login.vue'
  42. import LeaderLine from "../../public/js/leaderline.js"
  43. import { getClassDetail } from '../request/api.js'
  44. import {
  45. callUIInteraction,
  46. } from "../webrtcVideo";
  47. import { getVideoUrl } from '../request/api';
  48. export default ({
  49. name: 'Histogram',
  50. components: { Login, Left, Right, ElScrollbar, ElPagination, ElDialog, videoPlay, ElCarousel, ElCarouselItem, CircleProgress },
  51. setup() {
  52. const titleDialog = ref("")
  53. // 视频数据
  54. const videoData = reactive({
  55. width: "100%", //播放器高度
  56. height: "100%", //播放器高度
  57. color: "red", //主题色
  58. title: "互动教室", //视频名称
  59. // src: "https://cdn.jsdelivr.net/gh/xdlumia/files/video-play/IronMan.mp4", //视频源
  60. type: 'm3u8',
  61. src: '',
  62. muted: false, //静音
  63. webFullScreen: false,
  64. // speedRate: ["0.75", "1.0", "1.25", "1.5", "2.0"], //播放倍速
  65. autoPlay: false, //自动播放
  66. loop: false, //循环播放
  67. mirror: false, //镜像画面
  68. ligthOff: false, //关灯模式
  69. volume: 0.3, //默认音量大小
  70. control: true, //是否显示控制
  71. currentTime: 0,//跳转到固定播放时间
  72. controlBtns: [
  73. "audioTrack",
  74. "quality",
  75. "speedRate",
  76. "volume",
  77. "setting",
  78. "pip",
  79. "pageFullScreen",
  80. "fullScreen",
  81. ], //显示所有按钮,
  82. });
  83. // 物联设备类型统计
  84. const interDevice = ref([])
  85. // 位置弹框
  86. let centerDialogVisible = ref(false)
  87. // 获取点击点数据
  88. let clickData = reactive({})
  89. const triggerRef = ref({
  90. getBoundingClientRect() {
  91. // console.log("positon----方法返回元素的大小及其相对于视口的位置", position.value)
  92. return position.value
  93. },
  94. })
  95. const position = ref({
  96. top: 0,
  97. left: 0,
  98. bottom: 0,
  99. right: 0,
  100. })
  101. // 点击某个模型跟随移动
  102. const mousemoveHandler = (x, y) => {
  103. position.value = DOMRect.fromRect({
  104. width: 0,
  105. height: 0,
  106. x: x,
  107. y: y,
  108. })
  109. }
  110. //视频播放弹框
  111. const videoDialog = ref(false)
  112. // 播放视频
  113. const lookVideo = function () {
  114. videoDialog.value = true;
  115. console.log("点击了播放视频", 12312312)
  116. }
  117. // 播放视频
  118. const onPlay = function () {
  119. console.log("播放视频")
  120. }
  121. const linedomRef = ref(null)
  122. let lineContainer = ref(null)
  123. const popoverRef = ref(null)
  124. const lineStyleOption = ref({
  125. startPlug: 'disc',
  126. endPlug: 'disc',
  127. dash: true,
  128. color: '#2AC367',
  129. startPlugColor: '#fff',
  130. startPlugOutlineColor: '#2AC367',
  131. endPlugColor: '#fff', // translucent
  132. endPlugOutlineColor: '#2AC367',
  133. size: 3,
  134. startPlugSize: 1.5,
  135. startPlugOutlineSize: 2,
  136. endPlugSize: 1.5,
  137. endPlugOutlineSize: 2
  138. })
  139. const classDeviceInfo = ref([])
  140. const classDataLoaded = ref(false)
  141. // const classDevice = async function (deviceCode) {
  142. // let res = await getClassDetail(deviceCode)
  143. // console.log("获取到了当前点击物体得详情", res)
  144. // classDeviceInfo.value = res.data;
  145. // classDataLoaded.value = true
  146. // }
  147. const clickData1 = ref({})
  148. const mouseClick = function (e) {
  149. // console.log("屏幕点击位置看", e)
  150. clickData1.value.x = e.clientX;
  151. clickData1.value.y = e.clientY;
  152. }
  153. const handleResponseFunction = (data) => {
  154. console.log("从UE返回过来的值", data)
  155. if (data == "{isrotate}") {
  156. // console.log("旋转场景了", lineContainer, lineContainer.value);
  157. if (lineContainer.value) {
  158. lineContainer.value.remove()
  159. lineContainer.value = null
  160. }
  161. popoverRef.value.style.display = "none"
  162. return
  163. }
  164. let json = eval("(" + data + ")");//转对象
  165. console.log("clickData---点击的数据", json)
  166. if (json.url) {
  167. videoDialog.value = true;
  168. titleDialog.value = json.name
  169. getVideoUrl({ "rtsp": json.url }).then(res => {
  170. videoData.src = res.data.httpFlv;
  171. console.log("32424", videoData.src)
  172. })
  173. return
  174. }
  175. clickData.value = json;
  176. if (json.deviceCode) {
  177. console.log('sadasd',json.deviceCode);
  178. let replacedStr = json.deviceCode.replace("/", "A");
  179. getClassDetail(replacedStr).then(res => {
  180. console.log('sad21312',res);
  181. classDeviceInfo.value = res.data;
  182. console.log('asd2121',classDeviceInfo.value);
  183. // classDeviceInfo.value.map(i => {
  184. // if (i.value == "在线") {
  185. // i.online = true
  186. // }
  187. // if (i.value == "离线") {
  188. // i.online = false
  189. // }
  190. // })
  191. console.log("json.y ", json,);
  192. linedomRef.value.style.top = (clickData.value.y) + "px";
  193. linedomRef.value.style.left = (clickData.value.x) + "px";
  194. console.log("可以开始移动")
  195. console.log("看一下---小圆点的值--top", linedomRef.value.style.top)
  196. console.log("看一下---小圆点的值--left", linedomRef.value.style.left)
  197. // 弹出框位置
  198. popoverRef.value.style.display = "block"
  199. switch (json.direction) {
  200. case "Left":
  201. popoverRef.value.style.top = json.y - 30 + 'px'
  202. popoverRef.value.style.left = json.x - 320 + 'px'
  203. break;
  204. case "Up":
  205. popoverRef.value.style.top = (json.y - 300) + 'px'
  206. popoverRef.value.style.left = (json.x - 120) + 'px'
  207. break;
  208. case "Right":
  209. popoverRef.value.style.top = (Number(json.y)) -100+ 'px'
  210. popoverRef.value.style.left = Number(json.x) + 100 + 'px'
  211. break;
  212. case "Down":
  213. popoverRef.value.style.top = (Number(json.y) + 100) + 'px'
  214. popoverRef.value.style.left = Number(json.x) + 'px'
  215. break;
  216. default:
  217. popoverRef.value.style.top = json.y - 60 + 'px'
  218. popoverRef.value.style.left = json.x + 'px'
  219. break;
  220. }
  221. if (lineContainer.value) {
  222. lineContainer.value.remove()
  223. }
  224. lineContainer.value = new LeaderLine(linedomRef.value, popoverRef.value, lineStyleOption.value)
  225. lineContainer.value.show('draw', {
  226. duration: 100, //持续时长
  227. timing: 'ease-in' // 动画函数
  228. })
  229. lineContainer.value.endPlugOutline = true;
  230. lineContainer.value.startPlugOutline = true;
  231. lineContainer.value.position();
  232. })
  233. }
  234. }
  235. const windowSize = function () {
  236. // console.log("监听一下窗口是不是改了--click", lineContainer);
  237. callUIInteraction("windowSize")
  238. }
  239. onMounted(() => {
  240. addResponseEventListener("444", handleResponseFunction);
  241. window.addEventListener('resize', windowSize);
  242. // window.addEventListener('click', windowSize);
  243. // addResponseEventListener("widowSizeChange", windoChangeFunction);
  244. })
  245. const headImg = ref('./img/head.png')
  246. return {
  247. centerDialogVisible,
  248. interDevice,
  249. clickData,
  250. triggerRef,
  251. videoData,
  252. onPlay,
  253. videoDialog,
  254. lookVideo,
  255. linedomRef,
  256. popoverRef,
  257. lineContainer,
  258. classDeviceInfo,
  259. mouseClick,
  260. headImg,
  261. titleDialog
  262. }
  263. },
  264. })
  265. </script>
  266. <style scoped lang="scss">
  267. @import '../assets/css/home.scss';
  268. </style>