new-index.tsx 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  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. theme: 'round-button',
  410. className: 'confirm-button-group',
  411. cancelButtonText: '取消订单',
  412. confirmButtonText: '继续支付'
  413. })
  414. .then(async () => {
  415. orderStatus.orderObject.orderNo = result.orderNo
  416. orderStatus.orderObject.actualPrice = result.actualPrice
  417. orderStatus.orderObject.discountPrice = result.discountPrice
  418. orderStatus.orderObject.paymentConfig = {
  419. ...result.paymentConfig,
  420. paymentVendor: result.paymentVendor,
  421. paymentVersion: result.paymentVersion
  422. }
  423. routerTo()
  424. })
  425. .catch(() => {
  426. Dialog.close()
  427. // 只用取消订单,不用做其它处理
  428. cancelPayment(result.orderNo)
  429. })
  430. } else {
  431. routerTo()
  432. }
  433. }
  434. const routerTo = () => {
  435. const music = musicDetail.value
  436. router.push({
  437. path: '/orderDetail',
  438. query: {
  439. orderType: 'MUSIC',
  440. musicId: music.id
  441. }
  442. })
  443. }
  444. const cancelPayment = async (orderNo: string) => {
  445. try {
  446. await request.post('/api-student/userOrder/orderCancel', {
  447. data: {
  448. orderNo
  449. }
  450. })
  451. } catch {
  452. //
  453. }
  454. }
  455. const paymentType = computed(() => {
  456. let paymentType = musicDetail.value?.paymentType
  457. if (typeof paymentType === 'string') {
  458. paymentType = paymentType.split(',')
  459. return paymentType
  460. }
  461. return []
  462. })
  463. const buyState = computed(() => {
  464. const music = musicDetail.value
  465. return {
  466. play: music.play ? true : false, // 是否可以播放
  467. free: music?.paymentType.includes('FREE'),
  468. charge: music?.paymentType.includes('CHARGE'),
  469. vip: music?.paymentType.includes('VIP'),
  470. buy: music?.orderStatus === 'PAID' // 是否已买
  471. }
  472. })
  473. const shareStatus = ref(false)
  474. const shareUrl = ref('')
  475. const shareDiscount = ref(0)
  476. // console.log(data)
  477. const onShare = async () => {
  478. try {
  479. const res = await request.post('/api-teacher/open/musicShareProfit', {
  480. data: {
  481. bizId: musicDetail.value?.id,
  482. userId: state.user.data?.userId
  483. }
  484. })
  485. let url =
  486. location.origin +
  487. `/teacher/#/shareMusic?id=${musicDetail.value?.id}&recomUserId=${state.user.data?.userId}&userType=${state.platformType}`
  488. // 判断是否有活动
  489. if (res.data.discount === 1) {
  490. url += `&activityId=${res.data.activityId}`
  491. }
  492. shareDiscount.value = res.data.discount || 0
  493. console.log(url)
  494. shareUrl.value = url
  495. shareStatus.value = true
  496. return
  497. } catch {
  498. //
  499. }
  500. }
  501. const staffData = reactive({
  502. open: false,
  503. iframeSrc: '',
  504. musicXml: '',
  505. instrumentName: '',
  506. iframeRef: null as any,
  507. partIndex: 0,
  508. partList: [] as any[]
  509. })
  510. /** 渲染五线谱 */
  511. const renderStaff = () => {
  512. staffData.iframeSrc = `${location.origin}${location.pathname}osmd/index.html`
  513. staffData.musicXml = musicDetail.value?.xmlFileUrl || ''
  514. staffData.partList = musicDetail.value?.background || []
  515. staffData.instrumentName = getInstrumentName(
  516. staffData.partList[staffData.partIndex]?.track
  517. )
  518. }
  519. const musicIframeLoad = () => {
  520. const iframeRef: any = document.getElementById('staffIframeRef')
  521. if (iframeRef && iframeRef.contentWindow.renderXml) {
  522. iframeRef.contentWindow.renderXml(
  523. staffData.musicXml,
  524. staffData.partIndex
  525. )
  526. }
  527. }
  528. const resetRender = () => {
  529. const iframeRef: any = document.getElementById('staffIframeRef')
  530. if (iframeRef && iframeRef.contentWindow.renderXml) {
  531. iframeRef.contentWindow.resetRender(staffData.partIndex)
  532. staffData.instrumentName = getInstrumentName(
  533. staffData.partList[staffData.partIndex]?.track
  534. )
  535. }
  536. }
  537. const partColumns = computed(() => {
  538. return staffData.partList.map((item: any, index: number) => {
  539. const instrumentName = getInstrumentName(item.track)
  540. return {
  541. text: item.track + (instrumentName ? `(${instrumentName})` : ''),
  542. value: index
  543. }
  544. })
  545. })
  546. return () => (
  547. <div class={styles.detail}>
  548. <TheSticky position="top">
  549. <ColHeader
  550. background={background.value}
  551. border={false}
  552. isFixed={false}
  553. color={color.value}
  554. backIconColor="white"
  555. />
  556. </TheSticky>
  557. <img class={styles.bgImg} src={musicDetail.value?.titleImg} />
  558. <div class={styles.musicContentBg}></div>
  559. <div class={styles.bg}>
  560. <div class={styles.alumWrap}>
  561. <div class={styles.img}>
  562. {/* {albumDetail.value?.paymentType === 'CHARGE' && (
  563. <span class={styles.albumType}>付费</span>
  564. )} */}
  565. <Image
  566. class={styles.image}
  567. width="100%"
  568. height="100%"
  569. fit="cover"
  570. src={musicDetail.value?.titleImg}
  571. />
  572. </div>
  573. <div class={styles.alumDes}>
  574. <div class={[styles.alumTitle, 'van-ellipsis']}>
  575. {musicDetail.value?.musicSheetName}
  576. </div>
  577. <div class={[styles.des, 'van-multi-ellipsis--l2']}>
  578. {!musicDetail.value?.composer
  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. </>
  598. )}
  599. </div>
  600. </div>
  601. </div>
  602. <div class={styles.alumCollect}>
  603. <div class={styles.alumCollectItem} onClick={onShare}>
  604. <Image src={iconShare} />
  605. <span>分享</span>
  606. </div>
  607. <div
  608. class={styles.alumCollectItem}
  609. onClick={() => {
  610. if (showImg.length > 0) {
  611. downloadStatus.value = true
  612. } else {
  613. Toast('暂无图片')
  614. }
  615. }}
  616. >
  617. <img src={iconDownload} />
  618. <span>下载</span>
  619. </div>
  620. <div
  621. class={styles.alumCollectItem}
  622. onClick={() => toggleFavorite()}
  623. >
  624. <img src={musicDetail.value?.favorite ? iStart : oStart} />
  625. <span>{musicDetail.value?.favoriteCount}</span>
  626. </div>
  627. </div>
  628. {musicDetail.value?.id && !buyState.value.play && (
  629. <div class={styles.albumTips}>
  630. {buyState.value.charge && buyState.value.vip ? (
  631. <>
  632. <span>开通会员或点播单曲,即可自由练习该曲谱</span>
  633. <span class={styles.albumPrice}>
  634. ¥{moneyFormat(musicDetail.value?.musicPrice)}
  635. </span>
  636. </>
  637. ) : buyState.value.vip ? (
  638. <span>
  639. <img src={iconMemberSmall} class={styles.iconMemberSmall} />
  640. 此曲谱为会员专享,开通会员即可自由练习该曲谱
  641. </span>
  642. ) : buyState.value.charge ? (
  643. <>
  644. <span>此曲谱为点播曲谱,点播即可自由练习该曲谱</span>
  645. <span class={styles.albumPrice}>
  646. ¥{moneyFormat(musicDetail.value?.musicPrice)}
  647. </span>
  648. </>
  649. ) : (
  650. ''
  651. )}
  652. </div>
  653. )}
  654. </div>
  655. <div class={styles.musicContent}>
  656. {musicDetail.value?.notation ? (
  657. <span
  658. class={styles.iconTransfer}
  659. onClick={() => {
  660. staff.status = true
  661. }}
  662. >
  663. 转谱
  664. </span>
  665. ) : null}
  666. <p class={styles.musicTitle}>
  667. {(musicDetail.value?.musicSheetName
  668. ? musicDetail.value?.musicSheetName
  669. : '') +
  670. (staffData.instrumentName ? `(${staffData.instrumentName})` : '')}
  671. </p>
  672. {musicDetail.value?.musicSheetType === 'CONCERT' ? (
  673. <>
  674. {loading.value && (
  675. <>
  676. <Vue3Lottie
  677. animationData={AstronautJSON}
  678. class={styles.finch}
  679. ></Vue3Lottie>
  680. <p class={styles.finchLoad}>加载中...</p>
  681. </>
  682. )}
  683. <iframe
  684. id="staffIframeRef"
  685. src={staffData.iframeSrc}
  686. onLoad={musicIframeLoad}
  687. ></iframe>
  688. </>
  689. ) : (
  690. <>
  691. {showImg.length > 0 ? (
  692. <img src={showImg[0]} alt="" class={styles.musicImg} />
  693. ) : loading.value ? (
  694. <>
  695. <Vue3Lottie
  696. animationData={AstronautJSON}
  697. class={styles.finch}
  698. ></Vue3Lottie>
  699. <p class={styles.finchLoad}>加载中...</p>
  700. </>
  701. ) : (
  702. <div class={styles.empty}>
  703. <Image src={emtpy} class={styles.emptyImg} />
  704. <p class={styles.emptyTip}>暂无乐谱预览图</p>
  705. </div>
  706. )}
  707. </>
  708. )}
  709. </div>
  710. {musicDetail.value?.id && (
  711. <TheSticky position="bottom">
  712. <div style={{ backgroundColor: '#fff' }}>
  713. <div class={styles.videoOperation}>
  714. {audioFileUrl.value && (
  715. <>
  716. {!buyState.value.play &&
  717. freeRate.value != 100 &&
  718. freeRate.value != 0 && (
  719. <div class={[styles.audition]}>
  720. <img src={iconListen} />
  721. <span>每首曲目可试听{freeRate.value}%</span>
  722. </div>
  723. )}
  724. <div class={[styles.audio, styles.collectCell]}>
  725. <audio id="player" controls ref={audio}>
  726. <source src={audioFileUrl.value} type="audio/mp3" />
  727. </audio>
  728. </div>
  729. </>
  730. )}
  731. </div>
  732. <div ref={footers} class={styles.footers}>
  733. {/* 判断是否是免费的,或者已经购买过 */}
  734. {buyState.value.play ? (
  735. <Button
  736. round
  737. block
  738. type="primary"
  739. color="linear-gradient(270deg, #FF3C81 0%, #FF76A6 100%)"
  740. onClick={() => {
  741. player.value && player.value.stop()
  742. musicBuy(musicDetail.value, () => {}, {
  743. 'part-index': staffData.partIndex || 0
  744. })
  745. }}
  746. >
  747. 立即练习
  748. </Button>
  749. ) : (
  750. <div class={[styles.buyBtn]}>
  751. {/* 判断是否是需要收费的 */}
  752. {buyState.value.charge && (
  753. <Button
  754. round
  755. type="primary"
  756. color="linear-gradient(270deg, #FF204B 0%, #FE5B71 100%)"
  757. class={styles.primary}
  758. onClick={onBuy}
  759. >
  760. 立即点播
  761. </Button>
  762. )}
  763. {/* 判断是否有会员的 */}
  764. {buyState.value.vip && (
  765. <Button
  766. round
  767. block={!buyState.value.charge ? true : false}
  768. type="primary"
  769. color="linear-gradient(270deg, #FF204B 0%, #FE5B71 100%)"
  770. class={styles.memeber}
  771. onClick={() => {
  772. router.push({
  773. path: '/memberCenter',
  774. query: {
  775. ...route.query
  776. }
  777. })
  778. }}
  779. >
  780. {studentActivityId.value > 0 && (
  781. <div class={[styles.buttonDiscount]}>专属优惠</div>
  782. )}
  783. 开通会员
  784. </Button>
  785. )}
  786. </div>
  787. )}
  788. </div>
  789. </div>
  790. </TheSticky>
  791. )}
  792. <Popup
  793. v-model:show={shareStatus.value}
  794. style={{ background: 'transparent' }}
  795. teleport="body"
  796. >
  797. <ColShare
  798. teacherId={state.user.data?.userId}
  799. shareUrl={shareUrl.value}
  800. shareType="music"
  801. type="tenant"
  802. >
  803. <div class={styles.shareMate}>
  804. {shareDiscount.value === 1 && (
  805. <div class={styles.tagDiscount}>专属优惠</div>
  806. )}
  807. <img
  808. class={styles.icon}
  809. crossorigin="anonymous"
  810. src={musicDetail.value?.titleImg + `?t=${+new Date()}`}
  811. />
  812. <div class={styles.info}>
  813. <h4 class="van-multi-ellipsis--l2">
  814. {musicDetail.value?.musicSheetName}
  815. </h4>
  816. <p>作曲人:{musicDetail.value?.composer}</p>
  817. </div>
  818. </div>
  819. </ColShare>
  820. </Popup>
  821. <Popup v-model:show={downloadStatus.value} position="bottom" round>
  822. <Download
  823. imgList={JSON.parse(JSON.stringify(showImg))}
  824. musicSheetName={musicDetail.value.musicSheetName}
  825. />
  826. </Popup>
  827. <Popup
  828. v-model:show={staff.status}
  829. teleport="body"
  830. closeable
  831. style={{ width: '80%' }}
  832. class={styles.staffChange}
  833. round
  834. >
  835. <div class={styles.staffContainer}>
  836. <div class={styles.staffTitle}>选择转换曲谱</div>
  837. <RadioGroup v-model={staff.radio}>
  838. <CellGroup border={false}>
  839. <Cell
  840. center
  841. border={false}
  842. class={staff.radio === 'staff' ? styles.active : ''}
  843. onClick={() => onChangeStaff('staff')}
  844. >
  845. {{
  846. icon: () => (
  847. <Image src={staffDetafult} class={styles.staffImg} />
  848. ),
  849. title: () => <span class={styles.name}>五线谱</span>,
  850. value: () => (
  851. <Radio name="staff">
  852. {{
  853. icon: (props: any) => (
  854. <Icon
  855. class={styles.boxStyle}
  856. name={
  857. props.checked
  858. ? activeButtonIcon
  859. : inactiveButtonIcon
  860. }
  861. />
  862. )
  863. }}
  864. </Radio>
  865. )
  866. }}
  867. </Cell>
  868. <Cell
  869. center
  870. border={false}
  871. class={staff.radio === 'first' ? styles.active : ''}
  872. onClick={() => onChangeStaff('first')}
  873. >
  874. {{
  875. icon: () => (
  876. <Image src={firstDefault} class={styles.staffImg} />
  877. ),
  878. title: () => <span class={styles.name}>简谱-首调</span>,
  879. value: () => (
  880. <Radio name="first">
  881. {{
  882. icon: (props: any) => (
  883. <Icon
  884. class={styles.boxStyle}
  885. name={
  886. props.checked
  887. ? activeButtonIcon
  888. : inactiveButtonIcon
  889. }
  890. />
  891. )
  892. }}
  893. </Radio>
  894. )
  895. }}
  896. </Cell>
  897. <Cell
  898. center
  899. border={false}
  900. class={staff.radio === 'fixed' ? styles.active : ''}
  901. onClick={() => onChangeStaff('fixed')}
  902. >
  903. {{
  904. icon: () => (
  905. <Image src={fixedDefault} class={styles.staffImg} />
  906. ),
  907. title: () => <span class={styles.name}>简谱-固定调</span>,
  908. value: () => (
  909. <Radio name="fixed">
  910. {{
  911. icon: (props: any) => (
  912. <Icon
  913. class={styles.boxStyle}
  914. name={
  915. props.checked
  916. ? activeButtonIcon
  917. : inactiveButtonIcon
  918. }
  919. />
  920. )
  921. }}
  922. </Radio>
  923. )
  924. }}
  925. </Cell>
  926. </CellGroup>
  927. </RadioGroup>
  928. </div>
  929. </Popup>
  930. <Popup
  931. teleport="body"
  932. position="bottom"
  933. round
  934. v-model:show={staffData.open}
  935. >
  936. <Picker
  937. columns={partColumns.value}
  938. onConfirm={value => {
  939. staffData.open = false
  940. staffData.partIndex = value.value
  941. nextTick(() => {
  942. resetRender()
  943. })
  944. }}
  945. onCancel={() => (staffData.open = false)}
  946. />
  947. </Popup>
  948. </div>
  949. )
  950. }
  951. })