index.tsx 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630
  1. import {
  2. computed,
  3. defineComponent,
  4. nextTick,
  5. onMounted,
  6. onUnmounted,
  7. reactive,
  8. ref,
  9. watch
  10. } from 'vue'
  11. import umiRequest from 'umi-request'
  12. import { useRoute, useRouter } from 'vue-router'
  13. import request from '@/helpers/request'
  14. import ColHeader from '@/components/col-header'
  15. import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
  16. import {
  17. Button,
  18. Cell,
  19. CellGroup,
  20. Checkbox,
  21. Dialog,
  22. Icon,
  23. Image,
  24. Popup,
  25. RadioGroup,
  26. Sticky,
  27. Tag,
  28. Radio,
  29. Toast,
  30. Picker
  31. } from 'vant'
  32. import qs from 'query-string'
  33. import styles from './index.module.less'
  34. // import Item from '../list/item'
  35. import { useRect } from '@vant/use'
  36. import { Vue3Lottie } from 'vue3-lottie'
  37. import { getRandomKey, musicBuy } from '../music'
  38. import { getOssUploadUrl, state } from '@/state'
  39. // import { useEventTracking } from '@/helpers/hooks'
  40. import ColSticky from '@/components/col-sticky'
  41. import { browser, getHttpOrigin, moneyFormat } from '@/helpers/utils'
  42. import { orderStatus } from '@/views/order-detail/orderStatus'
  43. import iconShare from '@/views/music/album/icon_share.svg'
  44. import iconAlbum from './images/icon_album.png'
  45. import iconAlbum2 from './images/icon_album2.png'
  46. import iconDownload from './images/icon_download.png'
  47. import iconChange from './images/icon-change.png'
  48. import iconAddCourse from './images/icon-add-course.png'
  49. import iconRemoveCourse from './images/icon-remove-course.png'
  50. import AstronautJSON from './animate/bigLoad.json'
  51. import ColShare from '@/components/col-share'
  52. import iconCollect from './images/icon_collect.png'
  53. import iconCollectActive from './images/icon_collect_active.png'
  54. import iconListen from './images/icon_listen.png'
  55. import emtpy from './images/emtpy.png'
  56. import activeButtonIcon from '@common/images/icon_checkbox.png'
  57. import inactiveButtonIcon from '@common/images/icon_checkbox_default.png'
  58. import staffDetafult from './images/staff-default.png'
  59. import firstDefault from './images/first-default.png'
  60. import fixedDefault from './images/fixed-default.png'
  61. import Plyr from 'plyr'
  62. import 'plyr/dist/plyr.css'
  63. import Download from './download'
  64. import { getInstrumentName } from '@/constant/instruments'
  65. import { svgtopng } from '@/tenant/music/music-detail/formatSvgToImg'
  66. import { useThrottleFn } from '@vueuse/core'
  67. import {
  68. formatXML,
  69. getCustomInfo,
  70. onlyVisible
  71. } from '@/tenant/music/music-detail/instrument'
  72. export const getAssetsHomeFile = (fileName: string) => {
  73. const path = `../component/images/${fileName}`
  74. const modules = import.meta.globEager('../component/images/*')
  75. return modules[path].default
  76. }
  77. export default defineComponent({
  78. name: 'MusicDetail',
  79. setup() {
  80. const behaviorId = ref(getRandomKey())
  81. localStorage.setItem('behaviorId', behaviorId.value)
  82. const router = useRouter()
  83. const route = useRoute()
  84. const loading = ref(false)
  85. const aId = Number(route.query.activityId) || 0
  86. const studentActivityId = ref(aId)
  87. const isError = ref(false)
  88. const headers = ref(null)
  89. const footers = ref(null)
  90. const heightInfo = ref<any>('0')
  91. const musicDetail = ref<any>(null)
  92. const audioFileUrl = ref('')
  93. const showImg = ref([] as any)
  94. const firstList = ref<Array<any>>([])
  95. const fixedList = ref<Array<any>>([])
  96. const staffList = ref<Array<any>>([])
  97. const musicPdfUrl = ref('')
  98. const staffData = reactive({
  99. // open: false,
  100. // iframeSrc: '',
  101. // musicXml: '',
  102. // instrumentName: '',
  103. // iframeRef: null as any,
  104. // partIndex: 0,
  105. // partXmlIndex: 0,
  106. // tempPartList: [] as any[],
  107. // partList: [] as any[],
  108. // xmlPartList: [] as any[]
  109. musicId: route.query.id as any,
  110. isConcert: false, // 是否合奏
  111. details: {} as any,
  112. list: [], // 列表数据
  113. open: false,
  114. closed: true,
  115. audioReady: false,
  116. iframeSrc: "",
  117. musicXml: "",
  118. instrumentName: "",
  119. iframeRef: null as any,
  120. imgs: [] as any,
  121. musicPdfUrl: "", // 当前声轨PDF
  122. partList: [] as any[],
  123. partNames: [] as string[],
  124. selectedPartName: "" as any,
  125. selectedPartIndex: 0,
  126. isComberRender: false, // 是否合并谱显示
  127. metronomeUrl: "", // 合奏使用链接
  128. metronomeMp3Url: "", // 独奏使用链接
  129. })
  130. const defaultImgs = ref({
  131. first: false,
  132. fixed: false,
  133. staff: false
  134. })
  135. const downloadStatus = ref<boolean>(false)
  136. const staff = reactive({
  137. status: false,
  138. radio: 'staff' // staff first fixed
  139. })
  140. const colors: any = {
  141. FREE: {
  142. color: '#01B84F',
  143. text: '免费'
  144. },
  145. VIP: {
  146. color: '#CD863E',
  147. text: '会员'
  148. },
  149. CHARGE: {
  150. color: '#3591CE',
  151. text: '点播'
  152. }
  153. }
  154. // 更改预览状态
  155. const onChangeStaff = (type: string) => {
  156. staff.radio = type
  157. staff.status = false
  158. if (type == 'first') {
  159. loading.value = false
  160. const tempPdf = musicDetail.value?.firstPdfUrl
  161. initIframe(tempPdf, 'first', staffData.musicXml)
  162. } else if (type == 'fixed') {
  163. loading.value = false
  164. const tempPdf = musicDetail.value?.jianPdfUrl
  165. console.log(tempPdf, 'tempPdf')
  166. initIframe(tempPdf, 'fixed', staffData.musicXml)
  167. } else {
  168. loading.value = false
  169. const tempPdf = musicDetail.value?.musicPdfUrl
  170. initIframe(tempPdf, 'staff', staffData.musicXml)
  171. }
  172. }
  173. const initIframe = (tempPdf: string, staff: string, xml: string) => {
  174. if (tempPdf) {
  175. musicPdfUrl.value = tempPdf
  176. renderStaff()
  177. } else {
  178. musicPdfUrl.value = ''
  179. // 为了处理,之前是使用pdf渲染,现在又用osmd,iframe没有重新加载
  180. if (
  181. !staffData.iframeSrc ||
  182. staffData.iframeSrc.indexOf('pdf/web') !== -1
  183. ) {
  184. renderStaff()
  185. } else {
  186. resetRenderPage(staff, xml)
  187. }
  188. }
  189. }
  190. watch(
  191. () => staff.radio,
  192. (val: string) => {
  193. if (val == 'first') {
  194. showImg.value = firstList.value
  195. } else if (val == 'fixed') {
  196. showImg.value = fixedList.value
  197. } else {
  198. showImg.value = staffList.value
  199. }
  200. }
  201. )
  202. const FetchList = async (id?: any) => {
  203. if (loading.value) {
  204. return
  205. }
  206. loading.value = true
  207. isError.value = false
  208. try {
  209. const { data } = await request.get(state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student' + '/musicSheet/cbsDetail/' + route.query.id)
  210. musicDetail.value = data
  211. staffData.details = data
  212. // const res = await request.get(`/music/sheet/detail/${route.query.id}`, {
  213. // prefix:
  214. // state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
  215. // })
  216. // musicDetail.value = res.data
  217. // const background = res.data.background
  218. // audioFileUrl.value =
  219. // background && background.length > 0 ? background[0].audioFileUrl : ''
  220. // // const arrImgs = res.data.musicImg ? res.data.musicImg.split(',') : []
  221. // showImg.value = res.data.musicImg ? res.data.musicImg.split(',') : []
  222. // firstList.value = res.data.firstTone
  223. // ? res.data.firstTone.split(',')
  224. // : []
  225. // fixedList.value = res.data.fixedTone
  226. // ? res.data.fixedTone.split(',')
  227. // : []
  228. // staffList.value = res.data.musicImg ? res.data.musicImg.split(',') : []
  229. // // 初始化默认数据是否有值
  230. // if (firstList.value.length > 0) {
  231. // defaultImgs.value.first = true
  232. // }
  233. // if (fixedList.value.length > 0) {
  234. // defaultImgs.value.fixed = true
  235. // }
  236. // if (staffList.value.length > 0) {
  237. // defaultImgs.value.staff = true
  238. // }
  239. await toDetail(data)
  240. nextTick(async () => {
  241. if (
  242. (staffData.isConcert && staffData.metronomeUrl) ||
  243. (!staffData.isConcert && staffData.metronomeMp3Url)
  244. ) {
  245. initAudio();
  246. } else {
  247. renderStaff();
  248. }
  249. });
  250. // if (res.data.auditStatus === 'DOING') {
  251. // Dialog.confirm({
  252. // message: '曲目审核中',
  253. // showConfirmButton: true,
  254. // showCancelButton: false,
  255. // confirmButtonColor: 'var(--van-primary)'
  256. // }).then(() => {
  257. // if (browser().isApp) {
  258. // postMessage({ api: 'goBack' })
  259. // } else {
  260. // router.back()
  261. // }
  262. // })
  263. // }
  264. } catch (error) {
  265. isError.value = true
  266. }
  267. loading.value = false
  268. }
  269. const player = ref<any>(null)
  270. const audio = ref<any>(null)
  271. const freeRate = ref<any>(0)
  272. const initAudio = async () => {
  273. const controls = [
  274. 'play-large',
  275. 'play',
  276. 'progress',
  277. 'captions',
  278. // 'fullscreen',
  279. 'duration'
  280. ]
  281. player.value = new Plyr(audio.value, {
  282. controls: controls
  283. })
  284. const config = await request.get(
  285. '/api-student/sysConfig/queryByParamNameList',
  286. {
  287. params: {
  288. paramNames: 'music_sheet_free_rate'
  289. }
  290. }
  291. )
  292. freeRate.value = config.data[0]?.paramValue || 0
  293. player.value.on('timeupdate', () => {
  294. // 允许播放时间
  295. const players = player.value
  296. const playTime = (players.duration * freeRate.value) / 100 || 0
  297. // 时间,不能播放
  298. if (players.currentTime >= playTime && !buyState.value.play) {
  299. players.stop()
  300. // players.pause()
  301. }
  302. })
  303. }
  304. const showLoading = async (e: any) => {
  305. if (e.data?.api === 'musicStaffRender') {
  306. const osmdImg = e.data.osmdImg
  307. showImg.value = []
  308. const imgs: any = []
  309. for (let i = 0; i < osmdImg.length; i++) {
  310. const img = await svgtopng(
  311. osmdImg[i].img,
  312. osmdImg[i].width,
  313. osmdImg[i].height
  314. )
  315. imgs.push(img)
  316. }
  317. showImg.value = imgs
  318. loading.value = e.data.loading
  319. }
  320. }
  321. onMounted(async () => {
  322. postMessage({
  323. api: 'setStatusBarTextColor',
  324. content: { statusBarTextColor: true }
  325. })
  326. await FetchList()
  327. const { height } = useRect(headers as any)
  328. const footer = useRect(footers as any)
  329. heightInfo.value = height + footer.height
  330. // // 初始化音频
  331. // if (audioFileUrl.value) {
  332. // initAudio()
  333. // }
  334. window.addEventListener('message', showLoading)
  335. })
  336. onUnmounted(() => {
  337. postMessage({
  338. api: 'setStatusBarTextColor',
  339. content: { statusBarTextColor: false }
  340. })
  341. window.removeEventListener('message', showLoading)
  342. })
  343. const toggleFavorite = async () => {
  344. /**
  345. * 酷乐秀老师端 收藏曲目 music/sheet/favorite/id?providerType=?? 添加参数
  346. * @ApiModelProperty("曲目评测来源 TENANT 机构 PLATFORM 平台")
  347. * private String providerType;
  348. * 表示收藏的是机构曲目,还是平台曲目,
  349. */
  350. let apiUrl = '', providerType = ''
  351. if (browser().isTeacher) {
  352. providerType = state.projectType === 'tenant' ? 'TENANT' : 'PLATFORM'
  353. }
  354. apiUrl = `/music/sheet/favorite/${musicDetail.value?.bizId}`
  355. try {
  356. await request.post(apiUrl, {
  357. requestType: 'form',
  358. data: {
  359. providerType
  360. },
  361. prefix:
  362. state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
  363. })
  364. musicDetail.value.favorite = musicDetail.value?.favorite ? 0 : 1
  365. musicDetail.value.favoriteCount = musicDetail.value?.favorite
  366. ? musicDetail.value.favoriteCount + 1
  367. : musicDetail.value.favoriteCount - 1 < 0
  368. ? 0
  369. : musicDetail.value.favoriteCount - 1
  370. setTimeout(() => {
  371. Toast(musicDetail.value?.favorite ? '收藏成功' : '取消收藏成功')
  372. }, 100)
  373. } catch (error) {
  374. //
  375. }
  376. }
  377. const onAddCourse = async () => {
  378. try {
  379. const res = await request.post('/api-teacher/courseCourseware/submit', {
  380. data: {
  381. musicSheetId: musicDetail.value.bizId,
  382. clientType: 'TEACHER',
  383. userId: state.user.data?.userId
  384. }
  385. })
  386. // console.log(res)
  387. setTimeout(() => {
  388. musicDetail.value.coursewareId = res.data.id || ''
  389. Toast('已将曲目添加到课件')
  390. musicDetail.value.coursewareStatus = 1
  391. }, 100)
  392. } catch {
  393. //
  394. }
  395. }
  396. const removeCourse = async () => {
  397. Dialog.confirm({
  398. title: '提示',
  399. message: '您是否确定移出课件',
  400. confirmButtonColor: '#269a93',
  401. cancelButtonText: '取消',
  402. confirmButtonText: '确定'
  403. }).then(async () => {
  404. try {
  405. await request.post(
  406. '/api-teacher/courseCourseware/remove/' +
  407. musicDetail.value.coursewareId,
  408. {
  409. data: {}
  410. }
  411. )
  412. setTimeout(() => {
  413. Toast('移出成功')
  414. musicDetail.value.coursewareStatus = 0
  415. }, 100)
  416. } catch {
  417. //
  418. }
  419. })
  420. }
  421. const onBuy = async () => {
  422. const music = musicDetail.value
  423. orderStatus.orderObject.orderType = 'MUSIC'
  424. orderStatus.orderObject.orderName = music.name
  425. orderStatus.orderObject.orderDesc = music.name
  426. orderStatus.orderObject.actualPrice = music.musicPrice
  427. orderStatus.orderObject.recomUserId = route.query.recomUserId || 0
  428. orderStatus.orderObject.activityId = route.query.activityId || 0
  429. orderStatus.orderObject.orderNo = ''
  430. orderStatus.orderObject.orderList = [
  431. {
  432. orderType: 'MUSIC',
  433. goodsName: music.name,
  434. actualPrice: music.musicPrice,
  435. ...music
  436. }
  437. ]
  438. const res = await request.post('/api-student/userOrder/getPendingOrder', {
  439. data: {
  440. goodType: 'MUSIC',
  441. bizId: music.id
  442. }
  443. })
  444. const result = res.data
  445. if (result) {
  446. Dialog.confirm({
  447. title: '提示',
  448. message: '您有一个未支付的订单,是否继续支付?',
  449. confirmButtonColor: '#269a93',
  450. cancelButtonText: '取消订单',
  451. confirmButtonText: '继续支付'
  452. })
  453. .then(async () => {
  454. orderStatus.orderObject.orderNo = result.orderNo
  455. orderStatus.orderObject.actualPrice = result.actualPrice
  456. orderStatus.orderObject.discountPrice = result.discountPrice
  457. orderStatus.orderObject.paymentConfig = {
  458. ...result.paymentConfig,
  459. paymentVendor: result.paymentVendor,
  460. paymentVersion: result.paymentVersion
  461. }
  462. routerTo()
  463. })
  464. .catch(() => {
  465. Dialog.close()
  466. // 只用取消订单,不用做其它处理
  467. cancelPayment(result.orderNo)
  468. })
  469. } else {
  470. routerTo()
  471. }
  472. }
  473. const routerTo = () => {
  474. const music = musicDetail.value
  475. router.push({
  476. path: '/orderDetail',
  477. query: {
  478. orderType: 'MUSIC',
  479. musicId: music.id
  480. }
  481. })
  482. }
  483. const cancelPayment = async (orderNo: string) => {
  484. try {
  485. await request.post('/api-student/userOrder/orderCancel', {
  486. data: {
  487. orderNo
  488. }
  489. })
  490. } catch {}
  491. }
  492. const paymentType = computed(() => {
  493. let paymentType = musicDetail.value?.paymentType
  494. if (typeof paymentType === 'string') {
  495. paymentType = paymentType.split(',')
  496. return paymentType
  497. }
  498. return []
  499. })
  500. const buyState = computed(() => {
  501. const music = musicDetail.value
  502. return {
  503. hasTenantAlbum: route.query?.tenantAlbumId ? true : false, // 是否从专辑来的
  504. play: music.play ? true : false, // 是否可以播放
  505. free: music?.paymentType.includes('FREE'),
  506. charge: music?.paymentType.includes('CHARGE'),
  507. vip: music?.paymentType.includes('VIP'),
  508. buy: music?.orderStatus === 'PAID' // 是否已买
  509. }
  510. })
  511. const shareStatus = ref(false)
  512. const shareUrl = ref('')
  513. const shareDiscount = ref(0)
  514. const partColumns = ref<any>([]);
  515. // console.log(data)
  516. const onShare = async () => {
  517. try {
  518. const res = await request.post('/api-teacher/open/musicShareProfit', {
  519. data: {
  520. bizId: musicDetail.value?.bizId,
  521. userId: state.user.data?.userId
  522. }
  523. })
  524. let url =
  525. location.origin +
  526. `/teacher/#/shareMusic?id=${musicDetail.value?.bizId}&recomUserId=${state.user.data?.userId}&userType=${state.platformType}`
  527. // 判断是否有活动
  528. if (res.data.discount === 1) {
  529. url += `&activityId=${res.data.activityId}`
  530. }
  531. shareDiscount.value = res.data.discount || 0
  532. console.log(url)
  533. shareUrl.value = url
  534. shareStatus.value = true
  535. return
  536. } catch {}
  537. }
  538. /** 渲染五线谱 */
  539. const sortList = {
  540. 长笛: 1,
  541. 单簧管: 2,
  542. 中音单簧管: 3,
  543. 低音单簧管: 4,
  544. 高音萨克斯风: 5,
  545. 中音萨克斯风: 6,
  546. 次中音萨克斯风: 7,
  547. 低音萨克斯风: 8,
  548. 小号: 9,
  549. 长号: 10,
  550. 圆号: 11,
  551. 大号: 12,
  552. 上低音号: 13
  553. }
  554. const instrumentSort = (list: Array<any>) => {
  555. list.sort((a, b) => {
  556. return (
  557. (sortList[getInstrumentName(a.track)] || 20) -
  558. (sortList[getInstrumentName(b.track)] || 20)
  559. )
  560. })
  561. return list
  562. }
  563. const getPartNames = async (xmlUrl: string) => {
  564. const partNames: string[] = [];
  565. try {
  566. const res = await umiRequest.get(xmlUrl, { mode: "cors" });
  567. const xml: any = new DOMParser().parseFromString(res, "text/xml");
  568. for (const item of xml.getElementsByTagName("part-name")) {
  569. if (item.textContent) {
  570. partNames.push(item.textContent?.trim());
  571. }
  572. }
  573. } catch (error) {}
  574. return partNames;
  575. };
  576. // 根据当前选中的声部和曲目筛选出对应的声轨
  577. function filterSoundCodes(musicalInstruments: any) {
  578. // 老师端,加上乐器id
  579. const instrumentIds = 1005 // appState.instrumentId || appState.user?.instrumentId || route.query.instrumentId
  580. if (instrumentIds) {
  581. const { code } = musicalInstruments.find((item: any) => {
  582. return instrumentIds == item.id
  583. }) || {}
  584. return code
  585. }
  586. return null
  587. }
  588. // 根据当前选中的声部和曲目筛选出对应的声轨
  589. function filterSoundInfo(musicalInstruments: any) {
  590. if(musicalInstruments.length <= 0) return null
  591. // 老师端,加上乐器id
  592. const instrumentIds = 1005 //appState.instrumentId || appState.user?.instrumentId || route.query.instrumentId
  593. if (instrumentIds) {
  594. const item = musicalInstruments.find((item: any) => {
  595. return instrumentIds == item.musicalInstrumentId && item.audioPlayType == 'PLAY'
  596. }) || null
  597. return item
  598. }
  599. return null
  600. }
  601. const toDetail = async (row) => {
  602. const partNames = await getPartNames(row.xmlFileUrl);
  603. staffData.partNames = partNames;
  604. let partList = staffData.list || [];
  605. partList = partList.filter(
  606. (item: any) => !item.track?.toLocaleUpperCase()?.includes("COMMON")
  607. );
  608. partColumns.value = partList.map((item: any, index: number) => {
  609. const xmlIndex = staffData.partNames.filter((text: string) => text.toLocaleUpperCase() !== "COMMON").findIndex(
  610. (name: any) => name.trim() === item.track
  611. );
  612. const defaultIndex = row.musicSheetType !== "SINGLE" && row.isScoreRender ? index + 1 : index
  613. return {
  614. text: getInstrumentName(item.track as string),
  615. name: getInstrumentName(item.track as string), // true
  616. track: item.track,
  617. musicPdfUrl: item.soundMusicPdfUrl,
  618. xmlIndex,
  619. value: defaultIndex,
  620. };
  621. });
  622. staffData.details = row || {};
  623. staffData.musicXml = staffData.details?.xmlFileUrl;
  624. staffData.isComberRender = staffData.details?.isScoreRender;
  625. let defaultShowStaff
  626. if(staffData.details?.musicalInstruments) {
  627. const soundCodes = filterSoundCodes(staffData.details?.musicalInstruments)
  628. if (soundCodes) {
  629. const soundCodesArr = soundCodes.split(",").map((code: string) => {
  630. return code
  631. .toLowerCase()
  632. .replace(/^\d+|\d+$/g, "")
  633. .trim()
  634. })
  635. defaultShowStaff = partColumns.value.find((item: any) =>
  636. soundCodesArr.includes(
  637. item.track &&
  638. item.track
  639. .toLowerCase()
  640. .replace(/^\d+|\d+$/g, "")
  641. .trim()
  642. )
  643. )
  644. if(defaultShowStaff) {
  645. staffData.selectedPartIndex = defaultShowStaff.value
  646. }
  647. }
  648. }
  649. if (row.musicSheetType === "SINGLE") {
  650. staffData.musicPdfUrl = row.musicPdfUrl;
  651. // 生成的图片
  652. // staffData.imgs = row.musicImg ? row.musicImg.split(',') : [];
  653. } else {
  654. // 初始化数据
  655. // 是否显示总谱
  656. if (staffData.isComberRender) {
  657. partColumns.value.unshift({
  658. text: "总谱",
  659. value: 0,
  660. xmlIndex: 999,
  661. track: "",
  662. name: "总谱",
  663. });
  664. // 如果是总谱则默认选中,否则选择
  665. console.log(defaultShowStaff, 'defaultShowStaff')
  666. staffData.selectedPartIndex = row.defaultScoreRender? 0 : defaultShowStaff ? defaultShowStaff.value : 1
  667. if(row.defaultScoreRender) {
  668. staffData.musicPdfUrl = row.musicPdfUrl;
  669. } else {
  670. staffData.musicPdfUrl = defaultShowStaff.musicPdfUrl;
  671. }
  672. } else {
  673. const item = partColumns.value.find((item: any) => item.value === staffData.selectedPartIndex)
  674. console.log(item, partColumns.value, staffData.selectedPartIndex, 'selectedPartIndex')
  675. if (item) {
  676. staffData.musicPdfUrl = item.musicPdfUrl;
  677. } else {
  678. staffData.musicPdfUrl = "";
  679. }
  680. }
  681. }
  682. // 通过isScoreRender判断是否合并渲染
  683. // 多声轨, 不是单声部多声轨, 不是老师布置作业选择曲谱
  684. if (row.musicSheetType === "SINGLE") {
  685. staffData.isConcert = false;
  686. const musicSheetSoundList = staffData.details?.musicSheetSoundList || []
  687. const songs = filterSoundInfo(musicSheetSoundList)
  688. if(songs) {
  689. staffData.metronomeMp3Url = songs.audioFileUrl
  690. } else {
  691. // 为了处理节奏练习
  692. if(musicSheetSoundList.length > 0) {
  693. console.log(musicSheetSoundList, 'musicSheetSoundList')
  694. staffData.metronomeMp3Url = musicSheetSoundList[0].audioFileUrl
  695. }
  696. }
  697. } else {
  698. staffData.isConcert = true;
  699. const { audioFileUrl } = row.musicSheetAccompanimentList.find((item: any) => item.audioPlayType == 'PLAY')
  700. staffData.metronomeUrl = audioFileUrl
  701. }
  702. }
  703. const getPreViewCloud = (musicId: string, partIndex: number) => {
  704. const Authorization = sessionStorage.getItem("Authorization") || "";
  705. const musicScorePath = "/klx-music-score/";
  706. const musicScoreUrl = getHttpOrigin() + musicScorePath;
  707. // const musicScoreUrl = "https://test.gym.lexiaoya.cn" + musicScorePath;
  708. // const musicScoreUrl = 'http://192.168.3.68:3000/instrument.html';
  709. let href = `${musicScoreUrl}?t=${Date.now()}#/?id=${musicId}&Authorization=${Authorization}&part-index=${partIndex}&isPreView=true&zoom=0.5&downPng=A4`;
  710. // // 老师端加上systemType=teacher
  711. const browserInfo = browser()
  712. href += ('&systemType=' +( browserInfo.isStudent ? `student` : 'teacher'));
  713. // if (location.pathname.includes("accompany-teacher")) {
  714. // href += `&systemType=teacher`;
  715. // }
  716. return href
  717. };
  718. const renderStaff = async () => {
  719. // try {
  720. // if (staffData.musicPdfUrl) {
  721. // // staffData.iframeSrc =
  722. // // "/pdf/web/viewer.html?file=" +
  723. // // encodeURIComponent(staffData.musicPdfUrl);
  724. // // https://cdn.oss.dayaedu.com/daya202409/UOFW4q5.pdf
  725. // // https://cdn.oss.dayaedu.com/daya202409/UOFVK2A.pdf
  726. // // https://cdn.oss.dayaedu.com/daya202409/UODQffO.pdf
  727. // staffData.iframeSrc = `${getHttpOrigin()}${
  728. // location.pathname
  729. // }pdf/web/viewer.html?file=${encodeURIComponent(
  730. // staffData.musicPdfUrl
  731. // )}`;
  732. // } else {
  733. // staffData.iframeSrc = getPreViewCloud(
  734. // staffData.musicId,
  735. // currentColumn.value.xmlIndex
  736. // );
  737. // // staffData.iframeSrc = `/osmd/index.html`;
  738. // // staffData.iframeSrc = `${getHttpOrigin()}${location.pathname}osmd/index.html`;
  739. // }
  740. // } catch (error) {
  741. // //
  742. // }
  743. try {
  744. nextTick(() => {
  745. if (musicPdfUrl.value) {
  746. const url = `${location.origin}${
  747. location.pathname
  748. }pdf/web/viewer-pdf.html?file=${encodeURIComponent(
  749. musicPdfUrl.value
  750. )}&t=${Date.now()}`
  751. const iframeRef = document.querySelector('#staffIframeRef') as any
  752. iframeRef.contentWindow.location.replace(url)
  753. staffData.iframeSrc = url
  754. } else {
  755. // const url = `${location.origin}${
  756. // location.pathname
  757. // }osmd/index.html?t=${new Date().getTime()}`
  758. // // const url = `${location.origin}/osmd/index.html`
  759. // const iframeRef = document.querySelector('#staffIframeRef') as any
  760. // iframeRef.contentWindow.location.replace(
  761. // `${location.origin}${location.pathname}osmd/index.html`
  762. // )
  763. // staffData.iframeSrc = url
  764. staffData.iframeSrc = getPreViewCloud(
  765. // staffData.musicId,
  766. // currentColumn.value.xmlIndex
  767. // );
  768. // // staffData.iframeSrc = `/osmd/index.html`;
  769. // // staffData.iframeSrc = `${getHttpOrigin()}${location.pathname}osmd/index.html`;
  770. }
  771. })
  772. } catch (error) {
  773. //
  774. }
  775. }
  776. const musicIframeLoad = async () => {
  777. const iframeRef: any = document.getElementById('staffIframeRef')
  778. if (iframeRef && iframeRef.contentWindow.renderXml) {
  779. const res = await umiRequest.get(staffData.musicXml, {
  780. mode: 'cors'
  781. })
  782. const parseXmlInfo = getCustomInfo(res)
  783. const xml = formatXML(parseXmlInfo.parsedXML)
  784. const currentXml = onlyVisible(xml, staffData.partXmlIndex)
  785. iframeRef.contentWindow.renderXml(currentXml, 0, staff.radio)
  786. // iframeRef.contentWindow.renderXml(
  787. // staffData.musicXml,
  788. // staffData.partXmlIndex
  789. // )
  790. }
  791. }
  792. const resetRender = async () => {
  793. const iframeRef: any = document.getElementById('staffIframeRef')
  794. if (iframeRef && iframeRef.contentWindow.renderXml) {
  795. loading.value = true
  796. // iframeRef.contentWindow.resetRender(staffData.partXmlIndex)
  797. const res = await umiRequest.get(staffData.musicXml, {
  798. mode: 'cors'
  799. })
  800. const parseXmlInfo = getCustomInfo(res)
  801. const xml = formatXML(parseXmlInfo.parsedXML)
  802. const currentXml = onlyVisible(xml, staffData.partXmlIndex)
  803. iframeRef.contentWindow.renderXml(currentXml, 0)
  804. staffData.instrumentName = getInstrumentName(
  805. staffData.partList[staffData.partIndex]?.track
  806. )
  807. }
  808. }
  809. const resetRenderPage = async (type: string, xmlUrl: string) => {
  810. const iframeRef: any = document.getElementById('staffIframeRef')
  811. if (iframeRef && iframeRef.contentWindow.renderXml) {
  812. loading.value = true
  813. const res = await umiRequest.get(staffData.musicXml, {
  814. mode: 'cors'
  815. })
  816. const parseXmlInfo = getCustomInfo(res)
  817. const xml = formatXML(parseXmlInfo.parsedXML)
  818. const currentXml = onlyVisible(xml, staffData.partXmlIndex)
  819. iframeRef.contentWindow.resetRenderPage(type, currentXml)
  820. }
  821. }
  822. // const partColumns = computed(() => {
  823. // return staffData.partList.map((item: any, index: number) => {
  824. // const instrumentName =
  825. // musicDetail.value?.musicSheetType === 'CONCERT'
  826. // ? getInstrumentName(item.track)
  827. // : ''
  828. // return {
  829. // text: item.track + (instrumentName ? `(${instrumentName})` : ''),
  830. // value: index,
  831. // instrumentName,
  832. // musicPdfUrl: item.musicPdfUrl,
  833. // firstPdfUrl: item.firstPdfUrl,
  834. // jianPdfUrl: item.jianPdfUrl,
  835. // xmlValue: item.index,
  836. // track: item.track
  837. // }
  838. // })
  839. // })
  840. return () => {
  841. return (
  842. <div class={styles.detail}>
  843. <ColSticky position="top">
  844. <div ref={headers}>
  845. <ColHeader
  846. background="transparent"
  847. hideHeader={false}
  848. border={false}
  849. isFixed={false}
  850. color="#fff"
  851. title={musicDetail.value?.name}
  852. backIconColor="white"
  853. v-slots={{
  854. right: () => (
  855. <div
  856. class={styles.shareBtn}
  857. style={{
  858. color: '#fff'
  859. }}
  860. onClick={onShare}
  861. >
  862. <Image src={iconShare} />
  863. 分享
  864. </div>
  865. )
  866. }}
  867. />
  868. </div>
  869. </ColSticky>
  870. <img class={styles.bgImg} src={musicDetail.value?.musicCover} />
  871. <div class={styles.bgContent}></div>
  872. <div
  873. class={styles.musicContainer}
  874. style={{
  875. marginTop: '16px',
  876. height: `calc(100vh - var(--header-height) - var(--bottom-height) - 16px)`
  877. }}
  878. >
  879. <div>
  880. <Cell
  881. border={false}
  882. center
  883. class={styles.musicInfo}
  884. v-slots={{
  885. icon: () => (
  886. <Image
  887. class={styles.pImg}
  888. src={musicDetail.value?.musicCover}
  889. />
  890. ),
  891. title: () => (
  892. <div class={styles.info}>
  893. <h4
  894. class="van-ellipsis"
  895. // onClick={() => handleGotoMusicScore(musicDetail.value)}
  896. >
  897. {musicDetail.value?.name}
  898. </h4>
  899. <p
  900. style={{
  901. display: 'flex',
  902. alignItems: 'center'
  903. }}
  904. >
  905. {paymentType.value.map(
  906. tag =>
  907. tag && (
  908. <Tag
  909. style={{ color: colors[tag]?.color }}
  910. class={styles.tag}
  911. type="success"
  912. plain
  913. >
  914. {colors[tag].text}
  915. </Tag>
  916. )
  917. )}
  918. {musicDetail.value?.exquisiteFlag === 1 && (
  919. <Image
  920. class={styles.exquisiteFlag}
  921. src={getAssetsHomeFile('icon_exquisite.png')}
  922. />
  923. )}
  924. {musicDetail.value?.albumNums > 0 && (
  925. <Image
  926. class={styles.songAlbum}
  927. src={getAssetsHomeFile('icon_album_active.png')}
  928. />
  929. )}
  930. <span
  931. class={[
  932. styles.coomposer,
  933. browser().isApp &&
  934. musicDetail.value?.sourceType === 'TEACHER' &&
  935. state.platformType === 'STUDENT' &&
  936. styles.links
  937. ]}
  938. onClick={() => {
  939. if (
  940. browser().isApp &&
  941. musicDetail.value?.sourceType === 'TEACHER' &&
  942. state.platformType === 'STUDENT'
  943. ) {
  944. router.push({
  945. path: '/teacherHome',
  946. query: {
  947. teacherId: musicDetail.value?.userId,
  948. tabs: 'music'
  949. }
  950. })
  951. }
  952. }}
  953. >
  954. <img class={styles.iconAlbum2} src={iconAlbum2} />
  955. <span>
  956. {musicDetail.value?.userName ||
  957. '游客' + (musicDetail.value?.userId || '')}
  958. </span>
  959. </span>
  960. </p>
  961. </div>
  962. ),
  963. value: () => (
  964. <>
  965. <span
  966. style={{
  967. visibility:
  968. state.platformType === 'TEACHER'
  969. ? 'visible'
  970. : 'hidden'
  971. }}
  972. class={styles.download}
  973. onClick={() => {
  974. if (musicDetail.value?.coursewareStatus) {
  975. removeCourse()
  976. } else {
  977. onAddCourse()
  978. }
  979. }}
  980. >
  981. <img
  982. src={
  983. musicDetail.value?.coursewareStatus
  984. ? iconRemoveCourse
  985. : iconAddCourse
  986. }
  987. />
  988. <span>
  989. {musicDetail.value?.coursewareStatus
  990. ? '移出课件'
  991. : '添加课件'}
  992. </span>
  993. </span>
  994. <span
  995. class={styles.download}
  996. onClick={() => toggleFavorite()}
  997. >
  998. <img
  999. src={
  1000. musicDetail.value?.favorite
  1001. ? iconCollectActive
  1002. : iconCollect
  1003. }
  1004. />
  1005. <span>收藏</span>
  1006. </span>
  1007. </>
  1008. )
  1009. }}
  1010. />
  1011. <div class={styles.functionSection}>
  1012. <div
  1013. class={styles.functionItem}
  1014. onClick={() => {
  1015. router.push({
  1016. path: '/look-album-list',
  1017. query: {
  1018. id: musicDetail.value?.bizId,
  1019. musicSubject: musicDetail.value?.musicSubject
  1020. }
  1021. })
  1022. }}
  1023. >
  1024. <img src={iconAlbum} />
  1025. <span>专辑</span>
  1026. </div>
  1027. {/* {musicDetail.value?.notation ? (
  1028. <span
  1029. class={styles.download}
  1030. onClick={() => {
  1031. staff.status = true
  1032. }}
  1033. style={{
  1034. display:
  1035. musicDetail.value?.musicSheetType !== 'CONCERT'
  1036. ? ''
  1037. : 'none'
  1038. }}
  1039. >
  1040. <img src={iconChangeStaff} />
  1041. <span>转谱</span>
  1042. </span>
  1043. ) : null} */}
  1044. <div
  1045. class={styles.functionItem}
  1046. style={{
  1047. display:
  1048. musicDetail.value?.musicSheetType === 'CONCERT'
  1049. ? ''
  1050. : 'none'
  1051. }}
  1052. onClick={() => {
  1053. if (musicDetail.value?.musicSheetType === 'CONCERT') {
  1054. staffData.open = true
  1055. }
  1056. }}
  1057. >
  1058. <img src={iconChange} />
  1059. <span>切换乐器</span>
  1060. </div>
  1061. {musicDetail.value?.notation ? (
  1062. <div
  1063. class={styles.functionItem}
  1064. style={{
  1065. display:
  1066. musicDetail.value?.musicSheetType === 'SINGLE'
  1067. ? ''
  1068. : 'none'
  1069. }}
  1070. onClick={() => {
  1071. staff.status = true
  1072. }}
  1073. >
  1074. <img src={iconChange} />
  1075. <span>转谱</span>
  1076. </div>
  1077. ) : null}
  1078. <div
  1079. class={styles.functionItem}
  1080. onClick={() => {
  1081. if (musicPdfUrl.value) {
  1082. const songName =
  1083. musicDetail.value?.name +
  1084. (staffData.instrumentName
  1085. ? `(${staffData.instrumentName})`
  1086. : '')
  1087. promisefiyPostMessage({
  1088. api: 'downloadFile',
  1089. content: {
  1090. downloadUrl: musicPdfUrl.value,
  1091. fileName: songName
  1092. }
  1093. })
  1094. return
  1095. }
  1096. if (showImg.value.length > 0) {
  1097. downloadStatus.value = true
  1098. } else {
  1099. Toast('暂无图片')
  1100. }
  1101. }}
  1102. >
  1103. <img src={iconDownload} />
  1104. <span>下载</span>
  1105. </div>
  1106. </div>
  1107. </div>
  1108. <div class={styles.musicContent}>
  1109. {staffData.details.id ? (
  1110. <>
  1111. {staffData.musicPdfUrl ? (
  1112. <>
  1113. {loading.value && (
  1114. <>
  1115. <Vue3Lottie
  1116. animationData={AstronautJSON}
  1117. class={styles.finch}
  1118. ></Vue3Lottie>
  1119. <p class={styles.finchLoad}>加载中...</p>
  1120. </>
  1121. )}
  1122. <iframe
  1123. style={{
  1124. opacity: loading.value ? 0 : 1,
  1125. }}
  1126. id="staffIframeRef"
  1127. src={staffData.iframeSrc}
  1128. onLoad={() => {
  1129. // 判断是用哪个渲染的
  1130. loading.value = false;
  1131. }}
  1132. ></iframe>
  1133. </>
  1134. ) : (
  1135. <>
  1136. <p class={styles.musicTitle}>
  1137. {staffData.details?.name && (
  1138. <>
  1139. {staffData.details?.name}
  1140. {/* {staffData.isConcert &&
  1141. currentColumn.value?.name
  1142. ? `(${
  1143. currentColumn.value
  1144. ?.name || ""
  1145. })`
  1146. : ""} */}
  1147. </>
  1148. )}
  1149. </p>
  1150. {loading.value && (
  1151. <>
  1152. <Vue3Lottie
  1153. animationData={AstronautJSON}
  1154. class={styles.finch}
  1155. ></Vue3Lottie>
  1156. <p class={styles.finchLoad}>加载中...</p>
  1157. </>
  1158. )}
  1159. <iframe
  1160. id="staffIframeRef"
  1161. style={{
  1162. opacity: loading.value ? 0 : 1,
  1163. }}
  1164. src={staffData.iframeSrc}
  1165. onLoad={() => {
  1166. loading.value = false;
  1167. // musicIframeLoad();
  1168. }}
  1169. ></iframe>
  1170. </>
  1171. )}
  1172. </>
  1173. ) : null}
  1174. {/* {musicDetail.value?.musicSheetType === 'CONCERT' ||
  1175. musicPdfUrl.value ||
  1176. !defaultImgs.value[staff.radio] ? (
  1177. <>
  1178. {musicPdfUrl.value ? (
  1179. <iframe
  1180. id="staffIframeRef"
  1181. style={{
  1182. opacity: loading.value ? 0 : 1
  1183. }}
  1184. src={staffData.iframeSrc}
  1185. onLoad={() => {
  1186. // 判断是用哪个渲染的
  1187. loading.value = false
  1188. }}
  1189. ></iframe>
  1190. ) : (
  1191. <>
  1192. <p class={styles.musicTitle}>
  1193. {(musicDetail.value?.name
  1194. ? musicDetail.value?.name
  1195. : '') +
  1196. (staffData.instrumentName
  1197. ? `(${staffData.instrumentName})`
  1198. : '')}
  1199. </p>
  1200. {loading.value && (
  1201. <div>
  1202. <Vue3Lottie
  1203. animationData={AstronautJSON}
  1204. class={styles.finch}
  1205. ></Vue3Lottie>
  1206. </div>
  1207. )}
  1208. <iframe
  1209. id="staffIframeRef"
  1210. style={{
  1211. opacity: loading.value ? 0 : 1
  1212. }}
  1213. // src={staffData.iframeSrc}
  1214. onLoad={() => {
  1215. musicIframeLoad()
  1216. }}
  1217. ></iframe>
  1218. </>
  1219. )}
  1220. </>
  1221. ) : (
  1222. <>
  1223. <p class={styles.musicTitle}>
  1224. {(musicDetail.value?.name
  1225. ? musicDetail.value?.name
  1226. : '') +
  1227. (staffData.instrumentName
  1228. ? `(${staffData.instrumentName})`
  1229. : '')}
  1230. </p>
  1231. {showImg.value.length > 0 ? (
  1232. <div class={styles.musicImg}>
  1233. <img src={showImg.value[0]} alt="" />
  1234. </div>
  1235. ) : loading.value ? (
  1236. <>
  1237. <Vue3Lottie
  1238. animationData={AstronautJSON}
  1239. class={styles.finch}
  1240. ></Vue3Lottie>
  1241. <p class={styles.finchLoad}>加载中...</p>
  1242. </>
  1243. ) : (
  1244. <div class={styles.empty}>
  1245. <Image src={emtpy} class={styles.emptyImg} />
  1246. <p class={styles.emptyTip}>暂无乐谱预览图</p>
  1247. </div>
  1248. )}
  1249. </>
  1250. )} */}
  1251. </div>
  1252. </div>
  1253. {musicDetail.value?.bizId && (
  1254. <ColSticky
  1255. position="bottom"
  1256. background="white"
  1257. varName="--bottom-height"
  1258. >
  1259. <div ref={footers}>
  1260. <div class={styles.videoOperation}>
  1261. {audioFileUrl.value && (
  1262. <>
  1263. {!buyState.value.play &&
  1264. freeRate.value != 100 &&
  1265. freeRate.value != 0 && (
  1266. <div class={[styles.audition]}>
  1267. <img src={iconListen} />
  1268. <span>每首曲目可试听{freeRate.value}%</span>
  1269. </div>
  1270. )}
  1271. <div class={[styles.audio, styles.collectCell]}>
  1272. <audio id="player" controls ref={audio}>
  1273. <source src={audioFileUrl.value} type="audio/mp3" />
  1274. </audio>
  1275. </div>
  1276. </>
  1277. )}
  1278. </div>
  1279. {/* 判断是否是免费的,或者已经购买过,是否从专辑过来的 */}
  1280. {buyState.value.play ||
  1281. (state.platformType === 'TEACHER' &&
  1282. buyState.value.hasTenantAlbum) ? (
  1283. <Button
  1284. round
  1285. block
  1286. type="primary"
  1287. color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
  1288. onClick={() => {
  1289. const throttleFn = useThrottleFn(() => {
  1290. player.value && player.value.stop()
  1291. const item: any = partColumns.value.find(
  1292. (c: any) => c.value === staffData.partIndex
  1293. )
  1294. // 新版云教练的谱面类型使用musicRenderType字段
  1295. const musicRenderType = staff.radio === 'staff' ? 'staff' : staff.radio === 'first' ? 'firstTone' : staff.radio === 'fixed' ? 'fixedTone' : '';
  1296. let extraParam: any = {
  1297. 'part-index': item?.xmlValue || 0,
  1298. musicRenderType,
  1299. }
  1300. if (route.query.tenantAlbumId) {
  1301. extraParam.albumId = route.query.tenantAlbumId
  1302. }
  1303. musicBuy(musicDetail.value, () => {}, extraParam)
  1304. }, 500)
  1305. throttleFn()
  1306. }}
  1307. >
  1308. 立即练习
  1309. </Button>
  1310. ) : (
  1311. <div class={styles.colSticky}>
  1312. {/* 只有,有点播类型的才显示价格 */}
  1313. {buyState.value.charge && (
  1314. <div class={styles.priceSection}>
  1315. <span>点播价:</span>
  1316. <span class={styles.price}>
  1317. <i>¥</i>
  1318. {moneyFormat(musicDetail.value?.musicPrice)}
  1319. </span>
  1320. </div>
  1321. )}
  1322. <div class={[styles.buyBtn]}>
  1323. {/* 判断是否是需要收费的 */}
  1324. {buyState.value.charge && (
  1325. <Button
  1326. round
  1327. type="primary"
  1328. color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
  1329. class={styles.primary}
  1330. onClick={onBuy}
  1331. >
  1332. 立即点播
  1333. </Button>
  1334. )}
  1335. {/* 判断是否有会员的 */}
  1336. {buyState.value.vip && (
  1337. <Button
  1338. round
  1339. block={!buyState.value.charge ? true : false}
  1340. type="primary"
  1341. color="linear-gradient(180deg, #F7BD8D 0%, #CD8806 100%)"
  1342. class={styles.memeber}
  1343. onClick={() => {
  1344. router.push({
  1345. path: '/memberCenter',
  1346. query: {
  1347. ...route.query
  1348. }
  1349. })
  1350. }}
  1351. >
  1352. {studentActivityId.value > 0 && (
  1353. <div class={[styles.buttonDiscount]}>专属优惠</div>
  1354. )}
  1355. 开通会员
  1356. </Button>
  1357. )}
  1358. </div>
  1359. </div>
  1360. )}
  1361. </div>
  1362. </ColSticky>
  1363. )}
  1364. <Popup
  1365. v-model:show={shareStatus.value}
  1366. style={{ background: 'transparent' }}
  1367. teleport="body"
  1368. >
  1369. <ColShare
  1370. teacherId={state.user.data?.userId}
  1371. shareUrl={shareUrl.value}
  1372. shareType="music"
  1373. >
  1374. <div class={styles.shareMate}>
  1375. {shareDiscount.value === 1 && (
  1376. <div class={styles.tagDiscount}>专属优惠</div>
  1377. )}
  1378. <img
  1379. class={styles.icon}
  1380. crossorigin="anonymous"
  1381. src={musicDetail.value?.musicCover}
  1382. />
  1383. <div class={styles.info}>
  1384. <h4 class="van-multi-ellipsis--l2">
  1385. {musicDetail.value?.name}
  1386. </h4>
  1387. <p>作曲人:{musicDetail.value?.composer}</p>
  1388. </div>
  1389. </div>
  1390. </ColShare>
  1391. </Popup>
  1392. <Popup v-model:show={downloadStatus.value} position="bottom" round>
  1393. {downloadStatus.value && (
  1394. <Download
  1395. imgList={JSON.parse(JSON.stringify(showImg.value))}
  1396. name={
  1397. musicDetail.value?.name +
  1398. (staffData.instrumentName
  1399. ? `(${staffData.instrumentName})`
  1400. : '')
  1401. }
  1402. />
  1403. )}
  1404. </Popup>
  1405. <Popup
  1406. v-model:show={staff.status}
  1407. teleport="body"
  1408. closeable
  1409. style={{ width: '80%' }}
  1410. round
  1411. >
  1412. <div class={styles.staffContainer}>
  1413. <div class={styles.staffTitle}>选择转换曲谱</div>
  1414. <RadioGroup v-model={staff.radio}>
  1415. <CellGroup border={false}>
  1416. <Cell
  1417. center
  1418. border={false}
  1419. class={staff.radio === 'staff' ? styles.active : ''}
  1420. onClick={() => onChangeStaff('staff')}
  1421. >
  1422. {{
  1423. icon: () => (
  1424. <Image src={staffDetafult} class={styles.staffImg} />
  1425. ),
  1426. title: () => <span class={styles.name}>五线谱</span>,
  1427. value: () => (
  1428. <Radio name="staff">
  1429. {{
  1430. icon: (props: any) => (
  1431. <Icon
  1432. class={styles.boxStyle}
  1433. size={16}
  1434. name={
  1435. props.checked
  1436. ? activeButtonIcon
  1437. : inactiveButtonIcon
  1438. }
  1439. />
  1440. )
  1441. }}
  1442. </Radio>
  1443. )
  1444. }}
  1445. </Cell>
  1446. <Cell
  1447. center
  1448. border={false}
  1449. class={staff.radio === 'first' ? styles.active : ''}
  1450. onClick={() => onChangeStaff('first')}
  1451. >
  1452. {{
  1453. icon: () => (
  1454. <Image src={firstDefault} class={styles.staffImg} />
  1455. ),
  1456. title: () => <span class={styles.name}>简谱-首调</span>,
  1457. value: () => (
  1458. <Radio name="first">
  1459. {{
  1460. icon: (props: any) => (
  1461. <Icon
  1462. class={styles.boxStyle}
  1463. size={16}
  1464. name={
  1465. props.checked
  1466. ? activeButtonIcon
  1467. : inactiveButtonIcon
  1468. }
  1469. />
  1470. )
  1471. }}
  1472. </Radio>
  1473. )
  1474. }}
  1475. </Cell>
  1476. <Cell
  1477. center
  1478. border={false}
  1479. class={staff.radio === 'fixed' ? styles.active : ''}
  1480. onClick={() => onChangeStaff('fixed')}
  1481. >
  1482. {{
  1483. icon: () => (
  1484. <Image src={fixedDefault} class={styles.staffImg} />
  1485. ),
  1486. title: () => <span class={styles.name}>简谱-固定调</span>,
  1487. value: () => (
  1488. <Radio name="fixed">
  1489. {{
  1490. icon: (props: any) => (
  1491. <Icon
  1492. class={styles.boxStyle}
  1493. size={16}
  1494. name={
  1495. props.checked
  1496. ? activeButtonIcon
  1497. : inactiveButtonIcon
  1498. }
  1499. />
  1500. )
  1501. }}
  1502. </Radio>
  1503. )
  1504. }}
  1505. </Cell>
  1506. </CellGroup>
  1507. </RadioGroup>
  1508. </div>
  1509. </Popup>
  1510. <Popup
  1511. teleport="body"
  1512. position="bottom"
  1513. round
  1514. v-model:show={staffData.open}
  1515. >
  1516. <Picker
  1517. columns={partColumns.value}
  1518. onConfirm={value => {
  1519. staffData.open = false
  1520. staffData.partIndex = value.value
  1521. staffData.partXmlIndex = value.xmlValue
  1522. staffData.instrumentName = value.instrumentName
  1523. showImg.value = []
  1524. nextTick(() => {
  1525. let tempPdf = value?.musicPdfUrl
  1526. if (musicDetail.value?.musicSheetType !== 'CONCERT') {
  1527. // tempPdf = ''
  1528. if (staff.radio === 'first') {
  1529. tempPdf = value?.firstPdfUrl
  1530. } else if (staff.radio === 'fixed') {
  1531. tempPdf = value?.jianPdfUrl
  1532. } else if (staff.radio === 'staff') {
  1533. tempPdf = value?.musicPdfUrl
  1534. }
  1535. }
  1536. if (tempPdf) {
  1537. musicPdfUrl.value = tempPdf
  1538. renderStaff()
  1539. } else {
  1540. musicPdfUrl.value = ''
  1541. loading.value = true
  1542. // 为了处理,之前是使用pdf渲染,现在又用osmd,iframe没有重新加载
  1543. if (staffData.iframeSrc.indexOf('pdf/web') !== -1) {
  1544. renderStaff()
  1545. } else {
  1546. resetRender()
  1547. }
  1548. }
  1549. })
  1550. }}
  1551. onCancel={() => (staffData.open = false)}
  1552. />
  1553. </Popup>
  1554. </div>
  1555. )
  1556. }
  1557. }
  1558. })