123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236 |
- import { Toast, Icon, Popup, Dialog } from 'vant'
- import {
- defineComponent,
- onMounted,
- reactive,
- nextTick,
- onUnmounted,
- ref,
- watch,
- Transition,
- computed,
- onBeforeUnmount
- } from 'vue'
- import iconBack from './image/back.svg'
- import styles from './index.module.less'
- import 'plyr/dist/plyr.css'
- import request from '@/helpers/request'
- import { state } from '@/state'
- import { useRoute } from 'vue-router'
- import {
- postMessage,
- promisefiyPostMessage,
- listenerMessage
- } from '@/helpers/native-message'
- import MusicScore from './component/musicScore'
- // import iconDian from './image/icon-dian.svg'
- // import iconPoint from './image/icon-point.svg'
- import { state as baseState } from '@/state'
- import {
- iconUp,
- iconDown,
- // iconPen,
- iconTouping,
- iconCourseType,
- iconMenu
- } from './image/icons.json'
- import Points from './component/points'
- import { browser } from '@/helpers/utils'
- import { Vue3Lottie } from 'vue3-lottie'
- import playLoadData from './datas/data.json'
- import { usePageVisibility } from '@vant/use'
- import PlayRecordTime from './playRecordTime'
- // import { handleCheckVip } from '../hook/useFee'
- import OGuide from './component/o-guide'
- import Tool, { ToolItem, ToolType } from './component/tool'
- import Pen from './component/tools/pen'
- // import VideoItem from './component/video-item';
- import VideoPlay from './component/video-play'
- import { musicBuy } from '../music'
- import { isPlay, penShow, toolOpen, whitePenShow } from '@/components/globalTools/globalTools'
- import CoursewareTips from './component/courseware-tips'
- import GlobalTools from '@/components/globalTools'
- import CoursewareType from './component/courseware-type'
- import { useNetwork } from '@vueuse/core'
- export default defineComponent({
- name: 'CoursewarePlay',
- setup() {
- const apiSuffix = ref(
- baseState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
- )
- const pageVisibility = usePageVisibility()
- const { isOnline } = useNetwork()
- /** 页面显示和隐藏 */
- watch(
- () => pageVisibility.value,
- value => {
- if (value == 'hidden') {
- handleStop()
- }
- }
- )
- /** 设置播放容器 16:9 */
- const parentContainer = reactive({
- width: '100vw'
- })
- // 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()
- // 横屏
- 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 route = useRoute()
- const headeRef = ref()
- const data = reactive({
- currentId: route.query.id as any,
- detail: null as any,
- knowledgePointList: [] as any,
- itemList: [] as any,
- showHead: true,
- isCourse: false,
- isRecordPlay: false,
- videoRefs: {},
- refLevelList: [] as any,
- videoState: 'init' as 'init' | 'play',
- videoItemRef: null as any,
- animationState: 'start' as 'start' | 'end',
- disableScreenRecordingFlag: '0' // disable recording
- })
- const activeData = reactive({
- isAutoPlay: true, // 是否自动播放
- nowTime: 0,
- model: true, // 遮罩
- isAnimation: true, // 是否动画
- videoBtns: true, // 视频
- currentTime: 0,
- duration: 0,
- timer: null as any,
- item: null as any
- })
- // 获取缓存路径
- const getCacheFilePath = async (material: any) => {
- const res = await promisefiyPostMessage({
- api: 'getCourseFilePath',
- content: {
- url: material.content,
- localPath: '',
- materialId: material.materialId,
- updateTime: material.updateTime,
- type: material.typeCode // SONG VIDEO IMAGE
- }
- })
- // console.log('缓存路径返回', res)
- return res
- }
- // 获取当前课程是否签退
- // const getCourseSchedule = async () => {
- // if (!route.query.courseId) return;
- // try {
- // const res = await request.get(
- // `${state.platformApi}/courseSchedule/detail/${route.query.courseId}`,
- // {
- // hideLoading: true
- // }
- // );
- // if (res?.data) {
- // data.isCourse =
- // res.data.status === 'ING' && state.platformType == 'TEACHER'
- // ? true
- // : false;
- // // data.isRecordPlay = Date.now() > dayjs(res.data.startTime).valueOf()
- // }
- // } catch (e) {
- // console.log(e);
- // }
- // };
- const getTempList = async (materialList: any, name: any) => {
- const list: any = []
- const browserInfo = browser()
- for (let j = 0; j < materialList.length; j++) {
- const material = materialList[j]
- //请求本地缓存
- if (browserInfo.isApp && ['VIDEO', 'IMG'].includes(material.typeCode)) {
- const localData: any = await getCacheFilePath(material)
- if (localData?.content?.localPath) {
- material.url = material.content
- material.content = localData.content.localPath
- } else {
- material.url = material.content + '?t=' + +new Date()
- material.content = material.content + '?t=' + +new Date()
- }
- }
- material.iframeRef = null
- material.videoEle = null
- material.tabName = name
- material.autoPlay = false //加载完成是否自动播放
- material.isprepare = false // 视频是否加载完成
- material.isRender = false // 是否渲染了
- list.push(material)
- // list.push({
- // ...material,
- // iframeRef: null,
- // videoEle: null,
- // tabName: name,
- // autoPlay: false, //加载完成是否自动播放
- // isprepare: false, // 视频是否加载完成
- // isRender: false // 是否渲染了
- // })
- }
- return list
- }
- const getItemList = async () => {
- const list: any = []
- for (let i = 0; i < data.knowledgePointList.length; i++) {
- const item = data.knowledgePointList[i]
- if (item.materialList && item.materialList.length > 0) {
- const tempList = await getTempList(item.materialList, item.name)
- list.push(...tempList)
- }
- // 第二层级
- if (item.children && item.children.length > 0) {
- const childrenList = item.children || []
- for (let j = 0; j < childrenList.length; j++) {
- const childItem = childrenList[j]
- const tempList = await getTempList(
- childItem.materialList,
- childItem.name
- )
- list.push(...tempList)
- }
- }
- }
- // console.log(list, 'list')
- let _firstIndex = list.findIndex(
- (n: any) =>
- n.knowledgePointMaterialRelationId == route.query.kId ||
- n.materialId == route.query.kId
- )
- _firstIndex = _firstIndex > -1 ? _firstIndex : 0
- const item = list[_firstIndex]
- // console.log(_firstIndex, '_firstIndex', route.query.kId, 'route.query.kId', item)
- // 是否自动播放
- if (activeData.isAutoPlay) {
- item.autoPlay = true
- }
- popupData.activeIndex = _firstIndex
- popupData.playIndex = _firstIndex
- popupData.tabName = item.tabName
- popupData.tabActive = item.knowledgePointId
- popupData.itemActive = item.id
- popupData.itemName = item.name
- nextTick(() => {
- data.itemList = list
- checkedAnimation(popupData.activeIndex)
- postMessage({
- api: 'courseLoading',
- content: {
- show: false,
- type: 'fullscreen'
- }
- })
- if (data.disableScreenRecordingFlag === '1') {
- // 检测是否录屏
- handleLimitScreenRecord()
- }
- setTimeout(() => {
- data.animationState = 'end'
- }, 500)
- })
- }
- const getDetail = async (id?: any) => {
- try {
- const res: any = await request.get(
- apiSuffix.value +
- `/tenantAlbumMusic/getLessonCourseDetail/${id || route.query.id}`,
- {
- hideLoading: true
- }
- )
- const result = res.data || {}
- result.lessonTargetDesc = result.lessonTargetDesc ? result.lessonTargetDesc.replace(/\n/g, "<br />") : ""
- data.detail = result;
- if (res?.data?.lockFlag) {
- postMessage({
- api: 'courseLoading',
- content: {
- show: false,
- type: 'fullscreen'
- }
- })
- Dialog.alert({
- title: '温馨提示',
- message: '课件已锁定'
- }).then(() => {
- goback()
- })
- return
- }
- if (Array.isArray(res?.data?.knowledgePointList)) {
- let index = 0
- data.knowledgePointList = res.data.knowledgePointList.map(
- (n: any) => {
- if (Array.isArray(n.materialList)) {
- n.materialList = n.materialList.map((item: any) => {
- index++
- const materialRefs = item.materialRefs
- ? item.materialRefs
- : []
- const materialMusicId =
- materialRefs.length > 0 ? materialRefs[0].resourceId : null
- return {
- ...item,
- materialMusicId,
- content: item.content,
- knowledgePointId: [item.knowledgePointId],
- materialId: item.id,
- id: index + '',
- typeCode: item.typeCode || item.type
- }
- })
- }
- if (Array.isArray(n.children)) {
- n.children = n.children.map((cn: any) => {
- cn.materialList = cn.materialList.map((item: any) => {
- index++
- const materialRefs = item.materialRefs
- ? item.materialRefs
- : []
- const materialMusicId =
- materialRefs.length > 0
- ? materialRefs[0].resourceId
- : null
- return {
- ...item,
- materialMusicId,
- content: item.content,
- knowledgePointId: [n.id, item.knowledgePointId],
- materialId: item.id,
- id: index + '',
- typeCode: item.typeCode || item.type
- }
- })
- return cn
- })
- }
- return n
- }
- )
- console.log(data.knowledgePointList, 'data.knowledgePointList')
- getItemList()
- }
- return true
- } catch (error) {
- console.log(error)
- }
- }
- const onTitleTip = (type: "phaseGoals" | "checkItem", text: string) => {
- handleStop()
- popupData.pointOpen = true
- popupData.pointContent = text
- if(type === "checkItem") {
- popupData.pointTitle = '检查事项'
- } else if(type === "phaseGoals") {
- popupData.pointTitle = '阶段目标'
- }
- }
- // ifram事件处理
- const iframeHandle = (ev: MessageEvent) => {
- console.log('headerTogge', ev)
- if (ev.data?.api === 'headerTogge') {
- activeData.model =
- ev.data.show || (ev.data.playState == 'play' ? false : true)
- }
- }
- //录屏时间触发
- const handleLimitScreenRecord = async () => {
- const result = await promisefiyPostMessage({
- api: 'getDeviceStatus',
- content: { type: 'video' }
- })
- const { status } = result?.content || {}
- if (status == '1') {
- data.itemList.forEach((item: any) => (item.autoPlay = false))
- handleStop()
- // 处理事件 - 事件事件后加载的
- checkVideoPlay()
- Dialog.alert({
- title: '温馨提示',
- message: '课件内容请勿录屏',
- beforeClose: () => {
- return new Promise(resolve => {
- promisefiyPostMessage({
- api: 'getDeviceStatus',
- content: { type: 'video' }
- }).then((res: any) => {
- const content = res.content
- if (content?.status == '1') {
- const activeItem = data.itemList[popupData.activeIndex]
- togglePlay(activeItem, false)
- resolve(false)
- } else {
- const activeItem = data.itemList[popupData.activeIndex]
- togglePlay(activeItem, true)
- resolve(true)
- }
- })
- })
- }
- })
- }
- }
- // 切换播放
- const togglePlay = (m: any, isPlay: boolean) => {
- if (isPlay) {
- m.videoEle?.play()
- } else {
- m.videoEle?.pause()
- }
- }
- let timers: any = null
- const checkVideoPlay = () => {
- const activeVideoRef = data.videoItemRef?.getPlyrRef()
- if (activeVideoRef) {
- timers = setInterval(() => {
- if (!activeVideoRef.paused()) {
- activeVideoRef.pause()
- clearInterval(timers)
- }
- activeVideoRef.pause()
- }, 100)
- }
- setTimeout(() => {
- clearInterval(timers)
- }, 3000)
- }
- // 获取支付渠道
- const sysParamConfig = async () => {
- try {
- const res = await request.get(
- apiSuffix.value + '/sysConfig/queryByParamName',
- {
- params: {
- paramName: 'disable_screen_recording_flag'
- }
- }
- )
- data.disableScreenRecordingFlag = res.data.paramValue || ''
- } catch {
- //
- }
- }
- const getRefLevel = async (id?: any) => {
- try {
- const res = await request.post(apiSuffix.value + '/tenantAlbumMusic/refLevel', {
- data: {
- lessonCoursewareDetailId: id || route.query.id
- }
- })
- data.refLevelList = res.data || []
- return true
- } catch {
- //
- }
- }
- onMounted(async () => {
- await sysParamConfig()
- // 只有老师端才有课程类型
- if(baseState.platformType === "TEACHER") {
- await getRefLevel()
- }
- await getDetail()
- // getCourseSchedule();
- window.addEventListener('message', iframeHandle)
- if (data.disableScreenRecordingFlag === '1') {
- // 禁止录屏 ios
- listenerMessage('setVideoPlayer', result => {
- if (result?.content?.status == 'pause') {
- handleLimitScreenRecord()
- }
- })
- // 禁止录屏 安卓
- postMessage({
- api: 'limitScreenRecord',
- content: {
- type: 1
- }
- })
- }
- })
- onBeforeUnmount(() => {
- if (data.disableScreenRecordingFlag === '1') {
- // 取消 禁止录屏
- postMessage({
- api: 'limitScreenRecord',
- content: {
- type: 0
- }
- })
- }
- })
- const playRef = ref()
- // 返回
- const goback = () => {
- try {
- playRef.value?.handleOut()
- } catch (error) {
- console.log(error)
- }
- postMessage({ api: 'back' })
- }
- const popupData = reactive({
- pointOpen: false,
- pointContent: "",
- pointTitle: "",
- coursewareOpen: false,
- open: false,
- activeIndex: 0,
- playIndex: 0,
- tabActive: '',
- tabName: '',
- itemActive: '',
- itemName: '',
- guideOpen: false,
- toolOpen: false // 工具弹窗控制
- })
- const stopVideo = (el: HTMLVideoElement) => {
- return new Promise(resolve => {
- if (el.paused) return resolve(true)
- el.onpause = () => {
- console.log('暂停')
- resolve(true)
- }
- el.pause()
- })
- }
- /**停止所有的播放 */
- const handleStop = async () => {
- const videos = document.querySelectorAll('video')
- for (let i = 0; i < videos.length; i++) {
- const videoEle = videos[i] as HTMLVideoElement
- await stopVideo(videoEle)
- }
- console.log('视频暂停完成')
- data.itemList.forEach((item: any) => {
- if (item.typeCode === 'SONG') {
- item.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)
- Toast.clear()
- activeData.timer = setTimeout(() => {
- activeData.model = false
- }, 4000)
- }
- /** 立即收起所有的模态框 */
- const clearModel = () => {
- clearTimeout(activeData.timer)
- Toast.clear()
- activeData.model = false
- }
- const toggleModel = (type = true) => {
- activeData.model = type
- }
- // 去点名,签退
- const gotoRollCall = (pageTag: string) => {
- postMessage({
- api: 'open_app_page',
- content: {
- action: 'app',
- pageTag: pageTag,
- url: '',
- params: JSON.stringify({ courseId: route.query.courseId })
- }
- })
- }
- // 双击
- const handleDbClick = () => {
- if (activeVideoItem.value.typeCode === 'VIDEO') {
- const activeVideoRef = data.videoItemRef?.getPlyrRef()
- if (activeVideoRef) {
- if (activeVideoRef.paused()) {
- activeVideoRef.play()
- } else {
- activeVideoRef.pause()
- Toast('已暂停')
- }
- }
- }
- }
- const effectIndex = ref(0)
- 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 = async (index: number) => {
- // 如果是当前正在播放 或者是视频最后一个
- if (popupData.activeIndex == index) return
- await handleStop()
- data.animationState = 'start'
- data.videoState = 'init'
- clearTimeout(acitveTimer.value)
- checkedAnimation(popupData.activeIndex, index)
- nextTick(() => {
- popupData.activeIndex = index
- acitveTimer.value = setTimeout(
- () => {
- popupData.playIndex = index
- const item = data.itemList[index]
- if (item) {
- popupData.tabActive = item.knowledgePointId
- popupData.itemActive = item.id
- popupData.itemName = item.name
- popupData.tabName = item.tabName
- if (item.typeCode == 'SONG') {
- activeData.model = true
- }
- }
- requestAnimationFrame(() => {
- const _effectIndex = effectIndex.value + 1
- effectIndex.value =
- _effectIndex >= effects.length - 1 ? 0 : _effectIndex
- if (item && item.typeCode === 'VIDEO') {
- // 自动播放下一个视频
- clearTimeout(activeData.timer)
- Toast.clear()
- item.autoPlay = true
- data.animationState = 'end'
- }
- })
- },
- activeData.isAnimation ? 850 : 0
- )
- })
- }
- /** 是否有转场动画 */
- const checkedAnimation = (index: number, nextIndex?: number) => {
- nextIndex = nextIndex ? nextIndex : index + 1
- 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 = (type: string) => {
- if (type === 'up') {
- handleSwipeChange(popupData.activeIndex - 1)
- } else {
- handleSwipeChange(popupData.activeIndex + 1)
- }
- }
- /** 弹窗关闭 */
- const handleClosePopup = () => {
- const item = data.itemList[popupData.activeIndex]
- if (item?.typeCode == 'VIDEO' && !item.videoEle?.paused) {
- setModelOpen()
- }
- }
- /** 教学数据 */
- const studyData = reactive({
- type: '' as ToolType,
- penShow: false
- })
- /** 打开教学工具 */
- const openStudyTool = (item: ToolItem) => {
- const activeItem = data.itemList[popupData.activeIndex]
- // 暂停视频和曲谱的播放
- if (activeItem.typeCode === 'VIDEO' && activeItem.videoEle) {
- activeItem.videoEle.pause()
- }
- if (activeItem.typeCode === 'SONG') {
- activeItem.iframeRef?.contentWindow?.postMessage(
- { api: 'setPlayState' },
- '*'
- )
- }
- clearModel()
- popupData.toolOpen = false
- studyData.type = item.type
- switch (item.type) {
- case 'pen':
- studyData.penShow = true
- break
- }
- }
- // 白板的批注打开时暂停播放
- watch(
- () => [whitePenShow.value, penShow.value],
- () => {
- if (whitePenShow.value || penShow.value) {
- handleStop()
- }
- }
- )
- // 是否收起
- watch(
- () => activeData.model,
- () => {
- if (activeData.model) {
- isPlay.value = false
- } else {
- isPlay.value = true
- toolOpen.value = false
- }
- }
- )
- /** 关闭教学工具 */
- const closeStudyTool = () => {
- studyData.type = 'init'
- toggleModel()
- }
- const activeVideoItem = computed(() => {
- const item = data.itemList[popupData.activeIndex]
- if (
- item &&
- item.typeCode &&
- item.typeCode.toLocaleUpperCase() === 'VIDEO'
- ) {
- return item
- }
- return {}
- })
- let closeModelTimer: any = null
- return () => (
- <div id="playContent" class={styles.playContent}>
- <div
- class={styles.coursewarePlay}
- style={{ width: parentContainer.width }}
- onClick={() => {
- clearTimeout(closeModelTimer)
- clearTimeout(activeData.timer)
- Toast.clear()
- if (Date.now() - activeData.nowTime < 300) {
- handleDbClick()
- return
- }
- activeData.nowTime = Date.now()
- closeModelTimer = setTimeout(() => {
- activeData.model = !activeData.model
- }, 300)
- }}
- >
- <div class={styles.wraps}>
- <div
- style={
- activeVideoItem.value.typeCode &&
- data.animationState === 'end' &&
- data.videoState === 'play'
- ? {
- zIndex: 15,
- opacity: 1
- }
- : { opacity: 0, zIndex: -1, pointerEvents: "none" }
- }
- class={styles.itemDiv}
- >
- <VideoPlay
- ref={(el: any) => (data.videoItemRef = el)}
- item={activeVideoItem.value}
- activeModel={activeData.model}
- onPlay={() => {
- data.videoState = 'play'
- data.animationState = 'end'
- if(whitePenShow.value || penShow.value || popupData.coursewareOpen || popupData.open || popupData.guideOpen || popupData.pointOpen) {
- handleStop()
- }
- }}
- onLoadedmetadata={(videoItem: any) => {
- data.videoState = 'play'
- activeVideoItem.value.videoEle = videoItem
- if (!activeVideoItem.value.isprepare) {
- activeVideoItem.value.isprepare = true
- }
- }}
- onPause={() => {
- clearTimeout(activeData.timer)
- // activeData.model = true
- }}
- onEnded={async () => {
- const _index = popupData.activeIndex + 1
- if (_index < data.itemList.length) {
- handleSwipeChange(_index)
- }
- }}
- onError={() => {
- // 视屏异常
- activeVideoItem.value.error = true
- }}
- />
- </div>
- {data.itemList.map((m: any, mIndex: number) => {
- const isRenderItem = Math.abs(popupData.activeIndex - mIndex) < 2
- const isRender = Math.abs(popupData.playIndex - mIndex) < 2
- // 判断是否是当前选中的元素
- const activeEle = popupData.playIndex === mIndex ? true : false
- return isRenderItem ? (
- <div
- key={'index' + mIndex}
- data-id={'data' + mIndex}
- class={[
- styles.itemDiv,
- activeEle && styles.itemActive,
- activeData.isAnimation && styles.acitveAnimation,
- isRenderItem ? styles.show : styles.hide
- ]}
- style={
- mIndex < popupData.activeIndex
- ? effects[effectIndex.value].prev
- : mIndex > popupData.activeIndex
- ? effects[effectIndex.value].next
- : {}
- }
- >
- <Transition name="van-fade">
- {m.typeCode === 'VIDEO' &&
- data.animationState !== 'end' &&
- data.videoState != 'play' && (
- <div class={styles.loadWrap}>
- <Vue3Lottie animationData={playLoadData}></Vue3Lottie>
- </div>
- )}
- </Transition>
- {isRender && m.typeCode === 'IMG' && (
- <>
- <img src={m.content} />
- {m.materialMusicId && (
- <div
- class={[
- styles.goPractice,
- activeData.model ? '' : styles.hide
- ]}
- onClick={(e: any) => {
- // 去云练习完整版
- e.stopPropagation()
- musicBuy({ id: m.materialMusicId }, () => {}, {
- setting: JSON.stringify({
- feeType: 'FREE'
- })
- })
- }}
- ></div>
- )}
- </>
- )}
- {isRender && m.typeCode === 'SONG' && (
- <MusicScore
- activeModel={activeData.model}
- data-vid={m.id}
- music={m}
- onSetIframe={(el: any) => {
- m.iframeRef = el
- }}
- />
- )}
- </div>
- ) : (
- ''
- )
- })}
- </div>
- {/* <Transition name="right">
- {activeData.model && (
- <div
- class={styles.rightFixedBtns}
- onClick={(e: Event) => {
- e.stopPropagation()
- clearTimeout(activeData.timer)
- }}
- >
- <div class={styles.btnsWrap}>
- <div
- class={[styles.fullBtn, styles.point]}
- onClick={() => (popupData.open = true)}
- >
- <img src={iconMenu} />
- <span>知识点</span>
- </div>
- </div>
- <div class={[styles.btnsWrap, styles.btnsBottom]}>
- {data.isCourse && (
- <>
- <div
- class={styles.fullBtn}
- onClick={() => gotoRollCall('student_roll_call')}
- >
- <img src={iconDian} />
- <span>点名</span>
- </div>
- <div
- class={styles.fullBtn}
- onClick={() => gotoRollCall('sign_out')}
- >
- <img src={iconPoint} />
- <span>签退</span>
- </div>
- </>
- )}
- </div>
- </div>
- )}
- </Transition> */}
- <Transition name="left">
- {activeData.model && (
- <div
- class={styles.leftFixedBtns}
- onClick={(e: Event) => e.stopPropagation()}
- >
- <div class={[styles.btnsWrap, styles.prePoint]}>
- {baseState.platformType === "TEACHER" && <div class={styles.fullBtn} onClick={() => {
- handleStop()
- popupData.coursewareOpen = true
- }}>
- <img src={iconCourseType} />
- </div>}
-
- <div class={styles.fullBtn} onClick={() => {
- handleStop()
- popupData.open = true
- }}>
- <img src={iconMenu} />
- {/* <span>知识点</span> */}
- </div>
-
- <div
- class={[styles.fullBtn, !(popupData.activeIndex != 0) && styles.disabled]}
- onClick={() => {
- if(popupData.activeIndex != 0) handlePreAndNext('up')
- }}
- >
- <img src={iconUp} />
- {/* <span style={{ textAlign: 'center' }}>上一个</span> */}
- </div>
- <div
- class={[styles.fullBtn, !(popupData.activeIndex != data.itemList.length - 1) && styles.disabled]}
- onClick={() => {
- if(popupData.activeIndex != data.itemList.length - 1) handlePreAndNext('down')
- }}
- >
- {/* <span style={{ textAlign: 'center' }}>下一个</span> */}
- <img src={iconDown} />
- </div>
- </div>
- </div>
- )}
- </Transition>
- </div>
- <div
- style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
- id="coursePlayHeader"
- class={styles.headerContainer}
- ref={headeRef}
- >
- <div class={styles.backBtn}>
- <Icon name={iconBack} onClick={() => {
- goback()
- }} />
- <div class={styles.titleSection}>
- <div class={styles.title}>{popupData.tabName}</div>
- <div class={styles.titleContent}>
- <p>{data.itemList[popupData.activeIndex]?.name}</p>
- {data.detail?.lessonTargetDesc ? <span onClick={() => onTitleTip('phaseGoals', data.detail?.lessonTargetDesc)}>阶段目标</span>: ""}
- {data.itemList[popupData.activeIndex]?.checkItem ? <span onClick={() => onTitleTip('checkItem', data.itemList[popupData.activeIndex]?.checkItem)}>检查事项</span> : ""}
- </div>
- </div>
- </div>
- {state.platformType === 'TEACHER' && (
- <div
- class={styles.headRight}
- onClick={(e: Event) => {
- e.stopPropagation()
- clearTimeout(activeData.timer)
- }}
- >
- <div class={styles.rightBtn} onClick={() => {
- handleStop()
- popupData.guideOpen = true
- }}>
- <img src={iconTouping} />
- </div>
- </div>
- )}
- </div>
- {/* <div
- style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
- id="coursePlayHeader"
- class={styles.headerContainer}
- ref={headeRef}
- >
- <div class={styles.backBtn} onClick={() => goback()}>
- <Icon name={iconBack} />
- </div>
- <div
- class={styles.menu}
- onClick={() => {
- const _effectIndex = effectIndex.value + 1
- effectIndex.value =
- _effectIndex >= effects.length - 1 ? 0 : _effectIndex
- setModelOpen()
- }}
- >
- {popupData.tabName}
- </div>
-
- </div> */}
- {/* 更多弹窗 */}
- <Popup
- class={styles.popupMore}
- overlayClass={styles.overlayClass}
- position="right"
- round
- v-model:show={popupData.toolOpen}
- onClose={handleClosePopup}
- >
- <Tool onHandleTool={openStudyTool} />
- </Popup>
- <Popup
- class={[styles.popup, styles.popupCoursewarePlay]}
- overlayClass={styles.overlayClass}
- position="right"
- round
- v-model:show={popupData.open}
- onClose={handleClosePopup}
- >
- <Points
- data={data.knowledgePointList}
- tabActive={popupData.tabActive}
- itemActive={popupData.itemActive}
- onHandleSelect={(res: any) => {
- // onChangeSwiper('change', res.itemActive)
- popupData.open = false
- toggleMaterial(res.itemActive)
- }}
- />
- </Popup>
- <Popup
- class={[styles.popup, styles.popupCoursewarePlay]}
- overlayClass={styles.overlayClass}
- position="right"
- round
- v-model:show={popupData.coursewareOpen}
- onClose={handleClosePopup}>
- {/* 课件类型 */}
- <CoursewareType list={data.refLevelList} onConfirm={async (item: any) => {
- // 判断是否为当前课程类型
- if(data.currentId === item.id) {
- return
- }
- data.currentId = item.id;
- const n = await getDetail(item.id);
- const s = await getRefLevel(item.id);
- if(n && s) {
- popupData.coursewareOpen = false;
- popupData.activeIndex = 0;
- nextTick(() => {
- popupData.open = true
- })
- } else {
- if(!isOnline.value) {
- Toast('网络异常')
- }
- }
- }} />
- </Popup>
- <Popup
- class={[styles.popup, styles.popupCoursewarePlay]}
- overlayClass={styles.overlayClass}
- position="right"
- round
- v-model:show={popupData.guideOpen}
- onClose={handleClosePopup}
- >
- <OGuide />
- </Popup>
- <Popup
- class={[styles.popup, styles.popupPoint]}
- round
- style={{ background: 'transparent !important' }}
- v-model:show={popupData.pointOpen}
- onClose={handleClosePopup}>
- <CoursewareTips onClose={() => {
- popupData.pointOpen = false
- }} content={popupData.pointContent} titleName={popupData.pointTitle} />
- </Popup>
- <GlobalTools />
- </div>
- )
- }
- })
|