new-index.tsx 33 KB

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