index.tsx 37 KB

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