index.tsx 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985
  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. export type ToolType = 'init' | 'pen' | 'whiteboard' | 'call';
  87. export type ToolItem = {
  88. type: ToolType;
  89. name: string;
  90. icon: string;
  91. };
  92. export default defineComponent({
  93. name: 'CoursewarePlay',
  94. props: {
  95. type: {
  96. type: String,
  97. default: ''
  98. },
  99. courseId: {
  100. type: String,
  101. default: ''
  102. },
  103. subjectId: {
  104. type: [String, Number],
  105. default: ''
  106. },
  107. // 教材编号
  108. lessonCourseId: {
  109. type: [String, Number],
  110. default: ''
  111. },
  112. detailId: {
  113. type: String,
  114. default: ''
  115. },
  116. // 班级编号
  117. classGroupId: {
  118. type: String,
  119. default: ''
  120. },
  121. // 上课记录编号
  122. classId: {
  123. type: String,
  124. defaault: ''
  125. },
  126. preStudentNum: {
  127. type: [String, Number],
  128. default: ''
  129. }
  130. },
  131. emits: ['close'],
  132. setup(props, { emit }) {
  133. const message = useMessage();
  134. const route = useRoute();
  135. const router = useRouter();
  136. const users = useUserStore();
  137. /** 设置播放容器 16:9 */
  138. const parentContainer = reactive({
  139. width: '100vw'
  140. });
  141. // const NPopoverRef = ref();
  142. // const setContainer = () => {
  143. // const min = Math.min(screen.width, screen.height);
  144. // const max = Math.max(screen.width, screen.height);
  145. // const width = min * (16 / 9);
  146. // if (width > max) {
  147. // parentContainer.width = '100vw';
  148. // return;
  149. // } else {
  150. // parentContainer.width = width + 'px';
  151. // }
  152. // };
  153. const handleInit = (type = 0) => {
  154. //设置容器16:9
  155. // setContainer();
  156. };
  157. handleInit();
  158. onUnmounted(() => {
  159. handleInit(1);
  160. });
  161. const data = reactive({
  162. type: 'class' as '' | 'preview' | 'class', // 预览类型
  163. courseId: '' as any, // 课件编号
  164. subjectId: '' as any, // 声部编号
  165. lessonCourseId: '' as any, // 教材编号
  166. lessonCoursewareDetailId: '' as any, // 章节
  167. detailId: '' as any, // 编号 - 课程编号
  168. classGroupId: '' as any, // 上课时需要 班级编号
  169. classId: '' as any, // 上课编号
  170. preStudentNum: '' as any, // 班上学生
  171. // detail: null,
  172. knowledgePointList: [] as any,
  173. itemList: [] as any,
  174. // showHead: true,
  175. // isCourse: false,
  176. // isRecordPlay: false,
  177. videoRefs: {} as any[],
  178. audioRefs: {} as any[],
  179. modelAttendStatus: false, // 布置作业提示弹窗
  180. modalAttendMessage: '本节课未设置课后作业,是否继续?',
  181. modelTrainStatus: false, // 训练设置
  182. selectClassStatus: false, // 选择课件
  183. homeworkStatus: true, // 布置作业完成时
  184. removeVisiable: false,
  185. removeTitle: '',
  186. removeContent: '',
  187. removeCourseStatus: false, // 是否布置作业
  188. teacherChapterName: '',
  189. selectResourceStatus: false,
  190. videoState: 'init' as 'init' | 'play',
  191. videoItemRef: null as any,
  192. animationState: 'start' as 'start' | 'end'
  193. });
  194. const activeData = reactive({
  195. // isAutoPlay: false, // 是否自动播放
  196. nowTime: 0,
  197. model: true, // 遮罩
  198. isAnimation: true, // 是否动画
  199. // videoBtns: true, // 视频
  200. // currentTime: 0,
  201. // duration: 0,
  202. timer: null as any,
  203. item: null as any
  204. });
  205. // 键盘事件监听状态
  206. const listenerKeyUpState = ref(false);
  207. const getDetail = async () => {
  208. try {
  209. const res = await api_teacherChapterLessonCoursewareDetail(
  210. data.courseId
  211. );
  212. data.teacherChapterName = res.data.name || '';
  213. const tempRows = res.data.chapterKnowledgeList || [];
  214. const temp: any = [];
  215. const allItem: any = [];
  216. tempRows.forEach((row: any, index: number) => {
  217. if (!Array.isArray(row.chapterKnowledgeMaterialList)) {
  218. return;
  219. }
  220. const childList: any[] = [];
  221. row.chapterKnowledgeMaterialList.forEach((child: any) => {
  222. if (!child.removeFlag) {
  223. const dataJson = child.dataJson ? JSON.parse(child.dataJson) : {};
  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: dataJson.setting ? dataJson.setting : {},
  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. return isRender ? (
  1371. <div
  1372. key={'index' + mIndex}
  1373. class={[
  1374. styles.itemDiv,
  1375. popupData.activeIndex === mIndex && styles.itemActive,
  1376. activeData.isAnimation && styles.acitveAnimation,
  1377. Math.abs(popupData.activeIndex - mIndex) < 2
  1378. ? styles.show
  1379. : styles.hide
  1380. ]}
  1381. style={
  1382. mIndex < popupData.activeIndex
  1383. ? effects[effectIndex.value].prev
  1384. : mIndex > popupData.activeIndex
  1385. ? effects[effectIndex.value].next
  1386. : {}
  1387. }
  1388. onClick={(e: Event) => {
  1389. e.stopPropagation();
  1390. clearTimeout(activeData.timer);
  1391. if (Date.now() - activeData.nowTime < 300) {
  1392. handleDbClick(m);
  1393. return;
  1394. }
  1395. activeData.nowTime = Date.now();
  1396. activeData.timer = setTimeout(() => {
  1397. activeData.model = !activeData.model;
  1398. Object.values(data.videoRefs).map((n: any) =>
  1399. n?.toggleHideControl(activeData.model)
  1400. );
  1401. Object.values(data.audioRefs).map((n: any) =>
  1402. n?.toggleHideControl(activeData.model)
  1403. );
  1404. if (activeData.model) {
  1405. setModelOpen();
  1406. }
  1407. }, 300);
  1408. }}>
  1409. {m.type === 'VIDEO' ? (
  1410. <>
  1411. <img
  1412. src={m.coverImg}
  1413. onLoad={() => {
  1414. m.isprepare = true;
  1415. }}
  1416. />
  1417. {/* <VideoPlay
  1418. ref={(v: any) => (data.videoRefs[mIndex] = v)}
  1419. item={m}
  1420. isEmtry={isEmtry}
  1421. onLoadedmetadata={(videoItem: any) => {
  1422. m.videoEle = videoItem;
  1423. m.isprepare = true;
  1424. }}
  1425. onTogglePlay={(paused: boolean) => {
  1426. m.autoPlay = false;
  1427. if (paused || popupData.open) {
  1428. clearTimeout(activeData.timer);
  1429. } else {
  1430. setModelOpen();
  1431. }
  1432. }}
  1433. onReset={() => {
  1434. if (!m.videoEle?.paused) {
  1435. setModelOpen();
  1436. }
  1437. }}
  1438. onError={() => {
  1439. console.log('video error');
  1440. m.error = true;
  1441. }}
  1442. /> */}
  1443. <Transition name="van-fade">
  1444. {
  1445. <div class={styles.loadWrap}>
  1446. <Vue3Lottie
  1447. animationData={playLoadData}></Vue3Lottie>
  1448. </div>
  1449. }
  1450. </Transition>
  1451. </>
  1452. ) : m.type === 'IMG' ? (
  1453. <img src={m.content} />
  1454. ) : m.type === 'SONG' ? (
  1455. <AudioPay
  1456. item={m}
  1457. ref={(v: any) => (data.audioRefs[mIndex] = v)}
  1458. onLoadedmetadata={(audioItem: any) => {
  1459. m.audioEle = audioItem;
  1460. m.isprepare = true;
  1461. }}
  1462. onTogglePlay={(paused: boolean) => {
  1463. m.autoPlay = false;
  1464. if (paused || popupData.open) {
  1465. clearTimeout(activeData.timer);
  1466. } else {
  1467. setModelOpen();
  1468. }
  1469. }}
  1470. onEnded={() => {
  1471. const _index = popupData.activeIndex + 1;
  1472. if (_index < data.itemList.length) {
  1473. handleSwipeChange(_index);
  1474. }
  1475. }}
  1476. onReset={() => {
  1477. if (!m.audioEle?.paused) {
  1478. setModelOpen();
  1479. }
  1480. }}
  1481. />
  1482. ) : // : m.type === 'PPT' ? <div class={styles.iframePpt}>
  1483. // <div class={styles.pptBox}></div>
  1484. // <iframe src={`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(m.content)}`} width='100%' height='100%' frameborder='1'></iframe>
  1485. // </div>
  1486. m.type === 'PPT' ? (
  1487. <iframe
  1488. src={`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(
  1489. m.content
  1490. )}`}
  1491. width="100%"
  1492. height="100%"
  1493. frameborder="1"></iframe>
  1494. ) : m.type === 'RHYTHM' ? (
  1495. <RhythmModal
  1496. item={m}
  1497. activeStatus={popupData.activeIndex === mIndex}
  1498. onSetIframe={(el: any) => {
  1499. m.iframeRef = el;
  1500. }}
  1501. />
  1502. ) : m.type === 'INSTRUMENT' || m.type === 'MUSICIAN' ? (
  1503. <InstruemntDetail
  1504. type="preview"
  1505. id={m.content}
  1506. contentType={m.type}
  1507. activeStatus={popupData.activeIndex === mIndex}
  1508. ref={(el: any) => (m.iframeRef = el)}
  1509. />
  1510. ) : m.type === 'MUSIC_WIKI' ? (
  1511. <MusicDetail
  1512. type="preview"
  1513. id={m.content}
  1514. contentType={m.type}
  1515. activeStatus={popupData.activeIndex === mIndex}
  1516. ref={(el: any) => (m.iframeRef = el)}
  1517. />
  1518. ) : m.type === 'THEORY' ? (
  1519. <TheotyDetail
  1520. type="preview"
  1521. id={m.content}
  1522. activeStatus={popupData.activeIndex === mIndex}
  1523. ref={(el: any) => (m.iframeRef = el)}
  1524. />
  1525. ) : (
  1526. <MusicScore
  1527. activeModel={activeData.model}
  1528. activeStatus={popupData.activeIndex === mIndex}
  1529. data-vid={m.id}
  1530. music={m}
  1531. onSetIframe={(el: any) => {
  1532. m.iframeRef = el;
  1533. }}
  1534. />
  1535. )}
  1536. </div>
  1537. ) : null;
  1538. })}
  1539. </div>
  1540. ) : (
  1541. ''
  1542. )}
  1543. </div>
  1544. </div>
  1545. {/* 右边操作栏 */}
  1546. <div
  1547. class={[
  1548. styles.rightColumn,
  1549. !rightColumnShow.value ? styles.rightColumnHide : '',
  1550. studyData.type !== 'init' &&
  1551. (studyData.penShow || studyData.whiteboardShow)
  1552. ? styles.rightColumnZ
  1553. : ''
  1554. ]}>
  1555. {rightList.map((item: any, index: number) => (
  1556. <div
  1557. class={[
  1558. styles.rightItem,
  1559. (item.id === 2 && data.preStudentNum <= 0) ||
  1560. (item.id === 10 && studyData.callStudentList.length <= 0)
  1561. ? styles.itemDisabled
  1562. : '',
  1563. item.id === 10 && !data.classId ? styles.itemHide : ''
  1564. ]}
  1565. onClick={() => operateRightBtn(item.id)}>
  1566. <NTooltip showArrow={false} placement="left">
  1567. {{
  1568. trigger: () => <img src={item.icon} />,
  1569. default: (
  1570. <>
  1571. {index === 0 && data.type === 'preview'
  1572. ? item.name2
  1573. : item.name}
  1574. </>
  1575. )
  1576. }}
  1577. </NTooltip>
  1578. </div>
  1579. ))}
  1580. </div>
  1581. {!rightColumnShow.value && (
  1582. <img
  1583. class={[
  1584. styles.rightHideIcon,
  1585. !rightColumnShow.value ? styles.rightIconShow : ''
  1586. ]}
  1587. src={rightHideIcon}
  1588. onClick={() => (rightColumnShow.value = true)}
  1589. />
  1590. )}
  1591. {/* 右下角悬浮按钮 */}
  1592. <div class={styles.bottomColumn}>
  1593. {bottomList.map((item: any, index: number) => (
  1594. <div
  1595. class={[
  1596. styles.bottomItem,
  1597. (item.id === 3 && !isUpArrow.value) ||
  1598. (item.id === 4 && !isDownArrow.value)
  1599. ? styles.itemDisabled
  1600. : ''
  1601. ]}
  1602. onClick={() => operateBottomBtn(item.id)}>
  1603. <NTooltip showArrow={false} placement="top">
  1604. {{
  1605. trigger: () => <img src={item.icon} />,
  1606. default: <>{item.name}</>
  1607. }}
  1608. </NTooltip>
  1609. {/* <img src={item.icon} />
  1610. <div class={styles.bottomTips}>{item.name}</div> */}
  1611. </div>
  1612. ))}
  1613. </div>
  1614. {/* 显示列表 */}
  1615. <NDrawer
  1616. v-model:show={popupData.open}
  1617. class={[styles.drawerContainer, styles.drawerContainerSource]}
  1618. onAfterLeave={handleClosePopup}
  1619. showMask={false}
  1620. blockScroll={false}
  1621. trapFocus={false}>
  1622. <NDrawerContent closable>
  1623. {{
  1624. header: () => (
  1625. <TheNoticeBar text={activeName.value || '资源列表'} />
  1626. ),
  1627. default: () => (
  1628. <SourceList
  1629. teacherChapterName={data.teacherChapterName}
  1630. knowledgePointList={data.knowledgePointList}
  1631. courseActiveIndex={popupData.courseActiveIndex}
  1632. activeItem={data.itemList[popupData.activeIndex]}
  1633. onConfirm={(item: any) => {
  1634. popupData.open = false;
  1635. toggleMaterial(item.id);
  1636. }}
  1637. />
  1638. )
  1639. }}
  1640. </NDrawerContent>
  1641. </NDrawer>
  1642. {/* 显示列表 */}
  1643. <NDrawer
  1644. v-model:show={popupData.chapterOpen}
  1645. class={styles.drawerContainer}
  1646. onAfterLeave={handleClosePopup}
  1647. showMask={false}
  1648. maskClosable={data.selectClassStatus ? false : true}
  1649. blockScroll={false}
  1650. trapFocus={false}>
  1651. <NDrawerContent title="切换章节" closable>
  1652. <Chapter
  1653. treeList={popupData.chapterDetails}
  1654. itemActive={data.detailId as any}
  1655. onHandleSelect={async (val: any) => {
  1656. // itemActive: child.id,
  1657. // itemName: child.name
  1658. popupData.courseId = val.itemActive;
  1659. data.selectClassStatus = true;
  1660. }}
  1661. />
  1662. </NDrawerContent>
  1663. </NDrawer>
  1664. {/* 批注 */}
  1665. {studyData.penShow && (
  1666. <Pen
  1667. show={studyData.type === 'pen'}
  1668. type={studyData.type}
  1669. close={() => closeStudyTool()}
  1670. />
  1671. )}
  1672. {studyData.whiteboardShow && (
  1673. <Pen
  1674. show={studyData.type === 'whiteboard'}
  1675. type={studyData.type}
  1676. close={() => closeStudyTool()}
  1677. />
  1678. )}
  1679. {studyData.callShow && (
  1680. <Pen
  1681. callStudents={studyData.callStudentList}
  1682. show={studyData.type === 'call'}
  1683. type={studyData.type}
  1684. close={() => closeStudyTool()}
  1685. />
  1686. )}
  1687. {/* 选择课件 */}
  1688. <NModal
  1689. transformOrigin="center"
  1690. v-model:show={data.selectClassStatus}
  1691. preset="card"
  1692. class={[
  1693. 'modalTitle background',
  1694. // styles.attendClassModal,
  1695. styles.selectClassModal
  1696. ]}
  1697. title={'选择课件'}>
  1698. <SelectClass
  1699. classId={data.classId}
  1700. courseId={popupData.courseId}
  1701. subjectId={data.subjectId}
  1702. onConfirm={async (val: any) => {
  1703. popupData.chapterLoading = true;
  1704. try {
  1705. data.detailId = val.itemActive;
  1706. data.courseId = val.chapterId;
  1707. const ids = formatParentId(
  1708. val.itemActive,
  1709. popupData.chapterDetails
  1710. );
  1711. data.lessonCoursewareDetailId = ids[0];
  1712. // 更新上课记录 上课的时候才更新
  1713. if (data.type !== 'preview') {
  1714. await classCourseScheduleUpdate();
  1715. }
  1716. await getDetail();
  1717. popupData.activeIndex = 0;
  1718. popupData.chapterOpen = false;
  1719. data.selectClassStatus = false;
  1720. } catch {
  1721. //
  1722. }
  1723. popupData.chapterLoading = false;
  1724. }}
  1725. />
  1726. </NModal>
  1727. {/* 布置作业 */}
  1728. <NModal
  1729. transformOrigin="center"
  1730. v-model:show={data.modelAttendStatus}
  1731. preset="card"
  1732. title={'课后作业'}
  1733. class={['modalTitle', styles.removeVisiable]}>
  1734. <div class={styles.studentRemove}>
  1735. <p>{data.modalAttendMessage}</p>
  1736. <NSpace class={styles.btnGroupModal} justify="center">
  1737. <NButton
  1738. type="default"
  1739. round
  1740. onClick={() => {
  1741. data.modelTrainStatus = true;
  1742. data.modelAttendStatus = false;
  1743. }}>
  1744. 布置作业
  1745. </NButton>
  1746. <NButton
  1747. type="primary"
  1748. round
  1749. onClick={() => {
  1750. handleStop();
  1751. data.modelAttendStatus = false;
  1752. }}>
  1753. 取消
  1754. </NButton>
  1755. </NSpace>
  1756. </div>
  1757. </NModal>
  1758. {/* 训练设置 */}
  1759. <NModal
  1760. transformOrigin="center"
  1761. v-model:show={data.modelTrainStatus}
  1762. preset="card"
  1763. class={[styles.attendClassModal, styles.trainClassModal]}
  1764. title={'作业设置'}>
  1765. <ClassWork
  1766. detailId={data.detailId}
  1767. subjectId={data.subjectId}
  1768. courseScheduleId={data.classId}
  1769. activeName={activeName.value}
  1770. classGroupId={data.classGroupId}
  1771. onClose={() => (data.modelTrainStatus = false)}
  1772. />
  1773. </NModal>
  1774. <NModal
  1775. transformOrigin="center"
  1776. class={['modalTitle background']}
  1777. title={'节拍器'}
  1778. preset="card"
  1779. v-model:show={showModalBeat.value}
  1780. style={{ width: '687px' }}>
  1781. <div class={styles.modeWrap}>
  1782. <iframe
  1783. src={`${vaildUrl()}/metronome/?id=${new Date().getTime()}`}
  1784. scrolling="no"
  1785. frameborder="0"
  1786. width="100%"
  1787. height={'650px'}></iframe>
  1788. </div>
  1789. </NModal>
  1790. <NModal
  1791. transformOrigin="center"
  1792. class={['background']}
  1793. v-model:show={showModalTone.value}>
  1794. <div>
  1795. <PlaceholderTone
  1796. onClose={() => {
  1797. showModalTone.value = false;
  1798. }}></PlaceholderTone>
  1799. </div>
  1800. </NModal>
  1801. <NModal
  1802. transformOrigin="center"
  1803. v-model:show={showModalTime.value}
  1804. class={['modalTitle background']}
  1805. title={'计时器'}
  1806. preset="card"
  1807. style={{ width: px2vw(772) }}>
  1808. <div>
  1809. <TimerMeter></TimerMeter>
  1810. </div>
  1811. </NModal>
  1812. <NModal
  1813. v-model:show={data.selectResourceStatus}
  1814. class={['modalTitle', styles.selectMusicModal]}
  1815. preset="card"
  1816. title={'选择资源'}>
  1817. <SelectResources from="class" />
  1818. </NModal>
  1819. <NModal
  1820. transformOrigin="center"
  1821. v-model:show={data.removeVisiable}
  1822. preset="card"
  1823. class={['modalTitle', styles.removeVisiable]}
  1824. title={data.removeTitle}>
  1825. <div class={styles.studentRemove}>
  1826. <p>{data.removeContent}</p>
  1827. <NSpace class={styles.btnGroupModal} justify="center">
  1828. <NButton
  1829. round
  1830. onClick={() => {
  1831. if (data.removeCourseStatus) {
  1832. if (globalState.application) {
  1833. document.exitFullscreen
  1834. ? document.exitFullscreen()
  1835. : document.mozCancelFullScreen
  1836. ? document.mozCancelFullScreen()
  1837. : document.webkitExitFullscreen
  1838. ? document.webkitExitFullscreen()
  1839. : '';
  1840. emit('close');
  1841. } else {
  1842. window.close();
  1843. }
  1844. } else {
  1845. data.removeVisiable = false;
  1846. }
  1847. }}>
  1848. {data.removeCourseStatus ? '结束课程' : '取消'}
  1849. </NButton>
  1850. <NButton
  1851. round
  1852. type="primary"
  1853. onClick={() => {
  1854. //
  1855. if (data.removeCourseStatus) {
  1856. data.modelTrainStatus = true;
  1857. data.removeVisiable = false;
  1858. } else {
  1859. if (globalState.application) {
  1860. document.exitFullscreen
  1861. ? document.exitFullscreen()
  1862. : document.mozCancelFullScreen
  1863. ? document.mozCancelFullScreen()
  1864. : document.webkitExitFullscreen
  1865. ? document.webkitExitFullscreen()
  1866. : '';
  1867. emit('close');
  1868. } else {
  1869. window.close();
  1870. }
  1871. }
  1872. }}>
  1873. {data.removeCourseStatus ? '布置作业' : '确定'}
  1874. </NButton>
  1875. </NSpace>
  1876. </div>
  1877. </NModal>
  1878. </div>
  1879. );
  1880. }
  1881. });
  1882. // roll-call/index.html