|
@@ -1,5 +1,14 @@
|
|
|
-import { Icon, Popup, Swipe, SwipeItem, Tab, Tabs } from 'vant'
|
|
|
-import { defineComponent, onMounted, reactive, nextTick, onUnmounted, ref } from 'vue'
|
|
|
+import { Button, Icon, Popup, Swipe, SwipeItem, Tab, Tabs } from 'vant'
|
|
|
+import {
|
|
|
+ defineComponent,
|
|
|
+ onMounted,
|
|
|
+ reactive,
|
|
|
+ nextTick,
|
|
|
+ onUnmounted,
|
|
|
+ ref,
|
|
|
+ watch,
|
|
|
+ Transition
|
|
|
+} from 'vue'
|
|
|
import iconBack from './image/back.svg'
|
|
|
import styles from './index.module.less'
|
|
|
import Plyr from 'plyr'
|
|
@@ -16,7 +25,6 @@ import Points from './component/points'
|
|
|
export default defineComponent({
|
|
|
name: 'CoursewarePlay',
|
|
|
setup() {
|
|
|
- const isTouch = ref(false)
|
|
|
const handleInit = () => {
|
|
|
postMessage({
|
|
|
api: 'setRequestedOrientation',
|
|
@@ -57,7 +65,9 @@ export default defineComponent({
|
|
|
const data = reactive({
|
|
|
detail: null,
|
|
|
active: '',
|
|
|
- knowledgePointList: [] as any
|
|
|
+ knowledgePointList: [] as any,
|
|
|
+ showHead: true,
|
|
|
+ players: [] as any
|
|
|
})
|
|
|
const getDetail = async () => {
|
|
|
try {
|
|
@@ -82,12 +92,12 @@ export default defineComponent({
|
|
|
}
|
|
|
const videoInit = () => {
|
|
|
console.log(document.querySelectorAll('.player'))
|
|
|
- const player = Plyr.setup('.player', {
|
|
|
+ data.players = Plyr.setup('.player', {
|
|
|
debug: false,
|
|
|
ratio: '16:9',
|
|
|
controls: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions']
|
|
|
})
|
|
|
- console.log('🚀 ~ player', player)
|
|
|
+ console.log('🚀 ~ player', data.players)
|
|
|
}
|
|
|
onMounted(() => {
|
|
|
handleInit()
|
|
@@ -99,7 +109,14 @@ export default defineComponent({
|
|
|
}
|
|
|
// 所有的切换
|
|
|
const handleChange = () => {
|
|
|
- console.log('切换了')
|
|
|
+ // console.log('切换了')
|
|
|
+ const iframes = document.querySelectorAll('.musicIframe')
|
|
|
+ Array.from(iframes).map((f: any) => {
|
|
|
+ f.contentWindow.postMessage({ api: 'setPlayState' }, '*')
|
|
|
+ })
|
|
|
+ data.players.forEach((p: any) => {
|
|
|
+ p.stop()
|
|
|
+ })
|
|
|
}
|
|
|
onUnmounted(() => {
|
|
|
postMessage({
|
|
@@ -124,60 +141,80 @@ export default defineComponent({
|
|
|
|
|
|
const popupData = reactive({
|
|
|
open: false,
|
|
|
- active: '',
|
|
|
- knowledgeId: '',
|
|
|
- materialId: ''
|
|
|
+ active: ''
|
|
|
})
|
|
|
+ // 监听切换
|
|
|
+ watch(
|
|
|
+ () => popupData.active,
|
|
|
+ () => {
|
|
|
+ console.log(data.active, '监听切换')
|
|
|
+ handleChange()
|
|
|
+ const knowledge = data.knowledgePointList.find((n: any) => n.id === data.active)
|
|
|
+ if (knowledge && knowledge?.materialList[knowledge.index]) {
|
|
|
+ // 如果是曲谱,隐藏头部
|
|
|
+ if (knowledge.materialList[knowledge.index]?.type === 'SONG') {
|
|
|
+ data.showHead = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.showHead = true
|
|
|
+ }
|
|
|
+ )
|
|
|
return () => (
|
|
|
<div class={styles.coursewarePlay}>
|
|
|
- <div class={styles.headerContainer}>
|
|
|
- <div class={styles.backBtn} onClick={() => goback()}>
|
|
|
- <Icon name={iconBack} />
|
|
|
- 返回
|
|
|
- </div>
|
|
|
- <div class={styles.menu}>
|
|
|
- <Tabs
|
|
|
- v-model:active={data.active}
|
|
|
- ellipsis={false}
|
|
|
- onChange={() => {
|
|
|
- const knowledge = data.knowledgePointList.find((_: any) => _.id === data.active)
|
|
|
- popupData.active = `${data.active}-${knowledge?.materialList?.[knowledge.index]?.id}`
|
|
|
- console.log("🚀 ~ popupData.active", popupData.active)
|
|
|
- handleChange()
|
|
|
- }}
|
|
|
- >
|
|
|
- {{
|
|
|
- default: () => {
|
|
|
- return data.knowledgePointList.map((n: any) => {
|
|
|
- return <Tab title={n.name} name={n.id}></Tab>
|
|
|
- })
|
|
|
- }
|
|
|
- // 'nav-right': () => <div style={{width: '40%'}} class={styles.menuLine}></div>
|
|
|
- }}
|
|
|
- </Tabs>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <Transition name='top'>
|
|
|
+ {data.showHead && (
|
|
|
+ <div class={styles.headerContainer}>
|
|
|
+ <div class={styles.backBtn} onClick={() => goback()}>
|
|
|
+ <Icon name={iconBack} />
|
|
|
+ 返回
|
|
|
+ </div>
|
|
|
+ <div class={styles.menu}>
|
|
|
+ <Tabs
|
|
|
+ v-model:active={data.active}
|
|
|
+ ellipsis={false}
|
|
|
+ onChange={() => {
|
|
|
+ const knowledge = data.knowledgePointList.find((_: any) => _.id === data.active)
|
|
|
+ popupData.active = `${data.active}-${
|
|
|
+ knowledge?.materialList?.[knowledge.index]?.id
|
|
|
+ }`
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ default: () => {
|
|
|
+ return data.knowledgePointList.map((n: any) => {
|
|
|
+ return <Tab title={n.name} name={n.id}></Tab>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 'nav-right': () => <div style={{width: '40%'}} class={styles.menuLine}></div>
|
|
|
+ }}
|
|
|
+ </Tabs>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ </Transition>
|
|
|
+
|
|
|
<Tabs class={styles.tabsContent} animated lazyRender={false} v-model:active={data.active}>
|
|
|
{data.knowledgePointList.map((item: any) => {
|
|
|
return (
|
|
|
<Tab name={item.id}>
|
|
|
<Swipe
|
|
|
style={{ height: '100vh' }}
|
|
|
+ showIndicators={false}
|
|
|
loop={false}
|
|
|
+ initialSwipe={item.index}
|
|
|
vertical
|
|
|
lazyRender={false}
|
|
|
onChange={(val: any) => {
|
|
|
item.index = val
|
|
|
popupData.active = `${item.id}-${item?.materialList?.[item.index]?.id}`
|
|
|
- console.log("🚀 ~ popupData.active", popupData.active)
|
|
|
- handleChange()
|
|
|
}}
|
|
|
>
|
|
|
{Array.isArray(item?.materialList) &&
|
|
|
item.materialList.map((m: any) => {
|
|
|
- if (popupData.active === ''){
|
|
|
+ if (popupData.active === '') {
|
|
|
popupData.active = `${item.id}-${m.id}`
|
|
|
- console.log("🚀 ~ popupData", popupData)
|
|
|
+ console.log('🚀 ~ popupData', popupData)
|
|
|
}
|
|
|
return (
|
|
|
<SwipeItem>
|
|
@@ -208,8 +245,24 @@ export default defineComponent({
|
|
|
<img src={iconMenu} />
|
|
|
<span>列表</span>
|
|
|
</div>
|
|
|
- <Popup class={styles.popup} overlayClass={styles.overlayClass} position="left" v-model:show={popupData.open}>
|
|
|
- <Points data={data.knowledgePointList} active={popupData.active} />
|
|
|
+ <Popup
|
|
|
+ class={styles.popup}
|
|
|
+ overlayClass={styles.overlayClass}
|
|
|
+ position="left"
|
|
|
+ v-model:show={popupData.open}
|
|
|
+ >
|
|
|
+ <Points
|
|
|
+ data={data.knowledgePointList}
|
|
|
+ active={popupData.active}
|
|
|
+ onHandleSelect={(res: any) => {
|
|
|
+ data.active = res.id
|
|
|
+ const knowledge = data.knowledgePointList.find((n: any) => n.id === res.id)
|
|
|
+ // console.log(res,knowledge)
|
|
|
+ knowledge && (knowledge.index = res.index)
|
|
|
+ popupData.active = res.active
|
|
|
+ popupData.open = false
|
|
|
+ }}
|
|
|
+ />
|
|
|
</Popup>
|
|
|
</div>
|
|
|
)
|