index.tsx 63 KB

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