home.vue 11 KB

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