1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273 |
- import TheSticky from '@/components/the-sticky'
- import styles from './new-index.module.less'
- import { useEventListener, useThrottleFn, useWindowScroll } from '@vueuse/core'
- import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
- // import iconShare from '../../images/icon-share.png'
- import oStart from '../album-detail/icon-hart.png'
- import iStart from '../album-detail/icon-hart-active.png'
- import iconDownload from './images/icon-download.png'
- import iconMemberSmall from './images/icon-member-small.png'
- import {
- computed,
- defineComponent,
- nextTick,
- onMounted,
- onUnmounted,
- reactive,
- ref,
- toRaw,
- 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 {
- Button,
- Cell,
- CellGroup,
- Dialog,
- Icon,
- Image,
- Popup,
- RadioGroup,
- Radio,
- Toast,
- Picker
- } from 'vant'
- import { useRect } from '@vant/use'
- import { Vue3Lottie } from 'vue3-lottie'
- import { getRandomKey, musicBuy } from '../music'
- import { getOssUploadUrl, state } from '@/state'
- import { browser, moneyFormat } from '@/helpers/utils'
- import { orderStatus } from '@/views/order-detail/orderStatus'
- import AstronautJSON from './animate/refresh_anim.json'
- // import ColShare from '@/components/col-share'
- import iconListen from './images/icon_listen.png'
- import iconTeacher from '@common/images/icon_teacher.png'
- import emtpy from './images/emtpy.png'
- import { state as baseState } from '@/state'
- import activeButtonIcon from './images/icon_checkbox.png'
- import inactiveButtonIcon from './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 { getUploadSign, onOnlyFileUpload } from '@/helpers/oss-file-upload'
- import { svgtopng } from './formatSvgToImg'
- // import { shareCall } from '@/teacher/share-page/share'
- import deepClone from '@/helpers/deep-clone'
- import { formatXML, getCustomInfo, onlyVisible } from './instrument'
- import { data } from 'browserslist'
- export default defineComponent({
- name: 'new-index',
- setup() {
- localStorage.setItem('behaviorId', getRandomKey())
- const router = useRouter()
- const route = useRoute()
- const loading = ref(false)
- const background = ref<string>('rgba(55, 205, 177, 0)')
- const color = ref<string>('#fff')
- 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 musicDetail = ref<any>(null)
- const audioFileUrl = ref('')
- const showImg = ref([] as any)
- const firstList = ref<Array<any>>([])
- const fixedList = ref<Array<any>>([])
- const staffList = ref<Array<any>>([])
- const musicPdfUrl = ref('')
- const uploadImgs = ref<boolean>(false)
- const defaultImgs = ref({
- first: false,
- fixed: false,
- staff: false
- })
- const downloadStatus = ref<boolean>(false)
- const staff = reactive({
- status: false,
- radio: 'staff' // staff first fixed
- })
- const apiSuffix = ref(
- baseState.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
- )
- // 更改预览状态
- const onChangeStaff = (type: string) => {
- staff.radio = type
- staff.status = false
-
- if (type == 'first') {
- loading.value = false
- const tempPdf = musicDetail.value?.firstPdfUrl
- initIframe(tempPdf, 'first', staffData.musicXml)
- } else if (type == 'fixed') {
- loading.value = false
- const tempPdf = musicDetail.value?.jianPdfUrl
- initIframe(tempPdf, 'first', staffData.musicXml)
- } else {
- loading.value = false
- const tempPdf = musicDetail.value?.musicPdfUrl
- initIframe(tempPdf, 'first', staffData.musicXml)
- }
- }
- watch(
- () => staff.radio,
- (val: string) => {
- if (val == 'first') {
- showImg.value = deepClone(firstList.value)
- } else if (val == 'fixed') {
- showImg.value = deepClone(fixedList.value)
- } else {
- showImg.value = deepClone(staffList.value)
- }
- }
- )
- const FetchList = async (id?: any) => {
- if (loading.value) {
- return
- }
- loading.value = true
- isError.value = false
- try {
- const res = await request.get(`/music/sheet/detail/${route.query.id}`, {
- prefix:
- state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student',
- params: {
- tenantAlbumId: route.query.tenantAlbumId || null
- }
- })
- musicDetail.value = res.data
- // 取原音,如果有多个则默认第一个
- const background = res.data.background
- audioFileUrl.value =
- background && background.length > 0 ? background[0].audioFileUrl : ''
- showImg.value = res.data.musicImg ? res.data.musicImg.split(',') : []
- firstList.value = res.data.firstTone
- ? res.data.firstTone.split(',')
- : []
- fixedList.value = res.data.fixedTone
- ? res.data.fixedTone.split(',')
- : []
- staffList.value = res.data.musicImg ? res.data.musicImg.split(',') : []
- // 初始化默认数据是否有值
- if (firstList.value.length > 0) {
- defaultImgs.value.first = true
- }
- if (fixedList.value.length > 0) {
- defaultImgs.value.fixed = true
- }
- if (staffList.value.length > 0) {
- defaultImgs.value.staff = true
- }
- nextTick(async () => {
- await toDetail()
- renderStaff()
- })
- } catch (error) {
- isError.value = true
- }
- if (musicDetail.value?.musicSheetType !== 'CONCERT') {
- 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(
- '/api-student/sysConfig/queryByParamNameList',
- {
- params: {
- paramNames: 'music_sheet_free_rate'
- }
- }
- )
- freeRate.value = config.data[0]?.paramValue || 0
- 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) => {
- // console.log(e, 'showLoading')
- if (e.data?.api === 'musicStaffRender') {
- const osmdImg = e.data.osmdImg
- showImg.value = []
- const imgs: any = []
- // 独奏并且的图片则不用生成
- if (
- musicDetail.value?.musicSheetType === 'SINGLE' &&
- musicDetail.value?.notation
- ) {
- if (
- (staff.radio === 'first' && firstList.value.length > 0) ||
- (staff.radio === 'fixed' && fixedList.value.length > 0) ||
- (staff.radio === 'staff' && staffList.value.length > 0)
- ) {
- if (staff.radio === 'first') {
- showImg.value = firstList.value
- } else if (staff.radio === 'fixed') {
- showImg.value = fixedList.value
- }
- if (staff.radio === 'staff') {
- showImg.value = staffList.value
- }
- loading.value = e.data.loading
- return
- }
- }
- uploadImgs.value = true
- if (osmdImg) {
- for (let i = 0; i < osmdImg.length; i++) {
- const img = await svgtopng(
- osmdImg[i].img,
- osmdImg[i].width,
- osmdImg[i].height
- )
- imgs.push(img)
- }
- }
- uploadImgs.value = false
- // 判断是否为独奏
- if (
- musicDetail.value?.musicSheetType === 'SINGLE' &&
- musicDetail.value?.notation
- ) {
- if (staff.radio === 'first') {
- firstList.value = imgs
- } else if (staff.radio === 'fixed') {
- fixedList.value = imgs
- } else if (staff.radio === 'staff') {
- staffList.value = imgs
- }
- showImg.value = imgs
- } else {
- showImg.value = imgs
- }
- loading.value = e.data.loading
- }
- }
- onMounted(async () => {
- 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)
- })
- onUnmounted(() => {
- postMessage({
- api: 'setStatusBarTextColor',
- content: { statusBarTextColor: false }
- })
- window.removeEventListener('message', showLoading)
- })
- const toggleFavorite = async () => {
- try {
- await request.post('/music/sheet/favorite/' + musicDetail.value?.id, {
- prefix:
- state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
- })
- musicDetail.value.favorite = musicDetail.value?.favorite ? 0 : 1
- musicDetail.value.favoriteCount = musicDetail.value?.favorite
- ? musicDetail.value.favoriteCount + 1
- : musicDetail.value.favoriteCount - 1 < 0
- ? 0
- : musicDetail.value.favoriteCount - 1
- setTimeout(() => {
- Toast(musicDetail.value?.favorite ? '收藏成功' : '取消收藏成功')
- }, 100)
- } catch (error) {
- //
- }
- }
- const onBuy = async () => {
- const music = musicDetail.value
- orderStatus.orderObject.orderType = 'MUSIC'
- orderStatus.orderObject.orderName = music.musicSheetName
- orderStatus.orderObject.orderDesc = music.musicSheetName
- 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.musicSheetName,
- actualPrice: music.musicPrice,
- ...music
- }
- ]
- const res = await request.post('/api-student/userOrder/getPendingOrder', {
- data: {
- goodType: 'MUSIC',
- bizId: music.id
- }
- })
- const result = res.data
- if (result) {
- Dialog.confirm({
- title: '提示',
- message: '您有一个未支付的订单,是否继续支付?',
- theme: 'round-button',
- className: 'confirm-button-group',
- 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 = musicDetail.value
- router.push({
- path: '/orderDetail',
- query: {
- orderType: 'MUSIC',
- musicId: music.id
- }
- })
- }
- const cancelPayment = async (orderNo: string) => {
- try {
- await request.post('/api-student/userOrder/orderCancel', {
- data: {
- orderNo
- }
- })
- } catch {
- //
- }
- }
- const buyState = computed(() => {
- const music = musicDetail.value
- 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 staffData = reactive({
- open: false,
- iframeSrc: '',
- musicXml: '',
- instrumentName: '',
- iframeRef: null as any,
- partIndex: 0,
- partXmlIndex: 0,
- partList: [] as any[],
- tempPartList: [] as any[],
- xmlPartList: [] as any[]
- })
- /** 渲染五线谱 */
- // 长笛、单簧管、萨克斯、小号、长号、圆号、大号、上低音号
- 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 toDetail = async () => {
- try {
- if (musicDetail.value?.xmlFileUrl) {
- // 获取文件
- const res = await umiRequest.get(musicDetail.value?.xmlFileUrl, {
- mode: 'cors'
- })
- let partNames: string[] = []
- const xml: any = new DOMParser().parseFromString(res, 'text/xml')
- for (const item of xml.getElementsByTagName('part-name')) {
- if (item.textContent) {
- partNames.push(item.textContent)
- }
- }
- partNames = partNames.filter(
- (item: any) => !item?.toLocaleUpperCase()?.includes('COMMON')
- )
- const partList: any = []
- for (let j = 0; j < partNames.length; j++) {
- partList.push({
- name: partNames[j],
- value: j
- })
- }
- staffData.xmlPartList = partList
- }
- staffData.musicXml = musicDetail.value?.xmlFileUrl || ''
- const tempList = musicDetail.value?.background || []
- const tempPartList = [] as any
- staffData.xmlPartList.forEach((part: any) => {
- const item = tempList.find((item: any) => item.track === part.name)
- if (item) {
- tempPartList.push({
- ...item,
- index: part.value
- })
- }
- })
- staffData.partList = tempPartList
- staffData.tempPartList = JSON.parse(JSON.stringify(staffData.partList))
- staffData.partList = instrumentSort(staffData.partList)
- // console.log(staffData.partList, ' staffData.partList')
- staffData.partXmlIndex = staffData.partList[0]?.index || 0
- staffData.instrumentName =
- musicDetail.value?.musicSheetType === 'CONCERT'
- ? getInstrumentName(staffData.partList[staffData.partIndex]?.track)
- : ''
- if (musicDetail.value?.musicSheetType === 'SINGLE') {
- musicPdfUrl.value = musicDetail.value?.musicPdfUrl
- } else {
- musicPdfUrl.value = staffData.partList[0]?.musicPdfUrl
- }
- } catch (error) {
- //
- }
- }
- const renderStaff = async () => {
- try {
- nextTick(() => {
- if (musicPdfUrl.value) {
- // const url = `${location.origin}${
- // location.pathname
- // }pdf/web/viewer-pdf.html?file=${encodeURIComponent(
- // musicPdfUrl.value
- // )}&t=${Date.now()}`
- const url = '/pdf/web/viewer-pdf.html?file=' +
- encodeURIComponent(musicPdfUrl.value) +
- '&t=' +
- Date.now()
-
- const iframeRef = document.querySelector('#staffIframeRef') as any
- iframeRef.contentWindow.location.replace(
- url
- )
- staffData.iframeSrc = url
- } else {
- // const url = `${location.origin}${location.pathname}osmd/index.html`
- const url = `${location.origin}/osmd/index.html`
- const iframeRef = document.querySelector('#staffIframeRef') as any
- iframeRef.contentWindow.location.replace(url)
- staffData.iframeSrc = url
- }
- })
- } catch (error) {
- //
- }
- }
- const musicIframeLoad = async () => {
- const iframeRef: any = document.getElementById('staffIframeRef')
- if (iframeRef && iframeRef.contentWindow.renderXml) {
- const res = await umiRequest.get(staffData.musicXml, {
- mode: 'cors'
- })
- const parseXmlInfo = getCustomInfo(res)
- const xml = formatXML(parseXmlInfo.parsedXML)
- const currentXml = onlyVisible(xml, staffData.partXmlIndex)
- iframeRef.contentWindow.renderXml(currentXml, 0)
- // iframeRef.contentWindow.renderXml(
- // staffData.musicXml,
- // staffData.partXmlIndex
- // )
- }
- }
- const resetRender = async () => {
- const iframeRef: any = document.getElementById('staffIframeRef')
- if (iframeRef && iframeRef.contentWindow.renderXml) {
- loading.value = true
- // iframeRef.contentWindow.resetRender(staffData.partXmlIndex)
- const res = await umiRequest.get(staffData.musicXml, {
- mode: 'cors'
- })
- const parseXmlInfo = getCustomInfo(res)
- const xml = formatXML(parseXmlInfo.parsedXML)
- const currentXml = onlyVisible(xml, staffData.partXmlIndex)
- iframeRef.contentWindow.renderXml(currentXml, 0)
- staffData.instrumentName = getInstrumentName(
- staffData.partList[staffData.partIndex]?.track
- )
- }
- }
- const resetRenderPage = async (type: string, xmlUrl: string) => {
- const iframeRef: any = document.getElementById('staffIframeRef')
- if (iframeRef && iframeRef.contentWindow.renderXml) {
- // console.log('resetRenderPage')
- // iframeRef.contentWindow.resetRenderPage(type, xmlUrl)
- const res = await umiRequest.get(staffData.musicXml, {
- mode: 'cors'
- })
- const parseXmlInfo = getCustomInfo(res)
- const xml = formatXML(parseXmlInfo.parsedXML)
- const currentXml = onlyVisible(xml, staffData.partXmlIndex)
- iframeRef.contentWindow.resetRenderPage(type, currentXml)
- }
- }
- const partColumns = computed(() => {
- return staffData.partList.map((item: any, index: number) => {
- const instrumentName =
- musicDetail.value?.musicSheetType === 'CONCERT'
- ? getInstrumentName(item.track)
- : ''
- return {
- text: item.track + (instrumentName ? `(${instrumentName})` : ''),
- value: index,
- instrumentName,
- musicPdfUrl: item.musicPdfUrl,
- firstPdfUrl: item.firstPdfUrl,
- jianPdfUrl: item.jianPdfUrl,
- xmlValue: item.index,
- track: item.track
- }
- })
- })
- const onDownloadApp = () => {
- Dialog.alert({
- title: '提示',
- message: '请在酷乐秀APP中使用',
- confirmButtonColor: '#2dc7aa'
- }).then(() => {
- window.location.href = location.origin + '/student/#/download'
- })
- }
- // 购买
- const onSubmit = async () => {
- const url =
- apiSuffix.value +
- '/tenantGroupAlbum/buyAlbumInfo?tenantGroupAlbumId=' +
- (route.query.taId || '')
- // if (state.albumId) {
- // url = url + '?albumId=' + state.albumId
- // }
- const { data } = await request.get(url)
- const details = data[0]
- orderStatus.orderObject.orderType = 'TENANT_ALBUM'
- orderStatus.orderObject.orderName = details.name
- orderStatus.orderObject.orderDesc = details.name
- orderStatus.orderObject.actualPrice = details.actualPrice
- // orderStatus.orderObject.recomUserId = route.query.recomUserId || 0
- // orderStatus.orderObject.activityId = route.query.activityId || 0
- orderStatus.orderObject.orderNo = ''
- orderStatus.orderObject.orderList = [
- {
- orderType: 'TENANT_ALBUM',
- goodsName: details.name,
- actualPrice: details.actualPrice,
- price: details.actualPrice,
- ...details
- }
- ]
- const res = await request.post('/api-student/userOrder/getPendingOrder', {
- data: {
- goodType: 'TENANT_ALBUM',
- bizId: details.id
- }
- })
- const result = res.data
- if (result) {
- Dialog.confirm({
- title: '提示',
- message: '您有一个未支付的订单,是否继续支付?',
- theme: 'round-button',
- className: 'confirm-button-group',
- 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
- }
- routerToALBUM(details.id)
- })
- .catch(() => {
- Dialog.close()
- // 只用取消订单,不用做其它处理
- cancelPaymentALBUM(result.orderNo)
- })
- } else {
- routerToALBUM(details.id)
- }
- }
- const cancelPaymentALBUM = async (orderNo: string) => {
- try {
- await request.post('/api-student/userOrder/orderCancel/v2', {
- data: {
- orderNo
- }
- })
- } catch {
- //
- }
- }
- const routerToALBUM = (id: string) => {
- router.push({
- path: '/orderDetail',
- query: {
- orderType: 'ALBUM',
- album: id
- }
- })
- }
- const initIframe = (tempPdf: string, staff: string, xml: string) => {
- if (tempPdf) {
- musicPdfUrl.value = tempPdf
- renderStaff()
- } else {
- musicPdfUrl.value = ''
- // 为了处理,之前是使用pdf渲染,现在又用osmd,iframe没有重新加载
- if (staffData.iframeSrc.indexOf('pdf/web') !== -1) {
- renderStaff()
- } else {
- resetRenderPage(staff, xml)
- }
- }
- }
- return () => (
- <div class={styles.detail}>
- <TheSticky position="top">
- <ColHeader
- background={background.value}
- hideHeader={false}
- border={false}
- isFixed={false}
- color={color.value}
- backIconColor="white"
- />
- </TheSticky>
- <img class={styles.bgImg} src={musicDetail.value?.titleImg} />
- <div class={styles.musicContentBg}></div>
- <div class={styles.bg}>
- <div class={styles.alumWrap}>
- <div class={styles.img}>
- {/* {albumDetail.value?.paymentType === 'CHARGE' && (
- <span class={styles.albumType}>付费</span>
- )} */}
- <Image
- class={styles.image}
- width="100%"
- height="100%"
- fit="cover"
- src={musicDetail.value?.titleImg}
- />
- </div>
- <div class={styles.alumDes}>
- <div class={[styles.alumTitle, 'van-ellipsis']}>
- {musicDetail.value?.musicSheetName}
- </div>
- <div class={[styles.des, 'van-multi-ellipsis--l2']}>
- {!musicDetail.value?.composer
- ? `上传者:${musicDetail.value?.addName || ''}`
- : `作曲:${musicDetail.value?.composer || ''}`}
- </div>
- </div>
- </div>
- <div class={[styles.alumCollect]}>
- <div
- class={[
- styles.alumCollectItem,
- showImg.value.length <= 0 && !musicPdfUrl.value
- ? styles.alumCollectItemActive
- : ''
- ]}
- onClick={() => {
- if (browser().isApp) {
- if (musicPdfUrl.value) {
- const songName =
- musicDetail.value?.musicSheetName +
- (staffData.instrumentName
- ? `(${staffData.instrumentName})`
- : '')
- promisefiyPostMessage({
- api: 'downloadFile',
- content: {
- downloadUrl: musicPdfUrl.value,
- fileName: songName
- }
- })
- return
- }
- if (showImg.value.length > 0) {
- downloadStatus.value = true
- }
- } else {
- onDownloadApp()
- }
- }}
- >
- <img src={iconDownload} />
- <span>下载曲谱</span>
- </div>
- <div
- class={styles.alumCollectItem}
- onClick={() => toggleFavorite()}
- >
- <img src={musicDetail.value?.favorite ? iStart : oStart} />
- <span>{musicDetail.value?.favoriteCount}人收藏</span>
- </div>
- </div>
- {/* {buyState.value.hasTenantAlbum ? 'true' : 'false'} */}
- {musicDetail.value?.id &&
- !buyState.value.play &&
- !buyState.value.hasTenantAlbum && (
- <div class={styles.albumTips}>
- {buyState.value.charge && buyState.value.vip ? (
- <>
- <span>开通会员或点播单曲,即可自由练习该曲谱</span>
- <span class={styles.albumPrice}>
- ¥{moneyFormat(musicDetail.value?.musicPrice)}
- </span>
- </>
- ) : buyState.value.vip ? (
- <span>
- <img src={iconMemberSmall} class={styles.iconMemberSmall} />
- 此曲谱为会员专享,开通会员即可自由练习该曲谱
- </span>
- ) : buyState.value.charge ? (
- <>
- <span>此曲谱为点播曲谱,点播即可自由练习该曲谱</span>
- <span class={styles.albumPrice}>
- ¥{moneyFormat(musicDetail.value?.musicPrice)}
- </span>
- </>
- ) : (
- ''
- )}
- </div>
- )}
- </div>
- <div class={styles.musicContent}>
- {musicDetail.value?.notation ? (
- <span
- class={styles.iconTransfer}
- style={{
- display:
- musicDetail.value?.musicSheetType === 'SINGLE' ? '' : 'none',
- // opacity: showImg.value.length <= 0 || data.musicPdfUrl ? 0.6 : 1
- }}
- onClick={() => {
- // if (showImg.value.length <= 0 || data.musicPdfUrl) return
- staff.status = true
- }}
- >
- 转谱
- </span>
- ) : null}
- <span
- class={styles.iconTransfer}
- style={{
- display:
- musicDetail.value?.musicSheetType === 'CONCERT' ? '' : 'none'
- }}
- onClick={() => {
- staffData.open = true
- }}
- >
- 切换声轨
- </span>
- {musicDetail.value?.musicSheetType === 'CONCERT' || musicPdfUrl.value ||
- !defaultImgs.value[staff.radio] ? (
- <>
- {musicPdfUrl.value ? (
- <iframe
- id="staffIframeRef"
- style={{
- opacity: loading.value ? 0 : 1,
- flex: "1 auto"
- }}
- // src={staffData.iframeSrc}
- onLoad={() => {
- // 判断是用哪个渲染的
- loading.value = false
- }}
- ></iframe>
- ) : (
- <>
- <p class={styles.musicTitle}>
- {(musicDetail.value?.musicSheetName
- ? musicDetail.value?.musicSheetName
- : '') +
- (staffData.instrumentName
- ? `(${staffData.instrumentName})`
- : '')}
- </p>
- {loading.value && (
- <div>
- <Vue3Lottie
- animationData={AstronautJSON}
- class={styles.finch}
- ></Vue3Lottie>
- {/* <p class={styles.finchLoad}>加载中...</p> */}
- </div>
- )}
- <iframe
- id="staffIframeRef"
- style={{
- opacity: loading.value ? 0 : 1,
- flex: "1 auto"
- }}
- // src={staffData.iframeSrc}
- onLoad={() => {
- musicIframeLoad()
- }}
- ></iframe>
- </>
- )}
- </>
- ) : (
- <div class={styles.imgSection}>
- <p class={styles.musicTitle}>
- {(musicDetail.value?.musicSheetName
- ? musicDetail.value?.musicSheetName
- : '') +
- (staffData.instrumentName
- ? `(${staffData.instrumentName})`
- : '')}
- </p>
- {showImg.value.length > 0 ? (
- <div class={styles.musicImg}>
- <div>
- <img src={showImg.value[0]} alt="" />
- </div>
- </div>
- ) : loading.value ? (
- <>
- <Vue3Lottie
- animationData={AstronautJSON}
- class={styles.finch}
- ></Vue3Lottie>
- {/* <p class={styles.finchLoad}>加载中...</p> */}
- </>
- ) : (
- <div class={styles.empty}>
- <Image src={emtpy} class={styles.emptyImg} />
- <p class={styles.emptyTip}>暂无乐谱预览图</p>
- </div>
- )}
- </div>
- )}
- </div>
- {musicDetail.value?.id && (
- <TheSticky position="bottom" varName="--bottom-height">
- <div style={{ backgroundColor: '#fff' }}>
- <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>
- <div ref={footers} class={styles.footers}>
- {/* 判断是否是免费的,或者已经购买过 */}
- {buyState.value.play ? (
- <Button
- round
- block
- type="primary"
- color="linear-gradient( 270deg, #FF204B 0%, #FE5B71 100%)"
- onClick={() => {
- if (!browser().isApp) {
- onDownloadApp()
- return
- }
- const throttleFn = useThrottleFn(() => {
- player.value && player.value.stop()
- const item: any = partColumns.value.find(
- (c: any) => c.value === staffData.partIndex
- )
- // const index = staffData.tempPartList.findIndex(
- // (i: any) => i.track === item?.track
- // )
- musicBuy(musicDetail.value, () => {}, {
- 'part-index': item?.xmlValue || 0,
- sett: staff.radio,
- albumId: route.query.tenantAlbumId || '', // 专辑编号
- // 1:忽略系统节拍器
- ignoreSysMetronome:
- route.query.subjectType === 'MUSIC' ? 1 : 0
- })
- }, 500)
- throttleFn()
- }}
- >
- 立即练习
- </Button>
- ) : buyState.value.hasTenantAlbum && !buyState.value.play ? (
- <Button
- disabled={route.query.buyStatus === '1'}
- round
- block
- type="primary"
- color="linear-gradient( 270deg, #FF204B 0%, #FE5B71 100%)"
- onClick={() => {
- if (!browser().isApp) {
- onDownloadApp()
- return
- }
- if (route.query.type === 'search') {
- router.push('train-tool')
- } else {
- onSubmit()
- }
- }}
- >
- 开通训练教程
- </Button>
- ) : (
- <div class={[styles.buyBtn]}>
- {/* 判断是否是需要收费的 */}
- {buyState.value.charge && (
- <Button
- round
- type="primary"
- color="linear-gradient(270deg, #FF204B 0%, #FE5B71 100%)"
- class={styles.primary}
- onClick={() => {
- if (!browser().isApp) {
- onDownloadApp()
- return
- }
- onBuy()
- }}
- >
- 立即点播
- </Button>
- )}
- {/* 判断是否有会员的 */}
- {buyState.value.vip && (
- <Button
- round
- block={!buyState.value.charge ? true : false}
- type="primary"
- color="linear-gradient(270deg, #FF204B 0%, #FE5B71 100%)"
- class={styles.memeber}
- onClick={() => {
- if (!browser().isApp) {
- onDownloadApp()
- return
- }
- router.push({
- path: '/memberCenter',
- query: {
- ...route.query
- }
- })
- }}
- >
- {studentActivityId.value > 0 && (
- <div class={[styles.buttonDiscount]}>专属优惠</div>
- )}
- 开通会员
- </Button>
- )}
- </div>
- )}
- </div>
- </div>
- </TheSticky>
- )}
- <Popup v-model:show={downloadStatus.value} position="bottom" round>
- {downloadStatus.value && (
- <Download
- imgList={JSON.parse(JSON.stringify(showImg.value))}
- musicSheetName={musicDetail.value?.musicSheetName +
- (staffData.instrumentName
- ? `(${staffData.instrumentName})`
- : '')}
- />
- )}
- </Popup>
- <Popup
- v-model:show={staff.status}
- teleport="body"
- closeable
- style={{ width: '80%' }}
- class={styles.staffChange}
- 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 === 'staff' ? styles.active : ''}
- onClick={() => onChangeStaff('staff')}
- >
- {{
- icon: () => (
- <Image src={staffDetafult} class={styles.staffImg} />
- ),
- title: () => <span class={styles.name}>五线谱</span>,
- value: () => (
- <Radio name="staff">
- {{
- icon: (props: any) => (
- <Icon
- class={styles.boxStyle}
- 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}
- name={
- props.checked
- ? activeButtonIcon
- : inactiveButtonIcon
- }
- />
- )
- }}
- </Radio>
- )
- }}
- </Cell>
- <Cell
- center
- border={false}
- class={staff.radio === 'fixed' ? styles.active : ''}
- onClick={() => onChangeStaff('fixed')}
- >
- {{
- icon: () => (
- <Image src={fixedDefault} class={styles.staffImg} />
- ),
- title: () => <span class={styles.name}>简谱-固定调</span>,
- value: () => (
- <Radio name="fixed">
- {{
- icon: (props: any) => (
- <Icon
- class={styles.boxStyle}
- 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}
- onConfirm={value => {
- staffData.open = false
- staffData.partIndex = value.value
- staffData.partXmlIndex = value.xmlValue
- staffData.instrumentName = value.instrumentName
- showImg.value = []
- nextTick(() => {
- // const item = getInstrumentItem(musicDetail.value?.background || [], value.selectedOptions[0].track);
- let tempPdf = value?.musicPdfUrl
- if (musicDetail.value?.musicSheetType !== 'CONCERT') {
- // tempPdf = ''
- if (staff.radio === 'first') {
- tempPdf = value?.firstPdfUrl
- } else if (staff.radio === 'fixed') {
- tempPdf = value?.jianPdfUrl
- } else if (staff.radio === 'staff') {
- tempPdf = value?.musicPdfUrl
- }
- }
- if (tempPdf) {
- musicPdfUrl.value = tempPdf
- renderStaff()
- } else {
- musicPdfUrl.value = ''
- loading.value = true
- // 为了处理,之前是使用pdf渲染,现在又用osmd,iframe没有重新加载
- if (staffData.iframeSrc.indexOf('pdf/web') !== -1) {
- renderStaff()
- } else {
- resetRender()
- }
- }
- // resetRender()
- })
- }}
- onCancel={() => (staffData.open = false)}
- />
- </Popup>
- </div>
- )
- }
- })
|