|
@@ -27,10 +27,10 @@ import styles from './index.module.less'
|
|
|
import { useRect } from '@vant/use'
|
|
|
import { Vue3Lottie } from 'vue3-lottie'
|
|
|
import { getRandomKey, musicBuy } from '../music'
|
|
|
-import { state } from '@/state'
|
|
|
+import { getOssUploadUrl, state } from '@/state'
|
|
|
import { useEventTracking } from '@/helpers/hooks'
|
|
|
import ColSticky from '@/components/col-sticky'
|
|
|
-import { moneyFormat } from '@/helpers/utils'
|
|
|
+import { browser, moneyFormat } from '@/helpers/utils'
|
|
|
import { orderStatus } from '@/views/order-detail/orderStatus'
|
|
|
import iconShare from '@/views/music/album/icon_share.svg'
|
|
|
import iconAlbum from '@/views/music/component/images/icon_album.png'
|
|
@@ -70,6 +70,7 @@ export default defineComponent({
|
|
|
const footers = ref(null)
|
|
|
const heightInfo = ref<any>('0')
|
|
|
const musicDetail = ref<any>(null)
|
|
|
+ const audioFileUrl = ref('')
|
|
|
const showImg = ref<string>('')
|
|
|
const accompanyUrl = ref<string>('')
|
|
|
|
|
@@ -100,6 +101,12 @@ export default defineComponent({
|
|
|
state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
|
|
|
})
|
|
|
musicDetail.value = res.data
|
|
|
+
|
|
|
+ // 取原音,如果有多个则默认第一个
|
|
|
+ const background = res.data.background
|
|
|
+ audioFileUrl.value =
|
|
|
+ background && background.length > 0 ? background[0].audioFileUrl : ''
|
|
|
+
|
|
|
showImg.value = res.data.musicImg || ''
|
|
|
|
|
|
if (!showImg.value) {
|
|
@@ -138,9 +145,7 @@ export default defineComponent({
|
|
|
try {
|
|
|
const formData = new FormData()
|
|
|
const fileName =
|
|
|
- new Date().getTime() +
|
|
|
- musicDetail.value?.musicSheetName.replace(/ /gi, '_') +
|
|
|
- '.png'
|
|
|
+ new Date().getTime() + Math.ceil(Math.random() * 1000) + '.png'
|
|
|
const keyTime = new Date().getTime() + fileName
|
|
|
const obj = {
|
|
|
filename: fileName,
|
|
@@ -178,13 +183,13 @@ export default defineComponent({
|
|
|
const files = base64ToBlob(file)
|
|
|
|
|
|
formData.append('file', files, fileName)
|
|
|
- const ossUploadUrl = 'https://ks3-cn-beijing.ksyuncs.com/cloud-coach'
|
|
|
+ const ossUploadUrl = getOssUploadUrl('cloud-coach')
|
|
|
await umiRequest(ossUploadUrl, {
|
|
|
method: 'POST',
|
|
|
data: formData
|
|
|
})
|
|
|
Toast.clear()
|
|
|
- const imgurl = ossUploadUrl + '/' + keyTime
|
|
|
+ const imgurl = getOssUploadUrl('cloud-coach') + keyTime
|
|
|
|
|
|
await request.post(state.platformApi + '/open/music/sheet/img', {
|
|
|
data: { musicSheetId: musicDetail.value.id, musicImg: imgurl }
|
|
@@ -257,7 +262,7 @@ export default defineComponent({
|
|
|
heightInfo.value = height + footer.height
|
|
|
|
|
|
// 初始化音频
|
|
|
- if (musicDetail.value?.audioFileUrl) {
|
|
|
+ if (audioFileUrl.value) {
|
|
|
initAudio()
|
|
|
}
|
|
|
})
|
|
@@ -542,7 +547,7 @@ export default defineComponent({
|
|
|
<iframe
|
|
|
id="containerPrint"
|
|
|
ref="print"
|
|
|
- style="width: 100%;page-break-after:always; height: 0"
|
|
|
+ style="width: 540px;page-break-after:always; height: 0;"
|
|
|
src={accompanyUrl.value}
|
|
|
/>
|
|
|
<p class={styles.musicTitle}>
|
|
@@ -561,7 +566,7 @@ export default defineComponent({
|
|
|
)}
|
|
|
|
|
|
<div class={styles.videoOperation}>
|
|
|
- {musicDetail.value?.audioFileUrl && (
|
|
|
+ {audioFileUrl.value && (
|
|
|
<>
|
|
|
{!buyState.value.play && (
|
|
|
<div class={[styles.audition]}>
|
|
@@ -572,17 +577,31 @@ export default defineComponent({
|
|
|
|
|
|
<div class={[styles.audio, styles.collectCell]}>
|
|
|
<audio id="player" controls ref={audio}>
|
|
|
- <source
|
|
|
- src={musicDetail.value?.audioFileUrl}
|
|
|
- type="audio/mp3"
|
|
|
- />
|
|
|
+ <source src={audioFileUrl.value} type="audio/mp3" />
|
|
|
</audio>
|
|
|
</div>
|
|
|
</>
|
|
|
)}
|
|
|
|
|
|
<div class={[styles.collect, styles.collectCell]}>
|
|
|
- <div class={[styles.userInfo]}>
|
|
|
+ <div
|
|
|
+ class={[styles.userInfo]}
|
|
|
+ onClick={() => {
|
|
|
+ if (
|
|
|
+ browser().isApp &&
|
|
|
+ musicDetail.value?.sourceType === 'TEACHER' &&
|
|
|
+ state.platformType === 'STUDENT'
|
|
|
+ ) {
|
|
|
+ router.push({
|
|
|
+ path: '/teacherHome',
|
|
|
+ query: {
|
|
|
+ teacherId: musicDetail.value?.userId,
|
|
|
+ tabs: 'music'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
<img src={musicDetail.value?.userAvatar || iconTeacher} />
|
|
|
<span>{musicDetail.value?.userName}</span>
|
|
|
</div>
|
|
@@ -610,7 +629,8 @@ export default defineComponent({
|
|
|
router.push({
|
|
|
path: '/look-album-list',
|
|
|
query: {
|
|
|
- id: musicDetail.value?.id
|
|
|
+ id: musicDetail.value?.id,
|
|
|
+ musicSubject: musicDetail.value?.musicSubject
|
|
|
}
|
|
|
})
|
|
|
}}
|