123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029 |
- import { closeToast, Icon, Popup, showDialog, showToast } from 'vant';
- import {
- defineComponent,
- onMounted,
- reactive,
- nextTick,
- onUnmounted,
- ref,
- watch,
- Transition,
- computed
- } from 'vue';
- import iconBack from './image/back.svg';
- import styles from './index.module.less';
- import 'plyr/dist/plyr.css';
- import { useRoute, useRouter } from 'vue-router';
- import {
- listenerMessage,
- postMessage,
- promisefiyPostMessage,
- removeListenerMessage
- } from '@/helpers/native-message';
- import MusicScore from './component/musicScore';
- import iconMenu from './image/icon-menu.svg';
- import iconChange from './image/icon-change.svg';
- import iconDian from './image/icon-dian.svg';
- import iconPoint from './image/icon-point.svg';
- import iconUp from './image/icon-up.svg';
- import iconDown from './image/icon-down.svg';
- import Points from './component/points';
- import { browser, getSecondRPM } from '@/helpers/utils';
- import { Vue3Lottie } from 'vue3-lottie';
- import playLoadData from './datas/data.json';
- import { usePageVisibility } from '@vant/use';
- import AudioItem from './component/audio-item';
- import {
- api_classLessonCoursewareQuery,
- api_lessonCoursewareKnowledgeDetailDetail
- } from './api';
- import VideoItem from './component/video-item';
- import Chapter from './component/chapter';
- import {
- api_classLessonCoursewareDetail,
- api_lessonCoursewareDetail
- } from '../courseware-list/api';
- import detail from '../information/help-center/detail';
- import { state } from '@/state';
- export default defineComponent({
- name: 'CoursewarePlay',
- setup() {
- const pageVisibility = usePageVisibility();
- const lastTimeKey = 'lastTime' + (state?.user?.data?.phone ?? '');
- /** 设置播放容器 16:9 */
- const parentContainer = reactive({
- width: '100vw'
- });
- const setContainer = () => {
- let min = Math.min(screen.width, screen.height);
- let max = Math.max(screen.width, screen.height);
- let width = min * (16 / 9);
- if (width > max) {
- parentContainer.width = '100vw';
- return;
- } else {
- parentContainer.width = width + 'px';
- }
- };
- const handleInit = (type = 0) => {
- //设置容器16:9
- setContainer();
- // 横屏
- // postMessage(
- // {
- // api: 'setRequestedOrientation',
- // content: {
- // orientation: type
- // }
- // },
- // () => {
- // console.log(234);
- // }
- // );
- // 头,包括返回箭头
- // postMessage({
- // api: 'setTitleBarVisibility',
- // content: {
- // status: type
- // }
- // })
- // 安卓的状态栏
- postMessage({
- api: 'setStatusBarVisibility',
- content: {
- isVisibility: type
- }
- });
- // 进入页面设置常量
- postMessage({
- api: 'keepScreenLongLight',
- content: {
- isOpenLight: type ? true : false
- }
- });
- };
- handleInit();
- onUnmounted(() => {
- handleInit(1);
- window.removeEventListener('message', iframeHandle);
- });
- const getCourseDetail = async () => {
- try {
- if (route.query.tab == 'course') {
- const res = await api_classLessonCoursewareDetail({
- id: activeData.courseId as any,
- subjectId: activeData.subjectId
- });
- if (res?.code == 200 && Array.isArray(res?.data?.lessonList)) {
- data.courseDetails = res.data.lessonList || [];
- console.log('🚀 ~ data.details course:', data.courseDetails);
- }
- } else {
- const res = await api_lessonCoursewareDetail({
- id: route.query.lessonCoursewareId as any,
- subjectId: activeData.subjectId
- });
- if (res?.code == 200 && Array.isArray(res?.data?.lessonList)) {
- data.courseDetails = res.data.lessonList || [];
- }
- }
- console.log(data.courseDetails, 'data.courseDetails');
- } catch {
- //
- }
- };
- const route = useRoute();
- const headeRef = ref();
- const loadingClass = ref(false); // 重新加载课件
- const data = reactive({
- knowledgePointList: [] as any,
- courseDetails: [] as any,
- itemList: [] as any,
- videoRefs: {} as any[],
- videoState: 'init' as 'init' | 'play',
- videoItemRef: null as any,
- animationState: 'start' as 'start' | 'end'
- });
- const activeData = reactive({
- isAutoPlay: true, // 是否自动播放
- subjectId: route.query.subjectId,
- lessonCoursewareId: route.query.lessonCoursewareId,
- lessonCoursewareDetailId: route.query.lessonCoursewareDetailId,
- coursewareDetailKnowledgeId: route.query.id,
- courseId: route.query.courseId, // 我的课程专用编号
- nowTime: 0,
- model: true, // 遮罩
- isAnimation: true, // 是否动画
- videoBtns: true, // 视频
- currentTime: 0,
- duration: 0,
- timer: null as any,
- item: null as any
- });
- const getDetail = async () => {
- let courseList: any[] = [];
- if (route.query.tab == 'course') {
- const res = await api_classLessonCoursewareQuery({
- coursewareDetailKnowledgeId: activeData.coursewareDetailKnowledgeId,
- subjectId: activeData.subjectId,
- page: 1,
- rows: -1
- });
- if (res?.code === 200 && Array.isArray(res.data.rows)) {
- const tempRows = res.data.rows || [];
- tempRows.forEach((item: any) => {
- courseList.push({
- content: item.content,
- coverImg: item.coverImg,
- id: item.id,
- materialId: item.materialId,
- name: item.materialName,
- relOrder: 0,
- sourceFrom: item.source,
- type: item.materialType
- });
- });
- }
- } else {
- const res = await api_lessonCoursewareKnowledgeDetailDetail({
- lessonCoursewareKnowledgeDetailId:
- activeData.coursewareDetailKnowledgeId,
- subjectId: activeData.subjectId
- });
- if (res?.code === 200 && Array.isArray(res.data)) {
- courseList = res.data || [];
- }
- }
- // 课程
- if (courseList.length > 0) {
- data.knowledgePointList = courseList.map((item: any) => {
- return {
- ...item,
- url:
- item.type === 'SONG'
- ? 'https://oss.dayaedu.com/ktqy/1698420034679a22d3f7a.png'
- : item.type === 'PPT' ? 'https://oss.dayaedu.com/ktqy/12/1701931810284.png'
- : item.coverImg
- };
- });
- }
- data.itemList = data.knowledgePointList.map((m: any, index: number) => {
- if (!popupData.itemActive) {
- popupData.itemActive = m.id;
- popupData.itemName = m.name;
- }
- return {
- ...m,
- iframeRef: null,
- videoEle: null,
- autoPlay: false, //加载完成是否自动播放
- isprepare: false, // 视频是否加载完成
- isRender: false // 是否渲染了
- };
- });
- setTimeout(() => {
- data.animationState = 'end';
- }, 500);
- };
- // ifram事件处理
- const iframeHandle = (ev: MessageEvent) => {
- if (ev.data?.api === 'headerTogge') {
- activeData.model =
- ev.data.show || (ev.data.playState == 'play' ? false : true);
- }
- if (ev.data?.api === 'api_fingerPreView') {
- clearInterval(activeData.timer);
- activeData.model = !ev.data.state;
- }
- };
- onMounted(() => {
- postMessage({
- api: 'courseLoading',
- content: {
- show: false,
- type: 'fullscreen'
- }
- });
- getDetail();
- getCourseDetail();
- window.addEventListener('message', iframeHandle);
- });
- const playRef = ref();
- // 返回
- const goback = () => {
- try {
- playRef.value?.handleOut();
- } catch (error) {}
- postMessage({ api: 'goBack' });
- // router.back()
- };
- const popupData = reactive({
- open: false,
- activeIndex: 0,
- itemActive: '',
- itemName: '',
- itemPointName: route.query.name as any,
- chapterOpen: false
- });
- // 切换素材
- const toggleMaterial = (itemActive: any) => {
- const index = data.itemList.findIndex((n: any) => n.id == itemActive);
- if (index > -1) {
- handleSwipeChange(index);
- }
- };
- /** 延迟收起模态框 */
- const setModelOpen = () => {
- clearTimeout(activeData.timer);
- closeToast();
- activeData.model = !activeData.model;
- activeData.timer = setTimeout(() => {
- activeData.model = false;
- }, 4000);
- };
- const setModelOpen1 = () => {
- clearTimeout(activeData.timer);
- closeToast();
- activeData.model = true;
- activeData.timer = setTimeout(() => {
- activeData.model = false;
- }, 4000);
- };
- // 双击
- const handleDbClick = (item: any) => {
- if (item && ['VIDEO'].includes(item.type)) {
- console.log('双击');
- }
- };
- 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)',
- opacity: 0
- },
- next: {
- transform: 'translate3d(100%, 0, -800px) rotateY(120deg)',
- opacity: 0
- }
- },
- // 风车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 handleStop = () => {
- data.videoItemRef.pause();
- };
- 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;
- const item = data.itemList[index];
- popupData.activeIndex = index;
- popupData.itemActive = item.id;
- popupData.itemName = item.name;
- if (item.type == 'MUSIC') {
- activeData.model = true;
- } else if (item.type == 'VIDEO') {
- if (item.error) {
- data.videoRefs[index]?.onPlay();
- }
- setTimeout(() => {
- data.animationState = 'end';
- }, 800);
- }
- };
- // 上一个知识点, 下一个知识点
- const handlePreAndNext = async (type: string) => {
- if (type === 'up') {
- // 判断上面是否还有章节
- if (popupData.activeIndex > 0) {
- handleSwipeChange(popupData.activeIndex - 1);
- return;
- }
- // 获取当前是哪个章节
- let detailIndex = data.courseDetails.findIndex(
- (item: any) => item.id == activeData.lessonCoursewareDetailId
- );
- const detailItem = data.courseDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == activeData.coursewareDetailKnowledgeId
- );
- let lessonStatus = false; // 当前章节上面是否有内容
- let lessonCoursewareDetailId = '';
- let coursewareDetailKnowledgeId = '';
- let coursewareDetailKnowledgeName = '';
- while (lessonIndex >= 0) {
- lessonIndex--;
- if (lessonIndex >= 0) {
- if (detailItem[lessonIndex].containMaterial) {
- lessonStatus = true;
- lessonCoursewareDetailId =
- detailItem[lessonIndex].lessonCoursewareDetailId;
- coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
- coursewareDetailKnowledgeName = detailItem[lessonIndex].name;
- }
- }
- if (lessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往上一个章节走
- if (lessonStatus) {
- loadingClass.value = true;
- activeData.coursewareDetailKnowledgeId = coursewareDetailKnowledgeId;
- activeData.lessonCoursewareDetailId = lessonCoursewareDetailId;
- await getDetail();
- popupData.activeIndex = data.itemList.length - 1 || 0;
- popupData.itemActive =
- data.knowledgePointList[data.itemList.length - 1]?.id ||
- data.knowledgePointList[0]?.id;
- popupData.itemPointName = coursewareDetailKnowledgeName;
- popupData.itemName =
- data.knowledgePointList[data.itemList.length - 1]?.name ||
- data.knowledgePointList[0]?.name;
- localStorage.setItem(lastTimeKey, coursewareDetailKnowledgeId);
- popupData.chapterOpen = false;
- loadingClass.value = false;
- return;
- }
- let prevLessonStatus = false;
- while (detailIndex >= 0) {
- detailIndex--;
- const tempDetail =
- data.courseDetails[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;
- coursewareDetailKnowledgeName =
- tempDetail[tempLessonLength - 1].name;
- }
- tempLessonLength--;
- if (prevLessonStatus) {
- break;
- }
- }
- if (prevLessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往上一个章节走
- if (prevLessonStatus) {
- loadingClass.value = true;
- activeData.coursewareDetailKnowledgeId = coursewareDetailKnowledgeId;
- activeData.lessonCoursewareDetailId = lessonCoursewareDetailId;
- await getDetail();
- popupData.activeIndex = data.itemList.length - 1 || 0;
- popupData.itemActive =
- data.knowledgePointList[data.itemList.length - 1]?.id ||
- data.knowledgePointList[0]?.id;
- localStorage.setItem(lastTimeKey, coursewareDetailKnowledgeId);
- popupData.itemPointName = coursewareDetailKnowledgeName;
- popupData.itemName =
- data.knowledgePointList[data.itemList.length - 1]?.name ||
- data.knowledgePointList[0]?.name;
- popupData.chapterOpen = false;
- loadingClass.value = false;
- return;
- }
- } else {
- if (popupData.activeIndex < data.itemList.length - 1) {
- handleSwipeChange(popupData.activeIndex + 1);
- return;
- }
- // 获取当前是哪个章节
- let detailIndex = data.courseDetails.findIndex(
- (item: any) => item.id == activeData.lessonCoursewareDetailId
- );
- const detailItem = data.courseDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == activeData.coursewareDetailKnowledgeId
- );
- let lessonStatus = false; // 当前章节下面是否有内容
- let lessonCoursewareDetailId = '';
- let coursewareDetailKnowledgeId = '';
- let coursewareDetailKnowledgeName = '';
- while (lessonIndex < detailItem.length - 1) {
- lessonIndex++;
- if (lessonIndex >= 0) {
- if (detailItem[lessonIndex].containMaterial) {
- lessonStatus = true;
- lessonCoursewareDetailId =
- detailItem[lessonIndex].lessonCoursewareDetailId;
- coursewareDetailKnowledgeId = detailItem[lessonIndex].id;
- coursewareDetailKnowledgeName = detailItem[lessonIndex].name;
- }
- }
- if (lessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往下一个章节走
- if (lessonStatus) {
- loadingClass.value = true;
- activeData.coursewareDetailKnowledgeId = coursewareDetailKnowledgeId;
- activeData.lessonCoursewareDetailId = lessonCoursewareDetailId;
- await getDetail();
- popupData.activeIndex = 0;
- popupData.itemActive = data.knowledgePointList[0].id;
- popupData.itemName = data.knowledgePointList[0].name;
- localStorage.setItem(lastTimeKey, coursewareDetailKnowledgeId);
- popupData.itemPointName = coursewareDetailKnowledgeName;
- popupData.chapterOpen = false;
- loadingClass.value = false;
- return;
- }
- let nextLessonStatus = false;
- while (detailIndex <= data.courseDetails.length - 1) {
- detailIndex++;
- const tempDetail =
- data.courseDetails[detailIndex]?.knowledgeList || [];
- let tempLessonLength = 0;
- while (tempLessonLength <= tempDetail.length - 1) {
- if (tempDetail[tempLessonLength].containMaterial) {
- nextLessonStatus = true;
- lessonCoursewareDetailId =
- tempDetail[tempLessonLength].lessonCoursewareDetailId;
- coursewareDetailKnowledgeId = tempDetail[tempLessonLength].id;
- coursewareDetailKnowledgeName = tempDetail[tempLessonLength].name;
- }
- tempLessonLength++;
- if (nextLessonStatus) {
- break;
- }
- }
- if (nextLessonStatus) {
- break;
- }
- }
- // 判断当前章节下面课程是否有内容,否则往上一个章节走
- if (nextLessonStatus) {
- loadingClass.value = true;
- activeData.coursewareDetailKnowledgeId = coursewareDetailKnowledgeId;
- activeData.lessonCoursewareDetailId = lessonCoursewareDetailId;
- await getDetail();
- popupData.activeIndex = 0;
- popupData.itemActive = data.knowledgePointList[0].id;
- localStorage.setItem(lastTimeKey, coursewareDetailKnowledgeId);
- popupData.itemName = data.knowledgePointList[0].name;
- popupData.itemPointName = coursewareDetailKnowledgeName;
- popupData.chapterOpen = false;
- loadingClass.value = false;
- return;
- }
- }
- };
- /** 弹窗关闭 */
- const handleClosePopup = () => {
- // setModelOpen();
- };
- // popupData.activeIndex == 0 && styles.btnsDisabled
- // popupData.activeIndex == data.itemList.length - 1
- // 是否允许上一页
- const isUpArrow = computed(() => {
- /**
- * 1,判断当前课程中是否处在第一个资源;
- * 2,判断当前课程是否在当前章节的第一个;
- * 3,判断当前章节,当前课程上面还没有其它课程,是否有资源;
- * 4,判断当前章节上面还没有其它章节;
- * 5,判断上面章节里面课程是否有资源;
- */
- if (popupData.activeIndex > 0) {
- return true;
- }
- // 获取当前是哪个章节
- let detailIndex = data.courseDetails.findIndex(
- (item: any) => item.id == activeData.lessonCoursewareDetailId
- );
- const detailItem = data.courseDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == activeData.coursewareDetailKnowledgeId
- );
- // 说明已经是第一单元,第一课
- 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 = data.courseDetails[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 = data.courseDetails.findIndex(
- (item: any) => item.id == activeData.lessonCoursewareDetailId
- );
- const detailItem = data.courseDetails[detailIndex]?.knowledgeList || [];
- let lessonIndex = detailItem.findIndex(
- (item: any) => item.id == activeData.coursewareDetailKnowledgeId
- );
- // 说明已经是最后-单元,最后一课
- if (
- detailIndex >= data.courseDetails.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 >= data.courseDetails.length - 1) {
- return false;
- }
- let nextLessonStatus = false;
- while (detailIndex < data.courseDetails.length - 1) {
- detailIndex++;
- const tempDetail = data.courseDetails[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}>
- <div
- class={styles.coursewarePlay}
- style={{ width: parentContainer.width }}
- onClick={() => setModelOpen()}>
- {!loadingClass.value && (
- <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}>
- <VideoItem
- ref={(el: any) => (data.videoItemRef = el)}
- item={activeVideoItem.value}
- showModel={activeData.model}
- onClose={setModelOpen1}
- 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 =
- m.isRender || Math.abs(popupData.activeIndex - mIndex) < 2;
- const isEmtry = Math.abs(popupData.activeIndex - mIndex) > 4;
- if (isRender) {
- m.isRender = true;
- }
- 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) => {
- if (Date.now() - activeData.nowTime < 300) {
- handleDbClick(m);
- return;
- }
- activeData.nowTime = Date.now();
- }}>
- {m.type === 'IMG' && <img src={m.content} />}
- {m.type === 'PPT' && <iframe src={`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(m.content)}`} width='100%' height='100%' frameborder='1'></iframe>}
- {m.type === 'VIDEO' && (
- <img
- src={m.coverImg}
- onLoad={() => {
- m.isprepare = true;
- }}
- />
- )}
- {/* {m.type === 'VIDEO' && (
- <VideoItem
- ref={(v: any) => (data.videoRefs[mIndex] = v)}
- item={m}
- show={popupData.activeIndex === mIndex}
- pageVisibility={pageVisibility.value}
- showModel={activeData.model}
- isEmtry={isEmtry}
- onLoadedmetadata={() => {
- m.isprepare = true;
- m.error = false;
- }}
- onEnded={() => {
- const _index = popupData.activeIndex + 1;
- if (_index < data.itemList.length) {
- handleSwipeChange(_index);
- }
- }}
- onReset={() => {
- m.error = false;
- }}
- onError={() => {
- m.isprepare = true;
- m.error = true;
- }}
- />
- )} */}
- {m.type === 'SONG' && (
- <AudioItem
- item={m}
- show={popupData.activeIndex === mIndex}
- pageVisibility={pageVisibility.value}
- showModel={activeData.model}
- isEmtry={isEmtry}
- onEnded={() => {
- const _index = popupData.activeIndex + 1;
- if (_index < data.itemList.length) {
- handleSwipeChange(_index);
- }
- }}
- onClose={() => {
- clearTimeout(activeData.timer);
- activeData.timer = setTimeout(() => {
- activeData.model = false;
- }, 4000);
- }}
- />
- )}
- {m.type === 'MUSIC' && (
- <MusicScore
- pageVisibility={pageVisibility.value}
- show={popupData.activeIndex === mIndex}
- activeModel={activeData.model}
- data-vid={m.id}
- music={m}
- />
- )}
- {m.type === 'VIDEO' && (
- <Transition name="van-fade">
- {/* {!m.isprepare && (
- <div class={styles.loadWrap}>
- <Vue3Lottie
- style={{ width: '100%', height: '100%' }}
- animationData={playLoadData}></Vue3Lottie>
- </div>
- )} */}
- {data.videoState !== 'play' && (
- <div class={styles.loadWrap}>
- <Vue3Lottie
- style={{ width: '100%', height: '100%' }}
- animationData={playLoadData}></Vue3Lottie>
- </div>
- )}
- </Transition>
- )}
- </div>
- ) : (
- <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
- : {}
- }></div>
- );
- })}
- </div>
- )}
- <Transition name="right">
- {activeData.model && (
- <div
- class={styles.rightFixedBtns}
- onClick={(e: Event) => {
- e.stopPropagation();
- clearTimeout(activeData.timer);
- }}>
- <div
- class={[styles.fullBtn, styles.point]}
- onClick={() => (popupData.chapterOpen = true)}>
- <img src={iconChange} />
- <span>切换</span>
- </div>
- <div
- class={[styles.fullBtn, styles.point]}
- onClick={() => (popupData.open = true)}>
- <img src={iconMenu} />
- <span>课件</span>
- </div>
- <div
- class={[
- styles.fullBtn,
- // popupData.activeIndex == 0 && styles.btnsDisabled
- !isUpArrow.value && styles.btnsDisabled
- ]}
- onClick={() => handlePreAndNext('up')}>
- <img src={iconUp} />
- <span style={{ textAlign: 'center' }}>上一个</span>
- </div>
- <div
- class={[
- styles.fullBtn,
- !isDownArrow.value && styles.btnsDisabled
- ]}
- onClick={() => handlePreAndNext('down')}>
- <span style={{ textAlign: 'center' }}>下一个</span>
- <img src={iconDown} />
- </div>
- </div>
- )}
- </Transition>
- </div>
- <div
- style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
- class={styles.headerContainer}
- ref={headeRef}>
- <div class={styles.backBtn} onClick={() => goback()}>
- <Icon name={iconBack} />
- 返回
- </div>
- <div class={styles.menu}>{popupData.itemName}</div>
- </div>
- {/* 课件列表 */}
- <Popup
- class={styles.popup}
- style={{ background: 'rgba(0,0,0, 0.75)' }}
- overlayClass={styles.overlayClass}
- position="right"
- round
- v-model:show={popupData.open}
- onClose={handleClosePopup}>
- <Points
- data={data.knowledgePointList}
- itemActive={popupData.itemActive}
- itemName={popupData.itemPointName}
- onHandleSelect={(res: any) => {
- popupData.open = false;
- toggleMaterial(res.itemActive);
- }}
- />
- </Popup>
- {/* 知识点列表 */}
- <Popup
- class={styles.popup}
- style={{ background: 'rgba(0,0,0, 0.75)' }}
- overlayClass={styles.overlayClass}
- position="right"
- round
- v-model:show={popupData.chapterOpen}
- onClose={handleClosePopup}>
- <Chapter
- detail={data.courseDetails}
- itemActive={activeData.coursewareDetailKnowledgeId as any}
- active={activeData.lessonCoursewareDetailId as any}
- onHandleSelect={async (item: any) => {
- loadingClass.value = true;
- activeData.coursewareDetailKnowledgeId = item.itemActive;
- activeData.lessonCoursewareDetailId = item.tabActive;
- await getDetail();
- popupData.activeIndex = 0;
- popupData.itemActive = data.knowledgePointList[0].id;
- popupData.itemName = data.knowledgePointList[0].name;
- popupData.itemPointName = item.itemName;
- popupData.chapterOpen = false;
- loadingClass.value = false;
- }}
- />
- </Popup>
- </div>
- );
- }
- });
|