index.tsx 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830
  1. import {
  2. defineComponent,
  3. onMounted,
  4. reactive,
  5. onUnmounted,
  6. ref,
  7. Transition,
  8. computed,
  9. nextTick
  10. } from 'vue';
  11. import styles from './index.module.less';
  12. import 'plyr/dist/plyr.css';
  13. import MusicScore from './component/musicScore';
  14. import iconChange from './image/icon-change.png';
  15. import iconMenu from './image/icon-menu.png';
  16. import iconUp from './image/icon-up.png';
  17. import iconDown from './image/icon-down.png';
  18. import iconNote from './image/icon-note.png';
  19. import iconWhiteboard from './image/icon-whiteboard.png';
  20. import iconAssignHomework from './image/icon-assignHomework.png';
  21. import iconClose from './image/icon-close.png';
  22. import iconOverPreivew from './image/icon-over-preview.png';
  23. import { Vue3Lottie } from 'vue3-lottie';
  24. import playLoadData from './datas/data.json';
  25. import Moveable from 'moveable';
  26. import VideoPlay from './component/video-play';
  27. import {
  28. useMessage,
  29. NDrawer,
  30. NDrawerContent,
  31. NModal,
  32. NSpace,
  33. NButton,
  34. NTooltip,
  35. NPopover,
  36. NImage
  37. } from 'naive-ui';
  38. import CardType from '@/components/card-type';
  39. import Pen from './component/tools/pen';
  40. import AudioPay from './component/audio-pay';
  41. import TrainSettings from './model/train-settings';
  42. import { useRoute } from 'vue-router';
  43. import {
  44. courseScheduleUpdate,
  45. lessonCoursewareDetail,
  46. lessonPreTrainingPage,
  47. queryCourseware
  48. } from '../prepare-lessons/api';
  49. import Attentguide from '@/custom-plugins/guide-page/attent-guide';
  50. import { vaildUrl } from '/src/utils/urlUtils';
  51. import TimerMeter from '/src/components/timerMeter';
  52. import toneImage from '/src/components/layout/images/toneImage.png';
  53. import toolbox from '/src/components/layout/images/toolbox.png';
  54. import setTimeIcon from '/src/components/layout/images/setTimeIcon.png';
  55. import beatIcon from '/src/components/layout/images/beatIcon.png';
  56. import toneIcon from '/src/components/layout/images/toneIcon.png';
  57. import { px2vw } from '/src/utils';
  58. import PlaceholderTone from '/src/components/layout/modals/placeholderTone';
  59. import { state as globalState } from '/src/state';
  60. import Chapter from './model/chapter';
  61. export type ToolType = 'init' | 'pen' | 'whiteboard';
  62. export type ToolItem = {
  63. type: ToolType;
  64. name: string;
  65. icon: string;
  66. };
  67. export default defineComponent({
  68. name: 'CoursewarePlay',
  69. props: {
  70. type: {
  71. type: String,
  72. default: ''
  73. },
  74. subjectId: {
  75. type: [String, Number],
  76. default: ''
  77. },
  78. // 教材编号
  79. lessonCourseId: {
  80. type: [String, Number],
  81. default: ''
  82. },
  83. detailId: {
  84. type: String,
  85. default: ''
  86. },
  87. // 班级编号
  88. classGroupId: {
  89. type: String,
  90. default: ''
  91. },
  92. // 上课记录编号
  93. classId: {
  94. type: String,
  95. defaault: ''
  96. }
  97. },
  98. emits: ['close'],
  99. setup(props, { emit }) {
  100. const message = useMessage();
  101. const route = useRoute();
  102. /** 设置播放容器 16:9 */
  103. const parentContainer = reactive({
  104. width: '100vw'
  105. });
  106. const NPopoverRef = ref();
  107. const setContainer = () => {
  108. const min = Math.min(screen.width, screen.height);
  109. const max = Math.max(screen.width, screen.height);
  110. const width = min * (16 / 9);
  111. if (width > max) {
  112. parentContainer.width = '100vw';
  113. return;
  114. } else {
  115. parentContainer.width = width + 'px';
  116. }
  117. };
  118. const handleInit = (type = 0) => {
  119. //设置容器16:9
  120. // setContainer();
  121. };
  122. handleInit();
  123. const boxBoundaryInfo = reactive({
  124. isBoundary: false,
  125. isBoundaryType: '' as any,
  126. mainWidth: '' as any,
  127. mainHeight: '' as any,
  128. subWidth: '' as any,
  129. subHeight: '' as any
  130. });
  131. onUnmounted(() => {
  132. handleInit(1);
  133. window.removeEventListener('resize', resetSize);
  134. });
  135. const data = reactive({
  136. type: 'class' as '' | 'preview' | 'class', // 预览类型
  137. subjectId: '' as any, // 声部编号
  138. lessonCourseId: '' as any, // 教材编号
  139. lessonCoursewareDetailId: '' as any, // 章节
  140. detailId: '' as any, // 编号 - 课程编号
  141. classGroupId: '' as any, // 上课时需要 班级编号
  142. classId: '' as any, // 上课编号
  143. // detail: null,
  144. knowledgePointList: [] as any,
  145. itemList: [] as any,
  146. // showHead: true,
  147. // isCourse: false,
  148. // isRecordPlay: false,
  149. videoRefs: {} as any[],
  150. audioRefs: {} as any[],
  151. modelAttendStatus: false, // 布置作业提示弹窗
  152. modalAttendMessage: '本节课未设置课后作业,是否继续?',
  153. modelTrainStatus: false, // 训练设置
  154. homeworkStatus: true, // 布置作业完成时
  155. removeVisiable: false,
  156. removeTitle: '',
  157. removeContent: ''
  158. });
  159. const activeData = reactive({
  160. // isAutoPlay: false, // 是否自动播放
  161. nowTime: 0,
  162. model: true, // 遮罩
  163. isAnimation: true, // 是否动画
  164. // videoBtns: true, // 视频
  165. // currentTime: 0,
  166. // duration: 0,
  167. timer: null as any,
  168. item: null as any
  169. });
  170. const showGuide = ref(false);
  171. const getDetail = async () => {
  172. try {
  173. const res = await queryCourseware({
  174. coursewareDetailKnowledgeId: data.detailId,
  175. subjectId: data.subjectId,
  176. pag: 1,
  177. rows: 99
  178. });
  179. const tempRows = res.data.rows || [];
  180. const temp: any = [];
  181. tempRows.forEach((row: any) => {
  182. if (!row.removeFlag) {
  183. temp.push({
  184. id: row.id,
  185. materialId: row.materialId,
  186. coverImg: row.coverImg,
  187. type: row.materialType,
  188. title: row.materialName,
  189. isCollect: !!row.favoriteFlag,
  190. isSelected: row.source === 'PLATFORM' ? true : false,
  191. content: row.content
  192. });
  193. }
  194. });
  195. data.knowledgePointList = temp;
  196. data.itemList = data.knowledgePointList.map((m: any) => {
  197. return {
  198. ...m,
  199. iframeRef: null,
  200. videoEle: null,
  201. audioEle: null,
  202. autoPlay: false, //加载完成是否自动播放
  203. isprepare: false, // 视频是否加载完成
  204. isRender: false // 是否渲染了
  205. };
  206. });
  207. setTimeout(() => {
  208. showGuide.value = true;
  209. }, 500);
  210. } catch {
  211. //
  212. }
  213. };
  214. const directionType = ref('left');
  215. const showModalBeat = ref(false);
  216. const showModalTone = ref(false);
  217. const showModalTime = ref(false);
  218. const isDragIng = ref(false);
  219. const initMoveable = async () => {
  220. if (document.querySelector('.wrap')) {
  221. const moveable = new Moveable(document.querySelector('.wrap') as any, {
  222. target: document.querySelector('#moveNPopoverA') as any,
  223. // If the container is null, the position is fixed. (default: parentElement(document.body))
  224. container: document.querySelector('.wrap') as any,
  225. // snappable: true,
  226. // bounds: {"left":100,"top":100,"right":100,"bottom":100},
  227. draggable: true,
  228. resizable: false,
  229. scalable: false,
  230. rotatable: false,
  231. warpable: false,
  232. pinchable: false, // ["resizable", "scalable", "rotatable"]
  233. origin: false,
  234. keepRatio: false,
  235. // Resize, Scale Events at edges.
  236. edge: false,
  237. throttleDrag: 0,
  238. throttleResize: 0,
  239. throttleScale: 0,
  240. throttleRotate: 0
  241. });
  242. console.log('initMoveable完毕', moveable);
  243. moveable
  244. .on('dragStart', ({ target, clientX, clientY }) => {
  245. console.log('dragStart');
  246. })
  247. .on(
  248. 'drag',
  249. ({
  250. target,
  251. // transform,
  252. left,
  253. top,
  254. right,
  255. bottom
  256. // beforeDelta,
  257. // beforeDist,
  258. // delta,
  259. // dist,
  260. // clientX,
  261. // clientY
  262. }) => {
  263. isDragIng.value = true;
  264. if (NPopoverRef.value) {
  265. NPopoverRef.value.setShow(false);
  266. }
  267. const subdEl = document.getElementById(
  268. `moveNPopoverA`
  269. ) as HTMLDivElement;
  270. // console.log(subdEl, "subdEl", "drag");
  271. const subdElStyle = getComputedStyle(subdEl, null);
  272. const RectInfo = {
  273. left: Number(subdElStyle.left.replace('px', '')),
  274. top: Number(subdElStyle.top.replace('px', '')),
  275. width: Number(subdElStyle.width.replace('px', '')),
  276. height: Number(subdElStyle.height.replace('px', ''))
  277. };
  278. // target.style.transition = ''
  279. const mainWidth =
  280. parseInt(
  281. window.getComputedStyle(
  282. document.querySelector('.wrap') as Element
  283. ).width
  284. ) - RectInfo.width;
  285. const mainHeight =
  286. parseInt(
  287. window.getComputedStyle(
  288. document.querySelector('.wrap') as Element
  289. ).height
  290. ) - RectInfo.height;
  291. subdEl.style.transition = '';
  292. boxBoundaryInfo.isBoundary = false;
  293. boxBoundaryInfo.isBoundaryType = '';
  294. boxBoundaryInfo.mainHeight = mainHeight;
  295. boxBoundaryInfo.mainWidth = mainWidth;
  296. boxBoundaryInfo.subWidth = RectInfo.width;
  297. boxBoundaryInfo.subHeight = RectInfo.height;
  298. if (left < 0) {
  299. left = 2;
  300. boxBoundaryInfo.isBoundary = true;
  301. boxBoundaryInfo.isBoundaryType = 'left';
  302. }
  303. if (top < 0) {
  304. top = 2;
  305. boxBoundaryInfo.isBoundary = true;
  306. boxBoundaryInfo.isBoundaryType = 'top';
  307. }
  308. if (right < 0) {
  309. right = 2;
  310. }
  311. if (bottom < 0) {
  312. bottom = 2;
  313. }
  314. if (left > mainWidth - 2) {
  315. left = mainWidth - 2;
  316. // top = 2;
  317. boxBoundaryInfo.isBoundary = true;
  318. boxBoundaryInfo.isBoundaryType = 'right';
  319. }
  320. if (top > mainHeight - 2) {
  321. top = mainHeight - 2;
  322. boxBoundaryInfo.isBoundary = true;
  323. boxBoundaryInfo.isBoundaryType = 'bottom';
  324. }
  325. target!.style.left = `${left}px`;
  326. target!.style.top = `${top}px`;
  327. }
  328. )
  329. .on(
  330. 'dragEnd',
  331. async ({
  332. target,
  333. // isDrag,
  334. clientX
  335. // clientY
  336. }) => {
  337. if (document.body.clientWidth / 2 - clientX > 0) {
  338. // 往左出
  339. directionType.value = 'right';
  340. } else {
  341. // 往又出
  342. directionType.value = 'left';
  343. }
  344. console.log(target.style.left);
  345. isDragIng.value = false;
  346. // 在这里进行动画
  347. if (boxBoundaryInfo.isBoundary) {
  348. // 这里说明贴边了
  349. target.style.transition = '.3s';
  350. actionEnd(target, boxBoundaryInfo.isBoundaryType);
  351. }
  352. }
  353. );
  354. }
  355. };
  356. // ifram事件处理
  357. const iframeHandle = (ev: MessageEvent) => {
  358. if (ev.data?.api === 'headerTogge') {
  359. activeData.model =
  360. ev.data.show || (ev.data.playState == 'play' ? false : true);
  361. }
  362. if (ev.data?.api === 'api_fingerPreView') {
  363. clearInterval(activeData.timer);
  364. activeData.model = !ev.data.state;
  365. }
  366. };
  367. onMounted(() => {
  368. initMoveable();
  369. const query = route.query;
  370. // 先取参数,
  371. data.type = props.type || (query.type as any);
  372. data.subjectId = props.subjectId || query.subjectId;
  373. data.detailId = props.detailId || query.detailId;
  374. data.lessonCourseId = props.lessonCourseId || query.lessonCourseId;
  375. data.classGroupId = props.classGroupId || query.classGroupId;
  376. data.classId = props.classId || query.classId;
  377. const subdEl = document.getElementById(`moveNPopoverA`) as HTMLDivElement;
  378. initBoundaryWrap(subdEl, boxBoundaryInfo);
  379. initBoxRectInfo(subdEl, boxBoundaryInfo);
  380. window.addEventListener('message', iframeHandle);
  381. getDetail();
  382. getLessonCoursewareDetail();
  383. window.addEventListener('resize', resetSize);
  384. });
  385. const resetSize = () => {
  386. const subdEl = document.getElementById(`moveNPopoverA`) as HTMLDivElement;
  387. subdEl.style.display = 'none';
  388. boxBoundaryInfo.isBoundary = true;
  389. boxBoundaryInfo.isBoundaryType = 'right';
  390. if (NPopoverRef.value) {
  391. NPopoverRef.value.setShow(false);
  392. }
  393. setTimeout(() => {
  394. subdEl.style.transition = '';
  395. initBoxRectInfo(subdEl, boxBoundaryInfo);
  396. initBoundaryWrap(subdEl, boxBoundaryInfo);
  397. subdEl.style.display = 'block';
  398. }, 100);
  399. };
  400. const initBoundaryWrap = (target: any, wrapInfo: any) => {
  401. target.addEventListener('mouseenter', () => {
  402. if (wrapInfo.isBoundary) {
  403. // 如果在边框 就得还原 元素位置 还原完毕后 去除transition
  404. if (wrapInfo.isBoundaryType == 'left') {
  405. target.style.left = '2px';
  406. } else if (wrapInfo.isBoundaryType == 'right') {
  407. target.style.left = `${wrapInfo.mainWidth - 2}px`;
  408. } else if (wrapInfo.isBoundaryType == 'top') {
  409. target.style.top = `${2}px`;
  410. } else if (wrapInfo.isBoundaryType == 'bottom') {
  411. target.style.top = `${wrapInfo.mainHeight - 2}px`;
  412. }
  413. }
  414. rate(target, 0);
  415. });
  416. target.addEventListener('mouseleave', () => {
  417. console.log('mouseleave', wrapInfo.isBoundary);
  418. if (wrapInfo.isBoundary) {
  419. // 如果在边框 就得还原 元素位置 还原完毕后 去除transition
  420. if (wrapInfo.isBoundaryType == 'left') {
  421. actionEnd(target, 'left');
  422. } else if (wrapInfo.isBoundaryType == 'right') {
  423. actionEnd(target, 'right');
  424. } else if (wrapInfo.isBoundaryType == 'top') {
  425. actionEnd(target, 'top');
  426. } else if (wrapInfo.isBoundaryType == 'bottom') {
  427. actionEnd(target, 'bottom');
  428. }
  429. }
  430. // rate(target, 0)
  431. });
  432. // target.addEventListener('contextmenu', (event: any) => {
  433. // event.preventDefault();
  434. // dialog.warning({
  435. // title: '提示',
  436. // content: '是否收入托盘',
  437. // positiveText: '确定',
  438. // negativeText: '取消',
  439. // onPositiveClick: () => {
  440. // console.log('确定')
  441. // },
  442. // onNegativeClick: () => {
  443. // console.log('取消')
  444. // }
  445. // })
  446. // });
  447. // actionEnd(target, 'right');
  448. };
  449. // 这里是旋转
  450. const rate = (target: any, rate: any) => {
  451. target.style.transform = ' rotate(' + rate + ')';
  452. };
  453. // 这里是选装的方式
  454. const actionEnd = (target: any, type: any) => {
  455. switch (type) {
  456. case 'left':
  457. rate(target, '90deg');
  458. target!.style.left = `${2 - boxBoundaryInfo.subWidth / 2}px`;
  459. target!.style.top = `${top}px`;
  460. break;
  461. case 'right':
  462. rate(target, '-90deg');
  463. target!.style.left = `${
  464. boxBoundaryInfo.mainWidth - 2 + boxBoundaryInfo.subWidth / 2
  465. }px`;
  466. target!.style.top = `${top}px`;
  467. break;
  468. case 'top':
  469. target!.style.top = `${2 - boxBoundaryInfo.subHeight / 2}px`;
  470. rate(target, '-180deg');
  471. break;
  472. case 'bottom':
  473. target!.style.top = `${
  474. boxBoundaryInfo.mainHeight - 2 + boxBoundaryInfo.subHeight / 2
  475. }px`;
  476. break;
  477. default:
  478. rate(target, '-0');
  479. break;
  480. }
  481. };
  482. const initBoxRectInfo = (target: any, wrapInfo: any) => {
  483. // const subdEl = document.getElementById(`moveNPopoverA`) as HTMLDivElement;
  484. // console.log(subdEl, "subdEl", "drag");
  485. const subdElStyle = getComputedStyle(target, null);
  486. const RectInfo = {
  487. left: Number(subdElStyle.left.replace('px', '')),
  488. top: Number(subdElStyle.top.replace('px', '')),
  489. width: Number(subdElStyle.width.replace('px', '')),
  490. height: Number(subdElStyle.height.replace('px', ''))
  491. };
  492. // target.style.transition = ''
  493. const mainWidth =
  494. parseInt(
  495. window.getComputedStyle(document.querySelector('.wrap') as Element)
  496. .width
  497. ) - RectInfo.width;
  498. const mainHeight =
  499. parseInt(
  500. window.getComputedStyle(document.querySelector('.wrap') as Element)
  501. .height
  502. ) - RectInfo.height;
  503. // boxBoundaryInfo.isBoundary = false;
  504. // boxBoundaryInfo.isBoundaryType = '';
  505. wrapInfo.mainHeight = mainHeight;
  506. wrapInfo.mainWidth = mainWidth;
  507. wrapInfo.subWidth = RectInfo.width;
  508. wrapInfo.subHeight = RectInfo.height;
  509. target.style.transition = '.3s';
  510. };
  511. const onFullScreen = () => {
  512. if (data.type === 'preview') {
  513. const el: any = document.querySelector('#app');
  514. if (el.mozRequestFullScreen) {
  515. el.mozRequestFullScreen();
  516. } else if (el.webkitRequestFullscreen) {
  517. el.webkitRequestFullscreen();
  518. } else if (el.requestFullScreen) {
  519. el.requestFullscreen();
  520. }
  521. }
  522. };
  523. const popupData = reactive({
  524. open: false,
  525. activeIndex: 0,
  526. toolOpen: false, // 工具弹窗控制
  527. chapterOpen: false, // 切换章节
  528. chapterDetails: [] as any,
  529. chapterLoading: false // 加载数据
  530. });
  531. const formatParentId = (id: any, list: any, ids = [] as any) => {
  532. for (const item of list) {
  533. if (item.knowledgeList && item.knowledgeList.length > 0) {
  534. const cIds: any = formatParentId(id, item.knowledgeList, [
  535. ...ids,
  536. item.id
  537. ]);
  538. if (cIds.includes(id)) {
  539. return cIds;
  540. }
  541. }
  542. if (item.id === id) {
  543. return [...ids, id];
  544. }
  545. }
  546. return ids;
  547. };
  548. /** 获取章节 */
  549. const getLessonCoursewareDetail = async () => {
  550. try {
  551. const res = await lessonCoursewareDetail({
  552. id: data.lessonCourseId,
  553. subjectId: data.subjectId
  554. });
  555. popupData.chapterDetails = res.data.lessonList || [];
  556. const ids = formatParentId(data.detailId, popupData.chapterDetails);
  557. data.lessonCoursewareDetailId = ids[0];
  558. } catch {
  559. //
  560. }
  561. };
  562. /** 更新上课记录 */
  563. const classCourseScheduleUpdate = async () => {
  564. try {
  565. if (!data.classId) return;
  566. await courseScheduleUpdate({
  567. lessonCoursewareKnowledgeDetailId: data.detailId,
  568. id: data.classId
  569. });
  570. } catch {}
  571. };
  572. const activeName = computed(() => {
  573. let name = '';
  574. data.knowledgePointList.forEach((item: any, index: number) => {
  575. if (popupData.activeIndex === index) {
  576. name = item.title;
  577. }
  578. });
  579. return name;
  580. });
  581. /**停止所有的播放 */
  582. const handleStop = () => {
  583. for (let i = 0; i < data.itemList.length; i++) {
  584. const activeItem = data.itemList[i];
  585. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  586. activeItem.videoEle.currentTime(0);
  587. activeItem.videoEle.pause();
  588. }
  589. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  590. activeItem.audioEle.stop();
  591. }
  592. // console.log('🚀 ~ activeItem:', activeItem)
  593. // 停止曲谱的播放
  594. if (activeItem.type === 'MUSIC') {
  595. activeItem.iframeRef?.contentWindow?.postMessage(
  596. { api: 'setPlayState' },
  597. '*'
  598. );
  599. }
  600. }
  601. };
  602. // 切换素材
  603. const toggleMaterial = (itemActive: any) => {
  604. const index = data.itemList.findIndex((n: any) => n.id == itemActive);
  605. if (index > -1) {
  606. handleSwipeChange(index);
  607. }
  608. };
  609. /** 延迟收起模态框 */
  610. const setModelOpen = () => {
  611. clearTimeout(activeData.timer);
  612. message.destroyAll();
  613. activeData.timer = setTimeout(() => {
  614. activeData.model = false;
  615. Object.values(data.videoRefs).map((n: any) =>
  616. n.toggleHideControl(false)
  617. );
  618. Object.values(data.audioRefs).map((n: any) =>
  619. n.toggleHideControl(false)
  620. );
  621. }, 4000);
  622. };
  623. /** 立即收起所有的模态框 */
  624. const clearModel = () => {
  625. clearTimeout(activeData.timer);
  626. message.destroyAll();
  627. activeData.model = false;
  628. Object.values(data.videoRefs).map((n: any) =>
  629. n?.toggleHideControl(false)
  630. );
  631. Object.values(data.audioRefs).map((n: any) =>
  632. n?.toggleHideControl(false)
  633. );
  634. };
  635. const toggleModel = (type = true) => {
  636. activeData.model = type;
  637. Object.values(data.videoRefs).map((n: any) => n?.toggleHideControl(type));
  638. Object.values(data.audioRefs).map((n: any) => n?.toggleHideControl(type));
  639. };
  640. // 双击
  641. const handleDbClick = (item: any) => {
  642. if (item && item.type === 'VIDEO') {
  643. const videoEle: HTMLVideoElement = item.videoEle;
  644. if (videoEle) {
  645. if (videoEle.paused) {
  646. message.destroyAll();
  647. videoEle.play();
  648. } else {
  649. message.warning('已暂停');
  650. videoEle.pause();
  651. }
  652. }
  653. }
  654. };
  655. // 切换播放
  656. // const togglePlay = (m: any, isPlay: boolean) => {
  657. // if (isPlay) {
  658. // m.videoEle?.play();
  659. // } else {
  660. // m.videoEle?.pause();
  661. // }
  662. // };
  663. // const showIndex = ref(-4);
  664. const effectIndex = ref(3);
  665. const effects = [
  666. {
  667. prev: {
  668. transform: 'translate3d(0, 0, -800px) rotateX(180deg)'
  669. },
  670. next: {
  671. transform: 'translate3d(0, 0, -800px) rotateX(-180deg)'
  672. }
  673. },
  674. {
  675. prev: {
  676. transform: 'translate3d(-100%, 0, -800px)'
  677. },
  678. next: {
  679. transform: 'translate3d(100%, 0, -800px)'
  680. }
  681. },
  682. {
  683. prev: {
  684. transform: 'translate3d(-50%, 0, -800px) rotateY(80deg)'
  685. },
  686. next: {
  687. transform: 'translate3d(50%, 0, -800px) rotateY(-80deg)'
  688. }
  689. },
  690. {
  691. prev: {
  692. transform: 'translate3d(-100%, 0, -800px) rotateY(-120deg)'
  693. },
  694. next: {
  695. transform: 'translate3d(100%, 0, -800px) rotateY(120deg)'
  696. }
  697. },
  698. // 风车4
  699. {
  700. prev: {
  701. transform: 'translate3d(-50%, 50%, -800px) rotateZ(-14deg)',
  702. opacity: 0
  703. },
  704. next: {
  705. transform: 'translate3d(50%, 50%, -800px) rotateZ(14deg)',
  706. opacity: 0
  707. }
  708. },
  709. // 翻页5
  710. {
  711. prev: {
  712. transform: 'translateZ(-800px) rotate3d(0, -1, 0, 90deg)',
  713. opacity: 0
  714. },
  715. next: {
  716. transform: 'translateZ(-800px) rotate3d(0, 1, 0, 90deg)',
  717. opacity: 0
  718. },
  719. current: { transitionDelay: '700ms' }
  720. }
  721. ];
  722. const acitveTimer = ref();
  723. // 轮播切换
  724. const handleSwipeChange = (index: number) => {
  725. // 如果是当前正在播放 或者是视频最后一个
  726. if (popupData.activeIndex == index) return;
  727. handleStop();
  728. clearTimeout(acitveTimer.value);
  729. checkedAnimation(popupData.activeIndex, index);
  730. popupData.activeIndex = index;
  731. acitveTimer.value = setTimeout(
  732. () => {
  733. const item = data.itemList[index];
  734. if (item) {
  735. if (item.type == 'MUSIC') {
  736. activeData.model = true;
  737. }
  738. if (item.type === 'SONG') {
  739. // 自动播放下一个音频
  740. clearTimeout(activeData.timer);
  741. message.destroyAll();
  742. // item.autoPlay = false;
  743. // nextTick(() => {
  744. // item.audioEle?.onPlay();
  745. // });
  746. }
  747. if (item.type === 'VIDEO') {
  748. // 自动播放下一个视频
  749. clearTimeout(activeData.timer);
  750. message.destroyAll();
  751. nextTick(() => {
  752. if (item.error) {
  753. console.log(item, 'item error');
  754. item.videoEle?.src(item.content);
  755. item.error = false;
  756. // item.videoEle?.onPlay();
  757. }
  758. });
  759. // item.autoPlay = false;
  760. }
  761. }
  762. // requestAnimationFrame(() => {
  763. // const _effectIndex = effectIndex.value + 1;
  764. // effectIndex.value =
  765. // _effectIndex >= effects.length - 1 ? 0 : _effectIndex;
  766. // });
  767. },
  768. activeData.isAnimation ? 800 : 0
  769. );
  770. };
  771. /** 是否有转场动画 */
  772. const checkedAnimation = (index: number, nextIndex?: number) => {
  773. const item = data.itemList[index];
  774. const nextItem = data.itemList[nextIndex!];
  775. if (nextItem) {
  776. if (nextItem.knowledgePointId != item.knowledgePointId) {
  777. activeData.isAnimation = true;
  778. return;
  779. }
  780. const videoEle = item.videoEle;
  781. const nextVideo = nextItem.videoEle;
  782. if (videoEle && videoEle.duration < 8 && index < nextIndex!) {
  783. activeData.isAnimation = false;
  784. } else if (nextVideo && nextVideo.duration < 8 && index > nextIndex!) {
  785. activeData.isAnimation = false;
  786. } else {
  787. activeData.isAnimation = true;
  788. }
  789. } else {
  790. activeData.isAnimation = item?.adviseStudyTimeSecond < 8 ? false : true;
  791. }
  792. };
  793. // 上一个知识点, 下一个知识点
  794. const handlePreAndNext = async (type: string) => {
  795. // if (type === 'up') {
  796. // handleSwipeChange(popupData.activeIndex - 1);
  797. // } else {
  798. // handleSwipeChange(popupData.activeIndex + 1);
  799. // }
  800. if (type === 'up') {
  801. // 判断上面是否还有章节
  802. if (popupData.activeIndex > 0) {
  803. handleSwipeChange(popupData.activeIndex - 1);
  804. return;
  805. }
  806. // 获取当前是哪个章节
  807. let detailIndex = popupData.chapterDetails.findIndex(
  808. (item: any) => item.id == data.lessonCoursewareDetailId
  809. );
  810. const detailItem =
  811. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  812. let lessonIndex = detailItem.findIndex(
  813. (item: any) => item.id == data.detailId
  814. );
  815. let lessonStatus = false; // 当前章节上面是否有内容
  816. let lessonCoursewareDetailId = '';
  817. let coursewareDetailKnowledgeId = '';
  818. while (lessonIndex >= 0) {
  819. lessonIndex--;
  820. if (lessonIndex >= 0) {
  821. if (detailItem[lessonIndex].containMaterial) {
  822. lessonStatus = true;
  823. lessonCoursewareDetailId =
  824. detailItem[lessonIndex].lessonCoursewareDetailId;
  825. coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
  826. }
  827. }
  828. if (lessonStatus) {
  829. break;
  830. }
  831. }
  832. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  833. if (lessonStatus) {
  834. popupData.chapterLoading = true;
  835. data.detailId = coursewareDetailKnowledgeId;
  836. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  837. // 更新上课记录 上课的时候才更新
  838. if (data.type !== 'preview') {
  839. await classCourseScheduleUpdate();
  840. }
  841. await getDetail();
  842. popupData.activeIndex = data.itemList.length - 1 || 0;
  843. popupData.chapterOpen = false;
  844. popupData.chapterLoading = false;
  845. return;
  846. }
  847. let prevLessonStatus = false;
  848. while (detailIndex >= 0) {
  849. detailIndex--;
  850. const tempDetail =
  851. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  852. let tempLessonLength = tempDetail.length;
  853. while (tempLessonLength > 0) {
  854. if (tempDetail[tempLessonLength - 1].containMaterial) {
  855. prevLessonStatus = true;
  856. lessonCoursewareDetailId =
  857. tempDetail[tempLessonLength - 1].lessonCoursewareDetailId;
  858. coursewareDetailKnowledgeId = tempDetail[tempLessonLength - 1].id;
  859. }
  860. tempLessonLength--;
  861. if (prevLessonStatus) {
  862. break;
  863. }
  864. }
  865. if (prevLessonStatus) {
  866. break;
  867. }
  868. }
  869. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  870. if (prevLessonStatus) {
  871. popupData.chapterLoading = true;
  872. data.detailId = coursewareDetailKnowledgeId;
  873. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  874. await getDetail();
  875. popupData.activeIndex = data.itemList.length - 1 || 0;
  876. popupData.chapterLoading = false;
  877. return;
  878. }
  879. } else {
  880. if (popupData.activeIndex < data.itemList.length - 1) {
  881. handleSwipeChange(popupData.activeIndex + 1);
  882. return;
  883. }
  884. // 获取当前是哪个章节
  885. let detailIndex = popupData.chapterDetails.findIndex(
  886. (item: any) => item.id == data.lessonCoursewareDetailId
  887. );
  888. const detailItem =
  889. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  890. let lessonIndex = detailItem.findIndex(
  891. (item: any) => item.id == data.detailId
  892. );
  893. let lessonStatus = false; // 当前章节下面是否有内容
  894. let lessonCoursewareDetailId = '';
  895. let coursewareDetailKnowledgeId = '';
  896. while (lessonIndex < detailItem.length - 1) {
  897. lessonIndex++;
  898. if (lessonIndex >= 0) {
  899. if (detailItem[lessonIndex].containMaterial) {
  900. lessonStatus = true;
  901. lessonCoursewareDetailId =
  902. detailItem[lessonIndex].lessonCoursewareDetailId;
  903. coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
  904. }
  905. }
  906. if (lessonStatus) {
  907. break;
  908. }
  909. }
  910. // 判断当前章节下面课程是否有内容,否则往下一个章节走
  911. if (lessonStatus) {
  912. popupData.chapterLoading = true;
  913. data.detailId = coursewareDetailKnowledgeId;
  914. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  915. // 更新上课记录 上课的时候才更新
  916. if (data.type !== 'preview') {
  917. await classCourseScheduleUpdate();
  918. }
  919. await getDetail();
  920. popupData.activeIndex = 0;
  921. popupData.chapterOpen = false;
  922. popupData.chapterLoading = false;
  923. return;
  924. }
  925. let nextLessonStatus = false;
  926. while (detailIndex <= popupData.chapterDetails.length - 1) {
  927. detailIndex++;
  928. const tempDetail =
  929. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  930. let tempLessonLength = 0;
  931. while (tempLessonLength <= tempDetail.length - 1) {
  932. if (tempDetail[tempLessonLength].containMaterial) {
  933. nextLessonStatus = true;
  934. lessonCoursewareDetailId =
  935. tempDetail[tempLessonLength].lessonCoursewareDetailId;
  936. coursewareDetailKnowledgeId = tempDetail[tempLessonLength].id;
  937. }
  938. tempLessonLength++;
  939. if (nextLessonStatus) {
  940. break;
  941. }
  942. }
  943. if (nextLessonStatus) {
  944. break;
  945. }
  946. }
  947. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  948. if (nextLessonStatus) {
  949. popupData.chapterLoading = true;
  950. data.detailId = coursewareDetailKnowledgeId;
  951. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  952. // 更新上课记录 上课的时候才更新
  953. if (data.type !== 'preview') {
  954. await classCourseScheduleUpdate();
  955. }
  956. await getDetail();
  957. popupData.activeIndex = 0;
  958. popupData.chapterOpen = false;
  959. popupData.chapterLoading = false;
  960. return;
  961. }
  962. }
  963. };
  964. /** 弹窗关闭 */
  965. const handleClosePopup = () => {
  966. const item = data.itemList[popupData.activeIndex];
  967. if (item?.type == 'VIDEO' && !item.videoEle?.paused) {
  968. setModelOpen();
  969. }
  970. if (item?.type == 'SONG' && !item.audioEle?.paused) {
  971. setModelOpen();
  972. }
  973. };
  974. // 监听页面键盘事件 - 上下切换
  975. document.body.addEventListener('keyup', (e: KeyboardEvent) => {
  976. // console.log(e, 'e');
  977. if (e.code === 'ArrowUp') {
  978. if (popupData.activeIndex === 0) return;
  979. handlePreAndNext('up');
  980. } else if (e.code === 'ArrowDown') {
  981. if (popupData.activeIndex === data.itemList.length - 1) return;
  982. handlePreAndNext('down');
  983. }
  984. });
  985. /** 教学数据 */
  986. const studyData = reactive({
  987. type: '' as ToolType,
  988. penShow: false,
  989. whiteboardShow: false
  990. });
  991. /** 打开教学工具 */
  992. const openStudyTool = (item: ToolItem) => {
  993. const activeItem = data.itemList[popupData.activeIndex];
  994. // 暂停视频和曲谱的播放
  995. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  996. activeItem.videoEle.pause();
  997. }
  998. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  999. activeItem.audioEle.stop();
  1000. }
  1001. if (activeItem.type === 'MUSIC') {
  1002. activeItem.iframeRef?.contentWindow?.postMessage(
  1003. { api: 'setPlayState' },
  1004. '*'
  1005. );
  1006. }
  1007. clearModel();
  1008. popupData.toolOpen = false;
  1009. studyData.type = item.type;
  1010. switch (item.type) {
  1011. case 'pen':
  1012. studyData.penShow = true;
  1013. break;
  1014. case 'whiteboard':
  1015. studyData.whiteboardShow = true;
  1016. }
  1017. };
  1018. /** 关闭教学工具 */
  1019. const closeStudyTool = () => {
  1020. studyData.type = 'init';
  1021. toggleModel();
  1022. };
  1023. const startShowModal = (val: 'setTimeIcon' | 'beatIcon' | 'toneIcon') => {
  1024. if (val == 'setTimeIcon') {
  1025. showModalTime.value = true;
  1026. }
  1027. if (val == 'beatIcon') {
  1028. showModalBeat.value = true;
  1029. }
  1030. if (val == 'toneIcon') {
  1031. showModalTone.value = true;
  1032. }
  1033. };
  1034. // 是否允许上一页
  1035. const isUpArrow = computed(() => {
  1036. /**
  1037. * 1,判断当前课程中是否处在第一个资源;
  1038. * 2,判断当前课程是否在当前章节的第一个;
  1039. * 3,判断当前章节,当前课程上面还没有其它课程,是否有资源;
  1040. * 4,判断当前章节上面还没有其它章节;
  1041. * 5,判断上面章节里面课程是否有资源;
  1042. */
  1043. if (popupData.activeIndex > 0) {
  1044. return true;
  1045. }
  1046. // 获取当前是哪个章节
  1047. let detailIndex = popupData.chapterDetails.findIndex(
  1048. (item: any) => item.id == data.lessonCoursewareDetailId
  1049. );
  1050. const detailItem =
  1051. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1052. let lessonIndex = detailItem.findIndex(
  1053. (item: any) => item.id == data.detailId
  1054. );
  1055. // 说明已经是第一单元,第一课
  1056. if (detailIndex <= 0 && lessonIndex <= 0) {
  1057. return false;
  1058. }
  1059. let lessonStatus = false; // 当前章节上面是否有内容
  1060. while (lessonIndex >= 0) {
  1061. lessonIndex--;
  1062. if (lessonIndex >= 0) {
  1063. if (detailItem[lessonIndex].containMaterial) {
  1064. lessonStatus = true;
  1065. }
  1066. }
  1067. }
  1068. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  1069. if (lessonStatus) {
  1070. return true;
  1071. }
  1072. // 已经是第一个章节了
  1073. if (detailIndex <= 0) {
  1074. return false;
  1075. }
  1076. let prevLessonStatus = false;
  1077. while (detailIndex >= 0) {
  1078. detailIndex--;
  1079. const tempDetail =
  1080. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1081. let tempLessonLength = tempDetail.length;
  1082. while (tempLessonLength > 0) {
  1083. if (tempDetail[tempLessonLength - 1].containMaterial) {
  1084. prevLessonStatus = true;
  1085. }
  1086. tempLessonLength--;
  1087. }
  1088. if (prevLessonStatus) {
  1089. return true;
  1090. }
  1091. }
  1092. return false;
  1093. });
  1094. // 是否允许下一页
  1095. const isDownArrow = computed(() => {
  1096. if (popupData.activeIndex < data.itemList.length - 1) {
  1097. return true;
  1098. }
  1099. // 获取当前是哪个章节
  1100. let detailIndex = popupData.chapterDetails.findIndex(
  1101. (item: any) => item.id == data.lessonCoursewareDetailId
  1102. );
  1103. const detailItem =
  1104. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1105. let lessonIndex = detailItem.findIndex(
  1106. (item: any) => item.id == data.detailId
  1107. );
  1108. // 说明已经是最后-单元,最后一课
  1109. if (
  1110. detailIndex >= popupData.chapterDetails.length - 1 &&
  1111. lessonIndex >= detailItem.length - 1
  1112. ) {
  1113. return false;
  1114. }
  1115. let lessonStatus = false; // 当前章节下面是否有内容
  1116. while (lessonIndex < detailItem.length - 1) {
  1117. lessonIndex++;
  1118. if (lessonIndex >= 0) {
  1119. if (detailItem[lessonIndex].containMaterial) {
  1120. lessonStatus = true;
  1121. }
  1122. }
  1123. }
  1124. // 判断当前章节下面课程是否有内容,否则往下一个章节走
  1125. if (lessonStatus) {
  1126. return true;
  1127. }
  1128. // 已经是最后一个章节了
  1129. if (detailIndex >= popupData.chapterDetails.length - 1) {
  1130. return false;
  1131. }
  1132. let nextLessonStatus = false;
  1133. while (detailIndex < popupData.chapterDetails.length - 1) {
  1134. detailIndex++;
  1135. const tempDetail =
  1136. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1137. let tempLessonLength = 0;
  1138. while (tempLessonLength <= tempDetail.length - 1) {
  1139. if (tempDetail[tempLessonLength].containMaterial) {
  1140. nextLessonStatus = true;
  1141. }
  1142. tempLessonLength++;
  1143. }
  1144. if (nextLessonStatus) {
  1145. return true;
  1146. }
  1147. }
  1148. return false;
  1149. });
  1150. return () => (
  1151. <div id="playContent" class={[styles.playContent, 'wrap']}>
  1152. <div
  1153. onClick={() => {
  1154. clearTimeout(activeData.timer);
  1155. activeData.model = !activeData.model;
  1156. Object.values(data.videoRefs).map((n: any) =>
  1157. n.toggleHideControl(activeData.model)
  1158. );
  1159. Object.values(data.audioRefs).map((n: any) =>
  1160. n.toggleHideControl(activeData.model)
  1161. );
  1162. }}>
  1163. <div
  1164. class={styles.coursewarePlay}
  1165. style={{ width: parentContainer.width }}
  1166. onClick={(e: Event) => {
  1167. e.stopPropagation();
  1168. setModelOpen();
  1169. }}>
  1170. {!popupData.chapterLoading ? (
  1171. <div class={styles.wraps}>
  1172. {data.itemList.map((m: any, mIndex: number) => {
  1173. const isRender =
  1174. m.isRender || Math.abs(popupData.activeIndex - mIndex) < 2;
  1175. const isEmtry = Math.abs(popupData.activeIndex - mIndex) > 4;
  1176. if (isRender) {
  1177. m.isRender = true;
  1178. }
  1179. return isRender ? (
  1180. <div
  1181. key={'index' + mIndex}
  1182. class={[
  1183. styles.itemDiv,
  1184. popupData.activeIndex === mIndex && styles.itemActive,
  1185. activeData.isAnimation && styles.acitveAnimation,
  1186. Math.abs(popupData.activeIndex - mIndex) < 2
  1187. ? styles.show
  1188. : styles.hide
  1189. ]}
  1190. style={
  1191. mIndex < popupData.activeIndex
  1192. ? effects[effectIndex.value].prev
  1193. : mIndex > popupData.activeIndex
  1194. ? effects[effectIndex.value].next
  1195. : {}
  1196. }
  1197. onClick={(e: Event) => {
  1198. e.stopPropagation();
  1199. clearTimeout(activeData.timer);
  1200. if (Date.now() - activeData.nowTime < 300) {
  1201. handleDbClick(m);
  1202. return;
  1203. }
  1204. activeData.nowTime = Date.now();
  1205. activeData.timer = setTimeout(() => {
  1206. activeData.model = !activeData.model;
  1207. Object.values(data.videoRefs).map((n: any) =>
  1208. n.toggleHideControl(activeData.model)
  1209. );
  1210. Object.values(data.audioRefs).map((n: any) =>
  1211. n.toggleHideControl(activeData.model)
  1212. );
  1213. if (activeData.model) {
  1214. setModelOpen();
  1215. }
  1216. }, 300);
  1217. }}>
  1218. {m.type === 'VIDEO' ? (
  1219. <>
  1220. <VideoPlay
  1221. ref={(v: any) => (data.videoRefs[mIndex] = v)}
  1222. item={m}
  1223. isEmtry={isEmtry}
  1224. onLoadedmetadata={(videoItem: any) => {
  1225. m.videoEle = videoItem;
  1226. m.isprepare = true;
  1227. }}
  1228. onTogglePlay={(paused: boolean) => {
  1229. m.autoPlay = false;
  1230. if (paused || popupData.open) {
  1231. clearTimeout(activeData.timer);
  1232. } else {
  1233. setModelOpen();
  1234. }
  1235. }}
  1236. onReset={() => {
  1237. if (!m.videoEle?.paused) {
  1238. setModelOpen();
  1239. }
  1240. }}
  1241. onError={() => {
  1242. console.log('video error');
  1243. m.error = true;
  1244. }}
  1245. />
  1246. <Transition name="van-fade">
  1247. {!m.isprepare && (
  1248. <div class={styles.loadWrap}>
  1249. <Vue3Lottie
  1250. animationData={playLoadData}></Vue3Lottie>
  1251. </div>
  1252. )}
  1253. </Transition>
  1254. </>
  1255. ) : m.type === 'IMG' ? (
  1256. <img src={m.content} />
  1257. ) : m.type === 'SONG' ? (
  1258. <AudioPay
  1259. item={m}
  1260. ref={(v: any) => (data.audioRefs[mIndex] = v)}
  1261. onLoadedmetadata={(audioItem: any) => {
  1262. m.audioEle = audioItem;
  1263. m.isprepare = true;
  1264. }}
  1265. onTogglePlay={(paused: boolean) => {
  1266. m.autoPlay = false;
  1267. if (paused || popupData.open) {
  1268. clearTimeout(activeData.timer);
  1269. } else {
  1270. setModelOpen();
  1271. }
  1272. }}
  1273. onEnded={() => {
  1274. const _index = popupData.activeIndex + 1;
  1275. if (_index < data.itemList.length) {
  1276. handleSwipeChange(_index);
  1277. }
  1278. }}
  1279. onReset={() => {
  1280. if (!m.audioEle?.paused) {
  1281. setModelOpen();
  1282. }
  1283. }}
  1284. />
  1285. ) : (
  1286. <MusicScore
  1287. activeModel={activeData.model}
  1288. data-vid={m.id}
  1289. music={m}
  1290. onSetIframe={(el: any) => {
  1291. m.iframeRef = el;
  1292. }}
  1293. />
  1294. )}
  1295. </div>
  1296. ) : null;
  1297. })}
  1298. </div>
  1299. ) : (
  1300. ''
  1301. )}
  1302. <Transition name="right">
  1303. {activeData.model && (
  1304. <div
  1305. class={styles.rightFixedBtns}
  1306. onClick={(e: Event) => {
  1307. e.stopPropagation();
  1308. clearTimeout(activeData.timer);
  1309. }}>
  1310. <div
  1311. class={[styles.fullBtn]}
  1312. onClick={() => (popupData.chapterOpen = true)}>
  1313. <img src={iconChange} />
  1314. </div>
  1315. <div
  1316. class={[
  1317. styles.fullBtn,
  1318. styles.iconUp,
  1319. !isUpArrow.value ? styles.btnsDisabled : ''
  1320. ]}
  1321. onClick={() => {
  1322. if (!isUpArrow.value) return;
  1323. handlePreAndNext('up');
  1324. }}>
  1325. <img src={iconUp} />
  1326. </div>
  1327. <div id="attent-0">
  1328. <div
  1329. class={[styles.fullBtn, styles.point]}
  1330. onClick={() => (popupData.open = true)}>
  1331. <img src={iconMenu} />
  1332. </div>
  1333. <div
  1334. class={[
  1335. styles.fullBtn,
  1336. styles.iconDown,
  1337. !isDownArrow.value ? styles.btnsDisabled : ''
  1338. ]}
  1339. onClick={() => {
  1340. if (!isDownArrow.value) return;
  1341. handlePreAndNext('down');
  1342. }}>
  1343. <img src={iconDown} />
  1344. </div>
  1345. </div>
  1346. </div>
  1347. )}
  1348. </Transition>
  1349. </div>
  1350. </div>
  1351. <div
  1352. style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
  1353. class={styles.headerContainer}
  1354. // ref={headeRef}
  1355. >
  1356. {/* <div class={styles.backBtn} onClick={() => goback()}>
  1357. <Icon name={iconBack} />
  1358. 返回
  1359. </div> */}
  1360. <div class={styles.menu}>{activeName.value}</div>
  1361. </div>
  1362. {/* 布置作业按钮 */}
  1363. {data.type !== 'preview' ? (
  1364. <div
  1365. class={[
  1366. styles.assignHomeworkClose,
  1367. activeData.model ? '' : styles.sectionAnimateUp
  1368. ]}
  1369. onClick={async () => {
  1370. data.removeVisiable = true;
  1371. data.removeTitle = '结束课程';
  1372. data.removeContent = '请确认是否结束课程?';
  1373. }}>
  1374. <img src={iconClose} />
  1375. </div>
  1376. ) : (
  1377. ''
  1378. )}
  1379. <div
  1380. id="attent-3"
  1381. class={[
  1382. styles.assignHomework,
  1383. data.type !== 'preview' ? styles.isClose : '',
  1384. activeData.model ? '' : styles.sectionAnimateUp
  1385. ]}
  1386. onClick={async () => {
  1387. if (data.type === 'preview') {
  1388. handleStop();
  1389. data.removeVisiable = true;
  1390. data.removeTitle = '结束预览';
  1391. data.removeContent = '请确认是否结束预览?';
  1392. // onFullScreen();
  1393. } else {
  1394. const res = await lessonPreTrainingPage({
  1395. coursewareKnowledgeDetailId: data.detailId,
  1396. subjectId: data.subjectId,
  1397. page: 1,
  1398. rows: 99
  1399. });
  1400. console.log(res, 'res');
  1401. if (res.data.rows && res.data.rows.length) {
  1402. data.modalAttendMessage = '本节课已设置课后训练,是否布置?';
  1403. }
  1404. data.modelAttendStatus = true;
  1405. }
  1406. }}>
  1407. <img
  1408. src={data.type === 'preview' ? iconOverPreivew : iconAssignHomework}
  1409. />
  1410. </div>
  1411. {/* 白板 批注 */}
  1412. <div
  1413. class={[
  1414. styles.switchDisplaySection,
  1415. activeData.model ? '' : styles.sectionAnimate
  1416. ]}>
  1417. <NTooltip trigger="hover">
  1418. {{
  1419. trigger: () => (
  1420. <div
  1421. id="attent-1"
  1422. class={styles.displayBtn}
  1423. onClick={() =>
  1424. openStudyTool({
  1425. type: 'pen',
  1426. icon: iconNote,
  1427. name: '批注'
  1428. })
  1429. }>
  1430. <img src={iconNote} />
  1431. </div>
  1432. ),
  1433. default: () => '批注'
  1434. }}
  1435. </NTooltip>
  1436. <NTooltip trigger="hover">
  1437. {{
  1438. trigger: () => (
  1439. <div
  1440. id="attent-2"
  1441. class={styles.displayBtn}
  1442. onClick={() =>
  1443. openStudyTool({
  1444. type: 'whiteboard',
  1445. icon: iconWhiteboard,
  1446. name: '白板'
  1447. })
  1448. }>
  1449. <img src={iconWhiteboard} />
  1450. </div>
  1451. ),
  1452. default: () => '白板'
  1453. }}
  1454. </NTooltip>
  1455. </div>
  1456. {/* 显示列表 */}
  1457. <NDrawer
  1458. v-model:show={popupData.open}
  1459. class={styles.drawerContainer}
  1460. onAfterLeave={handleClosePopup}
  1461. showMask={false}>
  1462. <NDrawerContent title="资源列表" closable>
  1463. {data.knowledgePointList.map((item: any, index: number) => (
  1464. <div class={styles.cardContainer}>
  1465. <CardType
  1466. item={item}
  1467. isActive={popupData.activeIndex === index}
  1468. isCollect={false}
  1469. isShowCollect={false}
  1470. onClick={(item: any) => {
  1471. popupData.open = false;
  1472. toggleMaterial(item.id);
  1473. }}
  1474. />
  1475. </div>
  1476. ))}
  1477. </NDrawerContent>
  1478. </NDrawer>
  1479. {/* 显示列表 */}
  1480. <NDrawer
  1481. v-model:show={popupData.chapterOpen}
  1482. class={styles.drawerContainer}
  1483. onAfterLeave={handleClosePopup}
  1484. showMask={false}>
  1485. <NDrawerContent title="切换章节" closable>
  1486. <Chapter
  1487. treeList={popupData.chapterDetails}
  1488. itemActive={data.detailId as any}
  1489. onHandleSelect={async (val: any) => {
  1490. popupData.chapterLoading = true;
  1491. try {
  1492. data.detailId = val.itemActive;
  1493. const ids = formatParentId(
  1494. val.itemActive,
  1495. popupData.chapterDetails
  1496. );
  1497. data.lessonCoursewareDetailId = ids[0];
  1498. // 更新上课记录 上课的时候才更新
  1499. if (data.type !== 'preview') {
  1500. await classCourseScheduleUpdate();
  1501. }
  1502. await getDetail();
  1503. popupData.activeIndex = 0;
  1504. popupData.chapterOpen = false;
  1505. } catch {
  1506. //
  1507. }
  1508. popupData.chapterLoading = false;
  1509. }}
  1510. />
  1511. </NDrawerContent>
  1512. </NDrawer>
  1513. {/* 批注 */}
  1514. {studyData.penShow && (
  1515. <Pen
  1516. show={studyData.type === 'pen'}
  1517. type={studyData.type}
  1518. close={() => closeStudyTool()}
  1519. />
  1520. )}
  1521. {studyData.whiteboardShow && (
  1522. <Pen
  1523. show={studyData.type === 'whiteboard'}
  1524. type={studyData.type}
  1525. close={() => closeStudyTool()}
  1526. />
  1527. )}
  1528. {/* 布置作业 */}
  1529. <NModal
  1530. transformOrigin="center"
  1531. v-model:show={data.modelAttendStatus}
  1532. preset="card"
  1533. // class={styles.attendClassModal}
  1534. title={'课后作业'}
  1535. class={['modalTitle', styles.removeVisiable]}>
  1536. <div class={styles.studentRemove}>
  1537. <p>{data.modalAttendMessage}</p>
  1538. {/* <div class={styles.modelAttendContent}>
  1539. {data.modalAttendMessage}
  1540. </div> */}
  1541. <NSpace class={styles.btnGroupModal}>
  1542. <NButton
  1543. type="default"
  1544. round
  1545. onClick={() => {
  1546. data.modelAttendStatus = false;
  1547. handleStop();
  1548. // if (state.application) {
  1549. // emit('close');
  1550. // } else {
  1551. // window.close();
  1552. // }
  1553. data.modelAttendStatus = false;
  1554. }}>
  1555. 暂不布置
  1556. </NButton>
  1557. <NButton
  1558. type="primary"
  1559. round
  1560. onClick={() => {
  1561. data.modelTrainStatus = true;
  1562. data.modelAttendStatus = false;
  1563. }}>
  1564. 布置
  1565. </NButton>
  1566. </NSpace>
  1567. </div>
  1568. </NModal>
  1569. {/* 训练设置 */}
  1570. <NModal
  1571. transformOrigin="center"
  1572. v-model:show={data.modelTrainStatus}
  1573. preset="card"
  1574. class={[styles.attendClassModal, styles.trainClassModal]}
  1575. title={'作业设置'}>
  1576. <TrainSettings
  1577. detailId={data.detailId}
  1578. subjectId={data.subjectId}
  1579. classGroupId={data.classGroupId}
  1580. onClose={() => (data.modelTrainStatus = false)}
  1581. onConfirm={() => {
  1582. // 布置完作业之后直接关闭
  1583. // setTimeout(() => {
  1584. // handleStop();
  1585. // if (state.application) {
  1586. // emit('close');
  1587. // } else {
  1588. // window.close();
  1589. // }
  1590. // }, 1000);
  1591. data.modelTrainStatus = false;
  1592. }}
  1593. />
  1594. </NModal>
  1595. {/* <NModal transformOrigin='center'
  1596. v-model:show={data.homeworkStatus}
  1597. preset="card"
  1598. class={[styles.attendClassModal]}
  1599. closable={false}
  1600. maskClosable={false}
  1601. title={' '}>
  1602. <div class={styles.workContainer}>
  1603. <h2>作业布置成功</h2>
  1604. <p>倒</p>
  1605. </div>
  1606. </NModal> */}
  1607. {showGuide.value ? <Attentguide></Attentguide> : null}
  1608. <NPopover
  1609. raw
  1610. trigger="click"
  1611. show-arrow={false}
  1612. ref={NPopoverRef}
  1613. style="--n-box-shadow: none;"
  1614. placement={directionType.value as 'left' | 'right'}
  1615. v-slots={{
  1616. trigger: () => (
  1617. // 首页不显示工具箱
  1618. <img
  1619. // src={isDragIng.value ? dragingBoxIcon : toolbox}
  1620. src={toolbox}
  1621. id="moveNPopoverA"
  1622. style={{
  1623. display: ['/', '/home'].includes(route.path)
  1624. ? 'none'
  1625. : 'block'
  1626. }}
  1627. class={[
  1628. styles.toolboxImg,
  1629. 'moveNPopoverA',
  1630. isDragIng.value ? styles.isDragIng : ''
  1631. ]}
  1632. alt=""
  1633. />
  1634. )
  1635. }}>
  1636. <div class={styles.booxToolWrap}>
  1637. <div
  1638. class={styles.booxToolItem}
  1639. onClick={() => startShowModal('beatIcon')}>
  1640. <img src={beatIcon} alt="" />
  1641. 节拍器
  1642. </div>
  1643. <div
  1644. class={styles.booxToolItem}
  1645. onClick={() => startShowModal('toneIcon')}>
  1646. <img src={toneIcon} alt="" />
  1647. 调音器
  1648. </div>
  1649. <div
  1650. class={styles.booxToolItem}
  1651. onClick={() => startShowModal('setTimeIcon')}>
  1652. <img src={setTimeIcon} alt="" />
  1653. 计时器
  1654. </div>
  1655. </div>
  1656. </NPopover>
  1657. <NModal
  1658. transformOrigin="center"
  1659. class={['modalTitle background']}
  1660. title={'节拍器'}
  1661. preset="card"
  1662. v-model:show={showModalBeat.value}
  1663. style={{ width: '687px' }}>
  1664. <div class={styles.modeWrap}>
  1665. <iframe
  1666. src={`${vaildUrl()}/metronome/?id=${new Date().getTime()}`}
  1667. scrolling="no"
  1668. frameborder="0"
  1669. width="100%"
  1670. height={'650px'}></iframe>
  1671. </div>
  1672. </NModal>
  1673. <NModal
  1674. transformOrigin="center"
  1675. class={['background']}
  1676. v-model:show={showModalTone.value}>
  1677. <div>
  1678. <PlaceholderTone
  1679. onClose={() => {
  1680. showModalTone.value = false;
  1681. }}></PlaceholderTone>
  1682. </div>
  1683. </NModal>
  1684. <NModal
  1685. transformOrigin="center"
  1686. v-model:show={showModalTime.value}
  1687. class={['modalTitle background']}
  1688. title={'计时器'}
  1689. preset="card"
  1690. style={{ width: px2vw(772) }}>
  1691. <div>
  1692. <TimerMeter></TimerMeter>
  1693. </div>
  1694. </NModal>
  1695. <NModal
  1696. transformOrigin="center"
  1697. v-model:show={data.removeVisiable}
  1698. preset="card"
  1699. class={['modalTitle', styles.removeVisiable]}
  1700. title={data.removeTitle}>
  1701. <div class={styles.studentRemove}>
  1702. <p>{data.removeContent}</p>
  1703. <NSpace class={styles.btnGroupModal} justify="center">
  1704. <NButton round onClick={() => (data.removeVisiable = false)}>
  1705. 取消
  1706. </NButton>
  1707. <NButton
  1708. round
  1709. type="primary"
  1710. onClick={() => {
  1711. //
  1712. if (globalState.application) {
  1713. document.exitFullscreen
  1714. ? document.exitFullscreen()
  1715. : document.mozCancelFullScreen
  1716. ? document.mozCancelFullScreen()
  1717. : document.webkitExitFullscreen
  1718. ? document.webkitExitFullscreen()
  1719. : '';
  1720. emit('close');
  1721. } else {
  1722. window.close();
  1723. }
  1724. }}>
  1725. 确定
  1726. </NButton>
  1727. </NSpace>
  1728. </div>
  1729. </NModal>
  1730. </div>
  1731. );
  1732. }
  1733. });