index.tsx 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  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 {
  16. Button,
  17. Cell,
  18. CellGroup,
  19. Checkbox,
  20. Dialog,
  21. Icon,
  22. Image,
  23. Popup,
  24. RadioGroup,
  25. Sticky,
  26. Tag,
  27. Radio,
  28. Toast,
  29. Picker
  30. } from 'vant'
  31. import styles from './index.module.less'
  32. // import Item from '../list/item'
  33. import { useRect } from '@vant/use'
  34. import { Vue3Lottie } from 'vue3-lottie'
  35. import { getRandomKey, handleGotoMusicScore, musicBuy } from '../music'
  36. import { getOssUploadUrl, state } from '@/state'
  37. import { useEventTracking } from '@/helpers/hooks'
  38. import ColSticky from '@/components/col-sticky'
  39. import { browser, moneyFormat } from '@/helpers/utils'
  40. import { orderStatus } from '@/views/order-detail/orderStatus'
  41. import iconShare from '@/views/music/album/icon_share.svg'
  42. import iconAlbum from '@/views/music/component/images/icon_album.png'
  43. import iconDownload from './images/icon_download.png'
  44. import iconChangeStaff from './images/icon-change-staff.png'
  45. import AstronautJSON from './animate/bigLoad.json'
  46. import ColShare from '@/components/col-share'
  47. import iconCollect from './images/icon_collect.png'
  48. import iconCollectActive from './images/icon_collect_active.png'
  49. import iconListen from './images/icon_listen.png'
  50. import iconTeacher from '@common/images/icon_teacher.png'
  51. import emtpy from './images/emtpy.png'
  52. import activeButtonIcon from '@common/images/icon_checkbox.png'
  53. import inactiveButtonIcon from '@common/images/icon_checkbox_default.png'
  54. import staffDetafult from './images/staff-default.png'
  55. import staffActive from './images/staff-active.png'
  56. import firstDefault from './images/first-default.png'
  57. import firstActive from './images/first-active.png'
  58. import fixedDefault from './images/fixed-default.png'
  59. import fixedActive from './images/fixed-active.png'
  60. import qs from 'query-string'
  61. import Plyr from 'plyr'
  62. import 'plyr/dist/plyr.css'
  63. import Download from './download'
  64. import { getInstrumentName } from '@/constant/instruments'
  65. export const getAssetsHomeFile = (fileName: string) => {
  66. const path = `../component/images/${fileName}`
  67. const modules = import.meta.globEager('../component/images/*')
  68. return modules[path].default
  69. }
  70. export default defineComponent({
  71. name: 'MusicDetail',
  72. setup() {
  73. localStorage.setItem('behaviorId', getRandomKey())
  74. const router = useRouter()
  75. const route = useRoute()
  76. const loading = ref(false)
  77. const aId = Number(route.query.activityId) || 0
  78. const studentActivityId = ref(aId)
  79. const isError = ref(false)
  80. const headers = ref(null)
  81. const footers = ref(null)
  82. const heightInfo = ref<any>('0')
  83. const musicDetail = ref<any>(null)
  84. const audioFileUrl = ref('')
  85. let showImg = [] as any
  86. const firstList = ref<Array<any>>([])
  87. const fixedList = ref<Array<any>>([])
  88. const staffList = ref<Array<any>>([])
  89. const accompanyUrl = ref<string>('')
  90. const downloadStatus = ref<boolean>(false)
  91. const staff = reactive({
  92. status: false,
  93. radio: 'staff' // staff first fixed
  94. })
  95. const colors: any = {
  96. FREE: {
  97. color: '#01B84F',
  98. text: '免费'
  99. },
  100. VIP: {
  101. color: '#CD863E',
  102. text: '会员'
  103. },
  104. CHARGE: {
  105. color: '#3591CE',
  106. text: '点播'
  107. }
  108. }
  109. // 更改预览状态
  110. const onChangeStaff = (type: string) => {
  111. staff.radio = type
  112. staff.status = false
  113. }
  114. watch(
  115. () => staff.radio,
  116. (val: string) => {
  117. if (val == 'first') {
  118. showImg = firstList.value
  119. } else if (val == 'fixed') {
  120. showImg = fixedList.value
  121. } else {
  122. showImg = staffList.value
  123. }
  124. }
  125. )
  126. const FetchList = async (id?: any) => {
  127. if (loading.value) {
  128. return
  129. }
  130. loading.value = true
  131. isError.value = false
  132. try {
  133. const res = await request.get(`/music/sheet/detail/${route.query.id}`, {
  134. prefix:
  135. state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
  136. })
  137. musicDetail.value = res.data
  138. console.log(musicDetail.value.notation, 'musicDetail')
  139. // 取原音,如果有多个则默认第一个
  140. const background = res.data.background
  141. audioFileUrl.value =
  142. background && background.length > 0 ? background[0].audioFileUrl : ''
  143. // const arrImgs = res.data.musicImg ? res.data.musicImg.split(',') : []
  144. showImg = res.data.musicImg ? res.data.musicImg.split(',') : []
  145. firstList.value = res.data.firstTone
  146. ? res.data.firstTone.split(',')
  147. : []
  148. fixedList.value = res.data.fixedTone
  149. ? res.data.fixedTone.split(',')
  150. : []
  151. staffList.value = res.data.musicImg ? res.data.musicImg.split(',') : []
  152. // if (!showImg.value) {
  153. // setAccompanyUrl()
  154. // window.addEventListener(
  155. // 'message',
  156. // async e => {
  157. // // 给图片设置背景色
  158. // const tempCanvas = await imgToCanvas(e.data)
  159. // const img = convasToImg(tempCanvas)
  160. // // 开始上传图片
  161. // uploadFunction(img)
  162. // },
  163. // false
  164. // )
  165. // }
  166. nextTick(() => {
  167. renderStaff()
  168. })
  169. } catch (error) {
  170. isError.value = true
  171. }
  172. if (musicDetail.value?.musicSheetType !== 'CONCERT') {
  173. loading.value = false
  174. }
  175. }
  176. const base64ToBlob = data => {
  177. const arr = data.split(','),
  178. mime = arr[0].match(/:(.*?);/)[1]
  179. const bstr = atob(arr[1])
  180. let n = bstr.length
  181. const u8arr = new Uint8Array(n)
  182. while (n--) {
  183. u8arr[n] = bstr.charCodeAt(n)
  184. }
  185. return new Blob([u8arr], { type: mime })
  186. }
  187. const uploadFunction = async file => {
  188. try {
  189. const formData = new FormData()
  190. const fileName =
  191. new Date().getTime() + Math.ceil(Math.random() * 1000) + '.png'
  192. const keyTime = new Date().getTime() + fileName
  193. const obj = {
  194. filename: fileName,
  195. bucketName: 'cloud-coach',
  196. postData: {
  197. filename: fileName,
  198. acl: 'public-read',
  199. key: keyTime,
  200. unknowValueField: []
  201. }
  202. }
  203. const res = await request.post(state.platformApi + '/getUploadSign', {
  204. data: obj
  205. })
  206. Toast.loading({
  207. message: '加载中...',
  208. forbidClick: true,
  209. loadingType: 'spinner',
  210. duration: 0
  211. })
  212. const dataObj = {
  213. policy: res.data.policy,
  214. signature: res.data.signature,
  215. key: keyTime,
  216. KSSAccessKeyId: res.data.kssAccessKeyId,
  217. acl: 'public-read',
  218. name: fileName
  219. }
  220. for (const key in dataObj) {
  221. formData.append(key, dataObj[key])
  222. }
  223. const files = base64ToBlob(file)
  224. formData.append('file', files, fileName)
  225. const ossUploadUrl = getOssUploadUrl('cloud-coach')
  226. await umiRequest(ossUploadUrl, {
  227. method: 'POST',
  228. data: formData
  229. })
  230. Toast.clear()
  231. const imgurl = getOssUploadUrl('cloud-coach') + keyTime
  232. await request.post(state.platformApi + '/open/music/sheet/img', {
  233. data: { musicSheetId: musicDetail.value.id, musicImg: imgurl }
  234. })
  235. // showImg.value = imgurl
  236. } catch (e) {
  237. console.log(e)
  238. }
  239. }
  240. const setAccompanyUrl = () => {
  241. let url = location.origin
  242. if (
  243. location.host.includes('dev.colexiu') ||
  244. location.host.includes('192.168') ||
  245. location.host.includes('localhost')
  246. ) {
  247. url = 'https://dev.colexiu.com'
  248. }
  249. const music = musicDetail.value
  250. let subjectId = ''
  251. if (music.background && music.background.length > 0) {
  252. subjectId = music.background[0].id
  253. }
  254. accompanyUrl.value =
  255. url +
  256. `/accompany/colxiu-website.html?id=${music.id}&part-index=${subjectId}`
  257. }
  258. const player = ref<any>(null)
  259. const audio = ref<any>(null)
  260. const freeRate = ref<any>(0)
  261. const initAudio = async () => {
  262. const controls = [
  263. 'play-large',
  264. 'play',
  265. 'progress',
  266. 'captions',
  267. // 'fullscreen',
  268. 'duration'
  269. ]
  270. player.value = new Plyr(audio.value, {
  271. controls: controls
  272. })
  273. const config = await request.get(
  274. '/api-student/sysConfig/queryByParamNameList',
  275. {
  276. params: {
  277. paramNames: 'music_sheet_free_rate'
  278. }
  279. }
  280. )
  281. freeRate.value = config.data[0]?.paramValue || 0
  282. player.value.on('timeupdate', () => {
  283. // 允许播放时间
  284. const players = player.value
  285. const playTime = (players.duration * freeRate.value) / 100 || 0
  286. // 时间,不能播放
  287. if (players.currentTime >= playTime && !buyState.value.play) {
  288. players.stop()
  289. // players.pause()
  290. }
  291. })
  292. }
  293. const showLoading = (e: any) => {
  294. console.log(e)
  295. if(e.data?.api === 'musicStaffRender'){
  296. loading.value = e.data.loading
  297. }
  298. }
  299. onMounted(async () => {
  300. await FetchList()
  301. const { height } = useRect(headers as any)
  302. const footer = useRect(footers as any)
  303. heightInfo.value = height + footer.height
  304. // 初始化音频
  305. if (audioFileUrl.value) {
  306. initAudio()
  307. }
  308. window.addEventListener('message', showLoading)
  309. })
  310. onUnmounted(() => {
  311. window.removeEventListener('message', showLoading)
  312. })
  313. const toggleFavorite = async () => {
  314. try {
  315. await request.post('/music/sheet/favorite/' + musicDetail.value?.id, {
  316. prefix:
  317. state.platformType === 'TEACHER' ? '/api-teacher' : '/api-student'
  318. })
  319. musicDetail.value.favorite = musicDetail.value?.favorite ? 0 : 1
  320. musicDetail.value.favoriteCount = musicDetail.value?.favorite
  321. ? musicDetail.value.favoriteCount + 1
  322. : musicDetail.value.favoriteCount - 1 < 0
  323. ? 0
  324. : musicDetail.value.favoriteCount - 1
  325. setTimeout(() => {
  326. Toast(musicDetail.value?.favorite ? '收藏成功' : '取消收藏成功')
  327. }, 100)
  328. } catch (error) {
  329. //
  330. }
  331. }
  332. const onAddCourse = async () => {
  333. try {
  334. const res = await request.post('/api-teacher/courseCourseware/submit', {
  335. data: {
  336. musicSheetId: musicDetail.value.id,
  337. clientType: 'TEACHER',
  338. userId: state.user.data?.userId
  339. }
  340. })
  341. console.log(res)
  342. setTimeout(() => {
  343. musicDetail.value.coursewareId = res.data.id || ''
  344. Toast('添加成功')
  345. musicDetail.value.coursewareStatus = 1
  346. }, 100)
  347. } catch {
  348. //
  349. }
  350. }
  351. const removeCourse = async () => {
  352. Dialog.confirm({
  353. title: '提示',
  354. message: '您是否确定移除课件',
  355. confirmButtonColor: '#269a93',
  356. cancelButtonText: '取消',
  357. confirmButtonText: '确定'
  358. }).then(async () => {
  359. try {
  360. await request.post(
  361. '/api-teacher/courseCourseware/remove/' +
  362. musicDetail.value.coursewareId,
  363. {
  364. data: {}
  365. }
  366. )
  367. setTimeout(() => {
  368. Toast('移除成功')
  369. musicDetail.value.coursewareStatus = 0
  370. }, 100)
  371. } catch {
  372. //
  373. }
  374. })
  375. }
  376. const onBuy = async () => {
  377. const music = musicDetail.value
  378. orderStatus.orderObject.orderType = 'MUSIC'
  379. orderStatus.orderObject.orderName = music.musicSheetName
  380. orderStatus.orderObject.orderDesc = music.musicSheetName
  381. orderStatus.orderObject.actualPrice = music.musicPrice
  382. orderStatus.orderObject.recomUserId = route.query.recomUserId || 0
  383. orderStatus.orderObject.activityId = route.query.activityId || 0
  384. orderStatus.orderObject.orderNo = ''
  385. orderStatus.orderObject.orderList = [
  386. {
  387. orderType: 'MUSIC',
  388. goodsName: music.musicSheetName,
  389. actualPrice: music.musicPrice,
  390. ...music
  391. }
  392. ]
  393. const res = await request.post('/api-student/userOrder/getPendingOrder', {
  394. data: {
  395. goodType: 'MUSIC',
  396. bizId: music.id
  397. }
  398. })
  399. const result = res.data
  400. if (result) {
  401. Dialog.confirm({
  402. title: '提示',
  403. message: '您有一个未支付的订单,是否继续支付?',
  404. confirmButtonColor: '#269a93',
  405. cancelButtonText: '取消订单',
  406. confirmButtonText: '继续支付'
  407. })
  408. .then(async () => {
  409. orderStatus.orderObject.orderNo = result.orderNo
  410. orderStatus.orderObject.actualPrice = result.actualPrice
  411. orderStatus.orderObject.discountPrice = result.discountPrice
  412. routerTo()
  413. })
  414. .catch(() => {
  415. Dialog.close()
  416. // 只用取消订单,不用做其它处理
  417. cancelPayment(result.orderNo)
  418. })
  419. } else {
  420. routerTo()
  421. }
  422. }
  423. const routerTo = () => {
  424. const music = musicDetail.value
  425. router.push({
  426. path: '/orderDetail',
  427. query: {
  428. orderType: 'MUSIC',
  429. musicId: music.id
  430. }
  431. })
  432. }
  433. const cancelPayment = async (orderNo: string) => {
  434. try {
  435. await request.post('/api-student/userOrder/orderCancel', {
  436. data: {
  437. orderNo
  438. }
  439. })
  440. } catch {}
  441. }
  442. const paymentType = computed(() => {
  443. let paymentType = musicDetail.value?.paymentType
  444. if (typeof paymentType === 'string') {
  445. paymentType = paymentType.split(',')
  446. return paymentType
  447. }
  448. return []
  449. })
  450. const buyState = computed(() => {
  451. const music = musicDetail.value
  452. return {
  453. play: music.play ? true : false, // 是否可以播放
  454. free: music?.paymentType.includes('FREE'),
  455. charge: music?.paymentType.includes('CHARGE'),
  456. vip: music?.paymentType.includes('VIP'),
  457. buy: music?.orderStatus === 'PAID' // 是否已买
  458. }
  459. })
  460. const shareStatus = ref(false)
  461. const shareUrl = ref('')
  462. const shareDiscount = ref(0)
  463. // console.log(data)
  464. const onShare = async () => {
  465. try {
  466. const res = await request.post('/api-teacher/open/musicShareProfit', {
  467. data: {
  468. bizId: musicDetail.value?.id,
  469. userId: state.user.data?.userId
  470. }
  471. })
  472. let url =
  473. location.origin +
  474. `/teacher/#/shareMusic?id=${musicDetail.value?.id}&recomUserId=${state.user.data?.userId}&userType=${state.platformType}`
  475. // 判断是否有活动
  476. if (res.data.discount === 1) {
  477. url += `&activityId=${res.data.activityId}`
  478. }
  479. shareDiscount.value = res.data.discount || 0
  480. console.log(url)
  481. shareUrl.value = url
  482. shareStatus.value = true
  483. return
  484. } catch {}
  485. }
  486. const staffData = reactive({
  487. open: false,
  488. iframeSrc: '',
  489. musicXml: '',
  490. instrumentName: '',
  491. iframeRef: null as any,
  492. partIndex: 0,
  493. partList: [] as any[]
  494. })
  495. /** 渲染五线谱 */
  496. const renderStaff = () => {
  497. staffData.iframeSrc = `${location.origin}${location.pathname}osmd/index.html`
  498. staffData.musicXml = musicDetail.value?.xmlFileUrl || ''
  499. staffData.partList = musicDetail.value?.background || []
  500. staffData.instrumentName = getInstrumentName(staffData.partList[staffData.partIndex]?.track)
  501. }
  502. const musicIframeLoad = () => {
  503. const iframeRef: any = document.getElementById('staffIframeRef')
  504. if (iframeRef && iframeRef.contentWindow.renderXml){
  505. iframeRef.contentWindow.renderXml(staffData.musicXml, staffData.partIndex)
  506. }
  507. }
  508. const resetRender = () => {
  509. const iframeRef: any = document.getElementById('staffIframeRef')
  510. if (iframeRef && iframeRef.contentWindow.renderXml){
  511. iframeRef.contentWindow.resetRender(staffData.partIndex)
  512. staffData.instrumentName = getInstrumentName(staffData.partList[staffData.partIndex]?.track)
  513. }
  514. }
  515. const partColumns = computed(() => {
  516. return staffData.partList.map((item: any, index: number) => {
  517. const instrumentName = getInstrumentName(item.track)
  518. return {
  519. text: item.track + (instrumentName ? `(${instrumentName})` : ''),
  520. value: index
  521. }
  522. })
  523. })
  524. return () => {
  525. return (
  526. <div class={styles.detail}>
  527. <Sticky position="top">
  528. <div ref={headers}>
  529. <ColHeader
  530. background="transparent"
  531. border={false}
  532. isFixed={false}
  533. color="#fff"
  534. title={musicDetail.value?.musicSheetName}
  535. backIconColor="white"
  536. v-slots={{
  537. right: () => (
  538. <div
  539. class={styles.shareBtn}
  540. style={{
  541. color: '#fff'
  542. }}
  543. onClick={onShare}
  544. >
  545. <Image src={iconShare} />
  546. 分享
  547. </div>
  548. )
  549. }}
  550. />
  551. </div>
  552. </Sticky>
  553. <img class={styles.bgImg} src={musicDetail.value?.titleImg} />
  554. <div class={styles.bgContent}></div>
  555. <div
  556. class={styles.musicContainer}
  557. style={{
  558. marginTop: '16px',
  559. height: `calc(100vh - ${heightInfo.value + 16 + 'px'})`
  560. }}
  561. >
  562. <Cell
  563. border={false}
  564. center
  565. class={styles.musicInfo}
  566. v-slots={{
  567. icon: () => (
  568. <Image
  569. class={styles.pImg}
  570. src={musicDetail.value?.titleImg}
  571. />
  572. ),
  573. title: () => (
  574. <div class={styles.info}>
  575. <h4 class="van-ellipsis" onClick={() => handleGotoMusicScore(musicDetail.value)}>
  576. {musicDetail.value?.musicSheetName}
  577. </h4>
  578. <p
  579. style={{
  580. display: 'flex'
  581. }}
  582. >
  583. {paymentType.value.map(tag => (
  584. <Tag
  585. style={{ color: colors[tag].color }}
  586. class={styles.tag}
  587. type="success"
  588. plain
  589. >
  590. {colors[tag].text}
  591. </Tag>
  592. ))}
  593. {musicDetail.value?.exquisiteFlag === 1 && (
  594. <Image
  595. class={styles.exquisiteFlag}
  596. src={getAssetsHomeFile('icon_exquisite.png')}
  597. />
  598. )}
  599. {musicDetail.value?.albumNums > 0 && (
  600. <Image
  601. class={styles.songAlbum}
  602. src={getAssetsHomeFile('icon_album_active.png')}
  603. />
  604. )}
  605. <span class={styles.coomposer}>
  606. {musicDetail.value?.composer}
  607. </span>
  608. </p>
  609. </div>
  610. ),
  611. value: () => (
  612. <>
  613. <div class="van-cell__value" style={{display: musicDetail.value?.musicSheetType === 'SINGLE' ? '' : 'none'}}>
  614. {musicDetail.value?.notation ? (
  615. <span
  616. class={styles.download}
  617. onClick={() => {
  618. staff.status = true
  619. }}
  620. >
  621. <img src={iconChangeStaff} />
  622. <span>转谱</span>
  623. </span>
  624. ) : null}
  625. <span
  626. class={styles.download}
  627. onClick={() => {
  628. if (showImg.length > 0) {
  629. downloadStatus.value = true
  630. } else {
  631. Toast('暂无图片')
  632. }
  633. }}
  634. >
  635. <img src={iconDownload} />
  636. <span>下载曲谱</span>
  637. </span>
  638. </div>
  639. <span
  640. style={{display: musicDetail.value?.musicSheetType === 'CONCERT' ? '' : 'none'}}
  641. class={styles.download}
  642. onClick={() => {
  643. staffData.open = true
  644. }}
  645. >
  646. <Icon style={{background: 'rgba(246,246,246,1)', borderRadius: '50%', padding: '4px'}} size="20px" name="exchange" />
  647. <span>切换乐器</span>
  648. </span>
  649. </>
  650. )
  651. }}
  652. />
  653. <div class={styles.musicContent}>
  654. <p class={styles.musicTitle}>
  655. {musicDetail.value?.musicSheetName + (staffData.instrumentName ? `(${staffData.instrumentName})` : '')}
  656. </p>
  657. {musicDetail.value?.musicSheetType === 'CONCERT' ? (
  658. <>
  659. {loading.value && (
  660. <>
  661. <Vue3Lottie
  662. animationData={AstronautJSON}
  663. class={styles.finch}
  664. ></Vue3Lottie>
  665. <p class={styles.finchLoad}>加载中...</p>
  666. </>
  667. )}
  668. <iframe id="staffIframeRef" src={staffData.iframeSrc} onLoad={musicIframeLoad}></iframe>
  669. </>
  670. ) : <>
  671. {showImg.length > 0 ? (
  672. <img src={showImg[0]} alt="" class={styles.musicImg} />
  673. ) : loading.value ? (
  674. <>
  675. <Vue3Lottie
  676. animationData={AstronautJSON}
  677. class={styles.finch}
  678. ></Vue3Lottie>
  679. <p class={styles.finchLoad}>加载中...</p>
  680. </>
  681. ) : (
  682. <div class={styles.empty}>
  683. <Image src={emtpy} class={styles.emptyImg} />
  684. <p class={styles.emptyTip}>暂无乐谱预览图</p>
  685. </div>
  686. )}
  687. </>}
  688. <div class={styles.videoOperation}>
  689. {audioFileUrl.value && (
  690. <>
  691. {!buyState.value.play &&
  692. freeRate.value != 100 &&
  693. freeRate.value != 0 && (
  694. <div class={[styles.audition]}>
  695. <img src={iconListen} />
  696. <span>每首曲目可试听{freeRate.value}%</span>
  697. </div>
  698. )}
  699. <div class={[styles.audio, styles.collectCell]}>
  700. <audio id="player" controls ref={audio}>
  701. <source src={audioFileUrl.value} type="audio/mp3" />
  702. </audio>
  703. </div>
  704. </>
  705. )}
  706. <div class={[styles.collect, styles.collectCell]}>
  707. <div
  708. class={[styles.userInfo]}
  709. onClick={() => {
  710. if (
  711. browser().isApp &&
  712. musicDetail.value?.sourceType === 'TEACHER' &&
  713. state.platformType === 'STUDENT'
  714. ) {
  715. router.push({
  716. path: '/teacherHome',
  717. query: {
  718. teacherId: musicDetail.value?.userId,
  719. tabs: 'music'
  720. }
  721. })
  722. }
  723. }}
  724. >
  725. <img src={musicDetail.value?.userAvatar || iconTeacher} />
  726. <span>{musicDetail.value?.userName}</span>
  727. </div>
  728. <div class={styles.functionSection}>
  729. <div
  730. class={[styles.collectSection]}
  731. onClick={() => toggleFavorite()}
  732. >
  733. <span>{musicDetail.value?.favoriteCount}人收藏</span>
  734. <img
  735. src={
  736. musicDetail.value?.favorite
  737. ? iconCollectActive
  738. : iconCollect
  739. }
  740. />
  741. </div>
  742. {state.platformType === 'TEACHER' && (
  743. <div
  744. class={[styles.collectSection]}
  745. onClick={() => {
  746. if (musicDetail.value?.coursewareStatus) {
  747. removeCourse()
  748. } else {
  749. onAddCourse()
  750. }
  751. }}
  752. >
  753. <span>
  754. {musicDetail.value?.coursewareStatus
  755. ? '移出课件'
  756. : '添加到课件'}
  757. </span>
  758. {musicDetail.value?.coursewareStatus ? (
  759. <Icon name="clear" />
  760. ) : (
  761. <Icon name="add" size={18} />
  762. )}
  763. </div>
  764. )}
  765. </div>
  766. </div>
  767. </div>
  768. </div>
  769. <div
  770. class={[styles.lookAlbum, styles.collectCell]}
  771. onClick={() => {
  772. router.push({
  773. path: '/look-album-list',
  774. query: {
  775. id: musicDetail.value?.id,
  776. musicSubject: musicDetail.value?.musicSubject
  777. }
  778. })
  779. }}
  780. >
  781. <div>
  782. <img src={iconAlbum} />
  783. <span>进入曲目所在专辑列表</span>
  784. </div>
  785. <Icon name="arrow" size={16} color="#666" />
  786. </div>
  787. </div>
  788. {musicDetail.value?.id && (
  789. <ColSticky position="bottom" background="white">
  790. <div ref={footers}>
  791. {/* 判断是否是免费的,或者已经购买过 */}
  792. {buyState.value.play ? (
  793. <Button
  794. round
  795. block
  796. type="primary"
  797. color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
  798. onClick={() => {
  799. player.value && player.value.stop()
  800. musicBuy(musicDetail.value)
  801. }}
  802. >
  803. 立即练习
  804. </Button>
  805. ) : (
  806. <div class={styles.colSticky}>
  807. {/* 只有,有点播类型的才显示价格 */}
  808. {buyState.value.charge && (
  809. <div class={styles.priceSection}>
  810. <span>点播价:</span>
  811. <span class={styles.price}>
  812. <i>¥</i>
  813. {moneyFormat(musicDetail.value?.musicPrice)}
  814. </span>
  815. </div>
  816. )}
  817. <div class={[styles.buyBtn]}>
  818. {/* 判断是否是需要收费的 */}
  819. {buyState.value.charge && (
  820. <Button
  821. round
  822. type="primary"
  823. color="linear-gradient(180deg, #59E5D5 0%, #2DC7AA 100%)"
  824. class={styles.primary}
  825. onClick={onBuy}
  826. >
  827. 立即点播
  828. </Button>
  829. )}
  830. {/* 判断是否有会员的 */}
  831. {buyState.value.vip && (
  832. <Button
  833. round
  834. block={!buyState.value.charge ? true : false}
  835. type="primary"
  836. color="linear-gradient(180deg, #F7BD8D 0%, #CD8806 100%)"
  837. class={styles.memeber}
  838. onClick={() => {
  839. router.push({
  840. path: '/memberCenter',
  841. query: {
  842. ...route.query
  843. }
  844. })
  845. }}
  846. >
  847. {studentActivityId.value > 0 && (
  848. <div class={[styles.buttonDiscount]}>专属优惠</div>
  849. )}
  850. 开通会员
  851. </Button>
  852. )}
  853. </div>
  854. </div>
  855. )}
  856. </div>
  857. </ColSticky>
  858. )}
  859. <Popup
  860. v-model:show={shareStatus.value}
  861. style={{ background: 'transparent' }}
  862. teleport="body"
  863. >
  864. <ColShare
  865. teacherId={state.user.data?.userId}
  866. shareUrl={shareUrl.value}
  867. shareType="music"
  868. >
  869. <div class={styles.shareMate}>
  870. {shareDiscount.value === 1 && (
  871. <div class={styles.tagDiscount}>专属优惠</div>
  872. )}
  873. <img
  874. class={styles.icon}
  875. crossorigin="anonymous"
  876. src={
  877. musicDetail.value?.titleImg +
  878. `@base@tag=imgScale&h=80&w=80&m=1?t=${+new Date()}`
  879. }
  880. />
  881. <div class={styles.info}>
  882. <h4 class="van-multi-ellipsis--l2">
  883. {musicDetail.value?.musicSheetName}
  884. </h4>
  885. <p>作曲人:{musicDetail.value?.composer}</p>
  886. </div>
  887. </div>
  888. </ColShare>
  889. </Popup>
  890. <Popup v-model:show={downloadStatus.value} position="bottom" round>
  891. <Download
  892. imgList={JSON.parse(JSON.stringify(showImg))}
  893. musicSheetName={musicDetail.value.musicSheetName}
  894. />
  895. </Popup>
  896. <Popup
  897. v-model:show={staff.status}
  898. teleport="body"
  899. closeable
  900. style={{ width: '80%' }}
  901. round
  902. >
  903. <div class={styles.staffContainer}>
  904. <div class={styles.staffTitle}>选择转换曲谱</div>
  905. <RadioGroup v-model={staff.radio}>
  906. <CellGroup border={false}>
  907. <Cell
  908. center
  909. border={false}
  910. class={staff.radio === 'staff' ? styles.active : ''}
  911. onClick={() => onChangeStaff('staff')}
  912. >
  913. {{
  914. icon: () => (
  915. <Image src={staffDetafult} class={styles.staffImg} />
  916. ),
  917. title: () => <span class={styles.name}>五线谱</span>,
  918. value: () => (
  919. <Radio name="staff">
  920. {{
  921. icon: (props: any) => (
  922. <Icon
  923. class={styles.boxStyle}
  924. size={16}
  925. name={
  926. props.checked
  927. ? activeButtonIcon
  928. : inactiveButtonIcon
  929. }
  930. />
  931. )
  932. }}
  933. </Radio>
  934. )
  935. }}
  936. </Cell>
  937. <Cell
  938. center
  939. border={false}
  940. class={staff.radio === 'first' ? styles.active : ''}
  941. onClick={() => onChangeStaff('first')}
  942. >
  943. {{
  944. icon: () => (
  945. <Image src={firstDefault} class={styles.staffImg} />
  946. ),
  947. title: () => <span class={styles.name}>简谱-首调</span>,
  948. value: () => (
  949. <Radio name="first">
  950. {{
  951. icon: (props: any) => (
  952. <Icon
  953. class={styles.boxStyle}
  954. size={16}
  955. name={
  956. props.checked
  957. ? activeButtonIcon
  958. : inactiveButtonIcon
  959. }
  960. />
  961. )
  962. }}
  963. </Radio>
  964. )
  965. }}
  966. </Cell>
  967. <Cell
  968. center
  969. border={false}
  970. class={staff.radio === 'fixed' ? styles.active : ''}
  971. onClick={() => onChangeStaff('fixed')}
  972. >
  973. {{
  974. icon: () => (
  975. <Image src={fixedDefault} class={styles.staffImg} />
  976. ),
  977. title: () => <span class={styles.name}>简谱-固定调</span>,
  978. value: () => (
  979. <Radio name="fixed">
  980. {{
  981. icon: (props: any) => (
  982. <Icon
  983. class={styles.boxStyle}
  984. size={16}
  985. name={
  986. props.checked
  987. ? activeButtonIcon
  988. : inactiveButtonIcon
  989. }
  990. />
  991. )
  992. }}
  993. </Radio>
  994. )
  995. }}
  996. </Cell>
  997. </CellGroup>
  998. </RadioGroup>
  999. </div>
  1000. </Popup>
  1001. <Popup teleport="body" position="bottom" round v-model:show={staffData.open}>
  1002. <Picker columns={partColumns.value}
  1003. onConfirm={(value) => {
  1004. staffData.open = false
  1005. staffData.partIndex = value.value
  1006. nextTick(() => {
  1007. resetRender()
  1008. })
  1009. }}
  1010. onCancel={() => staffData.open = false}
  1011. />
  1012. </Popup>
  1013. </div>
  1014. )
  1015. }
  1016. }
  1017. })