lex-xin 4 月之前
父節點
當前提交
e2d4d1712a

+ 5 - 5
src/tenant/music/music-detail/download.tsx

@@ -45,10 +45,10 @@ export default defineComponent({
       if (image.value) {
         saveImg()
       } else {
-        console.log(
-          list.value[acitveIndex.value],
-          'list.value[acitveIndex.value]'
-        )
+        // console.log(
+        //   list.value[acitveIndex.value],
+        //   'list.value[acitveIndex.value]'
+        // )
         const tempCanvas = await imgToCanvas(
           list.value[acitveIndex.value] as any
         )
@@ -58,7 +58,7 @@ export default defineComponent({
         })
         const canvas = await addWatermark(titleCanvas, '酷乐秀')
         image.value = convasToImg(canvas)
-        console.log(image.value, 'image.value')
+        // console.log(image.value, 'image.value')
         await saveImg()
       }
     }

+ 21 - 11
src/tenant/music/music-detail/new-index.tsx

@@ -133,9 +133,18 @@ export default defineComponent({
       loading.value = true
       isError.value = false
       try {
-        const { data } = await request.get(state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student' + '/musicSheet/cbsDetail/' + route.query.id)
+        const {data} = await request.post('/musicSheet/detailSmall', {
+          prefix:
+            state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
+          data: {
+            musicSheetId: route.query.id,
+            tenantAlbumId: route.query.tenantAlbumId,
+            providerType: route.query.providerType,
+            instrumentId: staffData.instrumentId,
+            subjectId: staffData.subjectId
+          }
+        })
         staffData.details = data
-
         await toDetail(data)
       } catch (error) {
         isError.value = true
@@ -270,6 +279,11 @@ export default defineComponent({
         const instrumentId = instrumentIds.split(',')[0]
         staffData.instrumentId = instrumentId
       }
+      const subjectIds = state.user.data?.subjectId
+      if(subjectIds) {
+        const subjectId = subjectIds.split(',')[0]
+        staffData.subjectId = subjectId
+      }
 
       postMessage({
         api: 'setStatusBarTextColor',
@@ -407,6 +421,7 @@ export default defineComponent({
     const staffData = reactive({
       musicId: route.query.id as any,
       instrumentId: '', // 声部编号
+      subjectId: '', //
       isConcert: false, // 是否合奏
       details: {} as any,
       list: [], // 列表数据
@@ -526,12 +541,8 @@ export default defineComponent({
       // staffData.partNames = partNames;
       staff.radio = row.scoreType // 默认是什么谱页
       const tempSongList = row.musicSheetSoundList || []
-      let partList = tempSongList.filter(
-        (item: any) => item.audioPlayType === 'PLAY'
-      )
-      staffData.list = tempSongList.filter(
-        (item: any) => item.audioPlayType === 'PLAY'
-      )
+      let partList = tempSongList
+      staffData.list = tempSongList
       partList = partList.filter(
         (item: any) => !item.track?.toLocaleUpperCase()?.includes('COMMON')
       )
@@ -671,8 +682,8 @@ export default defineComponent({
     const getPreViewCloud = (musicId: string, partIndex: number, track: string) => {
       const Authorization = sessionStorage.getItem('Authorization') || ''
       const musicScorePath = '/klx-music-score/'
-      // const musicScoreUrl = getHttpOrigin() + musicScorePath
-      const musicScoreUrl = "https://dev.colexiu.com" + musicScorePath;
+      const musicScoreUrl = getHttpOrigin() + musicScorePath
+      // const musicScoreUrl = "https://dev.colexiu.com" + musicScorePath;
       // const musicScoreUrl = 'http://192.168.3.68:3000/instrument.html';
       let href = `${musicScoreUrl}?t=${Date.now()}#/?id=${musicId}&Authorization=${Authorization}&part-index=${partIndex}&isPreView=true&zoom=0.5&downPng=A4`
       // // 老师端加上systemType=teacher
@@ -1123,7 +1134,6 @@ export default defineComponent({
                           ignoreSysMetronome:
                             route.query.subjectType === 'MUSIC' ? 1 : 0
                         }
-                        console.log(currentColumn.value, 'currentColumn.value')
                         if (route.query.tenantAlbumId) {
                           extraParam.albumId = route.query.tenantAlbumId
                         }

+ 17 - 57
src/views/music/music-detail/index.tsx

@@ -183,7 +183,7 @@ export default defineComponent({
       loading.value = true
       isError.value = false
       try {
-        const {data} = await request.post('musicSheet/detailSmall', {
+        const {data} = await request.post('/musicSheet/detailSmall', {
           prefix:
             state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
           data: {
@@ -285,11 +285,16 @@ export default defineComponent({
       }
     }
     onMounted(async () => {
-      const instrumentIds = state.user.data?.instrumentId
-      if(instrumentIds) {
-        const instrumentId = instrumentIds.split(',')[0]
-        staffData.instrumentId = instrumentId
+      if(route.query.instrumentId) {
+        staffData.instrumentId = route.query.instrumentId as any
+      } else {
+        const instrumentIds = state.user.data?.instrumentId
+        if(instrumentIds) {
+          const instrumentId = instrumentIds.split(',')[0]
+          staffData.instrumentId = instrumentId
+        }
       }
+      
       const subjectIds = state.user.data?.subjectId
       if(subjectIds) {
         const subjectId = subjectIds.split(',')[0]
@@ -528,47 +533,6 @@ export default defineComponent({
       } catch {}
     }
 
-    
-    /** 渲染五线谱 */
-    // const sortList = {
-    //   长笛: 1,
-    //   单簧管: 2,
-    //   中音单簧管: 3,
-    //   低音单簧管: 4,
-    //   高音萨克斯风: 5,
-    //   中音萨克斯风: 6,
-    //   次中音萨克斯风: 7,
-    //   低音萨克斯风: 8,
-    //   小号: 9,
-    //   长号: 10,
-    //   圆号: 11,
-    //   大号: 12,
-    //   上低音号: 13
-    // }
-    // const instrumentSort = (list: Array<any>) => {
-    //   list.sort((a, b) => {
-    //     return (
-    //       (sortList[getInstrumentName(a.track)] || 20) -
-    //       (sortList[getInstrumentName(b.track)] || 20)
-    //     )
-    //   })
-    //   return list
-    // }
-
-    const getPartNames = async (xmlUrl: string) => {
-      const partNames: string[] = [];
-      try {
-        const res = await umiRequest.get(xmlUrl, { mode: "cors" });
-        const xml: any = new DOMParser().parseFromString(res, "text/xml");
-        for (const item of xml.getElementsByTagName("part-name")) {
-          if (item.textContent) {
-            partNames.push(item.textContent?.trim());
-          }
-        }
-      } catch (error) {}
-      return partNames;
-    };
-
     /** 获取分轨信息 */
     const getInstrumentItem = (instruments: any, name = "") => {
       name = name.toLocaleLowerCase().replace(/ /g, ""); //.replace(/\d*/gi, '')
@@ -624,19 +588,14 @@ export default defineComponent({
   }
 
   const toDetail = async (row: any) => {
-    // const partNames = await getPartNames(row.xmlFileUrl);
-    // staffData.partNames = partNames;
     staff.radio = row.scoreType // 默认是什么谱页
     const tempSongList = row.musicSheetSoundList || []
-    let partList = tempSongList.filter((item: any) => item.audioPlayType === 'PLAY')
-    staffData.list = tempSongList.filter((item: any) => item.audioPlayType === 'PLAY')
+    let partList = tempSongList
+    staffData.list = tempSongList
     partList = partList.filter(
       (item: any) => !item.track?.toLocaleUpperCase()?.includes("COMMON")
     );
     partColumns.value = partList.map((item: any, index: number) => {
-      // const xmlIndex = staffData.partNames.filter((text: string) => text.toLocaleUpperCase() !== "COMMON").findIndex(
-      //   (name: any) => name.trim() === item.track
-      // );
       // 因为合奏的,显示总谱会加一个声轨
       const defaultIndex = row.musicSheetType !== "SINGLE" && row.isScoreRender ? index + 1 : index
       const cnName = getInstrumentName(item.track)
@@ -753,8 +712,8 @@ export default defineComponent({
   const getPreViewCloud = (musicId: string, partIndex: number, track: string) => {
     const Authorization = sessionStorage.getItem("Authorization") || "";
     const musicScorePath = "/klx-music-score/";
-    // const musicScoreUrl = getHttpOrigin() + musicScorePath;
-    const musicScoreUrl = "https://dev.colexiu.com" + musicScorePath;
+    const musicScoreUrl = getHttpOrigin() + musicScorePath;
+    // const musicScoreUrl = "https://dev.colexiu.com" + musicScorePath;
     // const musicScoreUrl = 'http://192.168.3.68:3000/instrument.html';
     let href = `${musicScoreUrl}?t=${Date.now()}#/?id=${musicId}&Authorization=${Authorization}&isPreView=true&zoom=0.5&downPng=A4`; 
     // // 老师端加上systemType=teacher
@@ -812,7 +771,8 @@ export default defineComponent({
 
     const resetRender = () => {
       const iframeRef: any = document.getElementById("staffIframeRef")
-      iframeRef.contentWindow.location.replace(getPreViewCloud(staffData.musicId, currentColumn.value.xmlIndex, currentColumn.value.track))
+      console.log(currentColumn.value, "currentColumn.value")
+      iframeRef.contentWindow.location.replace(getPreViewCloud(staffData.musicId, currentColumn.value?.xmlIndex, currentColumn.value.track))
     }
     return () => {
       return (
@@ -1195,7 +1155,7 @@ export default defineComponent({
                           // 'part-index': currentColumn.value.track || 0,
                           'part-name': currentColumn.value.track?.trim(),
                           musicRenderType,
-                          instrumentId: route.query.instrumentId
+                          instrumentId: staffData.instrumentId
                         }
                         // 有专辑id
                         if (route.query.tenantAlbumId) {