|
@@ -21,7 +21,7 @@ import tagItem from '@/components/tagItem'
|
|
|
import code from './images/code.png'
|
|
|
import musicItem from './modals/musicItem'
|
|
|
import request from '@/helpers/request'
|
|
|
-import { useRoute } from 'vue-router'
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
import { getUserType, vaildTeachingUrl } from '@/helpers/utils'
|
|
|
import { imgToCanvas, addWatermark, convasToImg } from '@/helpers/imageFunction'
|
|
|
import printJS from 'print-js'
|
|
@@ -41,6 +41,7 @@ export default defineComponent({
|
|
|
},
|
|
|
setup(props, conent) {
|
|
|
const route = useRoute()
|
|
|
+ const router = useRouter()
|
|
|
const state = reactive({
|
|
|
title: props.title,
|
|
|
id: route.query.id,
|
|
@@ -56,7 +57,7 @@ export default defineComponent({
|
|
|
userType: '',
|
|
|
accompanyUrl: '',
|
|
|
imgData: '',
|
|
|
- imgUrl:''
|
|
|
+ imgUrl: ''
|
|
|
})
|
|
|
const print = ref()
|
|
|
const getMusicList = async () => {
|
|
@@ -69,11 +70,16 @@ export default defineComponent({
|
|
|
state.musicDetail = res.data
|
|
|
state.musicList = res.data.teacher.musicSheetList
|
|
|
state.subjectList = res.data.background
|
|
|
+
|
|
|
state.mp3Type = res.data.audioType
|
|
|
- state.activeRow = res.data.background[0]
|
|
|
- state.subjectId = res.data.background[0].id
|
|
|
+ if (state.subjectList && state.subjectList.length > 0) {
|
|
|
+ state.activeRow = res.data.background[0]
|
|
|
+ state.subjectId = res.data.background[0].id
|
|
|
+ }
|
|
|
+
|
|
|
state.teacherDetail = res.data.teacher
|
|
|
setAccompanyUrl()
|
|
|
+ console.log('调用')
|
|
|
} catch (e) {
|
|
|
console.log(e)
|
|
|
}
|
|
@@ -94,6 +100,9 @@ export default defineComponent({
|
|
|
}
|
|
|
const getDetail = (val: string | number) => {
|
|
|
state.id = val as string
|
|
|
+ router.push({
|
|
|
+ query: { ...route.query, id: state.id }
|
|
|
+ })
|
|
|
getMusicList()
|
|
|
}
|
|
|
watch(
|
|
@@ -104,10 +113,10 @@ export default defineComponent({
|
|
|
)
|
|
|
const setAccompanyUrl = () => {
|
|
|
let url = vaildTeachingUrl()
|
|
|
- // state.accompanyUrl =
|
|
|
- // url +
|
|
|
- // `/accompany/colxiu-website.html?id=${state.id}&part-index=${state.subjectId}`
|
|
|
- state.accompanyUrl = `http://192.168.3.8:3000/colxiu-website.html?id=${state.id}&part-index=${state.subjectId}`
|
|
|
+ state.accompanyUrl =
|
|
|
+ url +
|
|
|
+ `/accompany/colxiu-website.html?id=${state.id}&part-index=${state.subjectId}`
|
|
|
+ // state.accompanyUrl = `http://192.168.3.8:3000/colxiu-website.html?id=${state.id}&part-index=${state.subjectId}`
|
|
|
|
|
|
// var iframe = document.getElementById('containerPrint') as any //获取id为svgframe的iframe对象
|
|
|
// if (iframe.attachEvent) {
|
|
@@ -156,7 +165,7 @@ export default defineComponent({
|
|
|
const canvas = addWatermark(tempCanvas, '酷乐秀')
|
|
|
const imgUrl = convasToImg(canvas)
|
|
|
const link = document.createElement('a')
|
|
|
- link.setAttribute('download', state.musicDetail.musicSheetName)
|
|
|
+ link.setAttribute('download', state.musicDetail.musicSheetName + '.png')
|
|
|
|
|
|
// 添加时间戳,防止浏览器缓存图片
|
|
|
state.imgUrl = imgUrl
|
|
@@ -208,6 +217,7 @@ export default defineComponent({
|
|
|
<div class={classes.musicContent}>
|
|
|
{/* id="iframe" ref="iframe"*/}
|
|
|
<iframe
|
|
|
+
|
|
|
id="containerPrint"
|
|
|
ref="print"
|
|
|
style="width: 100%;height:750px;page-break-after:always;"
|