index.tsx 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163
  1. import {
  2. defineComponent,
  3. onMounted,
  4. reactive,
  5. onUnmounted,
  6. ref,
  7. Transition,
  8. computed
  9. } from 'vue';
  10. import styles from './index.module.less';
  11. import 'plyr/dist/plyr.css';
  12. import MusicScore from './component/musicScore';
  13. import iconMenu from './image/icon-menu.png';
  14. import iconUp from './image/icon-up.png';
  15. import iconDown from './image/icon-down.png';
  16. import iconNote from './image/icon-note.png';
  17. import iconWhiteboard from './image/icon-whiteboard.png';
  18. import iconAssignHomework from './image/icon-assignHomework.png';
  19. import iconOverPreivew from './image/icon-over-preview.png';
  20. import { Vue3Lottie } from 'vue3-lottie';
  21. import playLoadData from './datas/data.json';
  22. import Moveable from 'moveable';
  23. import VideoPlay from './component/video-play';
  24. import {
  25. useMessage,
  26. NDrawer,
  27. NDrawerContent,
  28. NModal,
  29. NSpace,
  30. NButton,
  31. NTooltip,
  32. NPopover,
  33. NImage
  34. } from 'naive-ui';
  35. import CardType from '@/components/card-type';
  36. import Pen from './component/tools/pen';
  37. import AudioPay from './component/audio-pay';
  38. import TrainSettings from './model/train-settings';
  39. import { useRoute } from 'vue-router';
  40. import { lessonPreTrainingPage, queryCourseware } from '../prepare-lessons/api';
  41. import Attentguide from '@/custom-plugins/guide-page/attent-guide';
  42. import { vaildUrl } from '/src/utils/urlUtils';
  43. import TimerMeter from '/src/components/timerMeter';
  44. import toneImage from '/src/components/layout/images/toneImage.png';
  45. import toolbox from '/src/components/layout/images/toolbox.png';
  46. import setTimeIcon from '/src/components/layout/images/setTimeIcon.png';
  47. import beatIcon from '/src/components/layout/images/beatIcon.png';
  48. import toneIcon from '/src/components/layout/images/toneIcon.png';
  49. import { px2vw } from '/src/utils';
  50. import PlaceholderTone from '/src/components/layout/modals/placeholderTone';
  51. import { state } from '/src/state';
  52. export type ToolType = 'init' | 'pen' | 'whiteboard';
  53. export type ToolItem = {
  54. type: ToolType;
  55. name: string;
  56. icon: string;
  57. };
  58. export default defineComponent({
  59. name: 'CoursewarePlay',
  60. props: {
  61. type: {
  62. type: String,
  63. default: ''
  64. },
  65. subjectId: {
  66. type: [String, Number],
  67. default: ''
  68. },
  69. detailId: {
  70. type: String,
  71. default: ''
  72. },
  73. classGroupId: {
  74. type: String,
  75. default: ''
  76. }
  77. },
  78. emits: ['close'],
  79. setup(props, { emit }) {
  80. const message = useMessage();
  81. const route = useRoute();
  82. /** 设置播放容器 16:9 */
  83. const parentContainer = reactive({
  84. width: '100vw'
  85. });
  86. const setContainer = () => {
  87. const min = Math.min(screen.width, screen.height);
  88. const max = Math.max(screen.width, screen.height);
  89. const width = min * (16 / 9);
  90. if (width > max) {
  91. parentContainer.width = '100vw';
  92. return;
  93. } else {
  94. parentContainer.width = width + 'px';
  95. }
  96. };
  97. const handleInit = (type = 0) => {
  98. //设置容器16:9
  99. // setContainer();
  100. };
  101. handleInit();
  102. onUnmounted(() => {
  103. handleInit(1);
  104. });
  105. const data = reactive({
  106. type: '' as '' | 'preview' | 'class', // 预览类型
  107. subjectId: '' as any, // 声部编号
  108. detailId: '' as any, // 编号 - 章节编号
  109. classGroupId: '' as any, // 上课时需要 班级编号
  110. // detail: null,
  111. knowledgePointList: [] as any,
  112. itemList: [] as any,
  113. // showHead: true,
  114. // isCourse: false,
  115. // isRecordPlay: false,
  116. videoRefs: {} as any[],
  117. audioRefs: {} as any[],
  118. modelAttendStatus: false, // 布置作业提示弹窗
  119. modalAttendMessage: '本节课未设置课后训练,是否继续?',
  120. modelTrainStatus: false, // 训练设置
  121. homeworkStatus: true // 布置作业完成时
  122. });
  123. const activeData = reactive({
  124. // isAutoPlay: false, // 是否自动播放
  125. nowTime: 0,
  126. model: true, // 遮罩
  127. isAnimation: true, // 是否动画
  128. // videoBtns: true, // 视频
  129. // currentTime: 0,
  130. // duration: 0,
  131. timer: null as any,
  132. item: null as any
  133. });
  134. const showGuide = ref(false);
  135. const getDetail = async () => {
  136. try {
  137. const res = await queryCourseware({
  138. coursewareDetailKnowledgeId: data.detailId,
  139. subjectId: data.subjectId,
  140. pag: 1,
  141. rows: 99
  142. });
  143. const tempRows = res.data.rows || [];
  144. const temp: any = [];
  145. tempRows.forEach((row: any) => {
  146. if (!row.removeFlag) {
  147. temp.push({
  148. id: row.id,
  149. materialId: row.materialId,
  150. coverImg: row.coverImg,
  151. type: row.materialType,
  152. title: row.materialName,
  153. isCollect: !!row.favoriteFlag,
  154. isSelected: row.source === 'PLATFORM' ? true : false,
  155. content: row.content
  156. });
  157. }
  158. });
  159. data.knowledgePointList = temp;
  160. data.itemList = data.knowledgePointList.map((m: any) => {
  161. return {
  162. ...m,
  163. iframeRef: null,
  164. videoEle: null,
  165. audioEle: null,
  166. autoPlay: false, //加载完成是否自动播放
  167. isprepare: false, // 视频是否加载完成
  168. isRender: false // 是否渲染了
  169. };
  170. });
  171. setTimeout(() => {
  172. showGuide.value = true;
  173. }, 500);
  174. } catch {
  175. //
  176. }
  177. };
  178. const directionType = ref('left');
  179. const showModalBeat = ref(false);
  180. const showModalTone = ref(false);
  181. const showModalTime = ref(false);
  182. const isDragIng = ref(false);
  183. const initMoveable = async () => {
  184. if (document.querySelector('.wrap')) {
  185. const moveable = new Moveable(document.querySelector('.wrap') as any, {
  186. target: document.querySelector('#moveNPopover') as any,
  187. // If the container is null, the position is fixed. (default: parentElement(document.body))
  188. container: document.querySelector('.wrap') as any,
  189. // snappable: true,
  190. // bounds: {"left":100,"top":100,"right":100,"bottom":100},
  191. draggable: true,
  192. resizable: false,
  193. scalable: false,
  194. rotatable: false,
  195. warpable: false,
  196. pinchable: false, // ["resizable", "scalable", "rotatable"]
  197. origin: false,
  198. keepRatio: false,
  199. // Resize, Scale Events at edges.
  200. edge: false,
  201. throttleDrag: 0,
  202. throttleResize: 0,
  203. throttleScale: 0,
  204. throttleRotate: 0
  205. });
  206. moveable
  207. // .on('dragStart', ({ target, clientX, clientY }) => {
  208. // console.log('dragStart');
  209. // })
  210. .on(
  211. 'drag',
  212. ({
  213. target,
  214. // transform,
  215. left,
  216. top,
  217. right,
  218. bottom
  219. // beforeDelta,
  220. // beforeDist,
  221. // delta,
  222. // dist,
  223. // clientX,
  224. // clientY
  225. }) => {
  226. isDragIng.value = true;
  227. const subdEl = document.getElementById(
  228. `moveNPopover`
  229. ) as HTMLDivElement;
  230. // console.log(subdEl, "subdEl", "drag");
  231. const subdElStyle = getComputedStyle(subdEl, null);
  232. const RectInfo = {
  233. left: Number(subdElStyle.left.replace('px', '')),
  234. top: Number(subdElStyle.top.replace('px', '')),
  235. width: Number(subdElStyle.width.replace('px', '')),
  236. height: Number(subdElStyle.height.replace('px', ''))
  237. };
  238. const mainWidth =
  239. parseInt(
  240. window.getComputedStyle(
  241. document.querySelector('.wrap') as Element
  242. ).width
  243. ) - RectInfo.width;
  244. const mainHeight =
  245. parseInt(
  246. window.getComputedStyle(
  247. document.querySelector('.wrap') as Element
  248. ).height
  249. ) - RectInfo.height;
  250. if (left < 0) {
  251. left = 2;
  252. }
  253. if (top < 0) {
  254. top = 2;
  255. }
  256. if (right < 0) {
  257. right = 2;
  258. }
  259. if (bottom < 0) {
  260. bottom = 2;
  261. }
  262. if (left > mainWidth - 2) {
  263. left = mainWidth - 2;
  264. }
  265. if (top > mainHeight - 2) {
  266. top = mainHeight - 2;
  267. }
  268. target!.style.left = `${left}px`;
  269. target!.style.top = `${top}px`;
  270. }
  271. )
  272. .on(
  273. 'dragEnd',
  274. async ({
  275. // target, isDrag,
  276. clientX
  277. // clientY
  278. }) => {
  279. if (document.body.clientWidth / 2 - clientX > 0) {
  280. // 往左出
  281. directionType.value = 'right';
  282. } else {
  283. // 往又出
  284. directionType.value = 'left';
  285. }
  286. isDragIng.value = false;
  287. }
  288. );
  289. }
  290. };
  291. // ifram事件处理
  292. const iframeHandle = (ev: MessageEvent) => {
  293. if (ev.data?.api === 'headerTogge') {
  294. activeData.model =
  295. ev.data.show || (ev.data.playState == 'play' ? false : true);
  296. }
  297. };
  298. onMounted(() => {
  299. const query = route.query;
  300. // 先取参数,
  301. data.type = props.type || (query.type as any);
  302. data.subjectId = props.subjectId || query.subjectId;
  303. data.detailId = props.detailId || query.detailId;
  304. data.classGroupId = props.classGroupId || query.classGroupId;
  305. initMoveable();
  306. window.addEventListener('message', iframeHandle);
  307. getDetail();
  308. });
  309. const onFullScreen = () => {
  310. if (data.type === 'preview') {
  311. const el: any = document.querySelector('#app');
  312. if (el.mozRequestFullScreen) {
  313. el.mozRequestFullScreen();
  314. } else if (el.webkitRequestFullscreen) {
  315. el.webkitRequestFullscreen();
  316. } else if (el.requestFullScreen) {
  317. el.requestFullscreen();
  318. }
  319. }
  320. };
  321. const popupData = reactive({
  322. open: false,
  323. activeIndex: 0,
  324. toolOpen: false // 工具弹窗控制
  325. });
  326. const activeName = computed(() => {
  327. let name = '';
  328. data.knowledgePointList.forEach((item: any, index: number) => {
  329. if (popupData.activeIndex === index) {
  330. name = item.title;
  331. }
  332. });
  333. return name;
  334. });
  335. /**停止所有的播放 */
  336. const handleStop = () => {
  337. for (let i = 0; i < data.itemList.length; i++) {
  338. const activeItem = data.itemList[i];
  339. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  340. activeItem.videoEle.currentTime(0);
  341. activeItem.videoEle.pause();
  342. }
  343. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  344. activeItem.audioEle.stop();
  345. }
  346. // console.log('🚀 ~ activeItem:', activeItem)
  347. // 停止曲谱的播放
  348. if (activeItem.type === 'MUSIC') {
  349. activeItem.iframeRef?.contentWindow?.postMessage(
  350. { api: 'setPlayState' },
  351. '*'
  352. );
  353. }
  354. }
  355. };
  356. // 切换素材
  357. const toggleMaterial = (itemActive: any) => {
  358. const index = data.itemList.findIndex((n: any) => n.id == itemActive);
  359. if (index > -1) {
  360. handleSwipeChange(index);
  361. }
  362. };
  363. /** 延迟收起模态框 */
  364. const setModelOpen = () => {
  365. clearTimeout(activeData.timer);
  366. message.destroyAll();
  367. activeData.timer = setTimeout(() => {
  368. activeData.model = false;
  369. Object.values(data.videoRefs).map((n: any) =>
  370. n.toggleHideControl(false)
  371. );
  372. Object.values(data.audioRefs).map((n: any) =>
  373. n.toggleHideControl(false)
  374. );
  375. }, 4000);
  376. };
  377. /** 立即收起所有的模态框 */
  378. const clearModel = () => {
  379. clearTimeout(activeData.timer);
  380. message.destroyAll();
  381. activeData.model = false;
  382. Object.values(data.videoRefs).map((n: any) =>
  383. n?.toggleHideControl(false)
  384. );
  385. Object.values(data.audioRefs).map((n: any) =>
  386. n?.toggleHideControl(false)
  387. );
  388. };
  389. const toggleModel = (type = true) => {
  390. activeData.model = type;
  391. Object.values(data.videoRefs).map((n: any) => n?.toggleHideControl(type));
  392. Object.values(data.audioRefs).map((n: any) => n?.toggleHideControl(type));
  393. };
  394. // 双击
  395. const handleDbClick = (item: any) => {
  396. if (item && item.type === 'VIDEO') {
  397. const videoEle: HTMLVideoElement = item.videoEle;
  398. if (videoEle) {
  399. if (videoEle.paused) {
  400. message.destroyAll();
  401. videoEle.play();
  402. } else {
  403. message.warning('已暂停');
  404. videoEle.pause();
  405. }
  406. }
  407. }
  408. };
  409. // 切换播放
  410. // const togglePlay = (m: any, isPlay: boolean) => {
  411. // if (isPlay) {
  412. // m.videoEle?.play();
  413. // } else {
  414. // m.videoEle?.pause();
  415. // }
  416. // };
  417. // const showIndex = ref(-4);
  418. const effectIndex = ref(3);
  419. const effects = [
  420. {
  421. prev: {
  422. transform: 'translate3d(0, 0, -800px) rotateX(180deg)'
  423. },
  424. next: {
  425. transform: 'translate3d(0, 0, -800px) rotateX(-180deg)'
  426. }
  427. },
  428. {
  429. prev: {
  430. transform: 'translate3d(-100%, 0, -800px)'
  431. },
  432. next: {
  433. transform: 'translate3d(100%, 0, -800px)'
  434. }
  435. },
  436. {
  437. prev: {
  438. transform: 'translate3d(-50%, 0, -800px) rotateY(80deg)'
  439. },
  440. next: {
  441. transform: 'translate3d(50%, 0, -800px) rotateY(-80deg)'
  442. }
  443. },
  444. {
  445. prev: {
  446. transform: 'translate3d(-100%, 0, -800px) rotateY(-120deg)'
  447. },
  448. next: {
  449. transform: 'translate3d(100%, 0, -800px) rotateY(120deg)'
  450. }
  451. },
  452. // 风车4
  453. {
  454. prev: {
  455. transform: 'translate3d(-50%, 50%, -800px) rotateZ(-14deg)',
  456. opacity: 0
  457. },
  458. next: {
  459. transform: 'translate3d(50%, 50%, -800px) rotateZ(14deg)',
  460. opacity: 0
  461. }
  462. },
  463. // 翻页5
  464. {
  465. prev: {
  466. transform: 'translateZ(-800px) rotate3d(0, -1, 0, 90deg)',
  467. opacity: 0
  468. },
  469. next: {
  470. transform: 'translateZ(-800px) rotate3d(0, 1, 0, 90deg)',
  471. opacity: 0
  472. },
  473. current: { transitionDelay: '700ms' }
  474. }
  475. ];
  476. const acitveTimer = ref();
  477. // 轮播切换
  478. const handleSwipeChange = (index: number) => {
  479. // 如果是当前正在播放 或者是视频最后一个
  480. if (popupData.activeIndex == index) return;
  481. handleStop();
  482. clearTimeout(acitveTimer.value);
  483. checkedAnimation(popupData.activeIndex, index);
  484. popupData.activeIndex = index;
  485. acitveTimer.value = setTimeout(
  486. () => {
  487. const item = data.itemList[index];
  488. if (item) {
  489. if (item.type == 'MUSIC') {
  490. activeData.model = true;
  491. }
  492. if (item.type === 'SONG') {
  493. // 自动播放下一个音频
  494. clearTimeout(activeData.timer);
  495. message.destroyAll();
  496. // item.autoPlay = false;
  497. // nextTick(() => {
  498. // item.audioEle?.onPlay();
  499. // });
  500. }
  501. if (item.type === 'VIDEO') {
  502. // 自动播放下一个视频
  503. clearTimeout(activeData.timer);
  504. message.destroyAll();
  505. // item.autoPlay = false;
  506. // nextTick(() => {
  507. // item.videoEle?.play();
  508. // });
  509. }
  510. }
  511. // requestAnimationFrame(() => {
  512. // const _effectIndex = effectIndex.value + 1;
  513. // effectIndex.value =
  514. // _effectIndex >= effects.length - 1 ? 0 : _effectIndex;
  515. // });
  516. },
  517. activeData.isAnimation ? 800 : 0
  518. );
  519. };
  520. /** 是否有转场动画 */
  521. const checkedAnimation = (index: number, nextIndex?: number) => {
  522. const item = data.itemList[index];
  523. const nextItem = data.itemList[nextIndex!];
  524. if (nextItem) {
  525. if (nextItem.knowledgePointId != item.knowledgePointId) {
  526. activeData.isAnimation = true;
  527. return;
  528. }
  529. const videoEle = item.videoEle;
  530. const nextVideo = nextItem.videoEle;
  531. if (videoEle && videoEle.duration < 8 && index < nextIndex!) {
  532. activeData.isAnimation = false;
  533. } else if (nextVideo && nextVideo.duration < 8 && index > nextIndex!) {
  534. activeData.isAnimation = false;
  535. } else {
  536. activeData.isAnimation = true;
  537. }
  538. } else {
  539. activeData.isAnimation = item?.adviseStudyTimeSecond < 8 ? false : true;
  540. }
  541. };
  542. // 上一个知识点, 下一个知识点
  543. const handlePreAndNext = (type: string) => {
  544. if (type === 'up') {
  545. handleSwipeChange(popupData.activeIndex - 1);
  546. } else {
  547. handleSwipeChange(popupData.activeIndex + 1);
  548. }
  549. };
  550. /** 弹窗关闭 */
  551. const handleClosePopup = () => {
  552. const item = data.itemList[popupData.activeIndex];
  553. if (item?.type == 'VIDEO' && !item.videoEle?.paused) {
  554. setModelOpen();
  555. }
  556. if (item?.type == 'SONG' && !item.audioEle?.paused) {
  557. setModelOpen();
  558. }
  559. };
  560. // 监听页面键盘事件 - 上下切换
  561. document.body.addEventListener('keyup', (e: KeyboardEvent) => {
  562. // console.log(e, 'e');
  563. if (e.code === 'ArrowUp') {
  564. if (popupData.activeIndex === 0) return;
  565. handlePreAndNext('up');
  566. } else if (e.code === 'ArrowDown') {
  567. if (popupData.activeIndex === data.itemList.length - 1) return;
  568. handlePreAndNext('down');
  569. }
  570. // else if (e.code === 'Space') {
  571. // handleStop();
  572. // }
  573. });
  574. /** 教学数据 */
  575. const studyData = reactive({
  576. type: '' as ToolType,
  577. penShow: false,
  578. whiteboardShow: false
  579. });
  580. /** 打开教学工具 */
  581. const openStudyTool = (item: ToolItem) => {
  582. const activeItem = data.itemList[popupData.activeIndex];
  583. // 暂停视频和曲谱的播放
  584. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  585. activeItem.videoEle.pause();
  586. }
  587. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  588. activeItem.audioEle.stop();
  589. }
  590. if (activeItem.type === 'MUSIC') {
  591. activeItem.iframeRef?.contentWindow?.postMessage(
  592. { api: 'setPlayState' },
  593. '*'
  594. );
  595. }
  596. clearModel();
  597. popupData.toolOpen = false;
  598. studyData.type = item.type;
  599. switch (item.type) {
  600. case 'pen':
  601. studyData.penShow = true;
  602. break;
  603. case 'whiteboard':
  604. studyData.whiteboardShow = true;
  605. }
  606. };
  607. /** 关闭教学工具 */
  608. const closeStudyTool = () => {
  609. studyData.type = 'init';
  610. toggleModel();
  611. };
  612. const startShowModal = (val: 'setTimeIcon' | 'beatIcon' | 'toneIcon') => {
  613. if (val == 'setTimeIcon') {
  614. showModalTime.value = true;
  615. }
  616. if (val == 'beatIcon') {
  617. showModalBeat.value = true;
  618. }
  619. if (val == 'toneIcon') {
  620. showModalTone.value = true;
  621. }
  622. };
  623. return () => (
  624. <div id="playContent" class={[styles.playContent, 'wrap']}>
  625. <div
  626. onClick={() => {
  627. clearTimeout(activeData.timer);
  628. activeData.model = !activeData.model;
  629. Object.values(data.videoRefs).map((n: any) =>
  630. n.toggleHideControl(activeData.model)
  631. );
  632. Object.values(data.audioRefs).map((n: any) =>
  633. n.toggleHideControl(activeData.model)
  634. );
  635. }}>
  636. <div
  637. class={styles.coursewarePlay}
  638. style={{ width: parentContainer.width }}
  639. onClick={(e: Event) => {
  640. e.stopPropagation();
  641. setModelOpen();
  642. }}>
  643. <div class={styles.wraps}>
  644. {data.itemList.map((m: any, mIndex: number) => {
  645. const isRender =
  646. m.isRender || Math.abs(popupData.activeIndex - mIndex) < 2;
  647. const isEmtry = Math.abs(popupData.activeIndex - mIndex) > 4;
  648. if (isRender) {
  649. m.isRender = true;
  650. }
  651. return isRender ? (
  652. <div
  653. key={'index' + mIndex}
  654. class={[
  655. styles.itemDiv,
  656. popupData.activeIndex === mIndex && styles.itemActive,
  657. activeData.isAnimation && styles.acitveAnimation,
  658. Math.abs(popupData.activeIndex - mIndex) < 2
  659. ? styles.show
  660. : styles.hide
  661. ]}
  662. style={
  663. mIndex < popupData.activeIndex
  664. ? effects[effectIndex.value].prev
  665. : mIndex > popupData.activeIndex
  666. ? effects[effectIndex.value].next
  667. : {}
  668. }
  669. onClick={(e: Event) => {
  670. e.stopPropagation();
  671. clearTimeout(activeData.timer);
  672. if (Date.now() - activeData.nowTime < 300) {
  673. handleDbClick(m);
  674. return;
  675. }
  676. activeData.nowTime = Date.now();
  677. activeData.timer = setTimeout(() => {
  678. activeData.model = !activeData.model;
  679. Object.values(data.videoRefs).map((n: any) =>
  680. n.toggleHideControl(activeData.model)
  681. );
  682. Object.values(data.audioRefs).map((n: any) =>
  683. n.toggleHideControl(activeData.model)
  684. );
  685. if (activeData.model) {
  686. setModelOpen();
  687. }
  688. }, 300);
  689. }}>
  690. {m.type === 'VIDEO' ? (
  691. <>
  692. <VideoPlay
  693. ref={(v: any) => (data.videoRefs[mIndex] = v)}
  694. item={m}
  695. isEmtry={isEmtry}
  696. onLoadedmetadata={(videoItem: any) => {
  697. m.videoEle = videoItem;
  698. m.isprepare = true;
  699. }}
  700. onTogglePlay={(paused: boolean) => {
  701. m.autoPlay = false;
  702. if (paused || popupData.open) {
  703. clearTimeout(activeData.timer);
  704. } else {
  705. setModelOpen();
  706. }
  707. }}
  708. onReset={() => {
  709. if (!m.videoEle?.paused) {
  710. setModelOpen();
  711. }
  712. }}
  713. />
  714. <Transition name="van-fade">
  715. {!m.isprepare && (
  716. <div class={styles.loadWrap}>
  717. <Vue3Lottie
  718. animationData={playLoadData}></Vue3Lottie>
  719. </div>
  720. )}
  721. </Transition>
  722. </>
  723. ) : m.type === 'IMG' ? (
  724. <img src={m.content} />
  725. ) : m.type === 'SONG' ? (
  726. <AudioPay
  727. item={m}
  728. ref={(v: any) => (data.audioRefs[mIndex] = v)}
  729. onLoadedmetadata={(audioItem: any) => {
  730. m.audioEle = audioItem;
  731. m.isprepare = true;
  732. }}
  733. onTogglePlay={(paused: boolean) => {
  734. m.autoPlay = false;
  735. if (paused || popupData.open) {
  736. clearTimeout(activeData.timer);
  737. } else {
  738. setModelOpen();
  739. }
  740. }}
  741. onEnded={() => {
  742. const _index = popupData.activeIndex + 1;
  743. if (_index < data.itemList.length) {
  744. handleSwipeChange(_index);
  745. }
  746. }}
  747. onReset={() => {
  748. if (!m.audioEle?.paused) {
  749. setModelOpen();
  750. }
  751. }}
  752. />
  753. ) : (
  754. <MusicScore
  755. activeModel={activeData.model}
  756. data-vid={m.id}
  757. music={m}
  758. onSetIframe={(el: any) => {
  759. m.iframeRef = el;
  760. }}
  761. />
  762. )}
  763. </div>
  764. ) : null;
  765. })}
  766. </div>
  767. <Transition name="right">
  768. {activeData.model && (
  769. <div
  770. class={styles.rightFixedBtns}
  771. onClick={(e: Event) => {
  772. e.stopPropagation();
  773. clearTimeout(activeData.timer);
  774. }}>
  775. <div
  776. class={[
  777. styles.fullBtn,
  778. popupData.activeIndex === 0 ? styles.btnsDisabled : ''
  779. ]}
  780. onClick={() => {
  781. if (popupData.activeIndex === 0) return;
  782. handlePreAndNext('up');
  783. }}>
  784. <img src={iconUp} />
  785. </div>
  786. <div id="attent-0">
  787. <div
  788. class={[styles.fullBtn, styles.point]}
  789. onClick={() => (popupData.open = true)}>
  790. <img src={iconMenu} />
  791. </div>
  792. <div
  793. class={[
  794. styles.fullBtn,
  795. popupData.activeIndex === data.itemList.length - 1
  796. ? styles.btnsDisabled
  797. : ''
  798. ]}
  799. onClick={() => {
  800. if (popupData.activeIndex === data.itemList.length - 1)
  801. return;
  802. handlePreAndNext('down');
  803. }}>
  804. <img src={iconDown} />
  805. </div>
  806. </div>
  807. </div>
  808. )}
  809. </Transition>
  810. </div>
  811. </div>
  812. <div
  813. style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
  814. class={styles.headerContainer}
  815. // ref={headeRef}
  816. >
  817. {/* <div class={styles.backBtn} onClick={() => goback()}>
  818. <Icon name={iconBack} />
  819. 返回
  820. </div> */}
  821. <div class={styles.menu}>{activeName.value}</div>
  822. </div>
  823. {/* 布置作业按钮 */}
  824. <div
  825. id="attent-3"
  826. class={[
  827. styles.assignHomework,
  828. activeData.model ? '' : styles.sectionAnimateUp
  829. ]}
  830. onClick={async () => {
  831. if (data.type === 'preview') {
  832. handleStop();
  833. if (state.application) {
  834. emit('close');
  835. } else {
  836. window.close();
  837. }
  838. // onFullScreen();
  839. } else {
  840. const res = await lessonPreTrainingPage({
  841. coursewareKnowledgeDetailId: data.detailId,
  842. subjectId: data.subjectId,
  843. page: 1,
  844. rows: 99
  845. });
  846. console.log(res, 'res');
  847. if (res.data.rows && res.data.rows.length) {
  848. data.modalAttendMessage = '本节课已设置课后训练,是否布置?';
  849. }
  850. data.modelAttendStatus = true;
  851. }
  852. }}>
  853. <img
  854. src={data.type === 'preview' ? iconOverPreivew : iconAssignHomework}
  855. />
  856. </div>
  857. {/* 白板 批注 */}
  858. <div
  859. class={[
  860. styles.switchDisplaySection,
  861. activeData.model ? '' : styles.sectionAnimate
  862. ]}>
  863. <NTooltip trigger="hover">
  864. {{
  865. trigger: () => (
  866. <div
  867. id="attent-1"
  868. class={styles.displayBtn}
  869. onClick={() =>
  870. openStudyTool({
  871. type: 'pen',
  872. icon: iconNote,
  873. name: '批注'
  874. })
  875. }>
  876. <img src={iconNote} />
  877. </div>
  878. ),
  879. default: () => '批注'
  880. }}
  881. </NTooltip>
  882. <NTooltip trigger="hover">
  883. {{
  884. trigger: () => (
  885. <div
  886. id="attent-2"
  887. class={styles.displayBtn}
  888. onClick={() =>
  889. openStudyTool({
  890. type: 'whiteboard',
  891. icon: iconWhiteboard,
  892. name: '白板'
  893. })
  894. }>
  895. <img src={iconWhiteboard} />
  896. </div>
  897. ),
  898. default: () => '白板'
  899. }}
  900. </NTooltip>
  901. </div>
  902. {/* 显示列表 */}
  903. <NDrawer
  904. v-model:show={popupData.open}
  905. class={styles.drawerContainer}
  906. onAfterLeave={handleClosePopup}
  907. showMask={false}>
  908. <NDrawerContent title="资源列表" closable>
  909. {data.knowledgePointList.map((item: any, index: number) => (
  910. <CardType
  911. item={item}
  912. isActive={popupData.activeIndex === index}
  913. isCollect={false}
  914. isShowCollect={false}
  915. onClick={(item: any) => {
  916. popupData.open = false;
  917. toggleMaterial(item.id);
  918. }}
  919. />
  920. ))}
  921. </NDrawerContent>
  922. </NDrawer>
  923. {/* 批注 */}
  924. {studyData.penShow && (
  925. <Pen
  926. show={studyData.type === 'pen'}
  927. type={studyData.type}
  928. close={() => closeStudyTool()}
  929. />
  930. )}
  931. {studyData.whiteboardShow && (
  932. <Pen
  933. show={studyData.type === 'whiteboard'}
  934. type={studyData.type}
  935. close={() => closeStudyTool()}
  936. />
  937. )}
  938. {/* 布置作业 */}
  939. <NModal
  940. v-model:show={data.modelAttendStatus}
  941. preset="card"
  942. class={styles.attendClassModal}
  943. title={'课后训练'}>
  944. <div class={styles.modelAttendContent}>{data.modalAttendMessage}</div>
  945. <NSpace class={styles.modelAttendBtnGroup}>
  946. <NButton
  947. type="default"
  948. round
  949. onClick={() => {
  950. data.modelAttendStatus = false;
  951. handleStop();
  952. if (state.application) {
  953. emit('close');
  954. } else {
  955. window.close();
  956. }
  957. }}>
  958. 暂不布置
  959. </NButton>
  960. <NButton
  961. type="primary"
  962. round
  963. onClick={() => {
  964. data.modelTrainStatus = true;
  965. data.modelAttendStatus = false;
  966. }}>
  967. 布置
  968. </NButton>
  969. </NSpace>
  970. </NModal>
  971. {/* 训练设置 */}
  972. <NModal
  973. v-model:show={data.modelTrainStatus}
  974. preset="card"
  975. class={[styles.attendClassModal, styles.trainClassModal]}
  976. title={'训练设置'}>
  977. <TrainSettings
  978. detailId={data.detailId}
  979. subjectId={data.subjectId}
  980. classGroupId={data.classGroupId}
  981. onClose={() => (data.modelTrainStatus = false)}
  982. onConfirm={() => {
  983. // 布置完作业之后直接关闭
  984. setTimeout(() => {
  985. handleStop();
  986. if (state.application) {
  987. emit('close');
  988. } else {
  989. window.close();
  990. }
  991. }, 1000);
  992. }}
  993. />
  994. </NModal>
  995. {/* <NModal
  996. v-model:show={data.homeworkStatus}
  997. preset="card"
  998. class={[styles.attendClassModal]}
  999. closable={false}
  1000. maskClosable={false}
  1001. title={' '}>
  1002. <div class={styles.workContainer}>
  1003. <h2>作业布置成功</h2>
  1004. <p>倒</p>
  1005. </div>
  1006. </NModal> */}
  1007. {showGuide.value ? <Attentguide></Attentguide> : null}
  1008. <NPopover
  1009. raw
  1010. trigger="click"
  1011. show-arrow={false}
  1012. style="--n-box-shadow: none;"
  1013. placement={directionType.value as 'left' | 'right'}
  1014. v-slots={{
  1015. trigger: () => (
  1016. // 首页不显示工具箱
  1017. <img
  1018. // src={isDragIng.value ? dragingBoxIcon : toolbox}
  1019. src={toolbox}
  1020. id="moveNPopover"
  1021. style={{
  1022. display: ['/', '/home'].includes(route.path)
  1023. ? 'none'
  1024. : 'block'
  1025. }}
  1026. class={[
  1027. styles.toolboxImg,
  1028. 'moveNPopover',
  1029. isDragIng.value ? styles.isDragIng : ''
  1030. ]}
  1031. alt=""
  1032. />
  1033. )
  1034. }}>
  1035. <div class={styles.booxToolWrap}>
  1036. <div
  1037. class={styles.booxToolItem}
  1038. onClick={() => startShowModal('beatIcon')}>
  1039. <img src={beatIcon} alt="" />
  1040. 节拍器
  1041. </div>
  1042. <div
  1043. class={styles.booxToolItem}
  1044. onClick={() => startShowModal('toneIcon')}>
  1045. <img src={toneIcon} alt="" />
  1046. 调音器
  1047. </div>
  1048. <div
  1049. class={styles.booxToolItem}
  1050. onClick={() => startShowModal('setTimeIcon')}>
  1051. <img src={setTimeIcon} alt="" />
  1052. 计时器
  1053. </div>
  1054. </div>
  1055. </NPopover>
  1056. <NModal
  1057. class={['modalTitle background']}
  1058. title={'节拍器'}
  1059. preset="card"
  1060. v-model:show={showModalBeat.value}
  1061. style={{ width: '687px' }}>
  1062. <div class={styles.modeWrap}>
  1063. <iframe
  1064. src={`${vaildUrl()}/metronome/?id=${new Date().getTime()}`}
  1065. scrolling="no"
  1066. frameborder="0"
  1067. width="100%"
  1068. height={'650px'}></iframe>
  1069. </div>
  1070. </NModal>
  1071. <NModal class={['background']} v-model:show={showModalTone.value}>
  1072. <div>
  1073. <PlaceholderTone
  1074. onClose={() => {
  1075. showModalTone.value = false;
  1076. }}></PlaceholderTone>
  1077. </div>
  1078. </NModal>
  1079. <NModal
  1080. v-model:show={showModalTime.value}
  1081. class={['modalTitle background']}
  1082. title={'计时器'}
  1083. preset="card"
  1084. style={{ width: px2vw(772) }}>
  1085. <div>
  1086. <TimerMeter></TimerMeter>
  1087. </div>
  1088. </NModal>
  1089. <NModal
  1090. v-model:show={data.removeVisiable}
  1091. preset="card"
  1092. class={['modalTitle', styles.removeVisiable]}
  1093. title={data.removeTitle}>
  1094. <div class={styles.studentRemove}>
  1095. <p>{data.removeContent}</p>
  1096. <NSpace class={styles.btnGroupModal} justify="center">
  1097. <NButton
  1098. round
  1099. type="primary"
  1100. onClick={() => {
  1101. //
  1102. }}>
  1103. 确定
  1104. </NButton>
  1105. <NButton round onClick={() => (data.removeVisiable = false)}>
  1106. 取消
  1107. </NButton>
  1108. </NSpace>
  1109. </div>
  1110. </NModal>
  1111. </div>
  1112. );
  1113. }
  1114. });