|
@@ -3,6 +3,7 @@ import {
|
|
defineComponent,
|
|
defineComponent,
|
|
nextTick,
|
|
nextTick,
|
|
onMounted,
|
|
onMounted,
|
|
|
|
+ onUnmounted,
|
|
reactive,
|
|
reactive,
|
|
ref,
|
|
ref,
|
|
watch
|
|
watch
|
|
@@ -25,7 +26,8 @@ import {
|
|
Sticky,
|
|
Sticky,
|
|
Tag,
|
|
Tag,
|
|
Radio,
|
|
Radio,
|
|
- Toast
|
|
|
|
|
|
+ Toast,
|
|
|
|
+ Picker
|
|
} from 'vant'
|
|
} from 'vant'
|
|
import styles from './index.module.less'
|
|
import styles from './index.module.less'
|
|
// import Item from '../list/item'
|
|
// import Item from '../list/item'
|
|
@@ -61,6 +63,7 @@ import fixedActive from './images/fixed-active.png'
|
|
import Plyr from 'plyr'
|
|
import Plyr from 'plyr'
|
|
import 'plyr/dist/plyr.css'
|
|
import 'plyr/dist/plyr.css'
|
|
import Download from './download'
|
|
import Download from './download'
|
|
|
|
+import { getInstrumentName } from '@/constant/instruments'
|
|
|
|
|
|
export const getAssetsHomeFile = (fileName: string) => {
|
|
export const getAssetsHomeFile = (fileName: string) => {
|
|
const path = `../component/images/${fileName}`
|
|
const path = `../component/images/${fileName}`
|
|
@@ -166,10 +169,17 @@ export default defineComponent({
|
|
// false
|
|
// false
|
|
// )
|
|
// )
|
|
// }
|
|
// }
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ renderStaff()
|
|
|
|
+ })
|
|
} catch (error) {
|
|
} catch (error) {
|
|
isError.value = true
|
|
isError.value = true
|
|
}
|
|
}
|
|
- loading.value = false
|
|
|
|
|
|
+ if (musicDetail.value?.musicSheetType !== 'CONCERT') {
|
|
|
|
+ loading.value = false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
const base64ToBlob = data => {
|
|
const base64ToBlob = data => {
|
|
const arr = data.split(','),
|
|
const arr = data.split(','),
|
|
@@ -298,6 +308,13 @@ export default defineComponent({
|
|
}
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ const showLoading = (e: any) => {
|
|
|
|
+ console.log(e)
|
|
|
|
+ if(e.data?.api === 'musicStaffRender'){
|
|
|
|
+ loading.value = e.data.loading
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
await FetchList()
|
|
await FetchList()
|
|
const { height } = useRect(headers as any)
|
|
const { height } = useRect(headers as any)
|
|
@@ -308,6 +325,11 @@ export default defineComponent({
|
|
if (audioFileUrl.value) {
|
|
if (audioFileUrl.value) {
|
|
initAudio()
|
|
initAudio()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ window.addEventListener('message', showLoading)
|
|
|
|
+ })
|
|
|
|
+ onUnmounted(() => {
|
|
|
|
+ window.removeEventListener('message', showLoading)
|
|
})
|
|
})
|
|
|
|
|
|
const toggleFavorite = async () => {
|
|
const toggleFavorite = async () => {
|
|
@@ -490,6 +512,46 @@ export default defineComponent({
|
|
return
|
|
return
|
|
} catch {}
|
|
} catch {}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ const staffData = reactive({
|
|
|
|
+ open: false,
|
|
|
|
+ iframeSrc: '',
|
|
|
|
+ musicXml: '',
|
|
|
|
+ instrumentName: '',
|
|
|
|
+ iframeRef: null as any,
|
|
|
|
+ partIndex: 0,
|
|
|
|
+ partList: [] as any[]
|
|
|
|
+ })
|
|
|
|
+ /** 渲染五线谱 */
|
|
|
|
+ const renderStaff = () => {
|
|
|
|
+ staffData.iframeSrc = `${location.origin}${location.pathname}osmd/index.html`
|
|
|
|
+ staffData.musicXml = musicDetail.value?.xmlFileUrl || ''
|
|
|
|
+ staffData.partList = musicDetail.value?.background || []
|
|
|
|
+ staffData.instrumentName = getInstrumentName(staffData.partList[staffData.partIndex]?.track)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ const musicIframeLoad = () => {
|
|
|
|
+ const iframeRef: any = document.getElementById('staffIframeRef')
|
|
|
|
+ if (iframeRef && iframeRef.contentWindow.renderXml){
|
|
|
|
+ iframeRef.contentWindow.renderXml(staffData.musicXml, staffData.partIndex)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const resetRender = () => {
|
|
|
|
+ const iframeRef: any = document.getElementById('staffIframeRef')
|
|
|
|
+ if (iframeRef && iframeRef.contentWindow.renderXml){
|
|
|
|
+ iframeRef.contentWindow.resetRender(staffData.partIndex)
|
|
|
|
+ staffData.instrumentName = getInstrumentName(staffData.partList[staffData.partIndex]?.track)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const partColumns = computed(() => {
|
|
|
|
+ return staffData.partList.map((item: any, index: number) => {
|
|
|
|
+ const instrumentName = getInstrumentName(item.track)
|
|
|
|
+ return {
|
|
|
|
+ text: item.track + (instrumentName ? `(${instrumentName})` : ''),
|
|
|
|
+ value: index
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
return () => {
|
|
return () => {
|
|
return (
|
|
return (
|
|
<div class={styles.detail}>
|
|
<div class={styles.detail}>
|
|
@@ -581,60 +643,84 @@ export default defineComponent({
|
|
),
|
|
),
|
|
value: () => (
|
|
value: () => (
|
|
<>
|
|
<>
|
|
- {musicDetail.value?.notation ? (
|
|
|
|
|
|
+ <div class="van-cell__value" style={{display: musicDetail.value?.musicSheetType === 'SINGLE' ? '' : 'none'}}>
|
|
|
|
+ {musicDetail.value?.notation ? (
|
|
|
|
+ <span
|
|
|
|
+ class={styles.download}
|
|
|
|
+ onClick={() => {
|
|
|
|
+ staff.status = true
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <img src={iconChangeStaff} />
|
|
|
|
+ <span>转谱</span>
|
|
|
|
+ </span>
|
|
|
|
+ ) : null}
|
|
<span
|
|
<span
|
|
class={styles.download}
|
|
class={styles.download}
|
|
onClick={() => {
|
|
onClick={() => {
|
|
- staff.status = true
|
|
|
|
|
|
+ if (showImg.length > 0) {
|
|
|
|
+ downloadStatus.value = true
|
|
|
|
+ } else {
|
|
|
|
+ Toast('暂无图片')
|
|
|
|
+ }
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- <img src={iconChangeStaff} />
|
|
|
|
- <span>转谱</span>
|
|
|
|
|
|
+ <img src={iconDownload} />
|
|
|
|
+ <span>下载曲谱</span>
|
|
</span>
|
|
</span>
|
|
- ) : null}
|
|
|
|
|
|
+ </div>
|
|
<span
|
|
<span
|
|
|
|
+ style={{display: musicDetail.value?.musicSheetType === 'CONCERT' ? '' : 'none'}}
|
|
class={styles.download}
|
|
class={styles.download}
|
|
onClick={() => {
|
|
onClick={() => {
|
|
- if (showImg.length > 0) {
|
|
|
|
- downloadStatus.value = true
|
|
|
|
- } else {
|
|
|
|
- Toast('暂无图片')
|
|
|
|
- }
|
|
|
|
|
|
+ staffData.open = true
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- <img src={iconDownload} />
|
|
|
|
- <span>下载曲谱</span>
|
|
|
|
|
|
+ <Icon style={{background: 'rgba(246,246,246,1)', borderRadius: '50%', padding: '4px'}} size="20px" name="exchange" />
|
|
|
|
+ <span>切换乐器</span>
|
|
</span>
|
|
</span>
|
|
|
|
+
|
|
</>
|
|
</>
|
|
)
|
|
)
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
<div class={styles.musicContent}>
|
|
<div class={styles.musicContent}>
|
|
- {/* <iframe
|
|
|
|
- id="containerPrint"
|
|
|
|
- ref="print"
|
|
|
|
- style="width: 540px;page-break-after:always; height: 0;"
|
|
|
|
- src={accompanyUrl.value}
|
|
|
|
- /> */}
|
|
|
|
<p class={styles.musicTitle}>
|
|
<p class={styles.musicTitle}>
|
|
- {musicDetail.value?.musicSheetName}
|
|
|
|
|
|
+ {musicDetail.value?.musicSheetName + (staffData.instrumentName ? `(${staffData.instrumentName})` : '')}
|
|
</p>
|
|
</p>
|
|
- {showImg.length > 0 ? (
|
|
|
|
- <img src={showImg[0]} alt="" class={styles.musicImg} />
|
|
|
|
- ) : loading.value ? (
|
|
|
|
|
|
+ {musicDetail.value?.musicSheetType === 'CONCERT' ? (
|
|
<>
|
|
<>
|
|
- <Vue3Lottie
|
|
|
|
- animationData={AstronautJSON}
|
|
|
|
- class={styles.finch}
|
|
|
|
- ></Vue3Lottie>
|
|
|
|
- <p class={styles.finchLoad}>加载中...</p>
|
|
|
|
|
|
+ {loading.value && (
|
|
|
|
+ <>
|
|
|
|
+ <Vue3Lottie
|
|
|
|
+ animationData={AstronautJSON}
|
|
|
|
+ class={styles.finch}
|
|
|
|
+ ></Vue3Lottie>
|
|
|
|
+ <p class={styles.finchLoad}>加载中...</p>
|
|
|
|
+ </>
|
|
|
|
+ )}
|
|
|
|
+ <iframe id="staffIframeRef" src={staffData.iframeSrc} onLoad={musicIframeLoad}></iframe>
|
|
|
|
+
|
|
</>
|
|
</>
|
|
- ) : (
|
|
|
|
- <div class={styles.empty}>
|
|
|
|
- <Image src={emtpy} class={styles.emptyImg} />
|
|
|
|
- <p class={styles.emptyTip}>暂无乐谱预览图</p>
|
|
|
|
- </div>
|
|
|
|
- )}
|
|
|
|
|
|
+ ) : <>
|
|
|
|
+ {showImg.length > 0 ? (
|
|
|
|
+ <img src={showImg[0]} alt="" class={styles.musicImg} />
|
|
|
|
+ ) : loading.value ? (
|
|
|
|
+ <>
|
|
|
|
+ <Vue3Lottie
|
|
|
|
+ animationData={AstronautJSON}
|
|
|
|
+ class={styles.finch}
|
|
|
|
+ ></Vue3Lottie>
|
|
|
|
+ <p class={styles.finchLoad}>加载中...</p>
|
|
|
|
+ </>
|
|
|
|
+ ) : (
|
|
|
|
+ <div class={styles.empty}>
|
|
|
|
+ <Image src={emtpy} class={styles.emptyImg} />
|
|
|
|
+ <p class={styles.emptyTip}>暂无乐谱预览图</p>
|
|
|
|
+ </div>
|
|
|
|
+ )}
|
|
|
|
+ </>}
|
|
|
|
+
|
|
|
|
|
|
<div class={styles.videoOperation}>
|
|
<div class={styles.videoOperation}>
|
|
{audioFileUrl.value && (
|
|
{audioFileUrl.value && (
|
|
@@ -753,7 +839,7 @@ export default defineComponent({
|
|
color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
|
|
color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
|
|
onClick={() => {
|
|
onClick={() => {
|
|
player.value && player.value.stop()
|
|
player.value && player.value.stop()
|
|
- musicBuy(musicDetail.value)
|
|
|
|
|
|
+ musicBuy(musicDetail.value, () => {}, {"part-index": staffData.partIndex || 0})
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
立即练习
|
|
立即练习
|
|
@@ -959,6 +1045,19 @@ export default defineComponent({
|
|
</RadioGroup>
|
|
</RadioGroup>
|
|
</div>
|
|
</div>
|
|
</Popup>
|
|
</Popup>
|
|
|
|
+
|
|
|
|
+ <Popup teleport="body" position="bottom" round v-model:show={staffData.open}>
|
|
|
|
+ <Picker columns={partColumns.value}
|
|
|
|
+ onConfirm={(value) => {
|
|
|
|
+ staffData.open = false
|
|
|
|
+ staffData.partIndex = value.value
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ resetRender()
|
|
|
|
+ })
|
|
|
|
+ }}
|
|
|
|
+ onCancel={() => staffData.open = false}
|
|
|
|
+ />
|
|
|
|
+ </Popup>
|
|
</div>
|
|
</div>
|
|
)
|
|
)
|
|
}
|
|
}
|