index.tsx 27 KB

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