1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432 |
- import {
- computed,
- defineComponent,
- nextTick,
- onBeforeUnmount,
- onMounted,
- onUnmounted,
- reactive,
- ref,
- watch
- } from 'vue'
- import umiRequest from 'umi-request'
- import { useRoute, useRouter } from 'vue-router'
- import request from '@/helpers/request'
- import ColHeader from '@/components/col-header'
- import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
- import {
- Button,
- Cell,
- CellGroup,
- Checkbox,
- Dialog,
- Icon,
- Image,
- Popup,
- RadioGroup,
- Sticky,
- Tag,
- Radio,
- Toast,
- Picker
- } from 'vant'
- import qs from 'query-string'
- import styles from './index.module.less'
- // import Item from '../list/item'
- import { useRect } from '@vant/use'
- import { Vue3Lottie } from 'vue3-lottie'
- import { getRandomKey, musicBuy } from '../music'
- import { getOssUploadUrl, state } from '@/state'
- // import { useEventTracking } from '@/helpers/hooks'
- import ColSticky from '@/components/col-sticky'
- import { browser, getHttpOrigin, moneyFormat } from '@/helpers/utils'
- import { orderStatus } from '@/views/order-detail/orderStatus'
- import iconShare from '@/views/music/album/icon_share.svg'
- import iconAlbum from './images/icon_album.png'
- import iconAlbum2 from './images/icon_album2.png'
- import iconDownload from './images/icon_download.png'
- import iconChange from './images/icon-change.png'
- import iconAddCourse from './images/icon-add-course.png'
- import iconRemoveCourse from './images/icon-remove-course.png'
- import AstronautJSON from './animate/bigLoad.json'
- import ColShare from '@/components/col-share'
- import iconCollect from './images/icon_collect.png'
- import iconCollectActive from './images/icon_collect_active.png'
- import iconListen from './images/icon_listen.png'
- import emtpy from './images/emtpy.png'
- import activeButtonIcon from '@common/images/icon_checkbox.png'
- import inactiveButtonIcon from '@common/images/icon_checkbox_default.png'
- import staffDetafult from './images/staff-default.png'
- import firstDefault from './images/first-default.png'
- import fixedDefault from './images/fixed-default.png'
- import Plyr from 'plyr'
- import 'plyr/dist/plyr.css'
- import Download from './download'
- import { getInstrumentName } from '@/constant/instruments'
- import { svgtopng } from '@/tenant/music/music-detail/formatSvgToImg'
- import { useThrottleFn } from '@vueuse/core'
- // import {
- // formatXML,
- // getCustomInfo,
- // onlyVisible
- // } from '@/tenant/music/music-detail/instrument'
- export const getAssetsHomeFile = (fileName: string) => {
- const path = `../component/images/${fileName}`
- const modules = import.meta.globEager('../component/images/*')
- return modules[path].default
- }
- export default defineComponent({
- name: 'MusicDetail',
- setup() {
- const behaviorId = ref(getRandomKey())
- localStorage.setItem('behaviorId', behaviorId.value)
- const router = useRouter()
- const route = useRoute()
- const loading = ref(false)
- const aId = Number(route.query.activityId) || 0
- const studentActivityId = ref(aId)
- const isError = ref(false)
- const headers = ref(null)
- const footers = ref(null)
- const heightInfo = ref<any>('0')
- const audioFileUrl = ref('')
- const staffData = reactive({
- musicId: route.query.id as any,
- instrumentId: '', // 声部编号
- subjectId: '',
- isConcert: false, // 是否合奏
- details: {} as any,
- list: [], // 列表数据
- open: false,
- closed: true,
- audioReady: false,
- iframeSrc: "",
- musicXml: "",
- instrumentName: "",
- iframeRef: null as any,
- imgs: [] as any,
- musicPdfUrl: "", // 当前声轨PDF
- partList: [] as any[],
- partNames: [] as string[],
- selectedPartName: "" as any,
- selectedPartIndex: 0,
- isComberRender: false, // 是否合并谱显示
- metronomeUrl: "", // 合奏使用链接
- metronomeMp3Url: "", // 独奏使用链接
- })
- // 当前先中的数据
- const currentColumn = computed(() => {
- console.log(1, partColumns.value, staffData.selectedPartIndex)
- return partColumns.value.find((item: any) => item.value === staffData.selectedPartIndex)
- })
- const downloadStatus = ref<boolean>(false)
- const staff = reactive({
- status: false,
- radio: 'STAVE' // STAVE: 五线谱; JIAN: 固定调; FIRST: 首调
- })
- const colors: any = {
- FREE: {
- color: '#01B84F',
- text: '免费'
- },
- VIP: {
- color: '#CD863E',
- text: '会员'
- },
- CHARGE: {
- color: '#3591CE',
- text: '点播'
- }
- }
- // 更改预览状态
- const onChangeStaff = (type: string) => {
- staff.radio = type
- staff.status = false
- if (type == 'FIRST') {
- loading.value = false
- const tempPdf = staffData.details?.firstPdfUrl
- initIframe(tempPdf, 'FIRST', staffData.musicXml)
- } else if (type == 'JIAN') {
- loading.value = false
- const tempPdf = staffData.details?.jianPdfUrl
- console.log(tempPdf, 'tempPdf')
- initIframe(tempPdf, 'JIAN', staffData.musicXml)
- } else {
- loading.value = false
- const tempPdf = staffData.details?.musicPdfUrl
- initIframe(tempPdf, 'STAVE', staffData.musicXml)
- }
- }
- const initIframe = (tempPdf: string, staff: string, xml: string) => {
- if (tempPdf) {
- staffData.musicPdfUrl = tempPdf
- } else {
- staffData.musicPdfUrl = ''
- }
- renderStaff()
- }
-
- const FetchList = async (id?: any) => {
- if (loading.value) {
- return
- }
- loading.value = true
- isError.value = false
- try {
- 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)
- if (data.auditStatus === 'DOING') {
- Dialog.confirm({
- message: '曲目审核中',
- showConfirmButton: true,
- showCancelButton: false,
- confirmButtonColor: 'var(--van-primary)'
- }).then(() => {
- if (browser().isApp) {
- postMessage({ api: 'goBack' })
- } else {
- router.back()
- }
- })
- }
- } catch (error) {
- isError.value = true
- }
- loading.value = false
- }
- const player = ref<any>(null)
- const audio = ref<any>(null)
- const freeRate = ref<any>(0)
- const initAudio = async () => {
- const controls = [
- 'play-large',
- 'play',
- 'progress',
- 'captions',
- // 'fullscreen',
- 'duration'
- ]
- player.value = new Plyr(audio.value, {
- controls: controls
- })
- const config = await request.get(
- '/sysConfig/queryByParamNameList',
- {
- prefix: state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
- params: {
- paramNames: 'music_sheet_free_rate'
- }
- }
- )
- freeRate.value = config.data[0]?.paramValue || 0
- // player.value.on("ready", () => {
- // staffData.audioReady = true;
- // nextTick(async () => {
- // console.log('1111')
- // renderStaff();
- // });
- // });
- nextTick(async () => {
- renderStaff();
- });
- player.value.on('timeupdate', () => {
- // 允许播放时间
- const players = player.value
- const playTime = (players.duration * freeRate.value) / 100 || 0
- // 时间,不能播放
- if (players.currentTime >= playTime && !buyState.value.play) {
- players.stop()
- // players.pause()
- }
- })
- }
- const showLoading = async (e: any) => {
- if (e.data?.api === 'musicStaffRender') {
- const osmdImg = e.data.osmdImg
- // showImg.value = []
- const imgs: any = []
- for (let i = 0; i < osmdImg.length; i++) {
- const img = await svgtopng(
- osmdImg[i].img,
- osmdImg[i].width,
- osmdImg[i].height
- )
- imgs.push(img)
- }
- staffData.imgs = imgs
- loading.value = e.data.loading
- }
- }
- onMounted(async () => {
- 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]
- staffData.subjectId = subjectId
- }
-
- postMessage({
- api: 'setStatusBarTextColor',
- content: { statusBarTextColor: true }
- })
- await FetchList()
- const { height } = useRect(headers as any)
- const footer = useRect(footers as any)
- heightInfo.value = height + footer.height
- // // 初始化音频
- // if (audioFileUrl.value) {
- // initAudio()
- // }
- window.addEventListener('message', showLoading)
- })
- onBeforeUnmount(() => {
- postMessage({
- api: 'setStatusBarTextColor',
- content: { statusBarTextColor: false }
- })
- })
- onUnmounted(() => {
- window.removeEventListener('message', showLoading)
- })
- const toggleFavorite = async () => {
- /**
- * 酷乐秀老师端 收藏曲目 music/sheet/favorite/id?providerType=?? 添加参数
- * @ApiModelProperty("曲目评测来源 TENANT 机构 PLATFORM 平台")
- * private String providerType;
- * 表示收藏的是机构曲目,还是平台曲目,
- */
- let apiUrl = '', providerType = ''
- if (browser().isTeacher) {
- providerType = route.query.tenantAlbumId || route.query.providerType == 'TENANT' ? 'TENANT' : 'PLATFORM'
- }
- apiUrl = `/music/sheet/favorite/${staffData.details?.bizId}`
- try {
- await request.post(apiUrl, {
- requestType: 'form',
- data: {
- providerType
- },
- prefix:
- state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
- })
- staffData.details.favorite = staffData.details?.favorite ? 0 : 1
- staffData.details.favoriteCount = staffData.details?.favorite
- ? staffData.details.favoriteCount + 1
- : staffData.details.favoriteCount - 1 < 0
- ? 0
- : staffData.details.favoriteCount - 1
- setTimeout(() => {
- Toast(staffData.details?.favorite ? '收藏成功' : '取消收藏成功')
- }, 100)
- } catch (error) {
- //
- }
- }
- const onAddCourse = async () => {
- try {
- const res = await request.post('/api-teacher/courseCourseware/submit', {
- data: {
- musicSheetId: staffData.details.bizId,
- clientType: 'TEACHER',
- userId: state.user.data?.userId
- }
- })
- // console.log(res)
- setTimeout(() => {
- staffData.details.coursewareId = res.data.id || ''
- Toast('已将曲目添加到课件')
- staffData.details.coursewareStatus = 1
- }, 100)
- } catch {
- //
- }
- }
- const removeCourse = async () => {
- Dialog.confirm({
- title: '提示',
- message: '您是否确定移出课件',
- confirmButtonColor: '#269a93',
- cancelButtonText: '取消',
- confirmButtonText: '确定'
- }).then(async () => {
- try {
- await request.post(
- '/api-teacher/courseCourseware/remove/' +
- staffData.details.coursewareId,
- {
- data: {}
- }
- )
- setTimeout(() => {
- Toast('移出成功')
- staffData.details.coursewareStatus = 0
- }, 100)
- } catch {
- //
- }
- })
- }
- const onBuy = async () => {
- const music = staffData.details
- orderStatus.orderObject.orderType = 'MUSIC'
- orderStatus.orderObject.orderName = music.name
- orderStatus.orderObject.orderDesc = music.name
- orderStatus.orderObject.actualPrice = music.musicPrice
- orderStatus.orderObject.recomUserId = route.query.recomUserId || 0
- orderStatus.orderObject.activityId = route.query.activityId || 0
- orderStatus.orderObject.orderNo = ''
- orderStatus.orderObject.orderList = [
- {
- orderType: 'MUSIC',
- goodsName: music.name,
- actualPrice: music.musicPrice,
- price: music.musicPrice,
- ...music
- }
- ]
- const res = await request.post('/userOrder/getPendingOrder', {
- prefix: state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
- data: {
- goodType: 'MUSIC',
- bizId: music.bizId
- }
- })
- const result = res.data
- if (result) {
- Dialog.confirm({
- title: '提示',
- message: '您有一个未支付的订单,是否继续支付?',
- confirmButtonColor: '#269a93',
- cancelButtonText: '取消订单',
- confirmButtonText: '继续支付'
- })
- .then(async () => {
- orderStatus.orderObject.orderNo = result.orderNo
- orderStatus.orderObject.actualPrice = result.actualPrice
- orderStatus.orderObject.discountPrice = result.discountPrice
- orderStatus.orderObject.paymentConfig = {
- ...result.paymentConfig,
- paymentVendor: result.paymentVendor,
- paymentVersion: result.paymentVersion
- }
- routerTo()
- })
- .catch(() => {
- Dialog.close()
- // 只用取消订单,不用做其它处理
- cancelPayment(result.orderNo)
- })
- } else {
- routerTo()
- }
- }
- const routerTo = () => {
- const music = staffData.details
- router.push({
- path: '/orderDetail',
- query: {
- orderType: 'MUSIC',
- musicId: music.bizId
- }
- })
- }
- const cancelPayment = async (orderNo: string) => {
- try {
- await request.post('/userOrder/orderCancel', {
- prefix: state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
- data: {
- orderNo
- }
- })
- } catch {}
- }
- const paymentType = computed(() => {
- let paymentType = staffData.details?.paymentType
- if (typeof paymentType === 'string') {
- paymentType = paymentType.split(',')
- return paymentType
- }
- return []
- })
- const buyState = computed(() => {
- const music = staffData.details
- return {
- hasTenantAlbum: route.query?.tenantAlbumId ? true : false, // 是否从专辑来的
- play: music.play ? true : false, // 是否可以播放
- free: music?.paymentType.includes('FREE'),
- charge: music?.paymentType.includes('CHARGE'),
- vip: music?.paymentType.includes('VIP'),
- buy: music?.orderStatus === 'PAID' // 是否已买
- }
- })
- const shareStatus = ref(false)
- const shareUrl = ref('')
- const shareDiscount = ref(0)
- const partColumns = ref<any>([]);
- // console.log(data)
- const onShare = async () => {
- try {
- const res = await request.post('/api-teacher/open/musicShareProfit', {
- data: {
- bizId: staffData.details?.bizId,
- userId: state.user.data?.userId
- }
- })
- let url =
- location.origin +
- `/teacher/#/shareMusic?id=${staffData.details?.bizId}&recomUserId=${state.user.data?.userId}&userType=${state.platformType}`
- // 判断是否有活动
- if (res.data.discount === 1) {
- url += `&activityId=${res.data.activityId}`
- }
- shareDiscount.value = res.data.discount || 0
- shareUrl.value = url
- shareStatus.value = true
- return
- } catch {}
- }
- /** 获取分轨信息 */
- const getInstrumentItem = (instruments: any, name = "") => {
- name = name.toLocaleLowerCase().replace(/ /g, ""); //.replace(/\d*/gi, '')
- if (!name) return "";
- for (let key in instruments) {
- const item = instruments[key];
- const _key = item.track?.toLocaleLowerCase().replace(/ /g, ""); //.replace(/\d*/gi, '')
- if (_key === name) {
- return item;
- }
- }
- return "";
- };
- // 根据当前选中的声部和曲目筛选出对应的声轨
- function filterSoundCodes(musicalInstruments: any) {
- // 老师端,加上乐器id
- const instrumentIds = staffData.instrumentId // appState.instrumentId || appState.user?.instrumentId || route.query.instrumentId
- if (instrumentIds) {
- const { track } = musicalInstruments.find((item: any) => {
- return instrumentIds == item.musicalInstrumentId
- }) || {}
- return track
- }
- return null
- }
- // 根据当前选中的声部和曲目筛选出对应的声轨
- function filterSoundInfo(musicalInstruments: any) {
- if(musicalInstruments.length <= 0) return null
- // 老师端,加上乐器id
- const instrumentIds = staffData.instrumentId //appState.instrumentId || appState.user?.instrumentId || route.query.instrumentId
- if (instrumentIds) {
- const item = musicalInstruments.find((item: any) => {
- return instrumentIds == item.musicalInstrumentId && item.audioPlayType == 'PLAY'
- }) || null
- return item
- }
- return null
- }
- // 获取PDF
- const getCurrentPdf = (item: any, scoreType: string) => {
- let pdfUrl = ''
- if(scoreType === 'FIRST') {
- pdfUrl = item.firstPdfUrl
- } else if(scoreType === 'JIAN') {
- pdfUrl = item.jianPdfUrl
- } else if(scoreType === 'STAVE') {
- pdfUrl = item.musicPdfUrl
- }
- return pdfUrl || ''
- }
- const toDetail = async (row: any) => {
- staff.radio = row.scoreType // 默认是什么谱页
- const tempSongList = row.musicSheetSoundList || []
- 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 defaultIndex = row.musicSheetType !== "SINGLE" && row.isScoreRender ? index + 1 : index
- const cnName = getInstrumentName(item.track)
- return {
- text: item.track + (cnName ? `(${cnName})` : ''),
- name: item.track + (cnName ? `(${cnName})` : ''), // true
- track: item.track,
- musicPdfUrl: item.musicPdfUrl,
- firstPdfUrl: item.firstPdfUrl,
- jianPdfUrl: item.jianPdfUrl,
- // xmlIndex,
- value: defaultIndex,
- };
- });
- staffData.details = row || {};
- staffData.musicXml = staffData.details?.xmlFileUrl;
- staffData.isComberRender = staffData.details?.isScoreRender;
-
- let defaultShowStaff: any
- if(staffData.details?.musicSheetSoundList) {
- const soundCodes = filterSoundCodes(staffData.details?.musicSheetSoundList)
- if (soundCodes) {
- const soundCodesArr = soundCodes.split(",").map((code: string) => {
- return code
- .toLowerCase()
- .replace(/^\d+|\d+$/g, "")
- .trim()
- })
- defaultShowStaff = partColumns.value.find((item: any) =>
- soundCodesArr.includes(
- item.track &&
- item.track
- .toLowerCase()
- .replace(/^\d+|\d+$/g, "")
- .trim()
- )
- )
- if(defaultShowStaff) {
- staffData.selectedPartIndex = defaultShowStaff.value
- }
- }
- }
-
- if (row.musicSheetType === "SINGLE") {
- staffData.musicPdfUrl = row.musicPdfUrl;
- // 生成的图片
- // staffData.imgs = row.musicImg ? row.musicImg.split(',') : [];
- } else {
- // 初始化数据
- // 是否显示总谱
- if (staffData.isComberRender) {
- partColumns.value.unshift({
- text: "总谱",
- value: 0,
- xmlIndex: 999,
- track: "",
- name: "总谱",
- });
- // 如果是总谱则默认选中,否则选择
- // staffData.selectedPartIndex = row.defaultScoreRender ? 0 : defaultShowStaff ? defaultShowStaff.value : 1
- staffData.selectedPartIndex = defaultShowStaff ? defaultShowStaff.value : 1
- let pdfUrl = ''
- if(row.defaultScoreRender) {
- pdfUrl = getCurrentPdf(row, row.scoreType)
- } else {
- staffData.musicPdfUrl = getCurrentPdf(defaultShowStaff, row.scoreType)
- }
- staffData.musicPdfUrl = pdfUrl
- } else {
- const item = partColumns.value.find((item: any) => item.value === staffData.selectedPartIndex)
- if (item) {
- staffData.musicPdfUrl = getCurrentPdf(item, row.scoreType) //item.musicPdfUrl;
- } else {
- staffData.musicPdfUrl = "";
- }
- }
- }
- // 通过isScoreRender判断是否合并渲染
- // 多声轨, 不是单声部多声轨, 不是老师布置作业选择曲谱
- // if (row.musicSheetType === "SINGLE") {
- // staffData.isConcert = false;
- // const musicSheetSoundList = staffData.details?.musicSheetSoundList || []
- // const songs = filterSoundInfo(musicSheetSoundList)
- // if(songs) {
- // staffData.metronomeMp3Url = songs.audioFileUrl
- // } else {
- // // 为了处理节奏练习
- // if(musicSheetSoundList.length > 0) {
- // staffData.metronomeMp3Url = musicSheetSoundList[0].audioFileUrl
- // }
- // }
- // } else {
- // staffData.isConcert = true;
- // const { audioFileUrl } = row.musicSheetAccompanimentList.find((item: any) => item.audioPlayType == 'PLAY')
- // staffData.metronomeUrl = audioFileUrl
- // }
- audioFileUrl.value = row.mp3Url
- if (
- audioFileUrl.value
- ) {
- // audioFileUrl.value = staffData.isConcert ? staffData.metronomeUrl : staffData.metronomeMp3Url
- nextTick(async () => {
- initAudio();
- });
- } else {
- renderStaff();
- }
- }
- 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://test.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
- href += ('&systemType=' +( state.platformType === "STUDENT" ? `student` : 'teacher'));
- // 总谱还是什么
- if(partIndex === 999) {
- href += `&part-index=${partIndex}`
- } else {
- href += `&part-name=${track}`
- }
- // musicRenderType
- // /** 五线谱 */
- // staff = "staff",
- // /** 简谱(首调) */
- // firstTone = "firstTone",
- // /** 固定音高 */
- // fixedTone = "fixedTone",
- if(staff.radio === "STAVE") {
- href += '&musicRenderType=staff'
- } else if(staff.radio === 'JIAN') {
- href += '&musicRenderType=fixedTone'
- } else if(staff.radio === 'FIRST') {
- href += '&musicRenderType=firstTone'
- }
-
- return href
- };
- const renderStaff = async () => {
- try {
- nextTick(() => {
- console.log(staffData.musicPdfUrl, 'staffData.musicPdfUrl')
- if (staffData.musicPdfUrl) {
- const url = `${location.origin}${
- location.pathname
- }pdf/web/viewer-pdf.html?file=${encodeURIComponent(
- staffData.musicPdfUrl
- )}&t=${Date.now()}`
- const iframeRef = document.querySelector('#staffIframeRef') as any
- iframeRef.contentWindow.location.replace(url)
- // staffData.iframeSrc = url
- } else {
- const url = getPreViewCloud(staffData.musicId, currentColumn.value.xmlIndex, currentColumn.value.track)
- console.log(url, 'staffIframeRef')
- const iframeRef = document.querySelector('#staffIframeRef') as any
- iframeRef.contentWindow.location.replace(url)
- // staffData.iframeSrc = url
- }
- })
- } catch (error) {
- //
- }
- }
- const resetRender = () => {
- const iframeRef: any = document.getElementById("staffIframeRef")
- console.log(currentColumn.value, "currentColumn.value")
- iframeRef.contentWindow.location.replace(getPreViewCloud(staffData.musicId, currentColumn.value?.xmlIndex, currentColumn.value.track))
- }
- return () => {
- return (
- <div class={styles.detail}>
- <ColSticky position="top">
- <div ref={headers}>
- <ColHeader
- background="transparent"
- hideHeader={false}
- border={false}
- isFixed={false}
- color="#fff"
- title={staffData.details?.name}
- backIconColor="white"
- v-slots={{
- right: () => (
- <div
- class={styles.shareBtn}
- style={{
- color: '#fff'
- }}
- onClick={onShare}
- >
- <Image src={iconShare} />
- 分享
- </div>
- )
- }}
- />
- </div>
- </ColSticky>
- <img class={styles.bgImg} src={staffData.details?.musicCover} />
- <div class={styles.bgContent}></div>
- <div
- class={styles.musicContainer}
- style={{
- marginTop: '16px',
- height: `calc(100vh - var(--header-height) - var(--bottom-height) - 16px)`
- }}
- >
- <div>
- <Cell
- border={false}
- center
- class={styles.musicInfo}
- v-slots={{
- icon: () => (
- <Image
- class={styles.pImg}
- src={ staffData.details?.musicCover}
- />
- ),
- title: () => (
- <div class={styles.info}>
- <h4
- class="van-ellipsis"
- // onClick={() => handleGotoMusicScore( staffData.details)}
- >
- { staffData.details?.name}
- </h4>
- <p
- style={{
- display: 'flex',
- alignItems: 'center'
- }}
- >
- {paymentType.value.map(
- tag =>
- tag && (
- <Tag
- style={{ color: colors[tag]?.color }}
- class={styles.tag}
- type="success"
- plain
- >
- {colors[tag].text}
- </Tag>
- )
- )}
- { staffData.details?.exquisiteFlag === 1 && (
- <Image
- class={styles.exquisiteFlag}
- src={getAssetsHomeFile('icon_exquisite.png')}
- />
- )}
- { staffData.details?.albumNums > 0 && (
- <Image
- class={styles.songAlbum}
- src={getAssetsHomeFile('icon_album_active.png')}
- />
- )}
- <span
- class={[
- styles.coomposer,
- browser().isApp &&
- staffData.details?.sourceType === 'TEACHER' &&
- state.platformType === 'STUDENT' &&
- styles.links
- ]}
- onClick={() => {
- if (
- browser().isApp &&
- staffData.details?.sourceType === 'TEACHER' &&
- state.platformType === 'STUDENT'
- ) {
- router.push({
- path: '/teacherHome',
- query: {
- teacherId: staffData.details?.userId,
- tabs: 'music'
- }
- })
- }
- }}
- >
- <img class={styles.iconAlbum2} src={iconAlbum2} />
- <span>
- { staffData.details?.userName ||
- '游客' + ( staffData.details?.userId || '')}
- </span>
- </span>
- </p>
- </div>
- ),
- value: () => (
- <>
- <span
- style={{
- visibility:
- state.platformType === 'TEACHER'
- ? 'visible'
- : 'hidden'
- }}
- class={styles.download}
- onClick={() => {
- if ( staffData.details?.coursewareStatus) {
- removeCourse()
- } else {
- onAddCourse()
- }
- }}
- >
- <img
- src={
- staffData.details?.coursewareStatus
- ? iconRemoveCourse
- : iconAddCourse
- }
- />
- <span>
- { staffData.details?.coursewareStatus
- ? '移出课件'
- : '添加课件'}
- </span>
- </span>
- <span
- class={styles.download}
- onClick={() => toggleFavorite()}
- >
- <img
- src={
- staffData.details?.favorite
- ? iconCollectActive
- : iconCollect
- }
- />
- <span>收藏</span>
- </span>
- </>
- )
- }}
- />
- <div class={styles.functionSection}>
- <div
- class={styles.functionItem}
- onClick={() => {
- router.push({
- path: '/look-album-list',
- query: {
- id: staffData.details?.bizId,
- musicSubject: staffData.details?.musicSubject
- }
- })
- }}
- >
- <img src={iconAlbum} />
- <span>专辑</span>
- </div>
- <div
- class={styles.functionItem}
- style={{
- display:
- staffData.details?.musicSheetType === 'CONCERT'
- ? ''
- : 'none'
- }}
- onClick={() => {
- if ( staffData.details?.musicSheetType === 'CONCERT') {
- staffData.open = true
- }
- }}
- >
- <img src={iconChange} />
- <span>切换乐器</span>
- </div>
- {/* 独奏的才有转谱功能 */}
- {staffData.details?.isConvertibleScore && staffData.details?.musicSheetType === 'SINGLE' ? (
- <div
- class={styles.functionItem}
- style={{
- display:
- staffData.details?.musicSheetType === 'SINGLE'
- ? ''
- : 'none'
- }}
- onClick={() => {
- staff.status = true
- }}
- >
- <img src={iconChange} />
- <span>转谱</span>
- </div>
- ) : null}
- <div
- class={[styles.functionItem, (loading.value ||
- (!staffData.musicPdfUrl && staffData.imgs.length <= 0)) ? styles.disabled : '']}
- onClick={() => {
- // console.log(loading.value, staffData.musicPdfUrl, staffData.imgs, '---------------')
- if((loading.value ||
- (!staffData.musicPdfUrl && staffData.imgs.length <= 0))) return
- if (staffData.musicPdfUrl) {
- const songName =
- staffData.details?.name +
- (staffData.isConcert &&
- currentColumn.value?.name
- ? `(${
- currentColumn.value
- ?.name || ""
- })`
- : "");
- promisefiyPostMessage({
- api: "downloadFile",
- content: {
- downloadUrl: staffData.musicPdfUrl,
- fileName: songName,
- },
- });
- } else {
- downloadStatus.value = true;
- }
- }}
- >
- <img src={iconDownload} />
- <span>下载</span>
- </div>
- </div>
- </div>
- <div class={styles.musicContent}>
- {staffData.details.id ? (
- <>
- {staffData.musicPdfUrl ? (
- <>
- {/* {loading.value && (
- <>
- <Vue3Lottie
- animationData={AstronautJSON}
- class={styles.finch}
- ></Vue3Lottie>
- <p class={styles.finchLoad}>加载中...</p>
- </>
- )} */}
- <iframe
- style={{
- opacity: loading.value ? 0 : 1,
- }}
- id="staffIframeRef"
- src={staffData.iframeSrc}
- onLoad={() => {
- // 判断是用哪个渲染的
- loading.value = false;
- }}
- ></iframe>
- </>
- ) : (
- <>
- <p class={styles.musicTitle}>
- {staffData.details?.name && (
- <>
- {staffData.details?.name}
- {staffData.isConcert &&
- currentColumn.value?.name
- ? `(${
- currentColumn.value
- ?.name || ""
- })`
- : ""}
- </>
- )}
- </p>
- {/* {loading.value && (
- <>
- <Vue3Lottie
- animationData={AstronautJSON}
- class={styles.finch}
- ></Vue3Lottie>
- <p class={styles.finchLoad}>加载中...</p>
- </>
- )} */}
- <iframe
- id="staffIframeRef"
- style={{
- opacity: loading.value ? 0 : 1,
- }}
- src={staffData.iframeSrc}
- onLoad={() => {
- loading.value = false;
- // musicIframeLoad();
- }}
- ></iframe>
- </>
- )}
- </>
- ) : null}
- </div>
- </div>
- {staffData.details?.bizId && (
- <ColSticky
- position="bottom"
- background="white"
- varName="--bottom-height"
- >
- <div ref={footers}>
- <div class={styles.videoOperation}>
- {audioFileUrl.value && (
- <>
- {!buyState.value.play &&
- freeRate.value != 100 &&
- freeRate.value != 0 && (
- <div class={[styles.audition]}>
- <img src={iconListen} />
- <span>每首曲目可试听{freeRate.value}%</span>
- </div>
- )}
- <div class={[styles.audio, styles.collectCell]}>
- <audio id="player" controls ref={audio}>
- <source src={audioFileUrl.value} type="audio/mp3" />
- </audio>
- </div>
- </>
- )}
- </div>
- {/* 判断是否是免费的,或者已经购买过,是否从专辑过来的 */}
- {buyState.value.play ||
- (state.platformType === 'TEACHER' &&
- buyState.value.hasTenantAlbum) ? (
- <Button
- round
- block
- type="primary"
- color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
- onClick={() => {
- const throttleFn = useThrottleFn(() => {
- player.value && player.value.stop()
- // 新版云教练的谱面类型使用musicRenderType字段
- let musicRenderType = ''
- if(staff.radio === "STAVE") {
- musicRenderType = 'staff'
- } else if(staff.radio === 'JIAN') {
- musicRenderType = 'fixedTone'
- } else if(staff.radio === 'FIRST') {
- musicRenderType = 'firstTone'
- }
- let extraParam: any = {
- // 'part-index': currentColumn.value.track || 0,
- 'part-name': currentColumn.value.track?.trim(),
- musicRenderType,
- instrumentId: staffData.instrumentId
- }
- // 有专辑id
- if (route.query.tenantAlbumId) {
- extraParam.albumId = route.query.tenantAlbumId
- } else if (browser().isTeacher && route.query.providerType == 'TENANT') {
- // 机构老师端
- extraParam.albumId = 1
- }
- musicBuy({
- id: staffData.details.bizId
- }, () => {}, extraParam)
- }, 300)
- throttleFn()
- }}
- >
- 立即练习
- </Button>
- ) : (
- <div class={styles.colSticky}>
- {/* 只有,有点播类型的才显示价格 */}
- {buyState.value.charge && (
- <div class={styles.priceSection}>
- <span>点播价:</span>
- <span class={styles.price}>
- <i>¥</i>
- {moneyFormat(staffData.details?.musicPrice)}
- </span>
- </div>
- )}
- <div class={[styles.buyBtn]}>
- {/* 判断是否是需要收费的 */}
- {buyState.value.charge && (
- <Button
- round
- type="primary"
- color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
- class={styles.primary}
- onClick={onBuy}
- >
- 立即点播
- </Button>
- )}
- {/* 判断是否有会员的 */}
- {buyState.value.vip && (
- <Button
- round
- block={!buyState.value.charge ? true : false}
- type="primary"
- color="linear-gradient(180deg, #F7BD8D 0%, #CD8806 100%)"
- class={styles.memeber}
- onClick={() => {
- router.push({
- path: '/memberCenter',
- query: {
- ...route.query
- }
- })
- }}
- >
- {studentActivityId.value > 0 && (
- <div class={[styles.buttonDiscount]}>专属优惠</div>
- )}
- 开通会员
- </Button>
- )}
- </div>
- </div>
- )}
- </div>
- </ColSticky>
- )}
- <Popup
- v-model:show={shareStatus.value}
- style={{ background: 'transparent' }}
- teleport="body"
- >
- <ColShare
- teacherId={state.user.data?.userId}
- shareUrl={shareUrl.value}
- shareType="music"
- >
- <div class={styles.shareMate}>
- {shareDiscount.value === 1 && (
- <div class={styles.tagDiscount}>专属优惠</div>
- )}
- <img
- class={styles.icon}
- crossorigin="anonymous"
- src={staffData.details?.musicCover}
- />
- <div class={styles.info}>
- <h4 class="van-multi-ellipsis--l2">
- {staffData.details?.name}
- </h4>
- <p>作曲人:{staffData.details?.composer}</p>
- </div>
- </div>
- </ColShare>
- </Popup>
- <Popup v-model:show={downloadStatus.value} position="bottom" round>
- {downloadStatus.value && (
- <Download
- imgList={JSON.parse(JSON.stringify(staffData.imgs))}
- musicSheetName={
- staffData.details.name +
- (staffData.isConcert &&
- currentColumn.value?.name
- ? `(${
- currentColumn.value?.name || ""
- })`
- : "")
- }
- />
- )}
- </Popup>
- <Popup
- v-model:show={staff.status}
- teleport="body"
- closeable
- style={{ width: '80%' }}
- round
- >
- <div class={styles.staffContainer}>
- <div class={styles.staffTitle}>选择转换曲谱</div>
- <RadioGroup v-model={staff.radio}>
- <CellGroup border={false}>
- <Cell
- center
- border={false}
- class={staff.radio === 'STAVE' ? styles.active : ''}
- onClick={() => onChangeStaff('STAVE')}
- >
- {{
- icon: () => (
- <Image src={staffDetafult} class={styles.staffImg} />
- ),
- title: () => <span class={styles.name}>五线谱</span>,
- value: () => (
- <Radio name="STAVE">
- {{
- icon: (props: any) => (
- <Icon
- class={styles.boxStyle}
- size={16}
- name={
- props.checked
- ? activeButtonIcon
- : inactiveButtonIcon
- }
- />
- )
- }}
- </Radio>
- )
- }}
- </Cell>
- <Cell
- center
- border={false}
- class={staff.radio === 'FIRST' ? styles.active : ''}
- onClick={() => onChangeStaff('FIRST')}
- >
- {{
- icon: () => (
- <Image src={firstDefault} class={styles.staffImg} />
- ),
- title: () => <span class={styles.name}>简谱-首调</span>,
- value: () => (
- <Radio name="FIRST">
- {{
- icon: (props: any) => (
- <Icon
- class={styles.boxStyle}
- size={16}
- name={
- props.checked
- ? activeButtonIcon
- : inactiveButtonIcon
- }
- />
- )
- }}
- </Radio>
- )
- }}
- </Cell>
- <Cell
- center
- border={false}
- class={staff.radio === 'JIAN' ? styles.active : ''}
- onClick={() => onChangeStaff('JIAN')}
- >
- {{
- icon: () => (
- <Image src={fixedDefault} class={styles.staffImg} />
- ),
- title: () => <span class={styles.name}>简谱-固定调</span>,
- value: () => (
- <Radio name="JIAN">
- {{
- icon: (props: any) => (
- <Icon
- class={styles.boxStyle}
- size={16}
- name={
- props.checked
- ? activeButtonIcon
- : inactiveButtonIcon
- }
- />
- )
- }}
- </Radio>
- )
- }}
- </Cell>
- </CellGroup>
- </RadioGroup>
- </div>
- </Popup>
- <Popup
- teleport="body"
- position="bottom"
- round
- v-model:show={staffData.open}
- >
- <Picker
- columns={partColumns.value}
- defaultIndex={staffData.selectedPartIndex}
- onConfirm={value => {
- staffData.open = false;
- staffData.selectedPartIndex = value.value;
- staffData.imgs = [];
- nextTick(() => {
- let tempPdf = "";
- if (staffData.isComberRender && value.xmlIndex === 999) {
- if (getCurrentPdf(staffData.list, staff.radio)) {
- tempPdf = getCurrentPdf(staffData.list, staff.radio);
- }
- } else {
- const item = getInstrumentItem(staffData.list, value.track);
- if (item && getCurrentPdf(item, staff.radio)) {
- tempPdf = getCurrentPdf(item, staff.radio);
- }
- }
- staffData.musicPdfUrl = tempPdf;
- if (tempPdf) {
- renderStaff();
- } else {
- loading.value = true;
- if (staffData.musicPdfUrl) {
- staffData.musicPdfUrl = "";
- renderStaff();
- } else {
- resetRender();
- }
- }
- });
- }}
- onCancel={() => (staffData.open = false)}
- />
- </Popup>
- </div>
- )
- }
- }
- })
|