import { defineComponent, toRefs, reactive, onMounted, ref, watch, nextTick } from 'vue' import classes from './index.module.less' import { ElButton, ElOption, ElSelect, ElScrollbar, ElMessageBox } from 'element-plus' import printIcon from './images/printIcon.png' import noMore from './images/noMore.png' import banner from './images/banner.png' import colVideo from '@/components/col-video/index' import iconClose from '@/views/login/images/icon_close.png' import start from '@/components/albumItem/images/start.png' import lineStart from '@/components/albumItem/images/lineStart.png' import oStart from '@/common/images/oStart.png' import oLineStart from '@/common/images/oLineStart.png' import teacher from '@/views/videoDetailList/images/teacher.png' import teacherHeader from '@/common/images/icon_teacher.png' import musiceIcon from '@/views/videoDetailList/images/musiceIcon.png' import music from '@/components/musicLIstItem/images/music.png' import tagItem from '@/components/tagItem' import code from '@/common/images/student_download.png' import musicItem from './modals/musicItem' import ablumIcon from '@/components/col-header/images/ablumIcon.png' import noAblumIcon from '@/components/col-header/images/noAblumIcon.png' import onlineIcon from '@/components/col-header/images/onlineIcon.png' import noOnlineIcon from '@/components/col-header/images/noOnlineIcon.png' import styleIcon from '@/components/col-header/images/styleIcon.png' import nostyleIcon from '@/components/col-header/images/nostyleIcon.png' import videoIcon from '@/components/col-header/images/videoIcon.png' import noVideoIcon from '@/components/col-header/images/noVideoIcon.png' import vipIcon from '@/components/col-header/images/vipIcon.png' import noVipIcon from '@/components/col-header/images/noVipIcon.png' import request from '@/helpers/request' import { useRoute, useRouter } from 'vue-router' import gou from './images/gou.png' import member from './images/member.png' import palyer from './images/palyer.png' // import vipIcon from '../images/vipIcon.png' import { getUserType, vaildTeachingUrl, getAuth, setAuth } from '@/helpers/utils' import { state as states } from '@/state' import { imgToCanvas, addWatermark, convasToImg, addMusicTitle } from '@/helpers/imageFunction' import arrow from '@/views/home/images/moreArrow.png' import { Vue3Lottie } from 'vue3-lottie' import 'vue3-lottie/dist/style.css' import AstronautJSON from '@/common/animate/bigLoad.json' import printJS from 'print-js' const chargeTypes = { CHARGE: '点播', FREE: '免费', VIP: '会员' } const chargeImg = { CHARGE: palyer, FREE: gou, VIP: member } const chargeClass = { CHARGE: 'charge', FREE: 'gou', VIP: 'member' } export default defineComponent({ name: 'muiscDetial', props: { title: { type: String, default: '' } }, components: { colVideo, tagItem, musicItem, Vue3Lottie }, setup(props, conent) { const route = useRoute() const router = useRouter() const state = reactive({ title: props.title, id: route.query.id, subjectId: '', subjectList: [], tagList: [], teacherDetail: {} as any, musicDetail: {} as any, musicList: [], mp3Type: '', activeRow: {} as any, showCode: false, userType: '', accompanyUrl: '', imgData: '', imgUrl: '', showImg: '', iconList: [] as any, ossUploadUrl: 'https://ks3-cn-beijing.ksyuncs.com/cloud-coach', dataObj: { policy: '', signature: '', key: '', KSSAccessKeyId: '', acl: 'public-read', name: '' }, fileList: [] as any }) nextTick(() => { // 禁用右键 // @ts-ignore:无法被执行的代码的错误 document.oncontextmenu = new Function('event.returnValue=false') // @ts-ignore:无法被执行的代码的错误 // 禁用选择 document.onselectstart = new Function('event.returnValue=false') // @ts-ignore:无法被执行的代码的错误 //禁止f12 document.οnkeydοwn = new Function('event.returnValue=false') }) // 上面的禁止f12那段代码没有生效,但是加了下面这段就能生效。 document.onkeydown = function (e) { if (e && e.keyCode === 123) { e.returnValue = false // e.keyCode = 0 //去掉也可以的,倘若要写,则需要setter 以及 getter配合使用,不配合,会报错 return false } } const print = ref() const getMusicList = async () => { try { const res = await request.get( `/api-website/open/music/sheet/detail/${state.id}`, {} ) state.musicDetail = res.data state.musicList = res.data.teacher.musicSheetList state.subjectList = res.data.background state.tagList = res.data.musicTagNames ? res.data.musicTagNames.split(',') : [] state.mp3Type = res.data.audioType 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 if (res.data.musicImg) { // 有图片 state.showImg = res.data.musicImg } else { window.addEventListener( 'message', async e => { console.log(e) state.imgData = e.data // printHander() // alert(e.data); const tempCanvas = await imgToCanvas(state.imgData) const showImg = convasToImg(tempCanvas) // 开始上传图片 // uploadFunction(showImg) state.showImg = showImg }, false ) } setAccompanyUrl() setUser() } catch (e) { console.log(e) } } const followVideo = async () => { try { const res = await request.get('/api-website/student/starOrUnStar', { params: { userId: state.teacherDetail.userId, starStatus: state.teacherDetail.star ? 0 : 1 } }) getMusicList() // state.otherVideoList = res.data } catch (e) { console.log(e) } } const getDetail = (val: string | number) => { state.id = val as string router.push({ query: { ...route.query, id: state.id } }) state.showImg = '' getMusicList() } watch( () => state.accompanyUrl, accompanyUrl => { state.accompanyUrl = accompanyUrl } ) 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}` } const setSvg = (val: any) => { console.log(val) } onMounted(() => { // window.setSvg = (val)=>{ // setSvg(val) // } getMusicList() state.userType = getUserType() state.showCode = state.userType == 'STUDENT' || !state.userType ? true : false // 拼链接 }) const uploadFunction =async (file) => { try { let fileName = state.musicDetail.musicSheetName.replaceAll(' ', '_') let key = new Date().getTime() + fileName let obj = { filename: fileName, bucketName: 'cloud-coach', postData: { filename: fileName, acl: 'public-read', key: key, unknowValueField: [] } } const { data } = await request.post('/api-website/getUploadSign', { data: obj }) state.dataObj = { policy: data.policy, signature: data.signature, key: key, KSSAccessKeyId: data.kssAccessKeyId, acl: 'public-read', name: fileName } } catch (e) { console.log(e) } } const setUser = () => { state.iconList = [] as any if (state.teacherDetail.tag.indexOf('STYLE') != -1) { state.iconList.push(styleIcon) } else { state.iconList.push(nostyleIcon) } if (state.teacherDetail.tag.indexOf('VIDEO') != -1) { state.iconList.push(videoIcon) } else { state.iconList.push(noVideoIcon) } if (state.teacherDetail.tag.indexOf('LIVE') != -1) { state.iconList.push(onlineIcon) } else { state.iconList.push(noOnlineIcon) } if (state.teacherDetail.tag.indexOf('MUSIC') != -1) { state.iconList.push(ablumIcon) } else { state.iconList.push(noAblumIcon) } } const printHander = async () => { const tempCanvas = await imgToCanvas(state.imgData) const showImg = convasToImg(tempCanvas) state.showImg = showImg const titleCanvas = addMusicTitle(tempCanvas, { title: state.musicDetail.musicSheetName, size: 18 }) const canvas = addWatermark(titleCanvas, '酷乐秀') const imgUrl = convasToImg(canvas) const link = document.createElement('a') link.setAttribute('download', state.musicDetail.musicSheetName + '.png') // 添加时间戳,防止浏览器缓存图片 state.imgUrl = imgUrl link.href = imgUrl link.click() } const gotoMusic = () => { router.push({ name: 'searchdetail', params: { search: state.teacherDetail.userName as string, type: 'music' } }) } const favoriteMusic = async () => { const tockn = getAuth() if (!tockn) { states.loginPopupStatus = true return } ElMessageBox.confirm( `是否${state.musicDetail.favorite ? '取消收藏' : '收藏'}该曲目?`, '提示', { type: 'warning' } ).then(async () => { try { const res = await request.post( `/api-website/music/sheet/favorite/${state.id}` ) getMusicList() // state.otherVideoList = res.data } catch (e) { console.log(e) } }) } return () => ( <>
声部:
下载乐谱
{state.musicDetail.musicSheetName}
{state.showImg ? (加载中...
温馨提示:该曲目暂不支持播放喔~
扫码下载酷乐秀APP
使用小酷Ai即可智能练习本首曲目哦!
*/}{state.musicDetail.favoriteNum}人收藏
作曲人:{state.musicDetail.composer}
声部:{state.musicDetail.subjectNames}
{state.teacherDetail.userName}
{/* {!state.teacherDetail.entryFlag ? ( '' ) : ({state.teacherDetail.fansNum}
粉丝数