lex 2 years ago
parent
commit
2228d7ad02
1 changed files with 11 additions and 7 deletions
  1. 11 7
      src/teacher/share-page/share-music/index.tsx

+ 11 - 7
src/teacher/share-page/share-music/index.tsx

@@ -68,6 +68,7 @@ export default defineComponent({
     const musicDetail = ref<any>(null)
     const showImg = ref<string>('')
     const accompanyUrl = ref<string>('')
+    const audioFileUrl = ref('')
     const wxStatus = ref<boolean>(false)
 
     const tmpUrl = `${location.origin}/student/#/music-detail?${qs.stringify(
@@ -106,6 +107,13 @@ export default defineComponent({
             userId: search.recomUserId
           }
         })
+
+        // 取原音,如果有多个则默认第一个
+        const background = res.data.musicSheet.background
+
+        audioFileUrl.value =
+          background && background.length > 0 ? background[0].audioFileUrl : ''
+        console.log(audioFileUrl.value)
         musicDetail.value = res.data.musicSheet
         showImg.value = musicDetail.value?.musicImg || ''
 
@@ -262,7 +270,7 @@ export default defineComponent({
       heightInfo.value = height + footer.height
 
       // 初始化音频
-      if (musicDetail.value?.audioFileUrl) {
+      if (audioFileUrl.value) {
         initAudio()
       }
     })
@@ -277,7 +285,6 @@ export default defineComponent({
     })
 
     const onShare = () => {
-      console.log(browser().weixin)
       if (browser().weixin) {
         wxStatus.value = true
         return
@@ -395,7 +402,7 @@ export default defineComponent({
               )}
 
               <div class={styles.videoOperation}>
-                {musicDetail.value?.audioFileUrl && (
+                {audioFileUrl.value && (
                   <>
                     {(paymentType.value.includes('CHARGE') ||
                       paymentType.value.includes('VIP')) &&
@@ -408,10 +415,7 @@ 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>
                   </>