home.vue 13 KB

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