index.tsx 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545
  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. import { useRouter } from 'vue-router';
  62. import { useUserStore } from '@/store/modules/users';
  63. import iconBeatIcon from './new-image/icon-beatIcon.png';
  64. import iconChange from './new-image/icon-change.png';
  65. import iconDown from './new-image/icon-down.png';
  66. import iconMenu from './new-image/icon-menu.png';
  67. import iconNote from './new-image/icon-note.png';
  68. import iconOverClass from './new-image/icon-overclass.png';
  69. import iconSetTime from './new-image/icon-setTime.png';
  70. import iconToneIcon from './new-image/icon-toneIcon.png';
  71. import iconUp from './new-image/icon-up.png';
  72. import iconWhite from './new-image/icon-white.png';
  73. import iconWork from './new-image/icon-work.png';
  74. import dayjs from 'dayjs';
  75. export type ToolType = 'init' | 'pen' | 'whiteboard';
  76. export type ToolItem = {
  77. type: ToolType;
  78. name: string;
  79. icon: string;
  80. };
  81. export default defineComponent({
  82. name: 'CoursewarePlay',
  83. props: {
  84. type: {
  85. type: String,
  86. default: ''
  87. },
  88. subjectId: {
  89. type: [String, Number],
  90. default: ''
  91. },
  92. // 教材编号
  93. lessonCourseId: {
  94. type: [String, Number],
  95. default: ''
  96. },
  97. detailId: {
  98. type: String,
  99. default: ''
  100. },
  101. // 班级编号
  102. classGroupId: {
  103. type: String,
  104. default: ''
  105. },
  106. // 上课记录编号
  107. classId: {
  108. type: String,
  109. defaault: ''
  110. },
  111. preStudentNum: {
  112. type: [String, Number],
  113. default: ''
  114. }
  115. },
  116. emits: ['close'],
  117. setup(props, { emit }) {
  118. const message = useMessage();
  119. const route = useRoute();
  120. const router = useRouter();
  121. const users = useUserStore();
  122. /** 设置播放容器 16:9 */
  123. const parentContainer = reactive({
  124. width: '100vw'
  125. });
  126. // const NPopoverRef = ref();
  127. // const setContainer = () => {
  128. // const min = Math.min(screen.width, screen.height);
  129. // const max = Math.max(screen.width, screen.height);
  130. // const width = min * (16 / 9);
  131. // if (width > max) {
  132. // parentContainer.width = '100vw';
  133. // return;
  134. // } else {
  135. // parentContainer.width = width + 'px';
  136. // }
  137. // };
  138. const handleInit = (type = 0) => {
  139. //设置容器16:9
  140. // setContainer();
  141. };
  142. handleInit();
  143. onUnmounted(() => {
  144. handleInit(1);
  145. });
  146. const data = reactive({
  147. type: 'class' as '' | 'preview' | 'class', // 预览类型
  148. subjectId: '' as any, // 声部编号
  149. lessonCourseId: '' as any, // 教材编号
  150. lessonCoursewareDetailId: '' as any, // 章节
  151. detailId: '' as any, // 编号 - 课程编号
  152. classGroupId: '' as any, // 上课时需要 班级编号
  153. classId: '' as any, // 上课编号
  154. preStudentNum: '' as any, // 班上学生
  155. // detail: null,
  156. knowledgePointList: [] as any,
  157. itemList: [] as any,
  158. // showHead: true,
  159. // isCourse: false,
  160. // isRecordPlay: false,
  161. videoRefs: {} as any[],
  162. audioRefs: {} as any[],
  163. modelAttendStatus: false, // 布置作业提示弹窗
  164. modalAttendMessage: '本节课未设置课后作业,是否继续?',
  165. modelTrainStatus: false, // 训练设置
  166. homeworkStatus: true, // 布置作业完成时
  167. removeVisiable: false,
  168. removeTitle: '',
  169. removeContent: ''
  170. });
  171. const activeData = reactive({
  172. // isAutoPlay: false, // 是否自动播放
  173. nowTime: 0,
  174. model: true, // 遮罩
  175. isAnimation: true, // 是否动画
  176. // videoBtns: true, // 视频
  177. // currentTime: 0,
  178. // duration: 0,
  179. timer: null as any,
  180. item: null as any
  181. });
  182. const getDetail = async () => {
  183. try {
  184. const res = await queryCourseware({
  185. coursewareDetailKnowledgeId: data.detailId,
  186. subjectId: data.subjectId,
  187. pag: 1,
  188. rows: 99
  189. });
  190. const tempRows = res.data.rows || [];
  191. const temp: any = [];
  192. tempRows.forEach((row: any) => {
  193. if (!row.removeFlag) {
  194. temp.push({
  195. id: row.id,
  196. materialId: row.materialId,
  197. coverImg: row.coverImg,
  198. type: row.materialType,
  199. title: row.materialName,
  200. isCollect: !!row.favoriteFlag,
  201. isSelected: row.source === 'PLATFORM' ? true : false,
  202. content: row.content
  203. });
  204. }
  205. });
  206. data.knowledgePointList = temp;
  207. data.itemList = data.knowledgePointList.map((m: any) => {
  208. return {
  209. ...m,
  210. iframeRef: null,
  211. videoEle: null,
  212. audioEle: null,
  213. autoPlay: false, //加载完成是否自动播放
  214. isprepare: false, // 视频是否加载完成
  215. isRender: false // 是否渲染了
  216. };
  217. });
  218. } catch {
  219. //
  220. }
  221. };
  222. const showModalBeat = ref(false);
  223. const showModalTone = ref(false);
  224. const showModalTime = ref(false);
  225. // ifram事件处理
  226. const iframeHandle = (ev: MessageEvent) => {
  227. console.log(ev.data?.api, ev.data, 'ev.data');
  228. if (ev.data?.api === 'headerTogge') {
  229. activeData.model =
  230. ev.data.show || (ev.data.playState == 'play' ? false : true);
  231. }
  232. //
  233. if (ev.data?.api === 'onAttendToggleMenu') {
  234. activeData.model = !activeData.model;
  235. }
  236. if (ev.data?.api === 'api_fingerPreView') {
  237. clearInterval(activeData.timer);
  238. activeData.model = !ev.data.state;
  239. }
  240. //
  241. if (ev.data?.api === 'documentBodyKeyup') {
  242. if (ev.data?.code === 'ArrowLeft') {
  243. setModalOpen();
  244. handlePreAndNext('up');
  245. }
  246. if (ev.data?.code === 'ArrowRight') {
  247. setModalOpen();
  248. handlePreAndNext('down');
  249. }
  250. }
  251. if (ev.data?.api === 'onLogin') {
  252. const documentDom: any = document;
  253. documentDom.exitFullscreen
  254. ? documentDom.exitFullscreen()
  255. : documentDom.mozCancelFullScreen
  256. ? documentDom.mozCancelFullScreen()
  257. : documentDom.webkitExitFullscreen
  258. ? documentDom.webkitExitFullscreen()
  259. : '';
  260. users.logout();
  261. router.replace('/login');
  262. }
  263. };
  264. onMounted(() => {
  265. // initMoveable();
  266. const query = route.query;
  267. console.log(query, props.preStudentNum, '学生人数');
  268. // 先取参数,
  269. data.type = props.type || (query.type as any);
  270. data.subjectId = props.subjectId || query.subjectId;
  271. data.detailId = props.detailId || query.detailId;
  272. data.lessonCourseId = props.lessonCourseId || query.lessonCourseId;
  273. data.classGroupId = props.classGroupId || query.classGroupId;
  274. data.classId = props.classId || query.classId;
  275. data.preStudentNum = props.preStudentNum || query.preStudentNum;
  276. window.addEventListener('message', iframeHandle);
  277. getDetail();
  278. getLessonCoursewareDetail();
  279. });
  280. const onFullScreen = () => {
  281. if (data.type === 'preview') {
  282. const el: any = document.querySelector('#app');
  283. if (el.mozRequestFullScreen) {
  284. el.mozRequestFullScreen();
  285. } else if (el.webkitRequestFullscreen) {
  286. el.webkitRequestFullscreen();
  287. } else if (el.requestFullScreen) {
  288. el.requestFullscreen();
  289. }
  290. }
  291. };
  292. const popupData = reactive({
  293. open: false,
  294. activeIndex: 0,
  295. toolOpen: false, // 工具弹窗控制
  296. chapterOpen: false, // 切换章节
  297. chapterDetails: [] as any,
  298. chapterLoading: false // 加载数据
  299. });
  300. const formatParentId = (id: any, list: any, ids = [] as any) => {
  301. for (const item of list) {
  302. if (item.knowledgeList && item.knowledgeList.length > 0) {
  303. const cIds: any = formatParentId(id, item.knowledgeList, [
  304. ...ids,
  305. item.id
  306. ]);
  307. if (cIds.includes(id)) {
  308. return cIds;
  309. }
  310. }
  311. if (item.id === id) {
  312. return [...ids, id];
  313. }
  314. }
  315. return ids;
  316. };
  317. /** 获取章节 */
  318. const getLessonCoursewareDetail = async () => {
  319. try {
  320. const res = await lessonCoursewareDetail({
  321. id: data.lessonCourseId,
  322. subjectId: data.subjectId
  323. });
  324. popupData.chapterDetails = res.data.lessonList || [];
  325. const ids = formatParentId(data.detailId, popupData.chapterDetails);
  326. data.lessonCoursewareDetailId = ids[0];
  327. } catch {
  328. //
  329. }
  330. };
  331. /** 更新上课记录 */
  332. const classCourseScheduleUpdate = async () => {
  333. try {
  334. if (!data.classId) return;
  335. await courseScheduleUpdate({
  336. lessonCoursewareKnowledgeDetailId: data.detailId,
  337. id: data.classId
  338. });
  339. } catch {
  340. //
  341. }
  342. };
  343. const activeName = computed(() => {
  344. let name = '';
  345. // data.knowledgePointList.forEach((item: any, index: number) => {
  346. // if (popupData.activeIndex === index) {
  347. // name = item.title;
  348. // }
  349. // });
  350. popupData.chapterDetails.forEach((chapter: any) => {
  351. if (chapter.id === data.lessonCoursewareDetailId) {
  352. name = chapter.name;
  353. chapter.knowledgeList?.forEach((know: any) => {
  354. if (know.id === data.detailId) {
  355. name += ' - ' + know.name;
  356. }
  357. });
  358. }
  359. });
  360. return name;
  361. });
  362. /**停止所有的播放 */
  363. const handleStop = () => {
  364. for (let i = 0; i < data.itemList.length; i++) {
  365. const activeItem = data.itemList[i];
  366. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  367. // console.log(activeItem.videoEle, ' activeItem.videoEle');
  368. try {
  369. activeItem.videoEle?.currentTime(0);
  370. activeItem.videoEle?.pause();
  371. } catch (e: any) {
  372. // console.log(e, 'e');
  373. }
  374. }
  375. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  376. activeItem.audioEle?.stop();
  377. }
  378. // console.log('🚀 ~ activeItem:', activeItem)
  379. // 停止曲谱的播放
  380. if (activeItem.type === 'MUSIC') {
  381. activeItem.iframeRef?.contentWindow?.postMessage(
  382. { api: 'setPlayState' },
  383. '*'
  384. );
  385. }
  386. }
  387. };
  388. // 切换素材
  389. const toggleMaterial = (itemActive: any) => {
  390. const index = data.itemList.findIndex((n: any) => n.id == itemActive);
  391. if (index > -1) {
  392. handleSwipeChange(index);
  393. }
  394. };
  395. /** 延迟收起模态框 */
  396. const setModelOpen = () => {
  397. clearTimeout(activeData.timer);
  398. message.destroyAll();
  399. activeData.timer = setTimeout(() => {
  400. activeData.model = false;
  401. Object.values(data.videoRefs).map((n: any) =>
  402. n?.toggleHideControl(false)
  403. );
  404. Object.values(data.audioRefs).map((n: any) =>
  405. n?.toggleHideControl(false)
  406. );
  407. }, 4000);
  408. };
  409. /** 立即收起所有的模态框 */
  410. const clearModel = () => {
  411. clearTimeout(activeData.timer);
  412. message.destroyAll();
  413. activeData.model = false;
  414. Object.values(data.videoRefs).map((n: any) =>
  415. n?.toggleHideControl(false)
  416. );
  417. Object.values(data.audioRefs).map((n: any) =>
  418. n?.toggleHideControl(false)
  419. );
  420. };
  421. const toggleModel = (type = true) => {
  422. activeData.model = type;
  423. Object.values(data.videoRefs).map((n: any) => n?.toggleHideControl(type));
  424. Object.values(data.audioRefs).map((n: any) => n?.toggleHideControl(type));
  425. };
  426. // 双击
  427. const handleDbClick = (item: any) => {
  428. if (item && item.type === 'VIDEO') {
  429. const videoEle: HTMLVideoElement = item.videoEle;
  430. if (videoEle) {
  431. if (videoEle.paused) {
  432. message.destroyAll();
  433. videoEle.play();
  434. } else {
  435. message.warning('已暂停');
  436. videoEle.pause();
  437. }
  438. }
  439. }
  440. };
  441. // 切换播放
  442. // const togglePlay = (m: any, isPlay: boolean) => {
  443. // if (isPlay) {
  444. // m.videoEle?.play();
  445. // } else {
  446. // m.videoEle?.pause();
  447. // }
  448. // };
  449. // const showIndex = ref(-4);
  450. const effectIndex = ref(3);
  451. const effects = [
  452. {
  453. prev: {
  454. transform: 'translate3d(0, 0, -800px) rotateX(180deg)'
  455. },
  456. next: {
  457. transform: 'translate3d(0, 0, -800px) rotateX(-180deg)'
  458. }
  459. },
  460. {
  461. prev: {
  462. transform: 'translate3d(-100%, 0, -800px)'
  463. },
  464. next: {
  465. transform: 'translate3d(100%, 0, -800px)'
  466. }
  467. },
  468. {
  469. prev: {
  470. transform: 'translate3d(-50%, 0, -800px) rotateY(80deg)'
  471. },
  472. next: {
  473. transform: 'translate3d(50%, 0, -800px) rotateY(-80deg)'
  474. }
  475. },
  476. {
  477. prev: {
  478. transform: 'translate3d(-100%, 0, -800px) rotateY(-120deg)'
  479. },
  480. next: {
  481. transform: 'translate3d(100%, 0, -800px) rotateY(120deg)'
  482. }
  483. },
  484. // 风车4
  485. {
  486. prev: {
  487. transform: 'translate3d(-50%, 50%, -800px) rotateZ(-14deg)',
  488. opacity: 0
  489. },
  490. next: {
  491. transform: 'translate3d(50%, 50%, -800px) rotateZ(14deg)',
  492. opacity: 0
  493. }
  494. },
  495. // 翻页5
  496. {
  497. prev: {
  498. transform: 'translateZ(-800px) rotate3d(0, -1, 0, 90deg)',
  499. opacity: 0
  500. },
  501. next: {
  502. transform: 'translateZ(-800px) rotate3d(0, 1, 0, 90deg)',
  503. opacity: 0
  504. },
  505. current: { transitionDelay: '700ms' }
  506. }
  507. ];
  508. const acitveTimer = ref();
  509. // 轮播切换
  510. const handleSwipeChange = (index: number) => {
  511. // 如果是当前正在播放 或者是视频最后一个
  512. if (popupData.activeIndex == index) return;
  513. handleStop();
  514. clearTimeout(acitveTimer.value);
  515. checkedAnimation(popupData.activeIndex, index);
  516. popupData.activeIndex = index;
  517. acitveTimer.value = setTimeout(
  518. () => {
  519. const item = data.itemList[index];
  520. if (item) {
  521. if (item.type == 'MUSIC') {
  522. activeData.model = true;
  523. }
  524. if (item.type === 'SONG') {
  525. // 自动播放下一个音频
  526. clearTimeout(activeData.timer);
  527. message.destroyAll();
  528. // item.autoPlay = false;
  529. // nextTick(() => {
  530. // item.audioEle?.onPlay();
  531. // });
  532. }
  533. if (item.type === 'VIDEO') {
  534. // 自动播放下一个视频
  535. clearTimeout(activeData.timer);
  536. message.destroyAll();
  537. nextTick(() => {
  538. if (item.error) {
  539. // console.log(item, 'item error');
  540. item.videoEle?.src(item.content);
  541. item.error = false;
  542. // item.videoEle?.onPlay();
  543. }
  544. });
  545. }
  546. }
  547. },
  548. activeData.isAnimation ? 800 : 0
  549. );
  550. };
  551. /** 是否有转场动画 */
  552. const checkedAnimation = (index: number, nextIndex?: number) => {
  553. const item = data.itemList[index];
  554. const nextItem = data.itemList[nextIndex!];
  555. if (nextItem) {
  556. if (nextItem.knowledgePointId != item.knowledgePointId) {
  557. activeData.isAnimation = true;
  558. return;
  559. }
  560. const videoEle = item.videoEle;
  561. const nextVideo = nextItem.videoEle;
  562. if (videoEle && videoEle.duration < 8 && index < nextIndex!) {
  563. activeData.isAnimation = false;
  564. } else if (nextVideo && nextVideo.duration < 8 && index > nextIndex!) {
  565. activeData.isAnimation = false;
  566. } else {
  567. activeData.isAnimation = true;
  568. }
  569. } else {
  570. activeData.isAnimation = item?.adviseStudyTimeSecond < 8 ? false : true;
  571. }
  572. };
  573. // 上一个知识点, 下一个知识点
  574. const handlePreAndNext = async (type: string) => {
  575. // if (type === 'up') {
  576. // handleSwipeChange(popupData.activeIndex - 1);
  577. // } else {
  578. // handleSwipeChange(popupData.activeIndex + 1);
  579. // }
  580. if (type === 'up') {
  581. // 判断上面是否还有章节
  582. if (popupData.activeIndex > 0) {
  583. handleSwipeChange(popupData.activeIndex - 1);
  584. return;
  585. }
  586. // 获取当前是哪个章节
  587. let detailIndex = popupData.chapterDetails.findIndex(
  588. (item: any) => item.id == data.lessonCoursewareDetailId
  589. );
  590. const detailItem =
  591. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  592. let lessonIndex = detailItem.findIndex(
  593. (item: any) => item.id == data.detailId
  594. );
  595. let lessonStatus = false; // 当前章节上面是否有内容
  596. let lessonCoursewareDetailId = '';
  597. let coursewareDetailKnowledgeId = '';
  598. while (lessonIndex >= 0) {
  599. lessonIndex--;
  600. if (lessonIndex >= 0) {
  601. if (detailItem[lessonIndex].containMaterial) {
  602. lessonStatus = true;
  603. lessonCoursewareDetailId =
  604. detailItem[lessonIndex].lessonCoursewareDetailId;
  605. coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
  606. }
  607. }
  608. if (lessonStatus) {
  609. break;
  610. }
  611. }
  612. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  613. if (lessonStatus) {
  614. popupData.chapterLoading = true;
  615. data.detailId = coursewareDetailKnowledgeId;
  616. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  617. // 更新上课记录 上课的时候才更新
  618. if (data.type !== 'preview') {
  619. await classCourseScheduleUpdate();
  620. }
  621. await getDetail();
  622. popupData.activeIndex = data.itemList.length - 1 || 0;
  623. popupData.chapterOpen = false;
  624. popupData.chapterLoading = false;
  625. return;
  626. }
  627. let prevLessonStatus = false;
  628. while (detailIndex >= 0) {
  629. detailIndex--;
  630. const tempDetail =
  631. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  632. let tempLessonLength = tempDetail.length;
  633. while (tempLessonLength > 0) {
  634. if (tempDetail[tempLessonLength - 1].containMaterial) {
  635. prevLessonStatus = true;
  636. lessonCoursewareDetailId =
  637. tempDetail[tempLessonLength - 1].lessonCoursewareDetailId;
  638. coursewareDetailKnowledgeId = tempDetail[tempLessonLength - 1].id;
  639. }
  640. tempLessonLength--;
  641. if (prevLessonStatus) {
  642. break;
  643. }
  644. }
  645. if (prevLessonStatus) {
  646. break;
  647. }
  648. }
  649. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  650. if (prevLessonStatus) {
  651. popupData.chapterLoading = true;
  652. data.detailId = coursewareDetailKnowledgeId;
  653. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  654. await getDetail();
  655. popupData.activeIndex = data.itemList.length - 1 || 0;
  656. popupData.chapterLoading = false;
  657. return;
  658. }
  659. } else {
  660. if (popupData.activeIndex < data.itemList.length - 1) {
  661. handleSwipeChange(popupData.activeIndex + 1);
  662. return;
  663. }
  664. // 获取当前是哪个章节
  665. let detailIndex = popupData.chapterDetails.findIndex(
  666. (item: any) => item.id == data.lessonCoursewareDetailId
  667. );
  668. const detailItem =
  669. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  670. let lessonIndex = detailItem.findIndex(
  671. (item: any) => item.id == data.detailId
  672. );
  673. let lessonStatus = false; // 当前章节下面是否有内容
  674. let lessonCoursewareDetailId = '';
  675. let coursewareDetailKnowledgeId = '';
  676. while (lessonIndex < detailItem.length - 1) {
  677. lessonIndex++;
  678. if (lessonIndex >= 0) {
  679. if (detailItem[lessonIndex].containMaterial) {
  680. lessonStatus = true;
  681. lessonCoursewareDetailId =
  682. detailItem[lessonIndex].lessonCoursewareDetailId;
  683. coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
  684. }
  685. }
  686. if (lessonStatus) {
  687. break;
  688. }
  689. }
  690. // 判断当前章节下面课程是否有内容,否则往下一个章节走
  691. if (lessonStatus) {
  692. popupData.chapterLoading = true;
  693. data.detailId = coursewareDetailKnowledgeId;
  694. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  695. // 更新上课记录 上课的时候才更新
  696. if (data.type !== 'preview') {
  697. await classCourseScheduleUpdate();
  698. }
  699. await getDetail();
  700. popupData.activeIndex = 0;
  701. popupData.chapterOpen = false;
  702. popupData.chapterLoading = false;
  703. return;
  704. }
  705. let nextLessonStatus = false;
  706. while (detailIndex <= popupData.chapterDetails.length - 1) {
  707. detailIndex++;
  708. const tempDetail =
  709. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  710. let tempLessonLength = 0;
  711. while (tempLessonLength <= tempDetail.length - 1) {
  712. if (tempDetail[tempLessonLength].containMaterial) {
  713. nextLessonStatus = true;
  714. lessonCoursewareDetailId =
  715. tempDetail[tempLessonLength].lessonCoursewareDetailId;
  716. coursewareDetailKnowledgeId = tempDetail[tempLessonLength].id;
  717. }
  718. tempLessonLength++;
  719. if (nextLessonStatus) {
  720. break;
  721. }
  722. }
  723. if (nextLessonStatus) {
  724. break;
  725. }
  726. }
  727. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  728. if (nextLessonStatus) {
  729. popupData.chapterLoading = true;
  730. data.detailId = coursewareDetailKnowledgeId;
  731. data.lessonCoursewareDetailId = lessonCoursewareDetailId;
  732. // 更新上课记录 上课的时候才更新
  733. if (data.type !== 'preview') {
  734. await classCourseScheduleUpdate();
  735. }
  736. await getDetail();
  737. popupData.activeIndex = 0;
  738. popupData.chapterOpen = false;
  739. popupData.chapterLoading = false;
  740. return;
  741. }
  742. }
  743. };
  744. /** 弹窗关闭 */
  745. const handleClosePopup = () => {
  746. const item = data.itemList[popupData.activeIndex];
  747. if (item?.type == 'VIDEO' && !item.videoEle?.paused) {
  748. setModelOpen();
  749. }
  750. if (item?.type == 'SONG' && !item.audioEle?.paused) {
  751. setModelOpen();
  752. }
  753. };
  754. // 监听页面键盘事件 - 上下切换
  755. document.body.addEventListener('keyup', (e: KeyboardEvent) => {
  756. // console.log(e, 'e');
  757. if (e.code === 'ArrowLeft') {
  758. // if (popupData.activeIndex === 0) return;
  759. setModalOpen();
  760. handlePreAndNext('up');
  761. } else if (e.code === 'ArrowRight') {
  762. // if (popupData.activeIndex === data.itemList.length - 1) return;
  763. setModalOpen();
  764. handlePreAndNext('down');
  765. }
  766. });
  767. const setModalOpen = (status = true) => {
  768. clearTimeout(activeData.timer);
  769. activeData.model = status;
  770. Object.values(data.videoRefs).map((n: any) =>
  771. n?.toggleHideControl(status)
  772. );
  773. Object.values(data.audioRefs).map((n: any) =>
  774. n?.toggleHideControl(status)
  775. );
  776. };
  777. /** 教学数据 */
  778. const studyData = reactive({
  779. type: '' as ToolType,
  780. penShow: false,
  781. whiteboardShow: false
  782. });
  783. /** 打开教学工具 */
  784. const openStudyTool = (item: ToolItem) => {
  785. const activeItem = data.itemList[popupData.activeIndex];
  786. // 暂停视频和曲谱的播放
  787. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  788. activeItem.videoEle?.pause();
  789. }
  790. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  791. activeItem.audioEle?.stop();
  792. }
  793. if (activeItem.type === 'MUSIC') {
  794. activeItem.iframeRef?.contentWindow?.postMessage(
  795. { api: 'setPlayState' },
  796. '*'
  797. );
  798. }
  799. clearModel();
  800. popupData.toolOpen = false;
  801. studyData.type = item.type;
  802. switch (item.type) {
  803. case 'pen':
  804. studyData.penShow = true;
  805. break;
  806. case 'whiteboard':
  807. studyData.whiteboardShow = true;
  808. }
  809. };
  810. /** 关闭教学工具 */
  811. const closeStudyTool = () => {
  812. studyData.type = 'init';
  813. toggleModel();
  814. };
  815. const startShowModal = (
  816. val: 'setTimeIcon' | 'beatIcon' | 'toneIcon' | 'iconNote2'
  817. ) => {
  818. if (val == 'setTimeIcon') {
  819. showModalTime.value = true;
  820. }
  821. if (val == 'beatIcon') {
  822. showModalBeat.value = true;
  823. }
  824. if (val == 'toneIcon') {
  825. showModalTone.value = true;
  826. }
  827. // if (val == 'iconNote2') {
  828. // if (NPopoverRef.value) {
  829. // NPopoverRef.value.setShow(false);
  830. // }
  831. // eventGlobal.emit('teacher-guideInfo-attend-class', 'attend-class');
  832. // }
  833. };
  834. // 是否允许上一页
  835. const isUpArrow = computed(() => {
  836. /**
  837. * 1,判断当前课程中是否处在第一个资源;
  838. * 2,判断当前课程是否在当前章节的第一个;
  839. * 3,判断当前章节,当前课程上面还没有其它课程,是否有资源;
  840. * 4,判断当前章节上面还没有其它章节;
  841. * 5,判断上面章节里面课程是否有资源;
  842. */
  843. if (popupData.activeIndex > 0) {
  844. return true;
  845. }
  846. // 获取当前是哪个章节
  847. let detailIndex = popupData.chapterDetails.findIndex(
  848. (item: any) => item.id == data.lessonCoursewareDetailId
  849. );
  850. const detailItem =
  851. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  852. let lessonIndex = detailItem.findIndex(
  853. (item: any) => item.id == data.detailId
  854. );
  855. // 说明已经是第一单元,第一课
  856. if (detailIndex <= 0 && lessonIndex <= 0) {
  857. return false;
  858. }
  859. let lessonStatus = false; // 当前章节上面是否有内容
  860. while (lessonIndex >= 0) {
  861. lessonIndex--;
  862. if (lessonIndex >= 0) {
  863. if (detailItem[lessonIndex].containMaterial) {
  864. lessonStatus = true;
  865. }
  866. }
  867. }
  868. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  869. if (lessonStatus) {
  870. return true;
  871. }
  872. // 已经是第一个章节了
  873. if (detailIndex <= 0) {
  874. return false;
  875. }
  876. let prevLessonStatus = false;
  877. while (detailIndex >= 0) {
  878. detailIndex--;
  879. const tempDetail =
  880. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  881. let tempLessonLength = tempDetail.length;
  882. while (tempLessonLength > 0) {
  883. if (tempDetail[tempLessonLength - 1].containMaterial) {
  884. prevLessonStatus = true;
  885. }
  886. tempLessonLength--;
  887. }
  888. if (prevLessonStatus) {
  889. return true;
  890. }
  891. }
  892. return false;
  893. });
  894. // 是否允许下一页
  895. const isDownArrow = computed(() => {
  896. if (popupData.activeIndex < data.itemList.length - 1) {
  897. return true;
  898. }
  899. // 获取当前是哪个章节
  900. let detailIndex = popupData.chapterDetails.findIndex(
  901. (item: any) => item.id == data.lessonCoursewareDetailId
  902. );
  903. const detailItem =
  904. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  905. let lessonIndex = detailItem.findIndex(
  906. (item: any) => item.id == data.detailId
  907. );
  908. // 说明已经是最后-单元,最后一课
  909. if (
  910. detailIndex >= popupData.chapterDetails.length - 1 &&
  911. lessonIndex >= detailItem.length - 1
  912. ) {
  913. return false;
  914. }
  915. let lessonStatus = false; // 当前章节下面是否有内容
  916. while (lessonIndex < detailItem.length - 1) {
  917. lessonIndex++;
  918. if (lessonIndex >= 0) {
  919. if (detailItem[lessonIndex].containMaterial) {
  920. lessonStatus = true;
  921. }
  922. }
  923. }
  924. // 判断当前章节下面课程是否有内容,否则往下一个章节走
  925. if (lessonStatus) {
  926. return true;
  927. }
  928. // 已经是最后一个章节了
  929. if (detailIndex >= popupData.chapterDetails.length - 1) {
  930. return false;
  931. }
  932. let nextLessonStatus = false;
  933. while (detailIndex < popupData.chapterDetails.length - 1) {
  934. detailIndex++;
  935. const tempDetail =
  936. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  937. let tempLessonLength = 0;
  938. while (tempLessonLength <= tempDetail.length - 1) {
  939. if (tempDetail[tempLessonLength].containMaterial) {
  940. nextLessonStatus = true;
  941. }
  942. tempLessonLength++;
  943. }
  944. if (nextLessonStatus) {
  945. return true;
  946. }
  947. }
  948. return false;
  949. });
  950. return () => (
  951. <div id="playContent" class={[styles.playContent, 'wrap']}>
  952. <div
  953. onClick={() => {
  954. clearTimeout(activeData.timer);
  955. activeData.model = !activeData.model;
  956. Object.values(data.videoRefs).map((n: any) =>
  957. n?.toggleHideControl(activeData.model)
  958. );
  959. Object.values(data.audioRefs).map((n: any) =>
  960. n?.toggleHideControl(activeData.model)
  961. );
  962. }}>
  963. <div
  964. class={styles.coursewarePlay}
  965. style={{ width: parentContainer.width }}
  966. onClick={(e: Event) => {
  967. e.stopPropagation();
  968. setModelOpen();
  969. }}>
  970. {!popupData.chapterLoading ? (
  971. <div class={styles.wraps}>
  972. {data.itemList.map((m: any, mIndex: number) => {
  973. const isRender = Math.abs(popupData.activeIndex - mIndex) < 2;
  974. const isEmtry = Math.abs(popupData.activeIndex - mIndex) > 4;
  975. // if (isRender) {
  976. // m.isRender = true;
  977. // }
  978. // console.log(isRender, 'isRender', mIndex);
  979. return isRender ? (
  980. <div
  981. key={'index' + mIndex}
  982. class={[
  983. styles.itemDiv,
  984. popupData.activeIndex === mIndex && styles.itemActive,
  985. activeData.isAnimation && styles.acitveAnimation,
  986. Math.abs(popupData.activeIndex - mIndex) < 2
  987. ? styles.show
  988. : styles.hide
  989. ]}
  990. style={
  991. mIndex < popupData.activeIndex
  992. ? effects[effectIndex.value].prev
  993. : mIndex > popupData.activeIndex
  994. ? effects[effectIndex.value].next
  995. : {}
  996. }
  997. onClick={(e: Event) => {
  998. e.stopPropagation();
  999. clearTimeout(activeData.timer);
  1000. if (Date.now() - activeData.nowTime < 300) {
  1001. handleDbClick(m);
  1002. return;
  1003. }
  1004. activeData.nowTime = Date.now();
  1005. activeData.timer = setTimeout(() => {
  1006. activeData.model = !activeData.model;
  1007. Object.values(data.videoRefs).map((n: any) =>
  1008. n?.toggleHideControl(activeData.model)
  1009. );
  1010. Object.values(data.audioRefs).map((n: any) =>
  1011. n?.toggleHideControl(activeData.model)
  1012. );
  1013. if (activeData.model) {
  1014. setModelOpen();
  1015. }
  1016. }, 300);
  1017. }}>
  1018. {m.type === 'VIDEO' ? (
  1019. <>
  1020. <VideoPlay
  1021. ref={(v: any) => (data.videoRefs[mIndex] = v)}
  1022. item={m}
  1023. isEmtry={isEmtry}
  1024. onLoadedmetadata={(videoItem: any) => {
  1025. m.videoEle = videoItem;
  1026. m.isprepare = true;
  1027. }}
  1028. onTogglePlay={(paused: boolean) => {
  1029. m.autoPlay = false;
  1030. if (paused || popupData.open) {
  1031. clearTimeout(activeData.timer);
  1032. } else {
  1033. setModelOpen();
  1034. }
  1035. }}
  1036. onReset={() => {
  1037. if (!m.videoEle?.paused) {
  1038. setModelOpen();
  1039. }
  1040. }}
  1041. onError={() => {
  1042. console.log('video error');
  1043. m.error = true;
  1044. }}
  1045. />
  1046. <Transition name="van-fade">
  1047. {!m.isprepare && (
  1048. <div class={styles.loadWrap}>
  1049. <Vue3Lottie
  1050. animationData={playLoadData}></Vue3Lottie>
  1051. </div>
  1052. )}
  1053. </Transition>
  1054. </>
  1055. ) : m.type === 'IMG' ? (
  1056. <img src={m.content} />
  1057. ) : m.type === 'SONG' ? (
  1058. <AudioPay
  1059. item={m}
  1060. ref={(v: any) => (data.audioRefs[mIndex] = v)}
  1061. onLoadedmetadata={(audioItem: any) => {
  1062. m.audioEle = audioItem;
  1063. m.isprepare = true;
  1064. }}
  1065. onTogglePlay={(paused: boolean) => {
  1066. m.autoPlay = false;
  1067. if (paused || popupData.open) {
  1068. clearTimeout(activeData.timer);
  1069. } else {
  1070. setModelOpen();
  1071. }
  1072. }}
  1073. onEnded={() => {
  1074. const _index = popupData.activeIndex + 1;
  1075. if (_index < data.itemList.length) {
  1076. handleSwipeChange(_index);
  1077. }
  1078. }}
  1079. onReset={() => {
  1080. if (!m.audioEle?.paused) {
  1081. setModelOpen();
  1082. }
  1083. }}
  1084. />
  1085. ) : (
  1086. <MusicScore
  1087. activeModel={activeData.model}
  1088. activeStatus={popupData.activeIndex === mIndex}
  1089. data-vid={m.id}
  1090. music={m}
  1091. onSetIframe={(el: any) => {
  1092. m.iframeRef = el;
  1093. }}
  1094. />
  1095. )}
  1096. </div>
  1097. ) : null;
  1098. })}
  1099. </div>
  1100. ) : (
  1101. ''
  1102. )}
  1103. </div>
  1104. </div>
  1105. {/* 头部样式 */}
  1106. <div
  1107. style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
  1108. class={styles.headerContainer}>
  1109. <div class={styles.menu}>{activeName.value}</div>
  1110. {'23:01'}
  1111. </div>
  1112. {/* 布置作业按钮 */}
  1113. <div
  1114. onClick={(e: any) => {
  1115. e.stopPropagation();
  1116. }}
  1117. class={[
  1118. styles.switchDisplaySection,
  1119. activeData.model ? '' : styles.sectionAnimate
  1120. ]}>
  1121. <NSpace class={styles.switchSpace}>
  1122. <div
  1123. class={styles.btnItem}
  1124. onClick={async () => {
  1125. if (data.type === 'preview') {
  1126. handleStop();
  1127. data.removeVisiable = true;
  1128. data.removeTitle = '结束预览';
  1129. data.removeContent = '请确认是否结束预览?';
  1130. } else {
  1131. data.removeVisiable = true;
  1132. data.removeTitle = '结束课程';
  1133. data.removeContent = '请确认是否结束课程?';
  1134. }
  1135. }}>
  1136. <img src={iconOverClass} />
  1137. <p>{data.type !== 'preview' ? '结束课程' : '结束预览'}</p>
  1138. </div>
  1139. {data.type !== 'preview' && (
  1140. <div
  1141. class={[
  1142. styles.btnItem,
  1143. data.preStudentNum <= 0 ? styles.btnsDisabled : ''
  1144. ]}
  1145. onClick={async () => {
  1146. // 学生人数必须大于0,才可以布置作业
  1147. if (data.preStudentNum <= 0) return;
  1148. const res = await lessonPreTrainingPage({
  1149. coursewareKnowledgeDetailId: data.detailId,
  1150. subjectId: data.subjectId,
  1151. page: 1,
  1152. rows: 99
  1153. });
  1154. if (res.data.rows && res.data.rows.length) {
  1155. data.modalAttendMessage =
  1156. '本节课已设置课后作业,是否布置?';
  1157. }
  1158. data.modelAttendStatus = true;
  1159. }}>
  1160. <img src={iconWork} />
  1161. <p>布置作业</p>
  1162. </div>
  1163. )}
  1164. <div
  1165. class={styles.btnItem}
  1166. onClick={() =>
  1167. openStudyTool({
  1168. type: 'pen',
  1169. icon: iconNote,
  1170. name: '批注'
  1171. })
  1172. }>
  1173. <img src={iconNote} />
  1174. <p>批注</p>
  1175. </div>
  1176. <div
  1177. class={styles.btnItem}
  1178. onClick={() =>
  1179. openStudyTool({
  1180. type: 'whiteboard',
  1181. icon: iconWhite,
  1182. name: '白板'
  1183. })
  1184. }>
  1185. <img src={iconWhite} />
  1186. <p>白板</p>
  1187. </div>
  1188. <div
  1189. class={styles.btnItem}
  1190. onClick={() => startShowModal('beatIcon')}>
  1191. <img src={iconToneIcon} />
  1192. <p>节拍器</p>
  1193. </div>
  1194. <div
  1195. class={styles.btnItem}
  1196. onClick={() => startShowModal('toneIcon')}>
  1197. <img src={iconSetTime} />
  1198. <p>调音器</p>
  1199. </div>
  1200. <div
  1201. class={styles.btnItem}
  1202. onClick={() => startShowModal('setTimeIcon')}>
  1203. <img src={iconBeatIcon} />
  1204. <p>计时器</p>
  1205. </div>
  1206. </NSpace>
  1207. <NSpace class={styles.switchSpace}>
  1208. <div
  1209. class={styles.btnItem}
  1210. onClick={() => (popupData.chapterOpen = true)}>
  1211. <img src={iconChange} />
  1212. <p>切换章节</p>
  1213. </div>
  1214. <div class={styles.btnItem} onClick={() => (popupData.open = true)}>
  1215. <img src={iconMenu} />
  1216. <p>资源列表</p>
  1217. </div>
  1218. <div
  1219. class={[
  1220. styles.btnItem,
  1221. !isUpArrow.value ? styles.btnsDisabled : ''
  1222. ]}
  1223. onClick={() => {
  1224. if (!isUpArrow.value) return;
  1225. handlePreAndNext('up');
  1226. }}>
  1227. <img src={iconUp} />
  1228. <p>上一个</p>
  1229. </div>
  1230. <div
  1231. class={[
  1232. styles.btnItem,
  1233. !isDownArrow.value ? styles.btnsDisabled : ''
  1234. ]}
  1235. onClick={() => {
  1236. if (!isDownArrow.value) return;
  1237. handlePreAndNext('down');
  1238. }}>
  1239. <img src={iconDown} />
  1240. <p>下一个</p>
  1241. </div>
  1242. </NSpace>
  1243. </div>
  1244. {/* 显示列表 */}
  1245. <NDrawer
  1246. v-model:show={popupData.open}
  1247. class={styles.drawerContainer}
  1248. onAfterLeave={handleClosePopup}
  1249. showMask={false}>
  1250. <NDrawerContent title="资源列表" closable>
  1251. {data.knowledgePointList.map((item: any, index: number) => (
  1252. <div class={styles.cardContainer}>
  1253. <CardType
  1254. item={item}
  1255. isActive={popupData.activeIndex === index}
  1256. isCollect={false}
  1257. isShowCollect={false}
  1258. onClick={(item: any) => {
  1259. popupData.open = false;
  1260. toggleMaterial(item.id);
  1261. }}
  1262. />
  1263. </div>
  1264. ))}
  1265. </NDrawerContent>
  1266. </NDrawer>
  1267. {/* 显示列表 */}
  1268. <NDrawer
  1269. v-model:show={popupData.chapterOpen}
  1270. class={styles.drawerContainer}
  1271. onAfterLeave={handleClosePopup}
  1272. showMask={false}
  1273. displayDirective="show">
  1274. <NDrawerContent title="切换章节" closable>
  1275. <Chapter
  1276. treeList={popupData.chapterDetails}
  1277. itemActive={data.detailId as any}
  1278. onHandleSelect={async (val: any) => {
  1279. popupData.chapterLoading = true;
  1280. try {
  1281. data.detailId = val.itemActive;
  1282. const ids = formatParentId(
  1283. val.itemActive,
  1284. popupData.chapterDetails
  1285. );
  1286. data.lessonCoursewareDetailId = ids[0];
  1287. // 更新上课记录 上课的时候才更新
  1288. if (data.type !== 'preview') {
  1289. await classCourseScheduleUpdate();
  1290. }
  1291. await getDetail();
  1292. popupData.activeIndex = 0;
  1293. popupData.chapterOpen = false;
  1294. } catch {
  1295. //
  1296. }
  1297. popupData.chapterLoading = false;
  1298. }}
  1299. />
  1300. </NDrawerContent>
  1301. </NDrawer>
  1302. {/* 批注 */}
  1303. {studyData.penShow && (
  1304. <Pen
  1305. show={studyData.type === 'pen'}
  1306. type={studyData.type}
  1307. close={() => closeStudyTool()}
  1308. />
  1309. )}
  1310. {studyData.whiteboardShow && (
  1311. <Pen
  1312. show={studyData.type === 'whiteboard'}
  1313. type={studyData.type}
  1314. close={() => closeStudyTool()}
  1315. />
  1316. )}
  1317. {/* 布置作业 */}
  1318. <NModal
  1319. transformOrigin="center"
  1320. v-model:show={data.modelAttendStatus}
  1321. preset="card"
  1322. // class={styles.attendClassModal}
  1323. title={'课后作业'}
  1324. class={['modalTitle', styles.removeVisiable]}>
  1325. <div class={styles.studentRemove}>
  1326. <p>{data.modalAttendMessage}</p>
  1327. {/* <div class={styles.modelAttendContent}>
  1328. {data.modalAttendMessage}
  1329. </div> */}
  1330. <NSpace class={styles.btnGroupModal}>
  1331. <NButton
  1332. type="default"
  1333. round
  1334. onClick={() => {
  1335. data.modelAttendStatus = false;
  1336. handleStop();
  1337. // if (state.application) {
  1338. // emit('close');
  1339. // } else {
  1340. // window.close();
  1341. // }
  1342. data.modelAttendStatus = false;
  1343. }}>
  1344. 暂不布置
  1345. </NButton>
  1346. <NButton
  1347. type="primary"
  1348. round
  1349. onClick={() => {
  1350. data.modelTrainStatus = true;
  1351. data.modelAttendStatus = false;
  1352. }}>
  1353. 布置
  1354. </NButton>
  1355. </NSpace>
  1356. </div>
  1357. </NModal>
  1358. {/* 训练设置 */}
  1359. <NModal
  1360. transformOrigin="center"
  1361. v-model:show={data.modelTrainStatus}
  1362. preset="card"
  1363. class={[styles.attendClassModal, styles.trainClassModal]}
  1364. title={'作业设置'}>
  1365. <TrainSettings
  1366. detailId={data.detailId}
  1367. subjectId={data.subjectId}
  1368. classGroupId={data.classGroupId}
  1369. onClose={() => (data.modelTrainStatus = false)}
  1370. onConfirm={() => {
  1371. // 布置完作业之后直接关闭
  1372. // setTimeout(() => {
  1373. // handleStop();
  1374. // if (state.application) {
  1375. // emit('close');
  1376. // } else {
  1377. // window.close();
  1378. // }
  1379. // }, 1000);
  1380. data.modelTrainStatus = false;
  1381. }}
  1382. />
  1383. </NModal>
  1384. <NModal
  1385. transformOrigin="center"
  1386. class={['modalTitle background']}
  1387. title={'节拍器'}
  1388. preset="card"
  1389. v-model:show={showModalBeat.value}
  1390. style={{ width: '687px' }}>
  1391. <div class={styles.modeWrap}>
  1392. <iframe
  1393. src={`${vaildUrl()}/metronome/?id=${new Date().getTime()}`}
  1394. scrolling="no"
  1395. frameborder="0"
  1396. width="100%"
  1397. height={'650px'}></iframe>
  1398. </div>
  1399. </NModal>
  1400. <NModal
  1401. transformOrigin="center"
  1402. class={['background']}
  1403. v-model:show={showModalTone.value}>
  1404. <div>
  1405. <PlaceholderTone
  1406. onClose={() => {
  1407. showModalTone.value = false;
  1408. }}></PlaceholderTone>
  1409. </div>
  1410. </NModal>
  1411. <NModal
  1412. transformOrigin="center"
  1413. v-model:show={showModalTime.value}
  1414. class={['modalTitle background']}
  1415. title={'计时器'}
  1416. preset="card"
  1417. style={{ width: px2vw(772) }}>
  1418. <div>
  1419. <TimerMeter></TimerMeter>
  1420. </div>
  1421. </NModal>
  1422. <NModal
  1423. transformOrigin="center"
  1424. v-model:show={data.removeVisiable}
  1425. preset="card"
  1426. class={['modalTitle', styles.removeVisiable]}
  1427. title={data.removeTitle}>
  1428. <div class={styles.studentRemove}>
  1429. <p>{data.removeContent}</p>
  1430. <NSpace class={styles.btnGroupModal} justify="center">
  1431. <NButton round onClick={() => (data.removeVisiable = false)}>
  1432. 取消
  1433. </NButton>
  1434. <NButton
  1435. round
  1436. type="primary"
  1437. onClick={() => {
  1438. //
  1439. if (globalState.application) {
  1440. document.exitFullscreen
  1441. ? document.exitFullscreen()
  1442. : document.mozCancelFullScreen
  1443. ? document.mozCancelFullScreen()
  1444. : document.webkitExitFullscreen
  1445. ? document.webkitExitFullscreen()
  1446. : '';
  1447. emit('close');
  1448. } else {
  1449. window.close();
  1450. }
  1451. }}>
  1452. 确定
  1453. </NButton>
  1454. </NSpace>
  1455. </div>
  1456. </NModal>
  1457. </div>
  1458. );
  1459. }
  1460. });