index.tsx 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515
  1. import {
  2. defineComponent,
  3. onMounted,
  4. reactive,
  5. onUnmounted,
  6. ref,
  7. Transition,
  8. computed,
  9. nextTick,
  10. watch,
  11. toRef
  12. } from 'vue';
  13. import styles from './index.module.less';
  14. import 'plyr/dist/plyr.css';
  15. import MusicScore from './component/musicScore';
  16. // import iconChange from './image/icon-change.png';
  17. // import iconMenu from './image/icon-menu.png';
  18. // import iconUp from './image/icon-up.png';
  19. // import iconDown from './image/icon-down.png';
  20. // import iconNote from './image/icon-note.png';
  21. // import iconWhiteboard from './image/icon-whiteboard.png';
  22. // import iconAssignHomework from './image/icon-assignHomework.png';
  23. // import iconClose from './image/icon-close.png';
  24. // import iconOverPreivew from './image/icon-over-preview.png';
  25. import { Vue3Lottie } from 'vue3-lottie';
  26. import playLoadData from './datas/data.json';
  27. // import Moveable from 'moveable';
  28. import VideoPlay from './component/video-play';
  29. import {
  30. useMessage,
  31. NDrawer,
  32. NDrawerContent,
  33. NModal,
  34. NSpace,
  35. NButton,
  36. NCollapse,
  37. NCollapseItem,
  38. NTooltip
  39. } from 'naive-ui';
  40. import CardType from '@/components/card-type';
  41. import Pen from './component/tools/pen';
  42. import AudioPay from './component/audio-pay';
  43. import TrainSettings from './model/train-settings';
  44. import { useRoute } from 'vue-router';
  45. import {
  46. api_teacherChapterLessonCoursewareDetail,
  47. courseScheduleUpdate,
  48. lessonCoursewareDetail,
  49. lessonPreTrainingPage,
  50. queryCourseware
  51. } from '../prepare-lessons/api';
  52. import { vaildUrl } from '/src/utils/urlUtils';
  53. import TimerMeter from '/src/components/timerMeter';
  54. import Metronome from '/src/components/Metronome';
  55. import { iframeDislableKeyboard, px2vw } from '/src/utils';
  56. import PlaceholderTone from '/src/components/layout/modals/placeholderTone';
  57. import { state as globalState, modalClickMask } from '/src/state';
  58. import Chapter from './model/chapter';
  59. import { useRouter } from 'vue-router';
  60. import { useUserStore } from '@/store/modules/users';
  61. import iconNote from './new-image/icon-note.png';
  62. import iconWhite from './new-image/icon-white.png';
  63. import timerMeterClose from './image/close.png';
  64. import rightIconEnd from './image/right_icon1.png';
  65. import rightIconArrange from './image/right_icon2.png';
  66. import rightIconPostil from './image/right_icon3.png';
  67. import rightIconWhiteboard from './image/right_icon4.png';
  68. import rightIconMetronome from './image/right_icon5.png';
  69. import rightIconTuner from './image/right_icon6.png';
  70. import rightIconTimer from './image/right_icon7.png';
  71. import rightIconCall from './image/right_icon10.png';
  72. import rightIconPackUp from './image/right_icon11.png';
  73. import leftIconPackUp from './image/right_icon8.png';
  74. import rightIconMusic from './image/right_icon9.png';
  75. import bottomIconSwitch from './image/bottom_icon1.png';
  76. import bottomIconResource from './image/bottom_icon2.png';
  77. import bottomIconPre from './image/bottom_icon3.png';
  78. import bottomIconNext from './image/bottom_icon4.png';
  79. import rightIconTool from './image/right_icon12.png';
  80. import rightHideIcon from './image/right_hide_icon.png';
  81. import leftHideIcon from './image/left_hide_icon.png';
  82. import SelectResources from '../prepare-lessons/model/select-resources';
  83. import { getStudentAfterWork, getStudentList } from '../studentList/api';
  84. import TheNoticeBar from '/src/components/TheNoticeBar';
  85. import ClassWork from './model/class-work';
  86. import SelectClass from './model/select-class';
  87. import SourceList from './model/source-list';
  88. import RhythmModal from './component/rhythm-modal';
  89. import InstruemntDetail from '/src/views/prepare-lessons/model/source-instrument/detail';
  90. import TheotyDetail from '/src/views/prepare-lessons/model/source-knowledge/detail';
  91. import MusicDetail from '/src/views/prepare-lessons/model/source-music/detail';
  92. import ListenModal from '/src/components/card-preview/listen-modal';
  93. import Train from '../prepare-lessons/components/lesson-main/train';
  94. import ResourceMain from '../prepare-lessons/components/resource-main';
  95. import { useResizeObserver } from '@vueuse/core';
  96. import { storage } from '/src/utils/storage';
  97. import { ACCESS_TOKEN_ADMIN } from '/src/store/mutation-types';
  98. import useDrag from '@/hooks/useDrag';
  99. import { getGuidanceShow } from '@/hooks/useDrag/useDragGuidance';
  100. import Dragbom from '@/hooks/useDrag/dragbom';
  101. import { api_cousseScheduleDetail } from '/src/api/user';
  102. export type ToolType = 'init' | 'pen' | 'whiteboard' | 'call';
  103. export type ToolItem = {
  104. type: ToolType;
  105. name: string;
  106. icon: string;
  107. };
  108. export default defineComponent({
  109. name: 'CoursewarePlay',
  110. props: {
  111. type: {
  112. type: String,
  113. default: ''
  114. },
  115. courseId: {
  116. type: String,
  117. default: ''
  118. },
  119. instrumentId: {
  120. type: [String, Number],
  121. default: ''
  122. },
  123. // 教材编号
  124. lessonCourseId: {
  125. type: [String, Number],
  126. default: ''
  127. },
  128. detailId: {
  129. type: String,
  130. default: ''
  131. },
  132. // 班级编号
  133. classGroupId: {
  134. type: String,
  135. default: ''
  136. },
  137. // 上课记录编号
  138. classId: {
  139. type: String,
  140. defaault: ''
  141. },
  142. preStudentNum: {
  143. type: [String, Number],
  144. default: ''
  145. }
  146. },
  147. emits: ['close'],
  148. setup(props, { emit }) {
  149. const message = useMessage();
  150. const route = useRoute();
  151. const router = useRouter();
  152. const users = useUserStore();
  153. /** 设置播放容器 16:9 */
  154. const parentContainer = reactive({
  155. width: '100vw'
  156. });
  157. // const NPopoverRef = ref();
  158. // const setContainer = () => {
  159. // const min = Math.min(screen.width, screen.height);
  160. // const max = Math.max(screen.width, screen.height);
  161. // const width = min * (16 / 9);
  162. // if (width > max) {
  163. // parentContainer.width = '100vw';
  164. // return;
  165. // } else {
  166. // parentContainer.width = width + 'px';
  167. // }
  168. // };
  169. const handleInit = (type = 0) => {
  170. //设置容器16:9
  171. // setContainer();
  172. };
  173. handleInit();
  174. onUnmounted(() => {
  175. handleInit(1);
  176. window.removeEventListener('online', handleOnline);
  177. window.removeEventListener('offline', handleOffline);
  178. });
  179. const data = reactive({
  180. type: 'class' as '' | 'preview' | 'class', // 预览类型
  181. courseId: '' as any, // 课件编号
  182. instrumentId: '' as any, // 声部编号
  183. lessonCourseId: '' as any, // 教材编号
  184. lessonCoursewareDetailId: '' as any, // 章节
  185. lessonCoursewareSubjectList: [] as any, // 教材上的声部
  186. detailId: '' as any, // 编号 - 课程编号
  187. classGroupId: '' as any, // 上课时需要 班级编号
  188. classId: '' as any, // 上课编号
  189. preStudentNum: '' as any, // 班上学生
  190. // detail: null,
  191. knowledgePointList: [] as any,
  192. itemList: [] as any,
  193. // showHead: true,
  194. // isCourse: false,
  195. // isRecordPlay: false,
  196. videoRefs: {} as any[],
  197. audioRefs: {} as any[],
  198. modelAttendStatus: false, // 布置作业提示弹窗
  199. modalAttendMessage: '本节课未设置课后作业,是否继续?',
  200. modelTrainStatus: false, // 训练设置
  201. selectClassStatus: false, // 选择课件
  202. homeworkStatus: true, // 布置作业完成时
  203. removeVisiable: false,
  204. nextEndShow: false,
  205. removeTitle: '',
  206. removeContent: '',
  207. removeCourseStatus: false, // 是否布置作业
  208. teacherChapterName: '',
  209. lessonPreTrainingId: null,
  210. selectResourceStatus: false,
  211. videoState: 'init' as 'init' | 'play',
  212. videoItemRef: null as any,
  213. animationState: 'start' as 'start' | 'end'
  214. });
  215. const activeData = reactive({
  216. isAutoPlay: false, // 是否自动播放
  217. nowTime: 0,
  218. model: true, // 遮罩
  219. isAnimation: true, // 是否动画
  220. // videoBtns: true, // 视频
  221. // currentTime: 0,
  222. // duration: 0,
  223. timer: null as any,
  224. item: null as any
  225. });
  226. // 键盘事件监听状态
  227. const listenerKeyUpState = ref(false);
  228. const getDetail = async () => {
  229. try {
  230. const res = await api_teacherChapterLessonCoursewareDetail(
  231. data.courseId
  232. );
  233. data.teacherChapterName = res.data.name || '';
  234. // 布置的作业编号
  235. data.lessonPreTrainingId = res.data.lessonPreTrainingId;
  236. // activeData.isAutoPlay = res.data.autoPlay || false; // 自动播放
  237. const tempRows = res.data.chapterKnowledgeList || [];
  238. const temp: any = [];
  239. const allItem: any = [];
  240. tempRows.forEach((row: any, index: number) => {
  241. if (!Array.isArray(row.chapterKnowledgeMaterialList)) {
  242. return;
  243. }
  244. const childList: any[] = [];
  245. row.chapterKnowledgeMaterialList.forEach((child: any) => {
  246. if (!child.removeFlag) {
  247. childList.push({
  248. id: child.id,
  249. materialId: child.bizId,
  250. coverImg: child.bizInfo.coverImg,
  251. type: child.type,
  252. title: child.bizInfo.name,
  253. dataJson: child.dataJson,
  254. isCollect: !!child.favoriteFlag,
  255. isSelected: child.source === 'PLATFORM' ? true : false,
  256. audioPlayTypeArray: child.audioPlayTypes
  257. ? child.audioPlayTypes.split(',')
  258. : [],
  259. content: child.bizInfo.content,
  260. parentIndex: index
  261. });
  262. }
  263. });
  264. temp.push({
  265. title: row.name,
  266. list: childList
  267. });
  268. allItem.push(...childList);
  269. });
  270. data.knowledgePointList = temp;
  271. data.itemList = allItem?.map((m: any) => {
  272. return {
  273. ...m,
  274. iframeRef: null,
  275. videoEle: null,
  276. audioEle: null,
  277. autoPlay: res.data.autoPlay || false, //加载完成是否自动播放
  278. isprepare: false, // 视频是否加载完成
  279. isRender: false // 是否渲染了
  280. };
  281. });
  282. setTimeout(() => {
  283. data.animationState = 'end';
  284. }, 500);
  285. } catch (e) {
  286. //
  287. console.log(e);
  288. }
  289. };
  290. const showModalBeat = ref(false);
  291. const showModalTone = ref(false);
  292. const showModalTime = ref(false);
  293. // ifram事件处理
  294. const iframeHandle = (ev: MessageEvent) => {
  295. // console.log(ev.data?.api, ev.data, 'ev.data');
  296. if (ev.data?.api === 'headerTogge') {
  297. activeData.model =
  298. ev.data.show || (ev.data.playState == 'play' ? false : true);
  299. }
  300. //
  301. if (ev.data?.api === 'onAttendToggleMenu') {
  302. activeData.model = !activeData.model;
  303. }
  304. if (ev.data?.api === 'api_fingerPreView') {
  305. clearInterval(activeData.timer);
  306. activeData.model = !ev.data.state;
  307. }
  308. //
  309. if (ev.data?.api === 'documentBodyKeyup') {
  310. if (ev.data?.code === 'ArrowUp') {
  311. setModalOpen();
  312. handlePreAndNext('up');
  313. }
  314. if (ev.data?.code === 'ArrowDown') {
  315. setModalOpen();
  316. handlePreAndNext('down');
  317. }
  318. }
  319. // 点名返回
  320. if (ev.data?.api === 'callBack') {
  321. closeStudyTool();
  322. studyData.callShow = false;
  323. }
  324. if (ev.data?.api === 'onLogin') {
  325. const documentDom: any = document;
  326. documentDom.exitFullscreen
  327. ? documentDom.exitFullscreen()
  328. : documentDom.mozCancelFullScreen
  329. ? documentDom.mozCancelFullScreen()
  330. : documentDom.webkitExitFullscreen
  331. ? documentDom.webkitExitFullscreen()
  332. : '';
  333. users.logout();
  334. router.replace('/login');
  335. }
  336. };
  337. onMounted(async () => {
  338. // initMoveable();
  339. const query = route.query;
  340. // console.log(query, props.preStudentNum, '学生人数');
  341. // 先取参数,
  342. data.type = props.type || (query.type as any);
  343. data.courseId = props.courseId || query.courseId;
  344. data.instrumentId = props.instrumentId || query.instrumentId;
  345. data.detailId = props.detailId || query.detailId;
  346. data.lessonCourseId = props.lessonCourseId || query.lessonCourseId;
  347. data.classGroupId = props.classGroupId || query.classGroupId;
  348. data.classId = props.classId || query.classId;
  349. data.preStudentNum = props.preStudentNum || query.preStudentNum;
  350. window.addEventListener('message', iframeHandle);
  351. // function handleEvent(event:) {
  352. // console.log('Event:', event.type, event);
  353. // }
  354. if (data.classId) {
  355. const res = await api_cousseScheduleDetail(data.classId);
  356. data.courseId = res.data.useChapterLessonCoursewareId;
  357. }
  358. getDetail();
  359. getLessonCoursewareDetail();
  360. if (data.type === 'preview') {
  361. // 预览隐藏点名和布置作业
  362. const hideListIds = [2, 10];
  363. let index = rightList.length - 1;
  364. while (index >= 0) {
  365. if (hideListIds.includes(rightList[index].id)) {
  366. // console.log(index);
  367. rightList.splice(index, 1);
  368. }
  369. index--;
  370. }
  371. }
  372. rollCallStudentList();
  373. window.addEventListener('online', handleOnline);
  374. window.addEventListener('offline', handleOffline);
  375. document.addEventListener('keydown', (e: KeyboardEvent) => {
  376. e.stopPropagation();
  377. e.preventDefault();
  378. if (
  379. data.nextEndShow ||
  380. data.removeVisiable ||
  381. data.selectResourceStatus ||
  382. showModalTime.value ||
  383. showModalTone.value ||
  384. showModalBeat.value ||
  385. data.modelTrainStatus ||
  386. data.modelAttendStatus ||
  387. data.selectClassStatus ||
  388. studyData.callShow ||
  389. studyData.whiteboardShow ||
  390. studyData.penShow ||
  391. popupData.chapterOpen ||
  392. popupData.open
  393. )
  394. return;
  395. if (e.code === 'ArrowUp' || e.code === 'PageUp') {
  396. // if (popupData.activeIndex === 0) return;
  397. setModalOpen();
  398. handlePreAndNext('up');
  399. } else if (e.code === 'ArrowDown' || e.code === 'PageDown') {
  400. // if (popupData.activeIndex === data.itemList.length - 1) return;
  401. setModalOpen();
  402. handlePreAndNext('down');
  403. } else if (e.code === 'Tab') {
  404. console.log('Space clicked');
  405. const activeItem = data.itemList[popupData.activeIndex];
  406. // console.log(activeItem, activeItem.videoEle);
  407. // 暂停视频和曲谱的播放
  408. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  409. activeItem.videoEle?.play();
  410. }
  411. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  412. activeItem.audioEle?.play();
  413. }
  414. if (activeItem.type === 'MUSIC') {
  415. activeItem.iframeRef?.contentWindow?.postMessage(
  416. { api: 'startPlayState' },
  417. '*'
  418. );
  419. }
  420. if (activeItem.type === 'LISTEN') {
  421. console.log(activeItem.type, 'listening');
  422. activeItem.iframeRef?.contentWindow?.postMessage(
  423. { api: 'startPlayState' },
  424. '*'
  425. );
  426. }
  427. if (activeItem.type === 'RHYTHM') {
  428. activeItem.iframeRef?.contentWindow?.postMessage(
  429. { api: 'setPlayState', data: true },
  430. '*'
  431. );
  432. }
  433. if (activeItem.type === 'PPT') {
  434. console.log(activeItem.iframeRef, 'activeItem.iframeRef;');
  435. activeItem.iframeRef?.focus();
  436. // 将焦点传递给 iframe 内部内容
  437. const iframeWindow = activeItem.iframeRef?.contentWindow;
  438. iframeWindow.postMessage({ type: 'focus' }, '*');
  439. }
  440. }
  441. });
  442. });
  443. const lineTimer = ref();
  444. const handleOnline = () => {
  445. clearTimeout(lineTimer.value);
  446. };
  447. const handleOffline = () => {
  448. lineTimer.value = setTimeout(() => {
  449. message.info('请检查网络', {
  450. showIcon: false,
  451. render: (props: any) => {
  452. return (
  453. <div style="background: rgba(0,0,0,.6); color: #fff; border-radius: 8px; padding: 6px 16px;">
  454. {props.content}
  455. </div>
  456. );
  457. }
  458. });
  459. }, 3000);
  460. };
  461. // const onFullScreen = () => {
  462. // if (data.type === 'preview') {
  463. // const el: any = document.querySelector('#app');
  464. // if (el.mozRequestFullScreen) {
  465. // el.mozRequestFullScreen();
  466. // } else if (el.webkitRequestFullscreen) {
  467. // el.webkitRequestFullscreen();
  468. // } else if (el.requestFullScreen) {
  469. // el.requestFullscreen();
  470. // }
  471. // }
  472. // };
  473. const popupData = reactive({
  474. open: false,
  475. activeIndex: 0,
  476. courseActiveIndex: 0, // 课件选择的第几个
  477. toolOpen: false, // 工具弹窗控制
  478. chapterOpen: false, // 切换章节
  479. chapterDetails: [] as any,
  480. courseId: null as any, // 章节编号
  481. chapterLoading: false // 加载数据
  482. });
  483. watch(
  484. () => [popupData.open, popupData.chapterOpen],
  485. val => {
  486. // 为了处理window电脑滑动时的问题 - pointr-events
  487. setTimeout(() => {
  488. const drawers = document.querySelectorAll('.n-drawer-container');
  489. if (val[0] || val[1]) {
  490. drawers?.forEach(drawer => {
  491. drawer.classList.remove('n-drawer-container-relative');
  492. });
  493. } else {
  494. drawers?.forEach(drawer => {
  495. drawer.classList.add('n-drawer-container-relative');
  496. });
  497. }
  498. }, 200);
  499. }
  500. );
  501. const formatParentId = (id: any, list: any, ids = [] as any) => {
  502. for (const item of list) {
  503. if (item.knowledgeList && item.knowledgeList.length > 0) {
  504. const cIds: any = formatParentId(id, item.knowledgeList, [
  505. ...ids,
  506. item.id
  507. ]);
  508. if (cIds.includes(id)) {
  509. return cIds;
  510. }
  511. }
  512. if (item.id === id) {
  513. return [...ids, id];
  514. }
  515. }
  516. return ids;
  517. };
  518. /** 获取章节 */
  519. const getLessonCoursewareDetail = async () => {
  520. try {
  521. const res = await lessonCoursewareDetail({
  522. id: data.lessonCourseId,
  523. instrumentId: data.instrumentId
  524. });
  525. popupData.chapterDetails = res.data.lessonList || [];
  526. const ids = formatParentId(data.detailId, popupData.chapterDetails);
  527. data.lessonCoursewareDetailId = ids[0];
  528. console.log(res.data, 'data');
  529. data.lessonCoursewareSubjectList = res.data.instrumentList || [];
  530. } catch {
  531. //
  532. }
  533. };
  534. /** 更新上课记录 */
  535. const classCourseScheduleUpdate = async () => {
  536. try {
  537. if (!data.classId) return;
  538. await courseScheduleUpdate({
  539. lessonCoursewareKnowledgeDetailId: data.detailId,
  540. id: data.classId
  541. });
  542. } catch {
  543. //
  544. }
  545. };
  546. const activeName = computed(() => {
  547. let name = '';
  548. popupData.chapterDetails.forEach((chapter: any) => {
  549. if (chapter.id === data.lessonCoursewareDetailId) {
  550. // name = chapter.name;
  551. chapter.knowledgeList?.forEach((know: any) => {
  552. if (know.id === data.detailId) {
  553. name = know.name;
  554. }
  555. });
  556. }
  557. });
  558. return name;
  559. });
  560. /**停止所有的播放 */
  561. const handleStop = (isStop = true) => {
  562. // console.log(isStop, 'stop');
  563. for (let i = 0; i < data.itemList.length; i++) {
  564. const activeItem = data.itemList[i];
  565. if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
  566. try {
  567. if (isStop) {
  568. activeItem.videoEle?.currentTime(0);
  569. }
  570. activeItem.videoEle?.pause();
  571. } catch (e: any) {
  572. // console.log(e, 'e');
  573. }
  574. }
  575. if (activeItem.type === 'SONG' && activeItem.audioEle) {
  576. activeItem.audioEle?.stop();
  577. }
  578. // console.log('🚀 ~ activeItem:', activeItem)
  579. // 停止曲谱的播放
  580. if (activeItem.type === 'MUSIC') {
  581. activeItem.iframeRef?.contentWindow?.postMessage(
  582. { api: 'setPlayState' },
  583. '*'
  584. );
  585. }
  586. if (
  587. activeItem.type === 'INSTRUMENT' ||
  588. activeItem.type === 'MUSICIAN' ||
  589. activeItem.type === 'MUSIC_WIKI' ||
  590. activeItem.type === 'THEORY'
  591. ) {
  592. activeItem.iframeRef?.handleChangeAudio('pause');
  593. }
  594. // console.log(activeItem.type, 'activeItem.type');
  595. if (activeItem.type === 'RHYTHM') {
  596. activeItem.iframeRef?.contentWindow?.postMessage(
  597. { api: 'setPlayState', data: false },
  598. '*'
  599. );
  600. }
  601. if (activeItem.type === 'LISTEN') {
  602. activeItem.iframeRef?.contentWindow?.postMessage(
  603. { api: 'setPlayState' },
  604. '*'
  605. );
  606. }
  607. }
  608. };
  609. // 切换素材
  610. const toggleMaterial = (itemActive: any) => {
  611. const index = data.itemList.findIndex((n: any) => n.id == itemActive);
  612. if (index > -1) {
  613. handleSwipeChange(index);
  614. }
  615. };
  616. /** 延迟收起模态框 */
  617. const setModelOpen = () => {
  618. clearTimeout(activeData.timer);
  619. message.destroyAll();
  620. activeData.timer = setTimeout(() => {
  621. activeData.model = false;
  622. Object.values(data.videoRefs).map((n: any) =>
  623. n?.toggleHideControl(false)
  624. );
  625. Object.values(data.audioRefs).map((n: any) =>
  626. n?.toggleHideControl(false)
  627. );
  628. }, 4000);
  629. };
  630. /** 立即收起所有的模态框 */
  631. const clearModel = () => {
  632. clearTimeout(activeData.timer);
  633. message.destroyAll();
  634. activeData.model = false;
  635. Object.values(data.videoRefs).map((n: any) =>
  636. n?.toggleHideControl(false)
  637. );
  638. Object.values(data.audioRefs).map((n: any) =>
  639. n?.toggleHideControl(false)
  640. );
  641. };
  642. const toggleModel = (type = true) => {
  643. activeData.model = type;
  644. Object.values(data.videoRefs).map((n: any) => n?.toggleHideControl(type));
  645. Object.values(data.audioRefs).map((n: any) => n?.toggleHideControl(type));
  646. };
  647. // 双击
  648. const handleDbClick = (item: any) => {
  649. if (item && item.type === 'VIDEO') {
  650. const videoEle: HTMLVideoElement = item.videoEle;
  651. if (videoEle) {
  652. if (videoEle.paused) {
  653. message.destroyAll();
  654. videoEle.play();
  655. } else {
  656. message.warning('已暂停');
  657. videoEle.pause();
  658. }
  659. }
  660. }
  661. };
  662. // ppt iframe 点击事件
  663. // const iframeClick = () => {
  664. // if(document.all) {
  665. // document.getElementById("iframe-ppt")?.attachEvent("click", () => {
  666. // activeData.model = !activeData.model
  667. // });
  668. // } else {
  669. // document.getElementById("iframe-ppt")?.contentWindow?.postMessage({
  670. // api: 'onAttendToggleMenu'
  671. // }, '*');
  672. // }
  673. // }
  674. // 切换播放
  675. // const togglePlay = (m: any, isPlay: boolean) => {
  676. // if (isPlay) {
  677. // m.videoEle?.play();
  678. // } else {
  679. // m.videoEle?.pause();
  680. // }
  681. // };
  682. // const showIndex = ref(-4);
  683. const effectIndex = ref(3);
  684. const effects = [
  685. {
  686. prev: {
  687. transform: 'translate3d(0, 0, -800px) rotateX(180deg)'
  688. },
  689. next: {
  690. transform: 'translate3d(0, 0, -800px) rotateX(-180deg)'
  691. }
  692. },
  693. {
  694. prev: {
  695. transform: 'translate3d(-100%, 0, -800px)'
  696. },
  697. next: {
  698. transform: 'translate3d(100%, 0, -800px)'
  699. }
  700. },
  701. {
  702. prev: {
  703. transform: 'translate3d(-50%, 0, -800px) rotateY(80deg)'
  704. },
  705. next: {
  706. transform: 'translate3d(50%, 0, -800px) rotateY(-80deg)'
  707. }
  708. },
  709. {
  710. prev: {
  711. transform: 'translate3d(-100%, 0, -800px) rotateY(-120deg)'
  712. },
  713. next: {
  714. transform: 'translate3d(100%, 0, -800px) rotateY(120deg)'
  715. }
  716. },
  717. // 风车4
  718. {
  719. prev: {
  720. transform: 'translate3d(-50%, 50%, -800px) rotateZ(-14deg)',
  721. opacity: 0
  722. },
  723. next: {
  724. transform: 'translate3d(50%, 50%, -800px) rotateZ(14deg)',
  725. opacity: 0
  726. }
  727. },
  728. // 翻页5
  729. {
  730. prev: {
  731. transform: 'translateZ(-800px) rotate3d(0, -1, 0, 90deg)',
  732. opacity: 0
  733. },
  734. next: {
  735. transform: 'translateZ(-800px) rotate3d(0, 1, 0, 90deg)',
  736. opacity: 0
  737. },
  738. current: { transitionDelay: '700ms' }
  739. }
  740. ];
  741. const acitveTimer = ref();
  742. // 轮播切换
  743. const handleSwipeChange = (index: number) => {
  744. // 如果是当前正在播放 或者是视频最后一个
  745. if (popupData.activeIndex == index) return;
  746. data.animationState = 'start';
  747. data.videoState = 'init';
  748. handleStop();
  749. clearTimeout(acitveTimer.value);
  750. activeData.model = true;
  751. checkedAnimation(popupData.activeIndex, index);
  752. popupData.activeIndex = index;
  753. // 处理资源列表滚动
  754. nextTick(() => {
  755. scrollResourceSection();
  756. });
  757. acitveTimer.value = setTimeout(
  758. () => {
  759. const item = data.itemList[index];
  760. if (item) {
  761. if (item.type == 'MUSIC') {
  762. activeData.model = true;
  763. }
  764. if (item.type === 'SONG') {
  765. // 自动播放下一个音频
  766. clearTimeout(activeData.timer);
  767. message.destroyAll();
  768. // item.autoPlay = false;
  769. // nextTick(() => {
  770. // item.audioEle?.onPlay();
  771. // });
  772. }
  773. if (item.type === 'VIDEO') {
  774. // 自动播放下一个视频
  775. clearTimeout(activeData.timer);
  776. message.destroyAll();
  777. nextTick(() => {
  778. if (item.error) {
  779. // console.log(item, 'item error');
  780. item.videoEle?.src(item.content);
  781. item.error = false;
  782. // item.videoEle?.onPlay();
  783. }
  784. data.animationState = 'end';
  785. });
  786. }
  787. if (item.type === 'PPT') {
  788. //
  789. }
  790. }
  791. },
  792. activeData.isAnimation ? 800 : 0
  793. );
  794. };
  795. /** 是否有转场动画 */
  796. const checkedAnimation = (index: number, nextIndex?: number) => {
  797. const item = data.itemList[index];
  798. const nextItem = data.itemList[nextIndex!];
  799. if (nextItem) {
  800. if (nextItem.knowledgePointId != item.knowledgePointId) {
  801. activeData.isAnimation = true;
  802. return;
  803. }
  804. const videoEle = item.videoEle;
  805. const nextVideo = nextItem.videoEle;
  806. if (videoEle && videoEle.duration < 8 && index < nextIndex!) {
  807. activeData.isAnimation = false;
  808. } else if (nextVideo && nextVideo.duration < 8 && index > nextIndex!) {
  809. activeData.isAnimation = false;
  810. } else {
  811. activeData.isAnimation = true;
  812. }
  813. } else {
  814. activeData.isAnimation = item?.adviseStudyTimeSecond < 8 ? false : true;
  815. }
  816. };
  817. // 上一个知识点, 下一个知识点
  818. const handlePreAndNext = async (type: string) => {
  819. if (type === 'up') {
  820. // 判断上面是否还有章节
  821. if (popupData.activeIndex > 0) {
  822. handleSwipeChange(popupData.activeIndex - 1);
  823. return;
  824. }
  825. // 获取当前是哪个章节
  826. let detailIndex = popupData.chapterDetails.findIndex(
  827. (item: any) => item.id == data.lessonCoursewareDetailId
  828. );
  829. const detailItem =
  830. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  831. let lessonIndex = detailItem.findIndex(
  832. (item: any) => item.id == data.detailId
  833. );
  834. let lessonStatus = false; // 当前章节上面是否有内容
  835. let lessonCoursewareDetailId = '';
  836. let coursewareDetailKnowledgeId = '';
  837. while (lessonIndex >= 0) {
  838. lessonIndex--;
  839. if (lessonIndex >= 0) {
  840. if (detailItem[lessonIndex].coursewareNum > 0) {
  841. lessonStatus = true;
  842. lessonCoursewareDetailId =
  843. detailItem[lessonIndex].lessonCoursewareDetailId;
  844. coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
  845. }
  846. }
  847. if (lessonStatus) {
  848. break;
  849. }
  850. }
  851. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  852. if (lessonStatus) {
  853. popupData.courseId = coursewareDetailKnowledgeId;
  854. data.selectClassStatus = true;
  855. return;
  856. }
  857. let prevLessonStatus = false;
  858. while (detailIndex >= 0) {
  859. detailIndex--;
  860. const tempDetail =
  861. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  862. let tempLessonLength = tempDetail.length;
  863. while (tempLessonLength > 0) {
  864. if (tempDetail[tempLessonLength - 1].coursewareNum > 0) {
  865. prevLessonStatus = true;
  866. lessonCoursewareDetailId =
  867. tempDetail[tempLessonLength - 1].lessonCoursewareDetailId;
  868. coursewareDetailKnowledgeId = tempDetail[tempLessonLength - 1].id;
  869. }
  870. tempLessonLength--;
  871. if (prevLessonStatus) {
  872. break;
  873. }
  874. }
  875. if (prevLessonStatus) {
  876. break;
  877. }
  878. }
  879. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  880. if (prevLessonStatus) {
  881. popupData.courseId = coursewareDetailKnowledgeId;
  882. data.selectClassStatus = true;
  883. return;
  884. }
  885. } else {
  886. if (popupData.activeIndex < data.itemList.length - 1) {
  887. handleSwipeChange(popupData.activeIndex + 1);
  888. return;
  889. }
  890. if (!isDownArrow.value) return;
  891. data.nextEndShow = true;
  892. }
  893. };
  894. // 当前课件结束之后选择下一个课件
  895. function handleNextEnd() {
  896. // 获取当前是哪个章节
  897. let detailIndex = popupData.chapterDetails.findIndex(
  898. (item: any) => item.id == data.lessonCoursewareDetailId
  899. );
  900. const detailItem =
  901. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  902. let lessonIndex = detailItem.findIndex(
  903. (item: any) => item.id == data.detailId
  904. );
  905. let lessonStatus = false; // 当前章节下面是否有内容
  906. let lessonCoursewareDetailId = '';
  907. let coursewareDetailKnowledgeId = '';
  908. while (lessonIndex < detailItem.length - 1) {
  909. lessonIndex++;
  910. if (lessonIndex >= 0) {
  911. if (detailItem[lessonIndex].coursewareNum > 0) {
  912. lessonStatus = true;
  913. lessonCoursewareDetailId =
  914. detailItem[lessonIndex].lessonCoursewareDetailId;
  915. coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
  916. }
  917. }
  918. if (lessonStatus) {
  919. break;
  920. }
  921. }
  922. // 判断当前章节下面课程是否有内容,否则往下一个章节走
  923. if (lessonStatus) {
  924. popupData.courseId = coursewareDetailKnowledgeId;
  925. data.selectClassStatus = true;
  926. return;
  927. }
  928. let nextLessonStatus = false;
  929. while (detailIndex <= popupData.chapterDetails.length - 1) {
  930. detailIndex++;
  931. const tempDetail =
  932. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  933. let tempLessonLength = 0;
  934. while (tempLessonLength <= tempDetail.length - 1) {
  935. if (tempDetail[tempLessonLength].coursewareNum > 0) {
  936. nextLessonStatus = true;
  937. lessonCoursewareDetailId =
  938. tempDetail[tempLessonLength].lessonCoursewareDetailId;
  939. coursewareDetailKnowledgeId = tempDetail[tempLessonLength].id;
  940. }
  941. tempLessonLength++;
  942. if (nextLessonStatus) {
  943. break;
  944. }
  945. }
  946. if (nextLessonStatus) {
  947. break;
  948. }
  949. }
  950. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  951. if (nextLessonStatus) {
  952. popupData.courseId = coursewareDetailKnowledgeId;
  953. data.selectClassStatus = true;
  954. return;
  955. }
  956. }
  957. /** 弹窗关闭 */
  958. const handleClosePopup = () => {
  959. const item = data.itemList[popupData.activeIndex];
  960. if (item?.type == 'VIDEO' && !item.videoEle?.paused) {
  961. setModelOpen();
  962. }
  963. if (item?.type == 'SONG' && !item.audioEle?.paused) {
  964. setModelOpen();
  965. }
  966. };
  967. // const toggleListenerKeyUp = (type: string) => {
  968. // if (type === 'remove') {
  969. // document.body.removeEventListener('keyup', () => {
  970. // listenerKeyUpState.value = false;
  971. // });
  972. // } else {
  973. // // 监听页面键盘事件 - 上下切换
  974. // document.body.addEventListener('keyup', (e: KeyboardEvent) => {
  975. // // console.log(e, 'e');
  976. // if (e.code === 'ArrowLeft') {
  977. // // if (popupData.activeIndex === 0) return;
  978. // setModalOpen();
  979. // handlePreAndNext('up');
  980. // } else if (e.code === 'ArrowRight') {
  981. // // if (popupData.activeIndex === data.itemList.length - 1) return;
  982. // setModalOpen();
  983. // handlePreAndNext('down');
  984. // }
  985. // });
  986. // listenerKeyUpState.value = true;
  987. // }
  988. // };
  989. // 监听切换到ppt课件时,手动移除键盘监听器
  990. // watch(() => popupData.activeIndex, () => {
  991. // const activeItem = data.itemList[popupData.activeIndex];
  992. // if (activeItem?.type === 'PPT') {
  993. // toggleListenerKeyUp('remove')
  994. // } else {
  995. // !listenerKeyUpState.value && toggleListenerKeyUp('add')
  996. // }
  997. // })
  998. watch(
  999. () => popupData.activeIndex,
  1000. () => {
  1001. const item = data.itemList[popupData.activeIndex];
  1002. popupData.courseActiveIndex = item.parentIndex;
  1003. }
  1004. );
  1005. const setModalOpen = (status = true) => {
  1006. clearTimeout(activeData.timer);
  1007. activeData.model = status;
  1008. Object.values(data.videoRefs).map((n: any) =>
  1009. n?.toggleHideControl(status)
  1010. );
  1011. Object.values(data.audioRefs).map((n: any) =>
  1012. n?.toggleHideControl(status)
  1013. );
  1014. };
  1015. /** 教学数据 */
  1016. const studyData = reactive({
  1017. type: '' as ToolType,
  1018. penShow: false,
  1019. whiteboardShow: false,
  1020. callShow: false,
  1021. callStudentList: [] as any // 学生列表
  1022. });
  1023. /** 打开教学工具 */
  1024. const openStudyTool = (item: ToolItem) => {
  1025. handleStop(false);
  1026. clearModel();
  1027. popupData.toolOpen = false;
  1028. studyData.type = item.type;
  1029. switch (item.type) {
  1030. case 'pen':
  1031. studyData.penShow = true;
  1032. break;
  1033. case 'whiteboard':
  1034. studyData.whiteboardShow = true;
  1035. break;
  1036. case 'call':
  1037. studyData.callShow = true;
  1038. break;
  1039. }
  1040. };
  1041. /** 关闭教学工具 */
  1042. const closeStudyTool = () => {
  1043. studyData.type = 'init';
  1044. toggleModel();
  1045. setModelOpen();
  1046. };
  1047. const startShowModal = (
  1048. val: 'setTimeIcon' | 'beatIcon' | 'toneIcon' | 'iconNote2'
  1049. ) => {
  1050. if (val == 'setTimeIcon') {
  1051. showModalTime.value = true;
  1052. }
  1053. if (val == 'beatIcon') {
  1054. showModalBeat.value = true;
  1055. }
  1056. if (val == 'toneIcon') {
  1057. showModalTone.value = true;
  1058. }
  1059. };
  1060. // 是否允许上一页
  1061. const isUpArrow = computed(() => {
  1062. /**
  1063. * 1,判断当前课程中是否处在第一个资源;
  1064. * 2,判断当前课程是否在当前章节的第一个;
  1065. * 3,判断当前章节,当前课程上面还没有其它课程,是否有资源;
  1066. * 4,判断当前章节上面还没有其它章节;
  1067. * 5,判断上面章节里面课程是否有资源;
  1068. */
  1069. if (popupData.activeIndex > 0) {
  1070. return true;
  1071. }
  1072. // 获取当前是哪个章节
  1073. let detailIndex = popupData.chapterDetails.findIndex(
  1074. (item: any) => item.id == data.lessonCoursewareDetailId
  1075. );
  1076. const detailItem =
  1077. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1078. let lessonIndex = detailItem.findIndex(
  1079. (item: any) => item.id == data.detailId
  1080. );
  1081. // 说明已经是第一单元,第一课
  1082. if (detailIndex <= 0 && lessonIndex <= 0) {
  1083. return false;
  1084. }
  1085. let lessonStatus = false; // 当前章节上面是否有内容
  1086. while (lessonIndex >= 0) {
  1087. lessonIndex--;
  1088. if (lessonIndex >= 0) {
  1089. if (detailItem[lessonIndex].coursewareNum > 0) {
  1090. lessonStatus = true;
  1091. }
  1092. }
  1093. }
  1094. // 判断当前章节下面课程是否有内容,否则往上一个章节走
  1095. if (lessonStatus) {
  1096. return true;
  1097. }
  1098. // 已经是第一个章节了
  1099. if (detailIndex <= 0) {
  1100. return false;
  1101. }
  1102. let prevLessonStatus = false;
  1103. while (detailIndex >= 0) {
  1104. detailIndex--;
  1105. const tempDetail =
  1106. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1107. let tempLessonLength = tempDetail.length;
  1108. while (tempLessonLength > 0) {
  1109. if (tempDetail[tempLessonLength - 1].coursewareNum > 0) {
  1110. prevLessonStatus = true;
  1111. }
  1112. tempLessonLength--;
  1113. }
  1114. if (prevLessonStatus) {
  1115. return true;
  1116. }
  1117. }
  1118. return false;
  1119. });
  1120. // 是否允许下一页
  1121. const isDownArrow = computed(() => {
  1122. if (popupData.activeIndex < data.itemList.length - 1) {
  1123. return true;
  1124. }
  1125. // 获取当前是哪个章节
  1126. let detailIndex = popupData.chapterDetails.findIndex(
  1127. (item: any) => item.id == data.lessonCoursewareDetailId
  1128. );
  1129. const detailItem =
  1130. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1131. let lessonIndex = detailItem.findIndex(
  1132. (item: any) => item.id == data.detailId
  1133. );
  1134. // 说明已经是最后-单元,最后一课
  1135. if (
  1136. detailIndex >= popupData.chapterDetails.length - 1 &&
  1137. lessonIndex >= detailItem.length - 1
  1138. ) {
  1139. return false;
  1140. }
  1141. let lessonStatus = false; // 当前章节下面是否有内容
  1142. while (lessonIndex < detailItem.length - 1) {
  1143. lessonIndex++;
  1144. if (lessonIndex >= 0) {
  1145. if (detailItem[lessonIndex].coursewareNum > 0) {
  1146. lessonStatus = true;
  1147. }
  1148. }
  1149. }
  1150. // 判断当前章节下面课程是否有内容,否则往下一个章节走
  1151. if (lessonStatus) {
  1152. return true;
  1153. }
  1154. // 已经是最后一个章节了
  1155. if (detailIndex >= popupData.chapterDetails.length - 1) {
  1156. return false;
  1157. }
  1158. let nextLessonStatus = false;
  1159. while (detailIndex < popupData.chapterDetails.length - 1) {
  1160. detailIndex++;
  1161. const tempDetail =
  1162. popupData.chapterDetails[detailIndex]?.knowledgeList || [];
  1163. let tempLessonLength = 0;
  1164. while (tempLessonLength <= tempDetail.length - 1) {
  1165. if (tempDetail[tempLessonLength].coursewareNum > 0) {
  1166. nextLessonStatus = true;
  1167. }
  1168. tempLessonLength++;
  1169. }
  1170. if (nextLessonStatus) {
  1171. return true;
  1172. }
  1173. }
  1174. return false;
  1175. });
  1176. const activeVideoItem = computed(() => {
  1177. const item = data.itemList[popupData.activeIndex];
  1178. if (item && item.type && item.type.toLocaleUpperCase() === 'VIDEO') {
  1179. return item;
  1180. }
  1181. return {};
  1182. });
  1183. // 右侧菜单栏
  1184. const rightList = reactive([
  1185. {
  1186. name: '上一个',
  1187. icon: bottomIconPre,
  1188. id: 11
  1189. },
  1190. {
  1191. name: '下一个',
  1192. icon: bottomIconNext,
  1193. id: 12
  1194. },
  1195. {
  1196. name: '资源列表',
  1197. icon: bottomIconResource,
  1198. id: 14
  1199. },
  1200. {
  1201. name: '切换章节',
  1202. icon: bottomIconSwitch,
  1203. id: 13
  1204. },
  1205. {
  1206. name: '曲目资源',
  1207. icon: rightIconMusic,
  1208. id: 9
  1209. },
  1210. {
  1211. name: '点名',
  1212. icon: rightIconCall,
  1213. id: 10
  1214. },
  1215. {
  1216. name: '布置作业',
  1217. icon: rightIconArrange,
  1218. id: 2
  1219. },
  1220. {
  1221. name: '工具箱',
  1222. icon: rightIconTool,
  1223. id: 15
  1224. },
  1225. {
  1226. name: '结束课程',
  1227. name2: '结束预览',
  1228. icon: rightIconEnd,
  1229. id: 1
  1230. },
  1231. {
  1232. name: '收起',
  1233. icon: leftIconPackUp,
  1234. id: 8
  1235. }
  1236. ]);
  1237. const tooltipList = [
  1238. {
  1239. name: '节拍器',
  1240. icon: rightIconMetronome,
  1241. id: 5
  1242. },
  1243. {
  1244. name: '计时器',
  1245. icon: rightIconTimer,
  1246. id: 7
  1247. },
  1248. {
  1249. name: '批注',
  1250. icon: rightIconPostil,
  1251. id: 3
  1252. },
  1253. {
  1254. name: '白板',
  1255. icon: rightIconWhiteboard,
  1256. id: 4
  1257. }
  1258. // {
  1259. // name: '调音器',
  1260. // icon: rightIconTuner,
  1261. // id: 6
  1262. // }
  1263. ];
  1264. // 默认收起菜单
  1265. const columnShow = ref(true);
  1266. // 菜单位置
  1267. const columnPos = ref<'left' | 'right'>('left');
  1268. watch(columnPos, () => {
  1269. for (let i = 0; i < data.itemList.length; i++) {
  1270. const activeItem = data.itemList[i];
  1271. if (['RHYTHM', 'MUSIC'].includes(activeItem.type)) {
  1272. activeItem.iframeRef?.contentWindow?.postMessage(
  1273. { api: 'imagePos', data: columnPos.value },
  1274. '*'
  1275. );
  1276. }
  1277. }
  1278. });
  1279. // 右边栏操作
  1280. const operateRightBtn = async (id: number) => {
  1281. if (![8, 11, 12, 13, 14].includes(id)) {
  1282. handleStop(false);
  1283. }
  1284. switch (id) {
  1285. case 1:
  1286. if (data.type === 'preview') {
  1287. data.removeVisiable = true;
  1288. data.removeTitle = '结束预览';
  1289. data.removeContent = '请确认是否结束预览?';
  1290. } else {
  1291. const res = await getStudentAfterWork({
  1292. courseScheduleId: data.classId,
  1293. page: 1,
  1294. rows: 99
  1295. });
  1296. if (res.data.rows && res.data.rows.length) {
  1297. data.removeContent = '请确认是否结束课程?';
  1298. data.removeCourseStatus = false;
  1299. } else {
  1300. data.removeContent = '本次课堂尚未布置作业,是否结束课程?';
  1301. data.removeCourseStatus = true;
  1302. }
  1303. data.removeVisiable = true;
  1304. data.removeTitle = '结束课程';
  1305. }
  1306. break;
  1307. case 2:
  1308. // 学生人数必须大于0,才可以布置作业
  1309. if (data.preStudentNum <= 0) return;
  1310. // const res = await lessonPreTrainingPage({
  1311. // coursewareKnowledgeDetailId: data.detailId,
  1312. // instrumentId: data.instrumentId,
  1313. // page: 1,
  1314. // rows: 99
  1315. // });
  1316. // if (res.data.rows && res.data.rows.length) {
  1317. // data.modalAttendMessage = '本节课已设置课后作业,是否布置?';
  1318. // }
  1319. // data.modelAttendStatus = true;
  1320. const res = await getStudentAfterWork({
  1321. courseScheduleId: data.classId,
  1322. page: 1,
  1323. rows: 99
  1324. });
  1325. if (res.data.rows && res.data.rows.length) {
  1326. // data.modalAttendMessage = '请确认是否结束课程?';
  1327. data.modalAttendMessage = '本次课程已布置作业,是否继续?';
  1328. data.modelAttendStatus = true;
  1329. } else {
  1330. data.modelTrainStatus = true;
  1331. nextTick(() => {
  1332. getModalHeight();
  1333. });
  1334. data.modelAttendStatus = false;
  1335. }
  1336. break;
  1337. case 3:
  1338. openStudyTool({
  1339. type: 'pen',
  1340. icon: iconNote,
  1341. name: '批注'
  1342. });
  1343. break;
  1344. case 4:
  1345. openStudyTool({
  1346. type: 'whiteboard',
  1347. icon: iconWhite,
  1348. name: '白板'
  1349. });
  1350. break;
  1351. case 5:
  1352. startShowModal('beatIcon');
  1353. break;
  1354. case 6:
  1355. startShowModal('toneIcon');
  1356. break;
  1357. case 7:
  1358. startShowModal('setTimeIcon');
  1359. break;
  1360. case 8:
  1361. columnShow.value = false;
  1362. break;
  1363. case 9:
  1364. // 选择曲目时需要暂停所有播放
  1365. handleStop(false);
  1366. data.selectResourceStatus = true;
  1367. break;
  1368. case 10:
  1369. // 点名
  1370. // await rollCallStudentList();
  1371. if (studyData.callStudentList.length > 0) {
  1372. openStudyTool({
  1373. type: 'call',
  1374. icon: iconWhite,
  1375. name: '点名'
  1376. });
  1377. return;
  1378. }
  1379. break;
  1380. case 11:
  1381. if (!isUpArrow.value) return;
  1382. handlePreAndNext('up');
  1383. break;
  1384. case 12:
  1385. if (!isDownArrow.value) return;
  1386. handlePreAndNext('down');
  1387. break;
  1388. case 13:
  1389. popupData.chapterOpen = true;
  1390. break;
  1391. case 14:
  1392. popupData.open = true;
  1393. nextTick(() => {
  1394. scrollResourceSection();
  1395. });
  1396. break;
  1397. default:
  1398. break;
  1399. }
  1400. };
  1401. // 点名学生列表
  1402. const rollCallStudentList = async () => {
  1403. //
  1404. if (!data.classId) return;
  1405. try {
  1406. const res = await getStudentList({
  1407. classGroupId: data.classGroupId,
  1408. page: 1,
  1409. rows: 999
  1410. });
  1411. const result = res.data || {};
  1412. if (Array.isArray(result.rows) && result.rows.length > 0) {
  1413. const tempStudents: any = [];
  1414. result.rows.forEach((row: any) => {
  1415. tempStudents.push({
  1416. name: row.nickname,
  1417. img: row.avatar
  1418. });
  1419. });
  1420. studyData.callStudentList = [...tempStudents];
  1421. }
  1422. } catch {
  1423. //
  1424. }
  1425. };
  1426. // 滚动到某个元素的位置
  1427. const scrollResourceSection = () => {
  1428. const drawerCardItemRefs =
  1429. document.querySelectorAll('.drawerCardItemRef');
  1430. if (
  1431. popupData.activeIndex >= 0 &&
  1432. drawerCardItemRefs[popupData.activeIndex]
  1433. ) {
  1434. drawerCardItemRefs[popupData.activeIndex].scrollIntoView();
  1435. }
  1436. };
  1437. const getModalHeight = () => {
  1438. const dom: any = document.querySelector('#model-homework-height');
  1439. if (dom) {
  1440. useResizeObserver(dom as HTMLElement, (entries: any) => {
  1441. const entry = entries[0];
  1442. const { height } = entry.contentRect;
  1443. dom.style.setProperty('--window-page-lesson-height', height + 'px');
  1444. });
  1445. }
  1446. };
  1447. /* 弹窗加拖动 */
  1448. // 引导页
  1449. getGuidanceShow();
  1450. // 选择课件弹窗
  1451. const selCourBoxClass = 'selCourBoxClass_drag';
  1452. const selCourDragData = useDrag(
  1453. [`${selCourBoxClass}>.n-card-header`, `${selCourBoxClass} .bom_drag`],
  1454. selCourBoxClass,
  1455. toRef(data, 'selectClassStatus'),
  1456. users.info.id
  1457. );
  1458. // 选择资源弹窗
  1459. const selResourBoxClass = 'selResourBoxClass_drag';
  1460. const selResourDragData = useDrag(
  1461. [
  1462. `${selResourBoxClass} .select-resource>.n-tabs>.n-tabs-nav--top.n-tabs-nav`,
  1463. `${selResourBoxClass} .bom_drag`
  1464. ],
  1465. selResourBoxClass,
  1466. toRef(data, 'selectResourceStatus'),
  1467. users.info.id
  1468. );
  1469. // 结束预览 结束课程确认弹窗
  1470. const removeResourBoxClass = 'removeResourBoxClass_drag';
  1471. const removeResourDragData = useDrag(
  1472. [
  1473. `${removeResourBoxClass}>.n-card-header`,
  1474. `${removeResourBoxClass} .bom_drag`
  1475. ],
  1476. removeResourBoxClass,
  1477. toRef(data, 'removeVisiable'),
  1478. users.info.id
  1479. );
  1480. // 章节next弹窗
  1481. const nextEndBoxClass = 'nextEndBoxClass_drag';
  1482. const nextEndBoxDragData = useDrag(
  1483. [`${nextEndBoxClass}>.n-card-header`, `${nextEndBoxClass} .bom_drag`],
  1484. nextEndBoxClass,
  1485. toRef(data, 'nextEndShow'),
  1486. users.info.id
  1487. );
  1488. // 章节切换弹窗
  1489. const chapterConBoxClass = 'chapterConBoxClass_drag';
  1490. const chapterConBoxDragData = useDrag(
  1491. [
  1492. `${chapterConBoxClass}>.n-card-header`,
  1493. `${chapterConBoxClass} .bom_drag`
  1494. ],
  1495. chapterConBoxClass,
  1496. toRef(popupData, 'chapterOpen'),
  1497. users.info.id
  1498. );
  1499. // 资源列表弹窗
  1500. const resourcesConBoxClass = 'resourcesConBoxClass_drag';
  1501. const resourcesConDragData = useDrag(
  1502. [
  1503. `${resourcesConBoxClass}>.n-card-header`,
  1504. `${resourcesConBoxClass} .bom_drag`
  1505. ],
  1506. resourcesConBoxClass,
  1507. toRef(popupData, 'open'),
  1508. users.info.id
  1509. );
  1510. // 计时器
  1511. const timerMeterConBoxClass = 'timerMeterConBoxClass_drag';
  1512. const timerMeterConDragData = useDrag(
  1513. [
  1514. `${timerMeterConBoxClass} .timeBomCon .bom_drag`,
  1515. `${timerMeterConBoxClass} .topDragDom`
  1516. ],
  1517. timerMeterConBoxClass,
  1518. showModalTime,
  1519. users.info.id
  1520. );
  1521. // 节拍器
  1522. const metronomeConBoxClass = 'metronomeConBoxClass_drag';
  1523. const metronomeConBoxDragData = useDrag(
  1524. [
  1525. `${metronomeConBoxClass} .topDragDom`,
  1526. `${metronomeConBoxClass} .bom_drag`
  1527. ],
  1528. metronomeConBoxClass,
  1529. showModalBeat,
  1530. users.info.id
  1531. );
  1532. // 布置作业弹窗
  1533. const modelTrainStatusConBoxClass = 'modelTrainStatusConBoxClass_drag';
  1534. const modelTrainStatusConBoxDragData = useDrag(
  1535. [
  1536. `${modelTrainStatusConBoxClass}>.n-card-header`,
  1537. `${modelTrainStatusConBoxClass} .bom_drag`
  1538. ],
  1539. modelTrainStatusConBoxClass,
  1540. toRef(data, 'modelTrainStatus'),
  1541. users.info.id
  1542. );
  1543. // 布置作业课后作业
  1544. const modelTrainHomeWordConBoxClass =
  1545. 'modelTrainHomeWordConBoxClassBoxClass_drag';
  1546. const modelTrainHomeWordConBoxDragData = useDrag(
  1547. [
  1548. `${modelTrainHomeWordConBoxClass}>.n-card-header`,
  1549. `${modelTrainHomeWordConBoxClass} .bom_drag`
  1550. ],
  1551. modelTrainHomeWordConBoxClass,
  1552. toRef(data, 'modelAttendStatus'),
  1553. users.info.id
  1554. );
  1555. return () => (
  1556. <div id="playContent" class={[styles.playContent, 'wrap']}>
  1557. <div
  1558. onClick={() => {
  1559. clearTimeout(activeData.timer);
  1560. activeData.model = !activeData.model;
  1561. Object.values(data.videoRefs).map((n: any) =>
  1562. n?.toggleHideControl(activeData.model)
  1563. );
  1564. Object.values(data.audioRefs).map((n: any) =>
  1565. n?.toggleHideControl(activeData.model)
  1566. );
  1567. }}>
  1568. <div
  1569. class={styles.coursewarePlay}
  1570. style={{ width: parentContainer.width }}>
  1571. {!popupData.chapterLoading ? (
  1572. <div class={styles.wraps}>
  1573. <div
  1574. style={
  1575. activeVideoItem.value.type &&
  1576. data.animationState === 'end' &&
  1577. data.videoState === 'play'
  1578. ? {
  1579. zIndex: 15,
  1580. opacity: 1
  1581. }
  1582. : { opacity: 0, zIndex: -1 }
  1583. }
  1584. class={styles.itemDiv}>
  1585. <VideoPlay
  1586. imagePos={columnPos.value}
  1587. ref={(el: any) => (data.videoItemRef = el)}
  1588. item={activeVideoItem.value}
  1589. showModel={activeData.model}
  1590. onClose={setModelOpen}
  1591. onLoadedmetadata={(videoItem: any) => {
  1592. if (data.itemList[popupData.activeIndex]) {
  1593. data.itemList[popupData.activeIndex].videoEle =
  1594. videoItem;
  1595. }
  1596. }}
  1597. onCanplay={() => {
  1598. data.videoState = 'play';
  1599. // activeVideoItem.value.videoEle = videoItem;
  1600. }}
  1601. onPause={() => {
  1602. clearTimeout(activeData.timer);
  1603. activeData.model = true;
  1604. }}
  1605. onEnded={() => {
  1606. // const _index = popupData.activeIndex + 1;
  1607. // if (_index < data.itemList.length) {
  1608. // handleSwipeChange(_index);
  1609. // }
  1610. }}
  1611. />
  1612. </div>
  1613. {data.itemList.map((m: any, mIndex: number) => {
  1614. const isRender = Math.abs(popupData.activeIndex - mIndex) < 2;
  1615. const isEmtry = Math.abs(popupData.activeIndex - mIndex) > 4;
  1616. // if (isRender && m.type === 'PPT') {
  1617. // setTimeout(() => iframeClick() ,500)
  1618. // }
  1619. // if (isRender) {
  1620. // m.isRender = true;
  1621. // }
  1622. // const isRender =
  1623. // m.isRender || Math.abs(popupData.activeIndex - mIndex) < 2;
  1624. // const isEmtry = Math.abs(popupData.activeIndex - mIndex) > 4;
  1625. // if (isRender) {
  1626. // m.isRender = true;
  1627. // }
  1628. return isRender ? (
  1629. <div
  1630. key={'index' + mIndex}
  1631. class={[
  1632. styles.itemDiv,
  1633. popupData.activeIndex === mIndex && styles.itemActive,
  1634. activeData.isAnimation && styles.acitveAnimation,
  1635. Math.abs(popupData.activeIndex - mIndex) < 2
  1636. ? styles.show
  1637. : styles.hide
  1638. ]}
  1639. style={
  1640. mIndex < popupData.activeIndex
  1641. ? effects[effectIndex.value].prev
  1642. : mIndex > popupData.activeIndex
  1643. ? effects[effectIndex.value].next
  1644. : {}
  1645. }
  1646. onClick={(e: Event) => {
  1647. e.stopPropagation();
  1648. clearTimeout(activeData.timer);
  1649. if (Date.now() - activeData.nowTime < 300) {
  1650. handleDbClick(m);
  1651. return;
  1652. }
  1653. activeData.nowTime = Date.now();
  1654. activeData.timer = setTimeout(() => {
  1655. activeData.model = !activeData.model;
  1656. Object.values(data.videoRefs).map((n: any) =>
  1657. n?.toggleHideControl(activeData.model)
  1658. );
  1659. Object.values(data.audioRefs).map((n: any) =>
  1660. n?.toggleHideControl(activeData.model)
  1661. );
  1662. if (activeData.model) {
  1663. setModelOpen();
  1664. }
  1665. }, 300);
  1666. }}>
  1667. {m.type === 'VIDEO' ? (
  1668. <>
  1669. <img
  1670. src={m.coverImg}
  1671. onLoad={() => {
  1672. m.isprepare = true;
  1673. }}
  1674. />
  1675. {/* <VideoPlay
  1676. ref={(v: any) => (data.videoRefs[mIndex] = v)}
  1677. item={m}
  1678. isEmtry={isEmtry}
  1679. onLoadedmetadata={(videoItem: any) => {
  1680. m.videoEle = videoItem;
  1681. m.isprepare = true;
  1682. }}
  1683. onTogglePlay={(paused: boolean) => {
  1684. m.autoPlay = false;
  1685. if (paused || popupData.open) {
  1686. clearTimeout(activeData.timer);
  1687. } else {
  1688. setModelOpen();
  1689. }
  1690. }}
  1691. onReset={() => {
  1692. if (!m.videoEle?.paused) {
  1693. setModelOpen();
  1694. }
  1695. }}
  1696. onError={() => {
  1697. console.log('video error');
  1698. m.error = true;
  1699. }}
  1700. /> */}
  1701. <Transition name="van-fade">
  1702. {
  1703. <div class={styles.loadWrap}>
  1704. <Vue3Lottie
  1705. animationData={playLoadData}></Vue3Lottie>
  1706. </div>
  1707. }
  1708. </Transition>
  1709. </>
  1710. ) : m.type === 'IMG' ? (
  1711. <img src={m.content} />
  1712. ) : m.type === 'SONG' ? (
  1713. <AudioPay
  1714. imagePos={columnPos.value}
  1715. item={m}
  1716. activeStatus={popupData.activeIndex === mIndex}
  1717. ref={(v: any) => (data.audioRefs[mIndex] = v)}
  1718. onLoadedmetadata={(audioItem: any) => {
  1719. m.audioEle = audioItem;
  1720. m.isprepare = true;
  1721. }}
  1722. onTogglePlay={(paused: boolean) => {
  1723. // m.autoPlay = false;
  1724. if (paused || popupData.open) {
  1725. clearTimeout(activeData.timer);
  1726. } else {
  1727. setModelOpen();
  1728. }
  1729. }}
  1730. onEnded={() => {
  1731. // const _index = popupData.activeIndex + 1;
  1732. // if (_index < data.itemList.length) {
  1733. // handleSwipeChange(_index);
  1734. // }
  1735. }}
  1736. onReset={() => {
  1737. if (!m.audioEle?.paused) {
  1738. setModelOpen();
  1739. }
  1740. }}
  1741. />
  1742. ) : // : m.type === 'PPT' ? <div class={styles.iframePpt}>
  1743. // <div class={styles.pptBox}></div>
  1744. // <iframe src={`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(m.content)}`} width='100%' height='100%' frameborder='1'></iframe>
  1745. // </div>
  1746. m.type === 'PPT' ? (
  1747. <iframe
  1748. src={`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(
  1749. m.content
  1750. )}`}
  1751. onLoad={(e: any) => {
  1752. nextTick(() => {
  1753. console.log(e, 'ppt', e.target);
  1754. m.iframeRef = e.target;
  1755. });
  1756. }}
  1757. width="100%"
  1758. height="100%"
  1759. frameborder="1"></iframe>
  1760. ) : m.type === 'RHYTHM' ? (
  1761. <RhythmModal
  1762. item={m}
  1763. activeStatus={popupData.activeIndex === mIndex}
  1764. imagePos={columnPos.value}
  1765. onSetIframe={(el: any) => {
  1766. m.iframeRef = el;
  1767. }}
  1768. />
  1769. ) : m.type === 'LISTEN' ? (
  1770. <ListenModal
  1771. item={m}
  1772. data-vid={m.id}
  1773. activeStatus={popupData.activeIndex === mIndex}
  1774. onSetIframe={(el: any) => {
  1775. m.iframeRef = el;
  1776. }}
  1777. />
  1778. ) : m.type === 'INSTRUMENT' || m.type === 'MUSICIAN' ? (
  1779. <InstruemntDetail
  1780. type="preview"
  1781. id={m.content}
  1782. contentType={m.type}
  1783. activeStatus={popupData.activeIndex === mIndex}
  1784. ref={(el: any) => (m.iframeRef = el)}
  1785. />
  1786. ) : m.type === 'MUSIC_WIKI' ? (
  1787. <MusicDetail
  1788. type="preview"
  1789. id={m.content}
  1790. contentType={m.type}
  1791. activeStatus={popupData.activeIndex === mIndex}
  1792. ref={(el: any) => (m.iframeRef = el)}
  1793. />
  1794. ) : m.type === 'THEORY' ? (
  1795. <TheotyDetail
  1796. type="preview"
  1797. id={m.content}
  1798. activeStatus={popupData.activeIndex === mIndex}
  1799. ref={(el: any) => (m.iframeRef = el)}
  1800. />
  1801. ) : (
  1802. <MusicScore
  1803. activeModel={activeData.model}
  1804. instrumentId={data.instrumentId}
  1805. activeStatus={popupData.activeIndex === mIndex}
  1806. data-vid={m.id}
  1807. music={m}
  1808. imagePos={columnPos.value}
  1809. onSetIframe={(el: any) => {
  1810. m.iframeRef = el;
  1811. }}
  1812. />
  1813. )}
  1814. </div>
  1815. ) : null;
  1816. })}
  1817. </div>
  1818. ) : (
  1819. ''
  1820. )}
  1821. </div>
  1822. </div>
  1823. {/* 右边操作栏 */}
  1824. <div
  1825. class={[
  1826. styles.rightColumn,
  1827. columnShow.value && columnPos.value === 'right'
  1828. ? ''
  1829. : styles.rightColumnHide
  1830. ]}>
  1831. {rightList.map((item: any) => (
  1832. <div class={styles.columnItemBox}>
  1833. <div
  1834. class={[
  1835. styles.columnItem,
  1836. (item.id === 2 && data.preStudentNum <= 0) ||
  1837. (item.id === 10 && studyData.callStudentList.length <= 0) ||
  1838. (item.id === 11 && !isUpArrow.value) ||
  1839. (item.id === 12 && !isDownArrow.value)
  1840. ? styles.itemDisabled
  1841. : ''
  1842. ]}
  1843. onClick={() => operateRightBtn(item.id)}>
  1844. <NTooltip
  1845. showArrow={false}
  1846. placement="left"
  1847. show={item.id === 15 ? undefined : false}
  1848. class={[
  1849. item.id === 15
  1850. ? 'columnItemTooltip rightColumnItemTooltip'
  1851. : ''
  1852. ]}>
  1853. {{
  1854. trigger: () => (
  1855. <img src={item.id === 8 ? rightIconPackUp : item.icon} />
  1856. ),
  1857. default: () =>
  1858. item.id === 15 ? (
  1859. <div class="tools">
  1860. {tooltipList.map(i => (
  1861. <div onClick={() => operateRightBtn(i.id)}>
  1862. <img src={i.icon} />
  1863. <div class="tit">{i.name}</div>
  1864. </div>
  1865. ))}
  1866. </div>
  1867. ) : item.id === 1 && data.type === 'preview' ? (
  1868. item.name2
  1869. ) : (
  1870. item.name
  1871. )
  1872. }}
  1873. </NTooltip>
  1874. </div>
  1875. </div>
  1876. ))}
  1877. </div>
  1878. <NTooltip showArrow={false} placement="left" show={false}>
  1879. {{
  1880. trigger: () => (
  1881. <div
  1882. class={[
  1883. styles.rightHideIcon,
  1884. !(columnShow.value && columnPos.value === 'right')
  1885. ? styles.rightIconShow
  1886. : ''
  1887. ]}
  1888. onClick={() => {
  1889. columnPos.value = 'right';
  1890. columnShow.value = true;
  1891. }}
  1892. />
  1893. ),
  1894. default: () => '按钮镜像'
  1895. }}
  1896. </NTooltip>
  1897. {/* 左边操作栏 */}
  1898. <div
  1899. class={[
  1900. styles.leftColumn,
  1901. columnShow.value && columnPos.value === 'left'
  1902. ? ''
  1903. : styles.leftColumnHide
  1904. ]}>
  1905. {rightList.map((item: any) => (
  1906. <div class={styles.columnItemBox}>
  1907. <div
  1908. class={[
  1909. styles.columnItem,
  1910. (item.id === 2 && data.preStudentNum <= 0) ||
  1911. (item.id === 10 && studyData.callStudentList.length <= 0) ||
  1912. (item.id === 11 && !isUpArrow.value) ||
  1913. (item.id === 12 && !isDownArrow.value)
  1914. ? styles.itemDisabled
  1915. : ''
  1916. ]}
  1917. onClick={() => operateRightBtn(item.id)}>
  1918. <NTooltip
  1919. showArrow={false}
  1920. placement="right"
  1921. show={item.id === 15 ? undefined : false}
  1922. class={[item.id === 15 ? 'columnItemTooltip' : '']}>
  1923. {{
  1924. trigger: () => <img src={item.icon} />,
  1925. default: () =>
  1926. item.id === 15 ? (
  1927. <div class="tools">
  1928. {tooltipList.map(i => (
  1929. <div onClick={() => operateRightBtn(i.id)}>
  1930. <img src={i.icon} />
  1931. <div class="tit">{i.name}</div>
  1932. </div>
  1933. ))}
  1934. </div>
  1935. ) : (
  1936. ''
  1937. )
  1938. }}
  1939. {/* : item.id === 1 && data.type === 'preview' ? ( item.name2 ) */}
  1940. </NTooltip>
  1941. </div>
  1942. </div>
  1943. ))}
  1944. </div>
  1945. <NTooltip showArrow={false} placement="right" show={false}>
  1946. {{
  1947. trigger: () => (
  1948. <div
  1949. class={[
  1950. styles.leftHideIcon,
  1951. !(columnShow.value && columnPos.value === 'left')
  1952. ? styles.leftIconShow
  1953. : ''
  1954. ]}
  1955. onClick={() => {
  1956. columnPos.value = 'left';
  1957. columnShow.value = true;
  1958. }}
  1959. />
  1960. ),
  1961. default: () => '按钮镜像'
  1962. }}
  1963. </NTooltip>
  1964. {/* 显示列表 */}
  1965. {/* <NDrawer
  1966. v-model:show={popupData.open}
  1967. class={[styles.drawerContainer, styles.drawerContainerSource]}
  1968. onAfterLeave={handleClosePopup}
  1969. showMask={false}
  1970. blockScroll={false}
  1971. trapFocus={false}>
  1972. <NDrawerContent closable>
  1973. {{
  1974. header: () => (
  1975. <TheNoticeBar text={activeName.value || '资源列表'} />
  1976. ),
  1977. default: () => (
  1978. <SourceList
  1979. teacherChapterName={data.teacherChapterName}
  1980. knowledgePointList={data.knowledgePointList}
  1981. courseActiveIndex={popupData.courseActiveIndex}
  1982. activeItem={data.itemList[popupData.activeIndex]}
  1983. onConfirm={(item: any) => {
  1984. popupData.open = false;
  1985. toggleMaterial(item.id);
  1986. }}
  1987. />
  1988. )
  1989. }}
  1990. </NDrawerContent>
  1991. </NDrawer> */}
  1992. <NModal
  1993. maskClosable={modalClickMask}
  1994. transformOrigin="center"
  1995. v-model:show={popupData.open}
  1996. preset="card"
  1997. class={[
  1998. 'modalTitle background',
  1999. styles.drawerContainer,
  2000. resourcesConBoxClass
  2001. ]}
  2002. style={resourcesConDragData.styleDrag.value}
  2003. title={activeName.value || '资源列表'}>
  2004. <SourceList
  2005. teacherChapterName={data.teacherChapterName}
  2006. knowledgePointList={data.knowledgePointList}
  2007. courseActiveIndex={popupData.courseActiveIndex}
  2008. activeItem={data.itemList[popupData.activeIndex]}
  2009. onConfirm={(item: any) => {
  2010. popupData.open = false;
  2011. toggleMaterial(item.id);
  2012. }}
  2013. />
  2014. <Dragbom></Dragbom>
  2015. </NModal>
  2016. {/* 章节切换 */}
  2017. {/* <NDrawer
  2018. v-model:show={popupData.chapterOpen}
  2019. class={styles.drawerContainer}
  2020. onAfterLeave={handleClosePopup}
  2021. showMask={false}
  2022. maskClosable={data.selectClassStatus ? false : true}
  2023. blockScroll={false}
  2024. trapFocus={false}>
  2025. <NDrawerContent title="切换章节" closable>
  2026. <Chapter
  2027. treeList={popupData.chapterDetails}
  2028. itemActive={data.detailId as any}
  2029. onHandleSelect={async (val: any) => {
  2030. // itemActive: child.id,
  2031. // itemName: child.name
  2032. popupData.courseId = val.itemActive;
  2033. data.selectClassStatus = true;
  2034. }}
  2035. />
  2036. </NDrawerContent>
  2037. </NDrawer> */}
  2038. <NModal
  2039. maskClosable={modalClickMask}
  2040. transformOrigin="center"
  2041. v-model:show={popupData.chapterOpen}
  2042. preset="card"
  2043. class={[
  2044. 'modalTitle background',
  2045. styles.drawerContainer,
  2046. chapterConBoxClass
  2047. ]}
  2048. style={chapterConBoxDragData.styleDrag.value}
  2049. title={'切换章节'}>
  2050. <Chapter
  2051. treeList={popupData.chapterDetails}
  2052. itemActive={data.detailId as any}
  2053. onHandleSelect={async (val: any) => {
  2054. // itemActive: child.id,
  2055. // itemName: child.name
  2056. popupData.courseId = val.itemActive;
  2057. data.selectClassStatus = true;
  2058. }}
  2059. />
  2060. <Dragbom></Dragbom>
  2061. </NModal>
  2062. {/* 批注 */}
  2063. {studyData.penShow && (
  2064. <Pen
  2065. isDrag={true}
  2066. show={studyData.type === 'pen'}
  2067. type={studyData.type}
  2068. close={() => closeStudyTool()}
  2069. />
  2070. )}
  2071. {studyData.whiteboardShow && (
  2072. <Pen
  2073. isDrag={true}
  2074. show={studyData.type === 'whiteboard'}
  2075. type={studyData.type}
  2076. close={() => closeStudyTool()}
  2077. />
  2078. )}
  2079. {studyData.callShow && (
  2080. <Pen
  2081. isDrag={true}
  2082. imagePos={columnPos.value}
  2083. callStudents={studyData.callStudentList}
  2084. show={studyData.type === 'call'}
  2085. type={studyData.type}
  2086. close={() => {
  2087. closeStudyTool();
  2088. studyData.callShow = false;
  2089. }}
  2090. />
  2091. )}
  2092. {/* 选择课件 */}
  2093. <NModal
  2094. maskClosable={modalClickMask}
  2095. transformOrigin="center"
  2096. v-model:show={data.selectClassStatus}
  2097. preset="card"
  2098. class={[
  2099. 'modalTitle background',
  2100. // styles.attendClassModal,
  2101. styles.selectClassModal,
  2102. selCourBoxClass
  2103. ]}
  2104. style={selCourDragData.styleDrag.value}
  2105. title={'选择课件'}>
  2106. <SelectClass
  2107. classId={data.classId}
  2108. courseId={popupData.courseId}
  2109. instrumentId={data.instrumentId}
  2110. lessonCoursewareSubjectList={data.lessonCoursewareSubjectList}
  2111. onConfirm={async (val: any) => {
  2112. popupData.chapterLoading = true;
  2113. try {
  2114. data.selectClassStatus = false;
  2115. data.detailId = val.itemActive;
  2116. data.courseId = val.chapterId;
  2117. const ids = formatParentId(
  2118. val.itemActive,
  2119. popupData.chapterDetails
  2120. );
  2121. data.lessonCoursewareDetailId = ids[0];
  2122. // 更新上课记录 上课的时候才更新
  2123. if (data.type !== 'preview') {
  2124. await classCourseScheduleUpdate();
  2125. }
  2126. await getDetail();
  2127. popupData.activeIndex = 0;
  2128. popupData.chapterOpen = false;
  2129. } catch {
  2130. //
  2131. }
  2132. popupData.chapterLoading = false;
  2133. }}
  2134. />
  2135. <Dragbom></Dragbom>
  2136. </NModal>
  2137. {/* 布置作业 */}
  2138. <NModal
  2139. maskClosable={modalClickMask}
  2140. transformOrigin="center"
  2141. v-model:show={data.modelAttendStatus}
  2142. preset="card"
  2143. title={'课后作业'}
  2144. style={modelTrainHomeWordConBoxDragData.styleDrag.value}
  2145. class={[
  2146. 'modalTitle',
  2147. styles.removeVisiable,
  2148. modelTrainHomeWordConBoxClass
  2149. ]}>
  2150. <div class={styles.studentRemove}>
  2151. <p>{data.modalAttendMessage}</p>
  2152. <NSpace class={styles.btnGroupModal} justify="center">
  2153. <NButton
  2154. type="default"
  2155. round
  2156. onClick={() => {
  2157. data.modelTrainStatus = true;
  2158. nextTick(() => {
  2159. getModalHeight();
  2160. });
  2161. data.modelAttendStatus = false;
  2162. }}>
  2163. 布置作业
  2164. </NButton>
  2165. <NButton
  2166. type="primary"
  2167. round
  2168. onClick={() => {
  2169. handleStop();
  2170. data.modelAttendStatus = false;
  2171. }}>
  2172. 取消
  2173. </NButton>
  2174. </NSpace>
  2175. </div>
  2176. <Dragbom></Dragbom>
  2177. </NModal>
  2178. {/* 训练设置 */}
  2179. {/* <NModal
  2180. transformOrigin="center"
  2181. v-model:show={data.modelTrainStatus}
  2182. preset="card"
  2183. class={[styles.attendClassModal, styles.trainClassModal]}
  2184. title={'作业设置'}>
  2185. <ClassWork
  2186. detailId={data.detailId}
  2187. instrumentId={data.instrumentId}
  2188. courseScheduleId={data.classId}
  2189. activeName={activeName.value}
  2190. classGroupId={data.classGroupId}
  2191. onClose={() => (data.modelTrainStatus = false)}
  2192. />
  2193. </NModal> */}
  2194. <NModal
  2195. maskClosable={modalClickMask}
  2196. v-model:show={data.modelTrainStatus}
  2197. preset="card"
  2198. class={[
  2199. 'modalTitle background',
  2200. styles.workVisiable,
  2201. modelTrainStatusConBoxClass
  2202. ]}
  2203. style={modelTrainStatusConBoxDragData.styleDrag.value}
  2204. title={'布置作业'}>
  2205. <div id="model-homework-height" class={styles.workContainer}>
  2206. <div class={styles.workTrain}>
  2207. <Train
  2208. from={'class'}
  2209. cardType="homeworkRecord"
  2210. lessonPreTraining={{
  2211. title: data.lessonPreTrainingId
  2212. ? ''
  2213. : data.teacherChapterName + '-课后作业',
  2214. chapterId: data.courseId, // 课件编号
  2215. id: data.lessonPreTrainingId // 作业编号
  2216. }}
  2217. coursewareKnowledgeDetailId={data.detailId}
  2218. classGroupId={data.classGroupId}
  2219. courseScheduleId={data.classId}
  2220. onChange={async (val: any) => {
  2221. data.modelTrainStatus = val.status;
  2222. // getCoursewareList();
  2223. if (val.saveWork && data.classId) {
  2224. data.lessonPreTrainingId = val.lessonPreTrainingId;
  2225. }
  2226. }}
  2227. />
  2228. </div>
  2229. <div class={styles.resourceMain}>
  2230. <ResourceMain from={'class'} cardType="homerowk-record" />
  2231. </div>
  2232. </div>
  2233. <Dragbom></Dragbom>
  2234. </NModal>
  2235. {/* <NModal
  2236. transformOrigin="center"
  2237. class={['modalTitle background', metronomeConBoxClass]}
  2238. title={'节拍器'}
  2239. preset="card"
  2240. v-model:show={showModalBeat.value}
  2241. style={{
  2242. width: '687px',
  2243. ...metronomeConBoxDragData.styleDrag.value
  2244. }}>
  2245. <div class={styles.modeWrap}>
  2246. <iframe
  2247. src={`${vaildUrl()}/metronome/?id=${new Date().getTime()}`}
  2248. scrolling="no"
  2249. frameborder="0"
  2250. width="100%"
  2251. onLoad={(val: any) => {
  2252. iframeDislableKeyboard(val.target);
  2253. }}
  2254. height={'650px'}></iframe>
  2255. <Dragbom></Dragbom>
  2256. </div>
  2257. </NModal> */}
  2258. <Metronome
  2259. v-model={showModalBeat.value}
  2260. dragClass={metronomeConBoxClass}
  2261. dragStyle={metronomeConBoxDragData.styleDrag.value}></Metronome>
  2262. <NModal
  2263. maskClosable={modalClickMask}
  2264. transformOrigin="center"
  2265. class={['background']}
  2266. v-model:show={showModalTone.value}>
  2267. <div>
  2268. <PlaceholderTone
  2269. onClose={() => {
  2270. showModalTone.value = false;
  2271. }}></PlaceholderTone>
  2272. </div>
  2273. </NModal>
  2274. <NModal
  2275. maskClosable={modalClickMask}
  2276. v-model:show={showModalTime.value}
  2277. class={timerMeterConBoxClass}
  2278. style={timerMeterConDragData.styleDrag.value}>
  2279. <div>
  2280. <img
  2281. class={styles.timerMeterClose}
  2282. src={timerMeterClose}
  2283. onClick={() => {
  2284. showModalTime.value = false;
  2285. }}
  2286. />
  2287. <div class="topDragDom"></div>
  2288. <TimerMeter></TimerMeter>
  2289. </div>
  2290. </NModal>
  2291. <NModal
  2292. maskClosable={modalClickMask}
  2293. v-model:show={data.selectResourceStatus}
  2294. class={['modalTitle', styles.selectMusicModal, selResourBoxClass]}
  2295. style={selResourDragData.styleDrag.value}
  2296. preset="card"
  2297. title={'选择资源'}>
  2298. <SelectResources from="class" instrumentId={data.instrumentId} />
  2299. <Dragbom></Dragbom>
  2300. </NModal>
  2301. <NModal
  2302. maskClosable={modalClickMask}
  2303. transformOrigin="center"
  2304. v-model:show={data.removeVisiable}
  2305. preset="card"
  2306. class={['modalTitle', styles.removeVisiable, removeResourBoxClass]}
  2307. style={removeResourDragData.styleDrag.value}
  2308. title={data.removeTitle}>
  2309. <div class={styles.studentRemove}>
  2310. <p>{data.removeContent}</p>
  2311. <NSpace class={styles.btnGroupModal} justify="center">
  2312. <NButton
  2313. round
  2314. onClick={() => {
  2315. if (data.removeCourseStatus) {
  2316. if (globalState.application) {
  2317. document.exitFullscreen
  2318. ? document.exitFullscreen()
  2319. : document.mozCancelFullScreen
  2320. ? document.mozCancelFullScreen()
  2321. : document.webkitExitFullscreen
  2322. ? document.webkitExitFullscreen()
  2323. : '';
  2324. emit('close');
  2325. } else {
  2326. window.close();
  2327. }
  2328. } else {
  2329. data.removeVisiable = false;
  2330. }
  2331. }}>
  2332. {data.removeCourseStatus ? '结束课程' : '取消'}
  2333. </NButton>
  2334. <NButton
  2335. round
  2336. type="primary"
  2337. onClick={() => {
  2338. //
  2339. if (data.removeCourseStatus) {
  2340. data.modelTrainStatus = true;
  2341. data.removeVisiable = false;
  2342. nextTick(() => {
  2343. getModalHeight();
  2344. });
  2345. } else {
  2346. if (globalState.application) {
  2347. document.exitFullscreen
  2348. ? document.exitFullscreen()
  2349. : document.mozCancelFullScreen
  2350. ? document.mozCancelFullScreen()
  2351. : document.webkitExitFullscreen
  2352. ? document.webkitExitFullscreen()
  2353. : '';
  2354. emit('close');
  2355. } else {
  2356. window.close();
  2357. if (route.query.source === 'admin') {
  2358. storage.remove(ACCESS_TOKEN_ADMIN);
  2359. window.parent.postMessage(
  2360. {
  2361. api: 'iframe_exit'
  2362. },
  2363. '*'
  2364. );
  2365. }
  2366. }
  2367. }
  2368. }}>
  2369. {data.removeCourseStatus ? '布置作业' : '确定'}
  2370. </NButton>
  2371. </NSpace>
  2372. <Dragbom></Dragbom>
  2373. </div>
  2374. </NModal>
  2375. <NModal
  2376. maskClosable={modalClickMask}
  2377. style={nextEndBoxDragData.styleDrag.value}
  2378. z-index={3000}
  2379. transformOrigin="center"
  2380. v-model:show={data.nextEndShow}
  2381. preset="card"
  2382. title={'提示'}
  2383. class={['modalTitle', styles.removeVisiable, nextEndBoxClass]}>
  2384. <div class={styles.studentRemove}>
  2385. <p>当前课件已结束,是否进入下一章节</p>
  2386. <NSpace class={styles.btnGroupModal} justify="center">
  2387. <NButton
  2388. type="default"
  2389. round
  2390. onClick={() => {
  2391. data.nextEndShow = false;
  2392. }}>
  2393. 取消
  2394. </NButton>
  2395. <NButton
  2396. type="primary"
  2397. round
  2398. onClick={() => {
  2399. data.nextEndShow = false;
  2400. handleNextEnd();
  2401. }}>
  2402. 确认
  2403. </NButton>
  2404. </NSpace>
  2405. <Dragbom></Dragbom>
  2406. </div>
  2407. </NModal>
  2408. </div>
  2409. );
  2410. }
  2411. });