home.vue 10 KB

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