index.tsx 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. import {
  2. closeToast,
  3. Icon,
  4. Loading,
  5. Popup,
  6. showToast,
  7. Slider,
  8. Swipe,
  9. SwipeInstance,
  10. SwipeItem
  11. } from 'vant'
  12. import {
  13. defineComponent,
  14. onMounted,
  15. reactive,
  16. nextTick,
  17. onUnmounted,
  18. ref,
  19. watch,
  20. Transition,
  21. TransitionGroup
  22. } from 'vue'
  23. import iconBack from './image/back.svg'
  24. import styles from './index.module.less'
  25. import 'plyr/dist/plyr.css'
  26. import request from '@/helpers/request'
  27. import { state } from '@/state'
  28. import { useRoute, useRouter } from 'vue-router'
  29. import { listenerMessage, postMessage, promisefiyPostMessage } from '@/helpers/native-message'
  30. import MusicScore from './component/musicScore'
  31. import iconMenu from './image/icon-menu.svg'
  32. import iconDian from './image/icon-dian.svg'
  33. import iconPoint from './image/icon-point.svg'
  34. import iconLoop from './image/icon-loop.svg'
  35. import iconLoopActive from './image/icon-loop-active.svg'
  36. import iconplay from './image/icon-play.svg'
  37. import iconpause from './image/icon-pause.svg'
  38. import iconUp from './image/icon-up.svg'
  39. import iconDown from './image/icon-down.svg'
  40. import Points from './component/points'
  41. import { browser, getSecondRPM } from '@/helpers/utils'
  42. import { Vue3Lottie } from 'vue3-lottie'
  43. import playLoadData from './datas/data.json'
  44. import { usePageVisibility, useRect } from '@vant/use'
  45. import PlayRecordTime from './playRecordTime'
  46. import dayjs from 'dayjs'
  47. import { Pagination, Navigation, EffectFade, EffectFlip, EffectCreative, Lazy } from 'swiper'
  48. import { Swiper, SwiperSlide } from 'swiper/vue'
  49. import 'swiper/less'
  50. import 'swiper/less/effect-fade'
  51. import 'swiper/less/effect-flip'
  52. import 'swiper/less/effect-creative'
  53. import { handleCheckVip } from '../hook/useFee'
  54. export default defineComponent({
  55. name: 'CoursewarePlay',
  56. setup() {
  57. const pageVisibility = usePageVisibility()
  58. const isPlay = ref(false)
  59. /** 页面显示和隐藏 */
  60. watch(pageVisibility, (value) => {
  61. const activeItem = data.itemList[popupData.activeIndex]
  62. if (activeItem.type != 'VIDEO') return
  63. if (value == 'hidden') {
  64. isPlay.value = !activeItem.paused
  65. handlePaused(activeItem)
  66. } else {
  67. // 页面显示,并且
  68. if (isPlay.value) handlePlay(activeItem)
  69. }
  70. })
  71. /** 设置播放容器 16:9 */
  72. const parentContainer = reactive({
  73. width: '100vw'
  74. })
  75. const setContainer = () => {
  76. let min = Math.min(screen.width, screen.height)
  77. let max = Math.max(screen.width, screen.height)
  78. let width = min * (16 / 9)
  79. if (width > max) {
  80. parentContainer.width = '100vw'
  81. return
  82. } else {
  83. parentContainer.width = width + 'px'
  84. }
  85. }
  86. const handleInit = (type = 0) => {
  87. // postMessage({
  88. // api: 'courseLoading',
  89. // content: {
  90. // show: true,
  91. // type: 'fullscreen'
  92. // }
  93. // })
  94. //设置容器16:9
  95. setContainer()
  96. // 横屏
  97. postMessage({
  98. api: 'setRequestedOrientation',
  99. content: {
  100. orientation: type
  101. }
  102. })
  103. // 头,包括返回箭头
  104. postMessage({
  105. api: 'setTitleBarVisibility',
  106. content: {
  107. status: type
  108. }
  109. })
  110. // 安卓的状态栏
  111. postMessage({
  112. api: 'setStatusBarVisibility',
  113. content: {
  114. isVisibility: type
  115. }
  116. })
  117. // 进入页面设置常量
  118. postMessage({
  119. api: 'keepScreenLongLight',
  120. content: {
  121. isOpenLight: type ? true : false
  122. }
  123. })
  124. }
  125. handleInit()
  126. onUnmounted(() => {
  127. handleInit(1)
  128. window.removeEventListener('message', iframeHandle)
  129. })
  130. const route = useRoute()
  131. const router = useRouter()
  132. const headeRef = ref()
  133. const data = reactive({
  134. detail: null,
  135. knowledgePointList: [] as any,
  136. itemList: [] as any,
  137. showHead: true,
  138. isCourse: false,
  139. isRecordPlay: false
  140. })
  141. const activeData = reactive({
  142. nowTime: 0,
  143. model: true, // 遮罩
  144. videoBtns: true, // 视频
  145. currentTime: 0,
  146. duration: 0,
  147. timer: null as any,
  148. item: null as any
  149. })
  150. // 获取缓存路径
  151. const getCacheFilePath = async (material: any) => {
  152. const res = await promisefiyPostMessage({
  153. api: 'getCourseFilePath',
  154. content: {
  155. url: material.content,
  156. localPath: '',
  157. materialId: material.materialId,
  158. updateTime: material.updateTime,
  159. type: material.type // SONG VIDEO IMAGE
  160. }
  161. })
  162. // console.log('缓存路径返回', res)
  163. return res
  164. }
  165. // 获取当前课程是否签退
  166. const getCourseSchedule = async () => {
  167. if (!route.query.courseId) return
  168. try {
  169. const res = await request.get(
  170. `${state.platformApi}/courseSchedule/detail/${route.query.courseId}`,
  171. {
  172. hideLoading: true
  173. }
  174. )
  175. if (res?.data) {
  176. data.isCourse =
  177. res.data.status === 'ING' && state.platformType == 'TEACHER' ? true : false
  178. // data.isRecordPlay = Date.now() > dayjs(res.data.startTime).valueOf()
  179. }
  180. } catch (e) {
  181. console.log(e)
  182. }
  183. }
  184. const getItemList = async () => {
  185. const list: any = []
  186. const browserInfo = browser()
  187. for (let i = 0; i < data.knowledgePointList.length; i++) {
  188. const item = data.knowledgePointList[i]
  189. const itemLength = item.materialList.length - 1
  190. for (let j = 0; j < item.materialList.length; j++) {
  191. const material = item.materialList[j]
  192. //请求本地缓存
  193. if (browserInfo.isApp && ['VIDEO', 'IMG'].includes(material.type)) {
  194. const localData = await getCacheFilePath(material)
  195. if (localData?.content?.localPath) {
  196. material.url = material.content
  197. material.content = localData.content.localPath
  198. // console.log("🚀 ~ material", material)
  199. }
  200. }
  201. let videoItem = {}
  202. if (material.type === 'VIDEO') {
  203. videoItem = {
  204. currentTime: 0,
  205. duration: 0,
  206. progress: 0,
  207. paused: true,
  208. loop: false,
  209. videoEle: null,
  210. timer: null,
  211. playModel: false,
  212. isprepare: false,
  213. isDrage: false,
  214. muted: true // 是否静音
  215. }
  216. }
  217. list.push({
  218. ...material,
  219. ...videoItem,
  220. iframeRef: null,
  221. tabName: item.name,
  222. isLast: j === itemLength, // 当前知识点
  223. autoPlay: false, //加载完成是否自动播放
  224. display: false
  225. })
  226. }
  227. }
  228. let item: any = null
  229. if (route.query.kId) {
  230. item = list.find((n: any) => n.materialId == route.query.kId)
  231. const _firstIndex = list.findIndex((n: any) => n.materialId == route.query.kId)
  232. popupData.firstIndex = _firstIndex > -1 ? _firstIndex : 0
  233. }
  234. item = item ? item : list[0] || {}
  235. if (item) {
  236. popupData.tabName = item.tabName
  237. popupData.tabActive = item.knowledgePointId
  238. popupData.itemActive = item.id
  239. popupData.itemName = item.name
  240. popupData.activeIndex = popupData.firstIndex
  241. item.autoPlay = true
  242. item.muted = true
  243. item.display = true
  244. }
  245. // console.log('🚀 ~ list', list)
  246. data.itemList = list
  247. nextTick(() => {
  248. postMessage({
  249. api: 'courseLoading',
  250. content: {
  251. show: false,
  252. type: 'fullscreen'
  253. }
  254. })
  255. })
  256. // setTimeout(() => {
  257. // }, 300)
  258. }
  259. const getDetail = async () => {
  260. try {
  261. const res: any = await request.get(
  262. state.platformApi + `/lessonCoursewareDetail/detail/${route.query.id}`,
  263. {
  264. hideLoading: true
  265. }
  266. )
  267. if (Array.isArray(res?.data)) {
  268. data.detail = res.data
  269. }
  270. if (Array.isArray(res?.data?.knowledgePointList)) {
  271. let index = 0
  272. data.knowledgePointList = res.data.knowledgePointList.map((n: any) => {
  273. if (Array.isArray(n.materialList)) {
  274. n.materialList = n.materialList.map((item: any) => {
  275. index++
  276. return {
  277. ...item,
  278. materialId: item.id,
  279. id: index + ''
  280. }
  281. })
  282. }
  283. return n
  284. })
  285. getItemList()
  286. }
  287. } catch (error) {}
  288. }
  289. // ifram事件处理
  290. const iframeHandle = (ev: MessageEvent) => {
  291. if (ev.data?.api === 'headerTogge') {
  292. // console.log("🚀 ~ ev.data", ev.data)
  293. activeData.model = ev.data.show || (ev.data.playState == 'play' ? true : false)
  294. }
  295. }
  296. const swiperDom = ref()
  297. onMounted(() => {
  298. const hasVip = handleCheckVip()
  299. console.error("🚀 ~ hasVip", hasVip)
  300. if (!hasVip) return;
  301. getDetail()
  302. getCourseSchedule()
  303. window.addEventListener('message', iframeHandle)
  304. })
  305. const playRef = ref()
  306. // 返回
  307. const goback = () => {
  308. try {
  309. playRef.value?.handleOut()
  310. } catch (error) {}
  311. if (route.query.source == 'my-course') {
  312. router.back()
  313. return
  314. }
  315. postMessage({ api: 'goBack' })
  316. }
  317. const swipeRef = ref<SwipeInstance>()
  318. const popupData = reactive({
  319. firstIndex: 0,
  320. open: false,
  321. activeIndex: 0,
  322. tabActive: '',
  323. tabName: '',
  324. itemActive: '',
  325. itemName: ''
  326. })
  327. /**停止所有的播放 */
  328. const handleStop = () => {
  329. const activeItem = data.itemList[popupData.activeIndex]
  330. for (let i = 0; i < data.itemList.length; i++) {
  331. const item = data.itemList[i]
  332. // 停止视频播放
  333. if (item.type === 'VIDEO') {
  334. // console.log("🚀 ~ item", item)
  335. if (item?.id != activeItem.id) {
  336. item.currentTime = 0
  337. item.progress = 0
  338. if (item.videoEle) {
  339. item.videoEle.currentTime = 0
  340. item.videoEle.pause()
  341. }
  342. }
  343. }
  344. // 停止曲谱的播放
  345. if (item.type === 'SONG') {
  346. item.iframeRef?.contentWindow?.postMessage({ api: 'setPlayState' }, '*')
  347. item.display = false
  348. }
  349. }
  350. }
  351. // 切换素材
  352. const toggleMaterial = () => {
  353. const index = data.itemList.findIndex((n: any) => n.id == popupData.itemActive)
  354. if (index > -1) {
  355. // swipeRef.value?.swipeTo(index, {
  356. // immediate: true
  357. // })
  358. swiperDom.value?.slideTo(index, 1000)
  359. }
  360. }
  361. /** 延迟收起模态框 */
  362. const setModelOpen = () => {
  363. clearTimeout(activeData.timer)
  364. closeToast()
  365. activeData.timer = setTimeout(() => {
  366. activeData.model = false
  367. }, 4000)
  368. }
  369. // 轮播切换
  370. const handleSwipeChange = (val: any) => {
  371. console.log('轮播切换')
  372. popupData.activeIndex = val
  373. const item = data.itemList[val]
  374. handleStop()
  375. if (item) {
  376. popupData.tabActive = item.knowledgePointId
  377. popupData.itemActive = item.id
  378. popupData.itemName = item.name
  379. popupData.tabName = item.tabName
  380. if (item.type == 'SONG') {
  381. activeData.model = true
  382. item.display = true
  383. }
  384. if (item.type === 'VIDEO') {
  385. // console.log("🚀 ~ item", item)
  386. // 自动播放下一个视频
  387. clearTimeout(activeData.timer)
  388. closeToast()
  389. item.currentTime = 0
  390. item.videoEle && (item.videoEle.currentTime = 0)
  391. nextTick(() => {
  392. item.autoPlay = true
  393. item.videoEle?.play()
  394. })
  395. }
  396. }
  397. }
  398. // 去点名,签退
  399. const gotoRollCall = (pageTag: string) => {
  400. postMessage({
  401. api: 'open_app_page',
  402. content: {
  403. action: 'app',
  404. pageTag: pageTag,
  405. url: '',
  406. params: JSON.stringify({ courseId: route.query.courseId })
  407. }
  408. })
  409. }
  410. // 双击
  411. const handleDbClick = (item: any) => {
  412. // console.log(item)
  413. if (item && item.type === 'VIDEO') {
  414. const videoEle: HTMLVideoElement = item.videoEle
  415. if (videoEle) {
  416. if (videoEle.paused) {
  417. closeToast()
  418. videoEle.play()
  419. } else {
  420. showToast('已暂停')
  421. videoEle.pause()
  422. }
  423. }
  424. }
  425. }
  426. // 暂停播放
  427. const handlePaused = (m: any) => {
  428. m.videoEle?.pause()
  429. m.paused = true
  430. }
  431. // 开始播放
  432. const handlePlay = (m: any) => {
  433. closeToast()
  434. m.videoEle?.play()
  435. }
  436. // 调整播放进度
  437. const handleChangeSlider = (m: any) => {
  438. if (m?.videoEle) {
  439. // console.log('进度条', m.progress)
  440. m.currentTime = m.duration * (m.progress / 100)
  441. m.videoEle.currentTime = m.currentTime
  442. }
  443. }
  444. //当前视频播放完
  445. const handleEnded = (m: any) => {
  446. // console.log(m)
  447. if (popupData.activeIndex != data.itemList.length - 1) {
  448. swiperDom.value.slideNext(800)
  449. // setTimeout(() => {
  450. // swipeRef.value?.next()
  451. // ;(document.querySelector('.swiper-button-next') as any)?.click()
  452. // swiperDom.value.navigation.nextEl.click()
  453. // swiperDom.value.slideNext(800)
  454. // }, 300)
  455. }
  456. }
  457. const effects = [
  458. {
  459. prev: {
  460. shadow: true,
  461. translate: [0, 0, -400]
  462. },
  463. next: {
  464. translate: ['100%', 0, 0]
  465. }
  466. },
  467. {
  468. prev: {
  469. shadow: true,
  470. translate: ['-120%', 0, -500]
  471. },
  472. next: {
  473. shadow: true,
  474. translate: ['120%', 0, -500]
  475. }
  476. },
  477. {
  478. prev: {
  479. shadow: true,
  480. translate: ['-20%', 0, -1]
  481. },
  482. next: {
  483. translate: ['100%', 0, 0]
  484. }
  485. },
  486. {
  487. prev: {
  488. shadow: true,
  489. translate: [0, 0, -800],
  490. rotate: [-180, 0, 0]
  491. },
  492. next: {
  493. shadow: true,
  494. translate: [0, 0, -800],
  495. rotate: [180, 0, 0]
  496. }
  497. },
  498. {
  499. prev: {
  500. shadow: true,
  501. translate: ['-125%', 0, -800],
  502. rotate: [0, 0, -90]
  503. },
  504. next: {
  505. shadow: true,
  506. translate: ['125%', 0, -800],
  507. rotate: [0, 0, 90]
  508. }
  509. },
  510. {
  511. prev: {
  512. shadow: true,
  513. origin: 'right center',
  514. translate: ['5%', 0, -200],
  515. rotate: [0, -100, 0]
  516. },
  517. next: {
  518. origin: 'left center',
  519. translate: ['-5%', 0, -200],
  520. rotate: [0, 100, 0]
  521. }
  522. },
  523. {
  524. prev: {
  525. scale: 0.3,
  526. opacity: 0.4
  527. },
  528. next: {
  529. opacity: 0.4,
  530. scale: 0.3
  531. }
  532. }
  533. ]
  534. const swiperType = ref(effects[3])
  535. // 上一个知识点, 下一个知识点
  536. const handlePreAndNext = (type: string) => {
  537. setTimeout(() => {
  538. if (type === 'up') {
  539. // swiperRef.value?.allowSlidePrev()
  540. // ;(document.querySelector('.swiper-button-prev') as any)?.click()
  541. // swiperDom.value.navigation.prevEl.click()
  542. swiperDom.value.slidePrev(800)
  543. } else {
  544. // swiperRef.value?.allowSlideNext()
  545. // ;(document.querySelector('.swiper-button-next') as any)?.click()
  546. // swiperDom.value.navigation.nextEl.click()
  547. // const nextKonwledgeId = data.itemList[popupData.activeIndex + 1].knowledgePointId
  548. // console.log(nextKonwledgeId === popupData.tabActive)
  549. // if (nextKonwledgeId === popupData.tabActive) {
  550. // swiperType.value = effects[2]
  551. // } else {
  552. // swiperType.value = effects[3]
  553. // }
  554. swiperDom.value.slideNext(800)
  555. }
  556. }, 400)
  557. }
  558. return () => (
  559. <div class={styles.playContent}>
  560. <div class={styles.coursewarePlay} style={{ width: parentContainer.width }}>
  561. {/* <swiper :modules="modules" :pagination="{ clickable: true }">
  562. <swiper-slide>Slide 1</swiper-slide>
  563. <swiper-slide>Slide 2</swiper-slide>
  564. <swiper-slide>Slide 3</swiper-slide>
  565. </swiper> */}
  566. {/*
  567. 知识点 翻
  568. 素材滑
  569. */}
  570. <Swiper
  571. style={{ height: '100%' }}
  572. effect="creative"
  573. modules={[Pagination, Navigation, EffectFade, EffectFlip, EffectCreative]}
  574. creativeEffect={swiperType.value}
  575. direction="vertical"
  576. navigation
  577. allowTouchMove={false}
  578. onSwiper={(swiper: any) => {
  579. // console.log(swiper, 'index')
  580. swiperDom.value = swiper
  581. }}
  582. onSlideChange={(swiper: any) => {
  583. // console.log(swiper, 'index')
  584. handleSwipeChange(swiper.activeIndex)
  585. }}
  586. >
  587. {data.itemList.map((m: any, mIndex: number) => {
  588. return (
  589. <SwiperSlide class={styles.swipeItem}>
  590. <div
  591. // class={[styles.itemDiv]}
  592. class={[styles.itemDiv]}
  593. onClick={() => {
  594. clearTimeout(activeData.timer)
  595. if (Date.now() - activeData.nowTime < 300) {
  596. handleDbClick(m)
  597. return
  598. }
  599. activeData.nowTime = Date.now()
  600. activeData.timer = setTimeout(() => {
  601. activeData.model = !activeData.model
  602. setModelOpen()
  603. }, 300)
  604. }}
  605. >
  606. {m.type === 'VIDEO' ? (
  607. <>
  608. <video
  609. class={['player']}
  610. playsinline="false"
  611. muted={m.muted}
  612. preload="auto"
  613. // class="player"
  614. data-vid={m.id}
  615. src={m.content}
  616. loop={m.loop}
  617. autoplay={m.autoPlay}
  618. onLoadedmetadata={(e: Event) => {
  619. const videoEle = e.target as unknown as HTMLVideoElement
  620. m.currentTime = videoEle.currentTime
  621. m.duration = videoEle.duration
  622. m.videoEle = videoEle
  623. m.isprepare = true
  624. }}
  625. onTimeupdate={(e: Event) => {
  626. if (!m.isprepare) return
  627. const videoEle = e.target as unknown as HTMLVideoElement
  628. m.currentTime = videoEle.currentTime
  629. m.progress = Number((videoEle.currentTime / m.duration) * 100)
  630. }}
  631. onPlay={() => {
  632. // 播放
  633. m.paused = false
  634. console.log('播放')
  635. setModelOpen()
  636. // 第一次播放
  637. if (m.muted) {
  638. m.muted = false
  639. m.autoPlay = false
  640. }
  641. }}
  642. onPause={() => {
  643. //暂停
  644. clearTimeout(activeData.timer)
  645. m.paused = true
  646. }}
  647. onEnded={() => handleEnded(m)}
  648. >
  649. <source src={m.content} type="video/mp4" />
  650. </video>
  651. {m.muted && (
  652. <div class={styles.loadWrap}>
  653. <Vue3Lottie animationData={playLoadData}></Vue3Lottie>
  654. </div>
  655. )}
  656. <div
  657. style={{ transform: activeData.model ? '' : 'translateY(100%)' }}
  658. class={styles.bottomFixedContainer}
  659. onClick={(e: Event) => {
  660. e.stopPropagation()
  661. setModelOpen()
  662. }}
  663. >
  664. <div style={{ opacity: m.isprepare ? '1' : '0' }}>
  665. <div class={styles.time}>
  666. <span>{getSecondRPM(m.currentTime)}</span>
  667. <span>{getSecondRPM(m.duration)}</span>
  668. </div>
  669. <div class={styles.slider}>
  670. <Slider
  671. onClick={() => setModelOpen()}
  672. buttonSize={16}
  673. step={1}
  674. modelValue={m.progress}
  675. onUpdate:modelValue={(val: any) => {
  676. console.log('val', val)
  677. m.progress = val
  678. handleChangeSlider(m)
  679. }}
  680. onDragStart={(e: Event) => {
  681. // 开始拖动,暂停播放
  682. console.log('开始拖动')
  683. // 如果拖动之前,视频是播放状态,拖动完毕后继续播放
  684. if (!m.paused) {
  685. m.isDrage = true
  686. }
  687. handlePaused(m)
  688. }}
  689. onDragEnd={(e: Event) => {
  690. console.log('结束拖动')
  691. if (m.isDrage) {
  692. m.isDrage = false
  693. handlePlay(m)
  694. }
  695. }}
  696. min={0}
  697. max={100}
  698. />
  699. </div>
  700. </div>
  701. <div class={styles.actions}>
  702. <div class={styles.actionBtn}>
  703. {m.isprepare ? (
  704. <>
  705. {m.paused ? (
  706. <img src={iconplay} onClick={(e: Event) => handlePlay(m)} />
  707. ) : (
  708. <img src={iconpause} onClick={(e: Event) => handlePaused(m)} />
  709. )}
  710. </>
  711. ) : (
  712. <Loading color="#fff" />
  713. )}
  714. {m.loop ? (
  715. <img
  716. src={iconLoopActive}
  717. onClick={(e: Event) => (m.loop = false)}
  718. />
  719. ) : (
  720. <img src={iconLoop} onClick={(e: Event) => (m.loop = true)} />
  721. )}
  722. </div>
  723. <div>{m.name}</div>
  724. </div>
  725. </div>
  726. </>
  727. ) : m.type === 'IMG' ? (
  728. <img src={m.content} />
  729. ) : (
  730. <MusicScore
  731. data-vid={m.id}
  732. music={m}
  733. onSetIframe={(el: any) => {
  734. m.iframeRef = el
  735. }}
  736. />
  737. )}
  738. </div>
  739. </SwiperSlide>
  740. )
  741. })}
  742. </Swiper>
  743. {/* <Swipe
  744. style={{ height: '100%' }}
  745. ref={swipeRef}
  746. showIndicators={false}
  747. loop={false}
  748. duration={0}
  749. // vertical
  750. lazyRender={true}
  751. touchable={false}
  752. initialSwipe={popupData.firstIndex}
  753. onChange={handleSwipeChange}
  754. >
  755. </Swipe> */}
  756. <div
  757. style={{ transform: activeData.model ? '' : 'translateY(-100%)' }}
  758. id="coursePlayHeader"
  759. class={styles.headerContainer}
  760. ref={headeRef}
  761. >
  762. <div class={styles.backBtn} onClick={() => goback()}>
  763. <Icon name={iconBack} />
  764. 返回
  765. </div>
  766. <div class={styles.menu}>{popupData.tabName}</div>
  767. {data.isCourse && <PlayRecordTime ref={playRef} list={data.itemList} />}
  768. </div>
  769. <Transition name="right">
  770. {activeData.model && (
  771. <div class={styles.rightFixedBtns}>
  772. <div
  773. class={styles.fullBtn}
  774. onClick={() => {
  775. clearTimeout(activeData.timer)
  776. popupData.open = true
  777. }}
  778. >
  779. <img src={iconMenu} />
  780. <span>知识点</span>
  781. </div>
  782. {data.isCourse && (
  783. <>
  784. <div
  785. class={[styles.fullBtn, styles.point]}
  786. onClick={() => gotoRollCall('student_roll_call')}
  787. >
  788. <img src={iconDian} />
  789. <span>点名</span>
  790. </div>
  791. <div class={styles.fullBtn} onClick={() => gotoRollCall('sign_out')}>
  792. <img src={iconPoint} />
  793. <span>签退</span>
  794. </div>
  795. </>
  796. )}
  797. </div>
  798. )}
  799. </Transition>
  800. <Transition name="left">
  801. {activeData.model && (
  802. <div class={styles.leftFixedBtns}>
  803. {popupData.activeIndex != 0 && (
  804. <div
  805. class={[styles.fullBtn, styles.prePoint]}
  806. onClick={() => handlePreAndNext('up')}
  807. >
  808. <img src={iconUp} />
  809. <span style={{ textAlign: 'center' }}>上一个</span>
  810. </div>
  811. )}
  812. {popupData.activeIndex != data.itemList.length - 1 && (
  813. <div class={[styles.fullBtn]} onClick={() => handlePreAndNext('down')}>
  814. <span style={{ textAlign: 'center' }}>下一个</span>
  815. <img src={iconDown} />
  816. </div>
  817. )}
  818. </div>
  819. )}
  820. </Transition>
  821. <Popup
  822. class={styles.popup}
  823. overlayClass={styles.overlayClass}
  824. position="right"
  825. round
  826. v-model:show={popupData.open}
  827. onClose={() => {
  828. const item = data.itemList[popupData.activeIndex]
  829. if (item?.type == 'VIDEO') {
  830. setModelOpen()
  831. }
  832. }}
  833. >
  834. <Points
  835. data={data.knowledgePointList}
  836. tabActive={popupData.tabActive}
  837. itemActive={popupData.itemActive}
  838. onHandleSelect={(res: any) => {
  839. // console.log(res)
  840. popupData.tabActive = res.tabActive
  841. popupData.itemActive = res.itemActive
  842. popupData.tabName = res.tabName
  843. popupData.open = false
  844. toggleMaterial()
  845. }}
  846. />
  847. </Popup>
  848. </div>
  849. </div>
  850. )
  851. }
  852. })