12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595 |
- import {
- defineComponent,
- onMounted,
- reactive,
- onUnmounted,
- ref,
- Transition,
- computed,
- nextTick
- } from 'vue';
- import styles from './index.module.less';
- import 'plyr/dist/plyr.css';
- import MusicScore from './component/musicScore';
- // import iconChange from './image/icon-change.png';
- // import iconMenu from './image/icon-menu.png';
- // import iconUp from './image/icon-up.png';
- // import iconDown from './image/icon-down.png';
- // import iconNote from './image/icon-note.png';
- // import iconWhiteboard from './image/icon-whiteboard.png';
- // import iconAssignHomework from './image/icon-assignHomework.png';
- // import iconClose from './image/icon-close.png';
- // import iconOverPreivew from './image/icon-over-preview.png';
- import { Vue3Lottie } from 'vue3-lottie';
- import playLoadData from './datas/data.json';
- // import Moveable from 'moveable';
- import VideoPlay from './component/video-play';
- import {
- useMessage,
- NDrawer,
- NDrawerContent,
- NModal,
- NSpace,
- NButton
- // NTooltip,
- // NPopover,
- // NImage
- } from 'naive-ui';
- import CardType from '@/components/card-type';
- import Pen from './component/tools/pen';
- import AudioPay from './component/audio-pay';
- import TrainSettings from './model/train-settings';
- import { useRoute } from 'vue-router';
- import {
- courseScheduleUpdate,
- lessonCoursewareDetail,
- lessonPreTrainingPage,
- queryCourseware
- } from '../prepare-lessons/api';
- // import Attentguide from '@/custom-plugins/guide-page/attent-guide';
- import { vaildUrl } from '/src/utils/urlUtils';
- import TimerMeter from '/src/components/timerMeter';
- // import toneImage from '/src/components/layout/images/toneImage.png';
- // import toolbox from '/src/components/layout/images/toolbox.png';
- // import setTimeIcon from '/src/components/layout/images/setTimeIcon.png';
- // import beatIcon from '/src/components/layout/images/beatIcon.png';
- // import toneIcon from '/src/components/layout/images/toneIcon.png';
- import { px2vw } from '/src/utils';
- import PlaceholderTone from '/src/components/layout/modals/placeholderTone';
- import { state as globalState } from '/src/state';
- import Chapter from './model/chapter';
- import { useRouter } from 'vue-router';
- import { useUserStore } from '@/store/modules/users';
- import iconBeatIcon from './new-image/icon-beatIcon.png';
- import iconChange from './new-image/icon-change.png';
- import iconDown from './new-image/icon-down.png';
- import iconMenu from './new-image/icon-menu.png';
- import iconNote from './new-image/icon-note.png';
- import iconOverClass from './new-image/icon-overclass.png';
- import iconSetTime from './new-image/icon-setTime.png';
- import iconToneIcon from './new-image/icon-toneIcon.png';
- import iconUp from './new-image/icon-up.png';
- import iconWhite from './new-image/icon-white.png';
- import iconWork from './new-image/icon-work.png';
- export type ToolType = 'init' | 'pen' | 'whiteboard';
- export type ToolItem = {
- type: ToolType;
- name: string;
- icon: string;
- };
- export default defineComponent({
- name: 'CoursewarePlay',
- props: {
- type: {
- type: String,
- default: ''
- },
- subjectId: {
- type: [String, Number],
- default: ''
- },
- // 教材编号
- lessonCourseId: {
- type: [String, Number],
- default: ''
- },
- detailId: {
- type: String,
- default: ''
- },
- // 班级编号
- classGroupId: {
- type: String,
- default: ''
- },
- // 上课记录编号
- classId: {
- type: String,
- defaault: ''
- },
- preStudentNum: {
- type: [String, Number],
- default: ''
- }
- },
- emits: ['close'],
- setup(props, { emit }) {
- const message = useMessage();
- const route = useRoute();
- const router = useRouter();
- const users = useUserStore();
- /** 设置播放容器 16:9 */
- const parentContainer = reactive({
- width: '100vw'
- });
- // const NPopoverRef = ref();
- // const setContainer = () => {
- // const min = Math.min(screen.width, screen.height);
- // const max = Math.max(screen.width, screen.height);
- // const width = min * (16 / 9);
- // if (width > max) {
- // parentContainer.width = '100vw';
- // return;
- // } else {
- // parentContainer.width = width + 'px';
- // }
- // };
- const handleInit = (type = 0) => {
- //设置容器16:9
- // setContainer();
- };
- handleInit();
- onUnmounted(() => {
- handleInit(1);
- });
- const data = reactive({
- type: 'class' as '' | 'preview' | 'class', // 预览类型
- subjectId: '' as any, // 声部编号
- lessonCourseId: '' as any, // 教材编号
- lessonCoursewareDetailId: '' as any, // 章节
- detailId: '' as any, // 编号 - 课程编号
- classGroupId: '' as any, // 上课时需要 班级编号
- classId: '' as any, // 上课编号
- preStudentNum: '' as any, // 班上学生
- // detail: null,
- knowledgePointList: [] as any,
- itemList: [] as any,
- // showHead: true,
- // isCourse: false,
- // isRecordPlay: false,
- videoRefs: {} as any[],
- audioRefs: {} as any[],
- modelAttendStatus: false, // 布置作业提示弹窗
- modalAttendMessage: '本节课未设置课后作业,是否继续?',
- modelTrainStatus: false, // 训练设置
- homeworkStatus: true, // 布置作业完成时
- removeVisiable: false,
- removeTitle: '',
- removeContent: '',
- videoState: 'init' as 'init' | 'play',
- videoItemRef: null as any,
- animationState: 'start' as 'start' | 'end'
- });
- const activeData = reactive({
- // isAutoPlay: false, // 是否自动播放
- nowTime: 0,
- model: true, // 遮罩
- isAnimation: true, // 是否动画
- // videoBtns: true, // 视频
- // currentTime: 0,
- // duration: 0,
- timer: null as any,
- item: null as any
- });
- const getDetail = async () => {
- try {
- const res = await queryCourseware({
- coursewareDetailKnowledgeId: data.detailId,
- subjectId: data.subjectId,
- pag: 1,
- rows: 99
- });
- const tempRows = res.data.rows || [];
- const temp: any = [];
- tempRows.forEach((row: any) => {
- if (!row.removeFlag) {
- temp.push({
- id: row.id,
- materialId: row.materialId,
- coverImg: row.coverImg,
- type: row.materialType,
- title: row.materialName,
- isCollect: !!row.favoriteFlag,
- isSelected: row.source === 'PLATFORM' ? true : false,
- content: row.content
- });
- }
- });
- data.knowledgePointList = temp;
- data.itemList = data.knowledgePointList.map((m: any) => {
- return {
- ...m,
- iframeRef: null,
- videoEle: null,
- audioEle: null,
- autoPlay: false, //加载完成是否自动播放
- isprepare: false, // 视频是否加载完成
- isRender: false // 是否渲染了
- };
- });
- setTimeout(() => {
- data.animationState = 'end'
- }, 500)
- } catch {
- //
- }
- };
- const showModalBeat = ref(false);
- const showModalTone = ref(false);
- const showModalTime = ref(false);
- // ifram事件处理
- const iframeHandle = (ev: MessageEvent) => {
- console.log(ev.data?.api, ev.data, 'ev.data');
- if (ev.data?.api === 'headerTogge') {
- activeData.model =
- ev.data.show || (ev.data.playState == 'play' ? false : true);
- }
- //
- if (ev.data?.api === 'onAttendToggleMenu') {
- activeData.model = !activeData.model;
- }
- if (ev.data?.api === 'api_fingerPreView') {
- clearInterval(activeData.timer);
- activeData.model = !ev.data.state;
- }
- //
- if (ev.data?.api === 'documentBodyKeyup') {
- if (ev.data?.code === 'ArrowLeft') {
- setModalOpen();
- handlePreAndNext('up');
- }
- if (ev.data?.code === 'ArrowRight') {
- setModalOpen();
- handlePreAndNext('down');
- }
- }
- if (ev.data?.api === 'onLogin') {
- const documentDom: any = document;
- documentDom.exitFullscreen
- ? documentDom.exitFullscreen()
- : documentDom.mozCancelFullScreen
- ? documentDom.mozCancelFullScreen()
- : documentDom.webkitExitFullscreen
- ? documentDom.webkitExitFullscreen()
- : '';
- users.logout();
- router.replace('/login');
- }
- };
- onMounted(() => {
- // initMoveable();
- const query = route.query;
- console.log(query, props.preStudentNum, '学生人数');
- // 先取参数,
- data.type = props.type || (query.type as any);
- data.subjectId = props.subjectId || query.subjectId;
- data.detailId = props.detailId || query.detailId;
- data.lessonCourseId = props.lessonCourseId || query.lessonCourseId;
- data.classGroupId = props.classGroupId || query.classGroupId;
- data.classId = props.classId || query.classId;
- data.preStudentNum = props.preStudentNum || query.preStudentNum;
- window.addEventListener('message', iframeHandle);
- getDetail();
- getLessonCoursewareDetail();
- });
- const onFullScreen = () => {
- if (data.type === 'preview') {
- const el: any = document.querySelector('#app');
- if (el.mozRequestFullScreen) {
- el.mozRequestFullScreen();
- } else if (el.webkitRequestFullscreen) {
- el.webkitRequestFullscreen();
- } else if (el.requestFullScreen) {
- el.requestFullscreen();
- }
- }
- };
- const popupData = reactive({
- open: false,
- activeIndex: 0,
- toolOpen: false, // 工具弹窗控制
- chapterOpen: false, // 切换章节
- chapterDetails: [] as any,
- chapterLoading: false // 加载数据
- });
- const formatParentId = (id: any, list: any, ids = [] as any) => {
- for (const item of list) {
- if (item.knowledgeList && item.knowledgeList.length > 0) {
- const cIds: any = formatParentId(id, item.knowledgeList, [
- ...ids,
- item.id
- ]);
- if (cIds.includes(id)) {
- return cIds;
- }
- }
- if (item.id === id) {
- return [...ids, id];
- }
- }
- return ids;
- };
- /** 获取章节 */
- const getLessonCoursewareDetail = async () => {
- try {
- const res = await lessonCoursewareDetail({
- id: data.lessonCourseId,
- subjectId: data.subjectId
- });
- popupData.chapterDetails = res.data.lessonList || [];
- const ids = formatParentId(data.detailId, popupData.chapterDetails);
- data.lessonCoursewareDetailId = ids[0];
- } catch {
- //
- }
- };
- /** 更新上课记录 */
- const classCourseScheduleUpdate = async () => {
- try {
- if (!data.classId) return;
- await courseScheduleUpdate({
- lessonCoursewareKnowledgeDetailId: data.detailId,
- id: data.classId
- });
- } catch {
- //
- }
- };
- const activeName = computed(() => {
- let name = '';
- // data.knowledgePointList.forEach((item: any, index: number) => {
- // if (popupData.activeIndex === index) {
- // name = item.title;
- // }
- // });
- popupData.chapterDetails.forEach((chapter: any) => {
- if (chapter.id === data.lessonCoursewareDetailId) {
- name = chapter.name;
- chapter.knowledgeList?.forEach((know: any) => {
- if (know.id === data.detailId) {
- name += ' - ' + know.name;
- }
- });
- }
- });
- return name;
- });
- /**停止所有的播放 */
- const handleStop = () => {
- for (let i = 0; i < data.itemList.length; i++) {
- const activeItem = data.itemList[i];
- if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
- // console.log(activeItem.videoEle, ' activeItem.videoEle');
- try {
- activeItem.videoEle?.currentTime(0);
- activeItem.videoEle?.pause();
- } catch (e: any) {
- // console.log(e, 'e');
- }
- }
- if (activeItem.type === 'SONG' && activeItem.audioEle) {
- activeItem.audioEle?.stop();
- }
- // console.log('🚀 ~ activeItem:', activeItem)
- // 停止曲谱的播放
- if (activeItem.type === 'MUSIC') {
- activeItem.iframeRef?.contentWindow?.postMessage(
- { api: 'setPlayState' },
- '*'
- );
- }
- }
- };
- // 切换素材
- const toggleMaterial = (itemActive: any) => {
- const index = data.itemList.findIndex((n: any) => n.id == itemActive);
- if (index > -1) {
- handleSwipeChange(index);
- }
- };
- /** 延迟收起模态框 */
- const setModelOpen = () => {
- clearTimeout(activeData.timer);
- message.destroyAll();
- activeData.timer = setTimeout(() => {
- activeData.model = false;
- Object.values(data.videoRefs).map((n: any) =>
- n?.toggleHideControl(false)
- );
- Object.values(data.audioRefs).map((n: any) =>
- n?.toggleHideControl(false)
- );
- }, 4000);
- };
- /** 立即收起所有的模态框 */
- const clearModel = () => {
- clearTimeout(activeData.timer);
- message.destroyAll();
- activeData.model = false;
- Object.values(data.videoRefs).map((n: any) =>
- n?.toggleHideControl(false)
- );
- Object.values(data.audioRefs).map((n: any) =>
- n?.toggleHideControl(false)
- );
- };
- const toggleModel = (type = true) => {
- activeData.model = type;
- Object.values(data.videoRefs).map((n: any) => n?.toggleHideControl(type));
- Object.values(data.audioRefs).map((n: any) => n?.toggleHideControl(type));
- };
- // 双击
- const handleDbClick = (item: any) => {
- if (item && item.type === 'VIDEO') {
- const videoEle: HTMLVideoElement = item.videoEle;
- if (videoEle) {
- if (videoEle.paused) {
- message.destroyAll();
- videoEle.play();
- } else {
- message.warning('已暂停');
- videoEle.pause();
- }
- }
- }
- };
- // 切换播放
- // const togglePlay = (m: any, isPlay: boolean) => {
- // if (isPlay) {
- // m.videoEle?.play();
- // } else {
- // m.videoEle?.pause();
- // }
- // };
- // const showIndex = ref(-4);
- const effectIndex = ref(3);
- const effects = [
- {
- prev: {
- transform: 'translate3d(0, 0, -800px) rotateX(180deg)'
- },
- next: {
- transform: 'translate3d(0, 0, -800px) rotateX(-180deg)'
- }
- },
- {
- prev: {
- transform: 'translate3d(-100%, 0, -800px)'
- },
- next: {
- transform: 'translate3d(100%, 0, -800px)'
- }
- },
- {
- prev: {
- transform: 'translate3d(-50%, 0, -800px) rotateY(80deg)'
- },
- next: {
- transform: 'translate3d(50%, 0, -800px) rotateY(-80deg)'
- }
- },
- {
- prev: {
- transform: 'translate3d(-100%, 0, -800px) rotateY(-120deg)'
- },
- next: {
- transform: 'translate3d(100%, 0, -800px) rotateY(120deg)'
- }
- },
- // 风车4
- {
- prev: {
- transform: 'translate3d(-50%, 50%, -800px) rotateZ(-14deg)',
- opacity: 0
- },
- next: {
- transform: 'translate3d(50%, 50%, -800px) rotateZ(14deg)',
- opacity: 0
- }
- },
- // 翻页5
- {
- prev: {
- transform: 'translateZ(-800px) rotate3d(0, -1, 0, 90deg)',
- opacity: 0
- },
- next: {
- transform: 'translateZ(-800px) rotate3d(0, 1, 0, 90deg)',
- opacity: 0
- },
- current: { transitionDelay: '700ms' }
- }
- ];
- const acitveTimer = ref();
- // 轮播切换
- const handleSwipeChange = (index: number) => {
- // 如果是当前正在播放 或者是视频最后一个
- if (popupData.activeIndex == index) return;
- data.animationState = 'start'
- data.videoState = 'init'
- handleStop();
- clearTimeout(acitveTimer.value);
- activeData.model = true;
- checkedAnimation(popupData.activeIndex, index);
- popupData.activeIndex = index;
- acitveTimer.value = setTimeout(
- () => {
- const item = data.itemList[index];
- if (item) {
- if (item.type == 'MUSIC') {
- activeData.model = true;
- }
- if (item.type === 'SONG') {
- // 自动播放下一个音频
- clearTimeout(activeData.timer);
- message.destroyAll();
- // item.autoPlay = false;
- // nextTick(() => {
- // item.audioEle?.onPlay();
- // });
- }
- if (item.type === 'VIDEO') {
- // 自动播放下一个视频
- clearTimeout(activeData.timer);
- message.destroyAll();
- nextTick(() => {
- if (item.error) {
- // console.log(item, 'item error');
- item.videoEle?.src(item.content);
- item.error = false;
- // item.videoEle?.onPlay();
- }
- data.animationState = 'end'
- });
- }
- }
- },
- activeData.isAnimation ? 800 : 0
- );
- };
- /** 是否有转场动画 */
- const checkedAnimation = (index: number, nextIndex?: number) => {
- const item = data.itemList[index];
- const nextItem = data.itemList[nextIndex!];
- if (nextItem) {
- if (nextItem.knowledgePointId != item.knowledgePointId) {
- activeData.isAnimation = true;
- return;
- }
- const videoEle = item.videoEle;
- const nextVideo = nextItem.videoEle;
- if (videoEle && videoEle.duration < 8 && index < nextIndex!) {
- activeData.isAnimation = false;
- } else if (nextVideo && nextVideo.duration < 8 && index > nextIndex!) {
- activeData.isAnimation = false;
- } else {
- activeData.isAnimation = true;
- }
- } else {
- activeData.isAnimation = item?.adviseStudyTimeSecond < 8 ? false : true;
- }
- };
- // 上一个知识点, 下一个知识点
- const handlePreAndNext = async (type: string) => {
- // if (type === 'up') {
- // handleSwipeChange(popupData.activeIndex - 1);
- // } else {
- // handleSwipeChange(popupData.activeIndex + 1);
- // }
- if (type === 'up') {
- // 判断上面是否还有章节
- if (popupData.activeIndex > 0) {
- handleSwipeChange(popupData.activeIndex - 1);
- return;
- }
- // 获取当前是哪个章节
- let detailIndex = popupData.chapterDetails.findIndex(
- (item: any) => item.id == data.lessonCoursewareDetailId
- );
- const detailItem =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == data.detailId
- );
- let lessonStatus = false; // 当前章节上面是否有内容
- let lessonCoursewareDetailId = '';
- let coursewareDetailKnowledgeId = '';
- while (lessonIndex >= 0) {
- lessonIndex--;
- if (lessonIndex >= 0) {
- if (detailItem[lessonIndex].containMaterial) {
- lessonStatus = true;
- lessonCoursewareDetailId =
- detailItem[lessonIndex].lessonCoursewareDetailId;
- coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
- }
- }
- if (lessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往上一个章节走
- if (lessonStatus) {
- popupData.chapterLoading = true;
- data.detailId = coursewareDetailKnowledgeId;
- data.lessonCoursewareDetailId = lessonCoursewareDetailId;
- // 更新上课记录 上课的时候才更新
- if (data.type !== 'preview') {
- await classCourseScheduleUpdate();
- }
- await getDetail();
- popupData.activeIndex = data.itemList.length - 1 || 0;
- popupData.chapterOpen = false;
- popupData.chapterLoading = false;
- return;
- }
- let prevLessonStatus = false;
- while (detailIndex >= 0) {
- detailIndex--;
- const tempDetail =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let tempLessonLength = tempDetail.length;
- while (tempLessonLength > 0) {
- if (tempDetail[tempLessonLength - 1].containMaterial) {
- prevLessonStatus = true;
- lessonCoursewareDetailId =
- tempDetail[tempLessonLength - 1].lessonCoursewareDetailId;
- coursewareDetailKnowledgeId = tempDetail[tempLessonLength - 1].id;
- }
- tempLessonLength--;
- if (prevLessonStatus) {
- break;
- }
- }
- if (prevLessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往上一个章节走
- if (prevLessonStatus) {
- popupData.chapterLoading = true;
- data.detailId = coursewareDetailKnowledgeId;
- data.lessonCoursewareDetailId = lessonCoursewareDetailId;
- await getDetail();
- popupData.activeIndex = data.itemList.length - 1 || 0;
- popupData.chapterLoading = false;
- return;
- }
- } else {
- if (popupData.activeIndex < data.itemList.length - 1) {
- handleSwipeChange(popupData.activeIndex + 1);
- return;
- }
- // 获取当前是哪个章节
- let detailIndex = popupData.chapterDetails.findIndex(
- (item: any) => item.id == data.lessonCoursewareDetailId
- );
- const detailItem =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == data.detailId
- );
- let lessonStatus = false; // 当前章节下面是否有内容
- let lessonCoursewareDetailId = '';
- let coursewareDetailKnowledgeId = '';
- while (lessonIndex < detailItem.length - 1) {
- lessonIndex++;
- if (lessonIndex >= 0) {
- if (detailItem[lessonIndex].containMaterial) {
- lessonStatus = true;
- lessonCoursewareDetailId =
- detailItem[lessonIndex].lessonCoursewareDetailId;
- coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
- }
- }
- if (lessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往下一个章节走
- if (lessonStatus) {
- popupData.chapterLoading = true;
- data.detailId = coursewareDetailKnowledgeId;
- data.lessonCoursewareDetailId = lessonCoursewareDetailId;
- // 更新上课记录 上课的时候才更新
- if (data.type !== 'preview') {
- await classCourseScheduleUpdate();
- }
- await getDetail();
- popupData.activeIndex = 0;
- popupData.chapterOpen = false;
- popupData.chapterLoading = false;
- return;
- }
- let nextLessonStatus = false;
- while (detailIndex <= popupData.chapterDetails.length - 1) {
- detailIndex++;
- const tempDetail =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let tempLessonLength = 0;
- while (tempLessonLength <= tempDetail.length - 1) {
- if (tempDetail[tempLessonLength].containMaterial) {
- nextLessonStatus = true;
- lessonCoursewareDetailId =
- tempDetail[tempLessonLength].lessonCoursewareDetailId;
- coursewareDetailKnowledgeId = tempDetail[tempLessonLength].id;
- }
- tempLessonLength++;
- if (nextLessonStatus) {
- break;
- }
- }
- if (nextLessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往上一个章节走
- if (nextLessonStatus) {
- popupData.chapterLoading = true;
- data.detailId = coursewareDetailKnowledgeId;
- data.lessonCoursewareDetailId = lessonCoursewareDetailId;
- // 更新上课记录 上课的时候才更新
- if (data.type !== 'preview') {
- await classCourseScheduleUpdate();
- }
- await getDetail();
- popupData.activeIndex = 0;
- popupData.chapterOpen = false;
- popupData.chapterLoading = false;
- return;
- }
- }
- };
- /** 弹窗关闭 */
- const handleClosePopup = () => {
- const item = data.itemList[popupData.activeIndex];
- if (item?.type == 'VIDEO' && !item.videoEle?.paused) {
- setModelOpen();
- }
- if (item?.type == 'SONG' && !item.audioEle?.paused) {
- setModelOpen();
- }
- };
- // 监听页面键盘事件 - 上下切换
- document.body.addEventListener('keyup', (e: KeyboardEvent) => {
- // console.log(e, 'e');
- if (e.code === 'ArrowLeft') {
- // if (popupData.activeIndex === 0) return;
- setModalOpen();
- handlePreAndNext('up');
- } else if (e.code === 'ArrowRight') {
- // if (popupData.activeIndex === data.itemList.length - 1) return;
- setModalOpen();
- handlePreAndNext('down');
- }
- });
- const setModalOpen = (status = true) => {
- clearTimeout(activeData.timer);
- activeData.model = status;
- Object.values(data.videoRefs).map((n: any) =>
- n?.toggleHideControl(status)
- );
- Object.values(data.audioRefs).map((n: any) =>
- n?.toggleHideControl(status)
- );
- };
- /** 教学数据 */
- const studyData = reactive({
- type: '' as ToolType,
- penShow: false,
- whiteboardShow: false
- });
- /** 打开教学工具 */
- const openStudyTool = (item: ToolItem) => {
- const activeItem = data.itemList[popupData.activeIndex];
- // 暂停视频和曲谱的播放
- if (activeItem.type === 'VIDEO' && activeItem.videoEle) {
- activeItem.videoEle?.pause();
- }
- if (activeItem.type === 'SONG' && activeItem.audioEle) {
- activeItem.audioEle?.stop();
- }
- if (activeItem.type === 'MUSIC') {
- activeItem.iframeRef?.contentWindow?.postMessage(
- { api: 'setPlayState' },
- '*'
- );
- }
- clearModel();
- popupData.toolOpen = false;
- studyData.type = item.type;
- switch (item.type) {
- case 'pen':
- studyData.penShow = true;
- break;
- case 'whiteboard':
- studyData.whiteboardShow = true;
- }
- };
- /** 关闭教学工具 */
- const closeStudyTool = () => {
- studyData.type = 'init';
- toggleModel();
- };
- const startShowModal = (
- val: 'setTimeIcon' | 'beatIcon' | 'toneIcon' | 'iconNote2'
- ) => {
- if (val == 'setTimeIcon') {
- showModalTime.value = true;
- }
- if (val == 'beatIcon') {
- showModalBeat.value = true;
- }
- if (val == 'toneIcon') {
- showModalTone.value = true;
- }
- // if (val == 'iconNote2') {
- // if (NPopoverRef.value) {
- // NPopoverRef.value.setShow(false);
- // }
- // eventGlobal.emit('teacher-guideInfo-attend-class', 'attend-class');
- // }
- };
- // 是否允许上一页
- const isUpArrow = computed(() => {
- /**
- * 1,判断当前课程中是否处在第一个资源;
- * 2,判断当前课程是否在当前章节的第一个;
- * 3,判断当前章节,当前课程上面还没有其它课程,是否有资源;
- * 4,判断当前章节上面还没有其它章节;
- * 5,判断上面章节里面课程是否有资源;
- */
- if (popupData.activeIndex > 0) {
- return true;
- }
- // 获取当前是哪个章节
- let detailIndex = popupData.chapterDetails.findIndex(
- (item: any) => item.id == data.lessonCoursewareDetailId
- );
- const detailItem =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == data.detailId
- );
- // 说明已经是第一单元,第一课
- if (detailIndex <= 0 && lessonIndex <= 0) {
- return false;
- }
- let lessonStatus = false; // 当前章节上面是否有内容
- while (lessonIndex >= 0) {
- lessonIndex--;
- if (lessonIndex >= 0) {
- if (detailItem[lessonIndex].containMaterial) {
- lessonStatus = true;
- }
- }
- }
- // 判断当前章节下面课程是否有内容,否则往上一个章节走
- if (lessonStatus) {
- return true;
- }
- // 已经是第一个章节了
- if (detailIndex <= 0) {
- return false;
- }
- let prevLessonStatus = false;
- while (detailIndex >= 0) {
- detailIndex--;
- const tempDetail =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let tempLessonLength = tempDetail.length;
- while (tempLessonLength > 0) {
- if (tempDetail[tempLessonLength - 1].containMaterial) {
- prevLessonStatus = true;
- }
- tempLessonLength--;
- }
- if (prevLessonStatus) {
- return true;
- }
- }
- return false;
- });
- // 是否允许下一页
- const isDownArrow = computed(() => {
- if (popupData.activeIndex < data.itemList.length - 1) {
- return true;
- }
- // 获取当前是哪个章节
- let detailIndex = popupData.chapterDetails.findIndex(
- (item: any) => item.id == data.lessonCoursewareDetailId
- );
- const detailItem =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == data.detailId
- );
- // 说明已经是最后-单元,最后一课
- if (
- detailIndex >= popupData.chapterDetails.length - 1 &&
- lessonIndex >= detailItem.length - 1
- ) {
- return false;
- }
- let lessonStatus = false; // 当前章节下面是否有内容
- while (lessonIndex < detailItem.length - 1) {
- lessonIndex++;
- if (lessonIndex >= 0) {
- if (detailItem[lessonIndex].containMaterial) {
- lessonStatus = true;
- }
- }
- }
- // 判断当前章节下面课程是否有内容,否则往下一个章节走
- if (lessonStatus) {
- return true;
- }
- // 已经是最后一个章节了
- if (detailIndex >= popupData.chapterDetails.length - 1) {
- return false;
- }
- let nextLessonStatus = false;
- while (detailIndex < popupData.chapterDetails.length - 1) {
- detailIndex++;
- const tempDetail =
- popupData.chapterDetails[detailIndex]?.knowledgeList || [];
- let tempLessonLength = 0;
- while (tempLessonLength <= tempDetail.length - 1) {
- if (tempDetail[tempLessonLength].containMaterial) {
- nextLessonStatus = true;
- }
- tempLessonLength++;
- }
- if (nextLessonStatus) {
- return true;
- }
- }
- return false;
- });
- const activeVideoItem = computed(() => {
- const item = data.itemList[popupData.activeIndex]
- if (item && item.type && item.type.toLocaleUpperCase() === 'VIDEO') {
- return item
- }
- return {}
- })
- return () => (
- <div id="playContent" class={[styles.playContent, 'wrap']}>
- <div
- onClick={() => {
- clearTimeout(activeData.timer);
- activeData.model = !activeData.model;
- Object.values(data.videoRefs).map((n: any) =>
- n?.toggleHideControl(activeData.model)
- );
- Object.values(data.audioRefs).map((n: any) =>
- n?.toggleHideControl(activeData.model)
- );
- }}>
- <div
- class={styles.coursewarePlay}
- style={{ width: parentContainer.width }}>
- {!popupData.chapterLoading ? (
- <div class={styles.wraps}>
- <div
- style={
- activeVideoItem.value.type &&
- data.animationState === 'end' &&
- data.videoState === 'play'
- ? {
- zIndex: 15,
- opacity: 1
- }
- : { opacity: 0, zIndex: -1 }
- }
- class={styles.itemDiv}
- >
- <VideoPlay
- ref={(el: any) => data.videoItemRef = el}
- item={activeVideoItem.value}
- showModel={activeData.model}
- onClose={setModelOpen}
- onCanplay={() => {
- data.videoState = 'play'
- }}
- onPause={() => {
- clearTimeout(activeData.timer)
- activeData.model = true
- }}
- onEnded={() => {
- const _index = popupData.activeIndex + 1
- if (_index < data.itemList.length) {
- handleSwipeChange(_index);
- }
- }}
- />
- </div>
- {data.itemList.map((m: any, mIndex: number) => {
- const isRender = Math.abs(popupData.activeIndex - mIndex) < 2;
- const isEmtry = Math.abs(popupData.activeIndex - mIndex) > 4;
- // if (isRender) {
- // m.isRender = true;
- // }
- // console.log(isRender, 'isRender', mIndex);
- return isRender ? (
- <div
- key={'index' + mIndex}
- class={[
- styles.itemDiv,
- popupData.activeIndex === mIndex && styles.itemActive,
- activeData.isAnimation && styles.acitveAnimation,
- Math.abs(popupData.activeIndex - mIndex) < 2
- ? styles.show
- : styles.hide
- ]}
- style={
- mIndex < popupData.activeIndex
- ? effects[effectIndex.value].prev
- : mIndex > popupData.activeIndex
- ? effects[effectIndex.value].next
- : {}
- }
- onClick={(e: Event) => {
- e.stopPropagation();
- clearTimeout(activeData.timer);
- if (Date.now() - activeData.nowTime < 300) {
- handleDbClick(m);
- return;
- }
- activeData.nowTime = Date.now();
- activeData.timer = setTimeout(() => {
- activeData.model = !activeData.model;
- Object.values(data.videoRefs).map((n: any) =>
- n?.toggleHideControl(activeData.model)
- );
- Object.values(data.audioRefs).map((n: any) =>
- n?.toggleHideControl(activeData.model)
- );
- if (activeData.model) {
- setModelOpen();
- }
- }, 300);
- }}>
- {m.type === 'VIDEO' ? (
- <>
- <img src={m.coverImg} onLoad={() => {
- m.isprepare = true;
- }} />
- {/* <VideoPlay
- ref={(v: any) => (data.videoRefs[mIndex] = v)}
- item={m}
- isEmtry={isEmtry}
- onLoadedmetadata={(videoItem: any) => {
- m.videoEle = videoItem;
- m.isprepare = true;
- }}
- onTogglePlay={(paused: boolean) => {
- m.autoPlay = false;
- if (paused || popupData.open) {
- clearTimeout(activeData.timer);
- } else {
- setModelOpen();
- }
- }}
- onReset={() => {
- if (!m.videoEle?.paused) {
- setModelOpen();
- }
- }}
- onError={() => {
- console.log('video error');
- m.error = true;
- }}
- /> */}
- <Transition name="van-fade">
- { (
- <div class={styles.loadWrap}>
- <Vue3Lottie
- animationData={playLoadData}></Vue3Lottie>
- </div>
- )}
- </Transition>
- </>
- ) : m.type === 'IMG' ? (
- <img src={m.content} />
- ) : m.type === 'SONG' ? (
- <AudioPay
- item={m}
- ref={(v: any) => (data.audioRefs[mIndex] = v)}
- onLoadedmetadata={(audioItem: any) => {
- m.audioEle = audioItem;
- m.isprepare = true;
- }}
- onTogglePlay={(paused: boolean) => {
- m.autoPlay = false;
- if (paused || popupData.open) {
- clearTimeout(activeData.timer);
- } else {
- setModelOpen();
- }
- }}
- onEnded={() => {
- const _index = popupData.activeIndex + 1;
- if (_index < data.itemList.length) {
- handleSwipeChange(_index);
- }
- }}
- onReset={() => {
- if (!m.audioEle?.paused) {
- setModelOpen();
- }
- }}
- />
- ) : (
- <MusicScore
- activeModel={activeData.model}
- activeStatus={popupData.activeIndex === mIndex}
- data-vid={m.id}
- music={m}
- onSetIframe={(el: any) => {
- m.iframeRef = el;
- }}
- />
- )}
- </div>
- ) : null;
- })}
- </div>
- ) : (
- ''
- )}
- </div>
- </div>
- {/* 头部样式 */}
- <div
- style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
- class={styles.headerContainer}>
- <div class={styles.menu}>{activeName.value}</div>
- </div>
- {/* 布置作业按钮 */}
- <div
- onClick={(e: any) => {
- e.stopPropagation();
- if (activeData.timer){
- setModelOpen();
- }
- }}
- class={[
- styles.switchDisplaySection,
- activeData.model ? '' : styles.sectionAnimate
- ]}>
- <NSpace class={styles.switchSpace}>
- <div
- class={styles.btnItem}
- onClick={async () => {
- if (data.type === 'preview') {
- handleStop();
- data.removeVisiable = true;
- data.removeTitle = '结束预览';
- data.removeContent = '请确认是否结束预览?';
- } else {
- data.removeVisiable = true;
- data.removeTitle = '结束课程';
- data.removeContent = '请确认是否结束课程?';
- }
- }}>
- <img src={iconOverClass} />
- <p>{data.type !== 'preview' ? '结束课程' : '结束预览'}</p>
- </div>
- {data.type !== 'preview' && (
- <div
- class={[
- styles.btnItem,
- data.preStudentNum <= 0 ? styles.btnsDisabled : ''
- ]}
- onClick={async () => {
- // 学生人数必须大于0,才可以布置作业
- if (data.preStudentNum <= 0) return;
- const res = await lessonPreTrainingPage({
- coursewareKnowledgeDetailId: data.detailId,
- subjectId: data.subjectId,
- page: 1,
- rows: 99
- });
- if (res.data.rows && res.data.rows.length) {
- data.modalAttendMessage =
- '本节课已设置课后作业,是否布置?';
- }
- data.modelAttendStatus = true;
- }}>
- <img src={iconWork} />
- <p>布置作业</p>
- </div>
- )}
- <div
- class={styles.btnItem}
- onClick={() =>
- openStudyTool({
- type: 'pen',
- icon: iconNote,
- name: '批注'
- })
- }>
- <img src={iconNote} />
- <p>批注</p>
- </div>
- <div
- class={styles.btnItem}
- onClick={() =>
- openStudyTool({
- type: 'whiteboard',
- icon: iconWhite,
- name: '白板'
- })
- }>
- <img src={iconWhite} />
- <p>白板</p>
- </div>
- <div
- class={styles.btnItem}
- onClick={() => startShowModal('beatIcon')}>
- <img src={iconToneIcon} />
- <p>节拍器</p>
- </div>
- <div
- class={styles.btnItem}
- onClick={() => startShowModal('toneIcon')}>
- <img src={iconSetTime} />
- <p>调音器</p>
- </div>
- <div
- class={styles.btnItem}
- onClick={() => startShowModal('setTimeIcon')}>
- <img src={iconBeatIcon} />
- <p>计时器</p>
- </div>
- </NSpace>
- <NSpace class={styles.switchSpace}>
- <div
- class={styles.btnItem}
- onClick={() => (popupData.chapterOpen = true)}>
- <img src={iconChange} />
- <p>切换章节</p>
- </div>
- <div class={styles.btnItem} onClick={() => (popupData.open = true)}>
- <img src={iconMenu} />
- <p>资源列表</p>
- </div>
- <div
- class={[
- styles.btnItem,
- !isUpArrow.value ? styles.btnsDisabled : ''
- ]}
- onClick={() => {
- if (!isUpArrow.value) return;
- handlePreAndNext('up');
- }}>
- <img src={iconUp} />
- <p>上一个</p>
- </div>
- <div
- class={[
- styles.btnItem,
- !isDownArrow.value ? styles.btnsDisabled : ''
- ]}
- onClick={() => {
- if (!isDownArrow.value) return;
- handlePreAndNext('down');
- }}>
- <img src={iconDown} />
- <p>下一个</p>
- </div>
- </NSpace>
- </div>
- {/* 显示列表 */}
- <NDrawer
- v-model:show={popupData.open}
- class={styles.drawerContainer}
- onAfterLeave={handleClosePopup}
- showMask={false}>
- <NDrawerContent title="资源列表" closable>
- {data.knowledgePointList.map((item: any, index: number) => (
- <div class={styles.cardContainer}>
- <CardType
- item={item}
- isActive={popupData.activeIndex === index}
- isCollect={false}
- isShowCollect={false}
- onClick={(item: any) => {
- popupData.open = false;
- toggleMaterial(item.id);
- }}
- />
- </div>
- ))}
- </NDrawerContent>
- </NDrawer>
- {/* 显示列表 */}
- <NDrawer
- v-model:show={popupData.chapterOpen}
- class={styles.drawerContainer}
- onAfterLeave={handleClosePopup}
- showMask={false}
- displayDirective="show">
- <NDrawerContent title="切换章节" closable>
- <Chapter
- treeList={popupData.chapterDetails}
- itemActive={data.detailId as any}
- onHandleSelect={async (val: any) => {
- popupData.chapterLoading = true;
- try {
- data.detailId = val.itemActive;
- const ids = formatParentId(
- val.itemActive,
- popupData.chapterDetails
- );
- data.lessonCoursewareDetailId = ids[0];
- // 更新上课记录 上课的时候才更新
- if (data.type !== 'preview') {
- await classCourseScheduleUpdate();
- }
- await getDetail();
- popupData.activeIndex = 0;
- popupData.chapterOpen = false;
- } catch {
- //
- }
- popupData.chapterLoading = false;
- }}
- />
- </NDrawerContent>
- </NDrawer>
- {/* 批注 */}
- {studyData.penShow && (
- <Pen
- show={studyData.type === 'pen'}
- type={studyData.type}
- close={() => closeStudyTool()}
- />
- )}
- {studyData.whiteboardShow && (
- <Pen
- show={studyData.type === 'whiteboard'}
- type={studyData.type}
- close={() => closeStudyTool()}
- />
- )}
- {/* 布置作业 */}
- <NModal
- transformOrigin="center"
- v-model:show={data.modelAttendStatus}
- preset="card"
- // class={styles.attendClassModal}
- title={'课后作业'}
- class={['modalTitle', styles.removeVisiable]}>
- <div class={styles.studentRemove}>
- <p>{data.modalAttendMessage}</p>
- {/* <div class={styles.modelAttendContent}>
- {data.modalAttendMessage}
- </div> */}
- <NSpace class={styles.btnGroupModal}>
- <NButton
- type="default"
- round
- onClick={() => {
- data.modelAttendStatus = false;
- handleStop();
- // if (state.application) {
- // emit('close');
- // } else {
- // window.close();
- // }
- data.modelAttendStatus = false;
- }}>
- 暂不布置
- </NButton>
- <NButton
- type="primary"
- round
- onClick={() => {
- data.modelTrainStatus = true;
- data.modelAttendStatus = false;
- }}>
- 布置
- </NButton>
- </NSpace>
- </div>
- </NModal>
- {/* 训练设置 */}
- <NModal
- transformOrigin="center"
- v-model:show={data.modelTrainStatus}
- preset="card"
- class={[styles.attendClassModal, styles.trainClassModal]}
- title={'作业设置'}>
- <TrainSettings
- detailId={data.detailId}
- subjectId={data.subjectId}
- classGroupId={data.classGroupId}
- onClose={() => (data.modelTrainStatus = false)}
- onConfirm={() => {
- // 布置完作业之后直接关闭
- // setTimeout(() => {
- // handleStop();
- // if (state.application) {
- // emit('close');
- // } else {
- // window.close();
- // }
- // }, 1000);
- data.modelTrainStatus = false;
- }}
- />
- </NModal>
- <NModal
- transformOrigin="center"
- class={['modalTitle background']}
- title={'节拍器'}
- preset="card"
- v-model:show={showModalBeat.value}
- style={{ width: '687px' }}>
- <div class={styles.modeWrap}>
- <iframe
- src={`${vaildUrl()}/metronome/?id=${new Date().getTime()}`}
- scrolling="no"
- frameborder="0"
- width="100%"
- height={'650px'}></iframe>
- </div>
- </NModal>
- <NModal
- transformOrigin="center"
- class={['background']}
- v-model:show={showModalTone.value}>
- <div>
- <PlaceholderTone
- onClose={() => {
- showModalTone.value = false;
- }}></PlaceholderTone>
- </div>
- </NModal>
- <NModal
- transformOrigin="center"
- v-model:show={showModalTime.value}
- class={['modalTitle background']}
- title={'计时器'}
- preset="card"
- style={{ width: px2vw(772) }}>
- <div>
- <TimerMeter></TimerMeter>
- </div>
- </NModal>
- <NModal
- transformOrigin="center"
- v-model:show={data.removeVisiable}
- preset="card"
- class={['modalTitle', styles.removeVisiable]}
- title={data.removeTitle}>
- <div class={styles.studentRemove}>
- <p>{data.removeContent}</p>
- <NSpace class={styles.btnGroupModal} justify="center">
- <NButton round onClick={() => (data.removeVisiable = false)}>
- 取消
- </NButton>
- <NButton
- round
- type="primary"
- onClick={() => {
- //
- if (globalState.application) {
- document.exitFullscreen
- ? document.exitFullscreen()
- : document.mozCancelFullScreen
- ? document.mozCancelFullScreen()
- : document.webkitExitFullscreen
- ? document.webkitExitFullscreen()
- : '';
- emit('close');
- } else {
- window.close();
- }
- }}>
- 确定
- </NButton>
- </NSpace>
- </div>
- </NModal>
- </div>
- );
- }
- });
|