new-index.tsx 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  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 class={[styles.des, 'van-multi-ellipsis--l2']}>
  572. {!musicDetail.value?.composer
  573. ? `上传者:${musicDetail.value?.addName || ''}`
  574. : `作曲:${musicDetail.value?.composer || ''}`}
  575. </div>
  576. <div class={styles.tags}>
  577. {musicDetail.value?.id && (
  578. <>
  579. {musicDetail.value?.musicTagNames &&
  580. musicDetail.value?.musicTagNames.split(',').map(name => (
  581. <span
  582. style={{
  583. borderColor: colors.FREE.color,
  584. color: colors.FREE.color
  585. }}
  586. class={styles.tag}
  587. >
  588. {name}
  589. </span>
  590. ))}
  591. </>
  592. )}
  593. </div>
  594. </div>
  595. </div>
  596. <div class={styles.alumCollect}>
  597. <div class={styles.alumCollectItem} onClick={onShare}>
  598. <Image src={iconShare} />
  599. <span>分享</span>
  600. </div>
  601. <div
  602. class={styles.alumCollectItem}
  603. onClick={() => {
  604. if (showImg.length > 0) {
  605. downloadStatus.value = true
  606. } else {
  607. Toast('暂无图片')
  608. }
  609. }}
  610. >
  611. <img src={iconDownload} />
  612. <span>下载</span>
  613. </div>
  614. <div
  615. class={styles.alumCollectItem}
  616. onClick={() => toggleFavorite()}
  617. >
  618. <img src={musicDetail.value?.favorite ? iStart : oStart} />
  619. <span>{musicDetail.value?.favoriteCount}</span>
  620. </div>
  621. </div>
  622. {musicDetail.value?.id && !buyState.value.play && (
  623. <div class={styles.albumTips}>
  624. {buyState.value.charge && buyState.value.vip ? (
  625. <>
  626. <span>开通会员或点播单曲,即可自由练习该曲谱</span>
  627. <span class={styles.albumPrice}>
  628. ¥{moneyFormat(musicDetail.value?.musicPrice)}
  629. </span>
  630. </>
  631. ) : buyState.value.vip ? (
  632. <span>
  633. <img src={iconMemberSmall} class={styles.iconMemberSmall} />
  634. 此曲谱为会员专享,开通会员即可自由练习该曲谱
  635. </span>
  636. ) : buyState.value.charge ? (
  637. <>
  638. <span>此曲谱为点播曲谱,点播即可自由练习该曲谱</span>
  639. <span class={styles.albumPrice}>
  640. ¥{moneyFormat(musicDetail.value?.musicPrice)}
  641. </span>
  642. </>
  643. ) : (
  644. ''
  645. )}
  646. </div>
  647. )}
  648. </div>
  649. <div class={styles.musicContent}>
  650. {musicDetail.value?.notation ? (
  651. <span
  652. class={styles.iconTransfer}
  653. onClick={() => {
  654. staff.status = true
  655. }}
  656. >
  657. 转谱
  658. </span>
  659. ) : null}
  660. <p class={styles.musicTitle}>
  661. {(musicDetail.value?.musicSheetName
  662. ? musicDetail.value?.musicSheetName
  663. : '') +
  664. (staffData.instrumentName ? `(${staffData.instrumentName})` : '')}
  665. </p>
  666. {musicDetail.value?.musicSheetType === 'CONCERT' ? (
  667. <>
  668. {loading.value && (
  669. <>
  670. <Vue3Lottie
  671. animationData={AstronautJSON}
  672. class={styles.finch}
  673. ></Vue3Lottie>
  674. <p class={styles.finchLoad}>加载中...</p>
  675. </>
  676. )}
  677. <iframe
  678. id="staffIframeRef"
  679. src={staffData.iframeSrc}
  680. onLoad={musicIframeLoad}
  681. ></iframe>
  682. </>
  683. ) : (
  684. <>
  685. {showImg.length > 0 ? (
  686. <img src={showImg[0]} alt="" class={styles.musicImg} />
  687. ) : loading.value ? (
  688. <>
  689. <Vue3Lottie
  690. animationData={AstronautJSON}
  691. class={styles.finch}
  692. ></Vue3Lottie>
  693. <p class={styles.finchLoad}>加载中...</p>
  694. </>
  695. ) : (
  696. <div class={styles.empty}>
  697. <Image src={emtpy} class={styles.emptyImg} />
  698. <p class={styles.emptyTip}>暂无乐谱预览图</p>
  699. </div>
  700. )}
  701. </>
  702. )}
  703. </div>
  704. {musicDetail.value?.id && (
  705. <TheSticky position="bottom">
  706. <div style={{ backgroundColor: '#fff' }}>
  707. <div class={styles.videoOperation}>
  708. {audioFileUrl.value && (
  709. <>
  710. {!buyState.value.play &&
  711. freeRate.value != 100 &&
  712. freeRate.value != 0 && (
  713. <div class={[styles.audition]}>
  714. <img src={iconListen} />
  715. <span>每首曲目可试听{freeRate.value}%</span>
  716. </div>
  717. )}
  718. <div class={[styles.audio, styles.collectCell]}>
  719. <audio id="player" controls ref={audio}>
  720. <source src={audioFileUrl.value} type="audio/mp3" />
  721. </audio>
  722. </div>
  723. </>
  724. )}
  725. </div>
  726. <div ref={footers} class={styles.footers}>
  727. {/* 判断是否是免费的,或者已经购买过 */}
  728. {buyState.value.play ? (
  729. <Button
  730. round
  731. block
  732. type="primary"
  733. color="linear-gradient(270deg, #FF3C81 0%, #FF76A6 100%)"
  734. onClick={() => {
  735. player.value && player.value.stop()
  736. musicBuy(musicDetail.value, () => {}, {
  737. 'part-index': staffData.partIndex || 0
  738. })
  739. }}
  740. >
  741. 立即练习
  742. </Button>
  743. ) : (
  744. <div class={[styles.buyBtn]}>
  745. {/* 判断是否是需要收费的 */}
  746. {buyState.value.charge && (
  747. <Button
  748. round
  749. type="primary"
  750. color="linear-gradient(270deg, #FF204B 0%, #FE5B71 100%)"
  751. class={styles.primary}
  752. onClick={onBuy}
  753. >
  754. 立即点播
  755. </Button>
  756. )}
  757. {/* 判断是否有会员的 */}
  758. {buyState.value.vip && (
  759. <Button
  760. round
  761. block={!buyState.value.charge ? true : false}
  762. type="primary"
  763. color="linear-gradient(270deg, #FF204B 0%, #FE5B71 100%)"
  764. class={styles.memeber}
  765. onClick={() => {
  766. router.push({
  767. path: '/memberCenter',
  768. query: {
  769. ...route.query
  770. }
  771. })
  772. }}
  773. >
  774. {studentActivityId.value > 0 && (
  775. <div class={[styles.buttonDiscount]}>专属优惠</div>
  776. )}
  777. 开通会员
  778. </Button>
  779. )}
  780. </div>
  781. )}
  782. </div>
  783. </div>
  784. </TheSticky>
  785. )}
  786. <Popup
  787. v-model:show={shareStatus.value}
  788. style={{ background: 'transparent' }}
  789. teleport="body"
  790. >
  791. <ColShare
  792. teacherId={state.user.data?.userId}
  793. shareUrl={shareUrl.value}
  794. shareType="music"
  795. type="tenant"
  796. >
  797. <div class={styles.shareMate}>
  798. {shareDiscount.value === 1 && (
  799. <div class={styles.tagDiscount}>专属优惠</div>
  800. )}
  801. <img
  802. class={styles.icon}
  803. crossorigin="anonymous"
  804. src={musicDetail.value?.titleImg + `?t=${+new Date()}`}
  805. />
  806. <div class={styles.info}>
  807. <h4 class="van-multi-ellipsis--l2">
  808. {musicDetail.value?.musicSheetName}
  809. </h4>
  810. <p>作曲人:{musicDetail.value?.composer}</p>
  811. </div>
  812. </div>
  813. </ColShare>
  814. </Popup>
  815. <Popup v-model:show={downloadStatus.value} position="bottom" round>
  816. <Download
  817. imgList={JSON.parse(JSON.stringify(showImg))}
  818. musicSheetName={musicDetail.value.musicSheetName}
  819. />
  820. </Popup>
  821. <Popup
  822. v-model:show={staff.status}
  823. teleport="body"
  824. closeable
  825. style={{ width: '80%' }}
  826. round
  827. >
  828. <div class={styles.staffContainer}>
  829. <div class={styles.staffTitle}>选择转换曲谱</div>
  830. <RadioGroup v-model={staff.radio}>
  831. <CellGroup border={false}>
  832. <Cell
  833. center
  834. border={false}
  835. class={staff.radio === 'staff' ? styles.active : ''}
  836. onClick={() => onChangeStaff('staff')}
  837. >
  838. {{
  839. icon: () => (
  840. <Image src={staffDetafult} class={styles.staffImg} />
  841. ),
  842. title: () => <span class={styles.name}>五线谱</span>,
  843. value: () => (
  844. <Radio name="staff">
  845. {{
  846. icon: (props: any) => (
  847. <Icon
  848. class={styles.boxStyle}
  849. size={16}
  850. name={
  851. props.checked
  852. ? activeButtonIcon
  853. : inactiveButtonIcon
  854. }
  855. />
  856. )
  857. }}
  858. </Radio>
  859. )
  860. }}
  861. </Cell>
  862. <Cell
  863. center
  864. border={false}
  865. class={staff.radio === 'first' ? styles.active : ''}
  866. onClick={() => onChangeStaff('first')}
  867. >
  868. {{
  869. icon: () => (
  870. <Image src={firstDefault} class={styles.staffImg} />
  871. ),
  872. title: () => <span class={styles.name}>简谱-首调</span>,
  873. value: () => (
  874. <Radio name="first">
  875. {{
  876. icon: (props: any) => (
  877. <Icon
  878. class={styles.boxStyle}
  879. size={16}
  880. name={
  881. props.checked
  882. ? activeButtonIcon
  883. : inactiveButtonIcon
  884. }
  885. />
  886. )
  887. }}
  888. </Radio>
  889. )
  890. }}
  891. </Cell>
  892. <Cell
  893. center
  894. border={false}
  895. class={staff.radio === 'fixed' ? styles.active : ''}
  896. onClick={() => onChangeStaff('fixed')}
  897. >
  898. {{
  899. icon: () => (
  900. <Image src={fixedDefault} class={styles.staffImg} />
  901. ),
  902. title: () => <span class={styles.name}>简谱-固定调</span>,
  903. value: () => (
  904. <Radio name="fixed">
  905. {{
  906. icon: (props: any) => (
  907. <Icon
  908. class={styles.boxStyle}
  909. size={16}
  910. name={
  911. props.checked
  912. ? activeButtonIcon
  913. : inactiveButtonIcon
  914. }
  915. />
  916. )
  917. }}
  918. </Radio>
  919. )
  920. }}
  921. </Cell>
  922. </CellGroup>
  923. </RadioGroup>
  924. </div>
  925. </Popup>
  926. <Popup
  927. teleport="body"
  928. position="bottom"
  929. round
  930. v-model:show={staffData.open}
  931. >
  932. <Picker
  933. columns={partColumns.value}
  934. onConfirm={value => {
  935. staffData.open = false
  936. staffData.partIndex = value.value
  937. nextTick(() => {
  938. resetRender()
  939. })
  940. }}
  941. onCancel={() => (staffData.open = false)}
  942. />
  943. </Popup>
  944. </div>
  945. )
  946. }
  947. })