index.tsx 52 KB

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