index.tsx 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. import {
  2. defineComponent,
  3. nextTick,
  4. onMounted,
  5. onUnmounted,
  6. reactive,
  7. watch,
  8. ref
  9. } from 'vue';
  10. // import WaveSurfer from 'wavesurfer.js';
  11. import styles from './index.module.less';
  12. import MSticky from '@/components/m-sticky';
  13. import MHeader from '@/components/m-header';
  14. import {
  15. Button,
  16. Cell,
  17. Image,
  18. List,
  19. Popup,
  20. Slider,
  21. showDialog,
  22. showToast,
  23. Sticky,
  24. TextEllipsis
  25. } from 'vant';
  26. import iconDownload from './images/icon-download.png';
  27. import iconShare from './images/icon-share.png';
  28. import iconDelete from './images/icon-delete.png';
  29. import iconEdit from './images/edit.png';
  30. import iconUpward from './images/upward.png';
  31. import iconMember from './images/icon-member.png';
  32. import iconZan from './images/icon-zan.png';
  33. import promptImg from './images/prompt.png';
  34. import confirmImg from './images/confirm.png';
  35. import canceImg from './images/cance.png';
  36. import iconZanActive from './images/icon-zan-active.png';
  37. import iconPlay from './images/icon-play.png';
  38. import iconPause from './images/icon-pause.png';
  39. import { postMessage, promisefiyPostMessage } from '@/helpers/native-message';
  40. import { browser, getGradeCh, getSecondRPM, vaildMusicScoreUrl } from '@/helpers/utils';
  41. import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router';
  42. import {
  43. api_userMusicDetail,
  44. api_userMusicRemove,
  45. api_userMusicStarPage
  46. } from './api';
  47. import MEmpty from '@/components/m-empty';
  48. import dayjs from 'dayjs';
  49. import MVideo from '@/components/m-video';
  50. import ShareModel from './share-model';
  51. import { usePageVisibility, useEventListener } from '@vant/use';
  52. import "plyr/dist/plyr.css";
  53. import Plyr from "plyr";
  54. import { Vue3Lottie } from "vue3-lottie";
  55. import audioBga from "./images/audioBga.json";
  56. import audioBga1 from "./images/leftCloud.json";
  57. import audioBga2 from "./images/rightCloud.json";
  58. import videobg from "./images/videobg.png";
  59. import playProgressData from "./playCreation/playProgress"
  60. import Loading from './loading';
  61. export default defineComponent({
  62. name: 'creation-detail',
  63. setup() {
  64. const route = useRoute();
  65. const router = useRouter();
  66. const isScreenScroll = ref(false)
  67. const lottieDom = ref()
  68. const lottieDom1 = ref()
  69. const lottieDom2 = ref()
  70. const mStickyBottom = ref()
  71. const mStickyUpward = ref()
  72. const state = reactive({
  73. id: route.query.id,
  74. deleteStatus: false,
  75. shareStatus: false,
  76. playType: '' as 'Audio' | 'Video' | '', // 播放类型
  77. musicDetail: {} as any,
  78. isClick: false,
  79. list: [] as any,
  80. listState: {
  81. dataShow: true, // 判断是否有数据
  82. loading: false,
  83. finished: false
  84. },
  85. params: {
  86. page: 1,
  87. rows: 20
  88. },
  89. _plrl: null as any,
  90. heightV:0,
  91. heightB:0
  92. });
  93. const plyrState = reactive({
  94. duration: 0,
  95. currentTime: 0,
  96. mediaTimeShow: false,
  97. playIngShow: true
  98. })
  99. // 谱面
  100. const staffState = reactive({
  101. staffSrc: "",
  102. isShow: false,
  103. height:"initial",
  104. speedRate:1,
  105. musicRenderType:"staff",
  106. partIndex: 0
  107. })
  108. const staffDom= ref<HTMLIFrameElement>()
  109. const {playStaff, pauseStaff, updateProgressStaff} = staffMoveInstance()
  110. // 获取列表
  111. const getStarList = async () => {
  112. try {
  113. if (state.isClick) return;
  114. state.isClick = true;
  115. const res = await api_userMusicStarPage({
  116. userMusicId: state.id,
  117. ...state.params
  118. });
  119. state.listState.loading = false;
  120. const result = res.data || {};
  121. // 处理重复请求数据
  122. if (state.list.length > 0 && result.current === 1) {
  123. return;
  124. }
  125. state.list = state.list.concat(result.rows || []);
  126. state.listState.finished = result.current >= result.pages;
  127. state.params.page = result.current + 1;
  128. state.listState.dataShow = state.list.length > 0;
  129. state.isClick = false;
  130. } catch {
  131. state.listState.dataShow = false;
  132. state.listState.finished = true;
  133. state.isClick = false;
  134. }
  135. };
  136. // 删除作品
  137. const onDelete = async () => {
  138. try {
  139. await api_userMusicRemove({ id: state.id });
  140. setTimeout(() => {
  141. state.deleteStatus = false;
  142. showToast('删除成功');
  143. }, 100);
  144. setTimeout(() => {
  145. if (browser().isApp) {
  146. postMessage({
  147. api: 'goBack'
  148. });
  149. } else {
  150. router.back();
  151. }
  152. }, 1200);
  153. } catch {
  154. //
  155. }
  156. };
  157. // 下载
  158. const onDownload = async () => {
  159. await promisefiyPostMessage({
  160. api: 'saveFile',
  161. content: {
  162. url: state.musicDetail.videoUrl
  163. }
  164. });
  165. };
  166. // 滚动事件
  167. const cleanScrollEvent = useEventListener('scroll', () => {
  168. const height =
  169. window.scrollY ||
  170. document.documentElement.scrollTop
  171. // 防止多次调用
  172. if(height > 0 && isScreenScroll.value === false){
  173. isScreenScroll.value = true
  174. setStatusBarTextColor(false)
  175. }
  176. if(height <= 0){
  177. isScreenScroll.value = false
  178. setStatusBarTextColor(true)
  179. }
  180. })
  181. // 设置导航栏颜色
  182. function setStatusBarTextColor(isWhite:boolean){
  183. postMessage({
  184. api: 'setStatusBarTextColor',
  185. content: { statusBarTextColor: isWhite }
  186. })
  187. }
  188. // 初始化 媒体播放
  189. function initMediaPlay(){
  190. const id = state.playType === "Audio" ? "#audioMediaSrc" : "#videoMediaSrc";
  191. state._plrl = new Plyr(id, {
  192. controls: ["progress"],
  193. fullscreen: { enabled: false },
  194. });
  195. const player = state._plrl
  196. // 创建音波数据
  197. if(state.playType === "Audio"){
  198. const audioDom = document.querySelector("#audioMediaSrc") as HTMLAudioElement
  199. const canvasDom = document.querySelector("#audioVisualizer") as HTMLCanvasElement
  200. const { pauseVisualDraw, playVisualDraw } = audioVisualDraw(audioDom, canvasDom)
  201. player.on('play', () => {
  202. lottieDom.value?.play()
  203. lottieDom1.value?.play()
  204. lottieDom2.value?.play()
  205. playVisualDraw()
  206. });
  207. player.on('pause', () => {
  208. lottieDom.value?.pause()
  209. lottieDom1.value?.pause()
  210. lottieDom2.value?.pause()
  211. pauseVisualDraw()
  212. });
  213. }
  214. player.on('loadedmetadata', () => {
  215. player.currentTime = playProgressData.playProgress
  216. });
  217. player.on("timeupdate", ()=>{
  218. plyrState.currentTime = player.currentTime
  219. })
  220. player.on('play', () => {
  221. plyrState.playIngShow = false
  222. playStaff()
  223. });
  224. player.on('pause', () => {
  225. plyrState.playIngShow = true
  226. pauseStaff()
  227. });
  228. player.on('ended', () => {
  229. player.currentTime = 0
  230. if(!player.playing){
  231. setTimeout(() => {
  232. updateProgressStaff(player.currentTime)
  233. }, 100);
  234. }
  235. });
  236. // 处理按压事件
  237. const handleStart = () => {
  238. plyrState.duration = player.duration
  239. plyrState.mediaTimeShow = true
  240. };
  241. // 处理松开事件
  242. const handleEnd = () => {
  243. plyrState.mediaTimeShow = false
  244. // 暂停的时候调用
  245. if(!player.playing){
  246. updateProgressStaff(player.currentTime)
  247. }
  248. };
  249. const progressDom = document.querySelector("#playMediaSection .plyr__controls .plyr__progress__container") as HTMLElement
  250. progressDom.addEventListener('mousedown', handleStart);
  251. progressDom.addEventListener('touchstart', handleStart);
  252. progressDom.addEventListener('mouseup', handleEnd);
  253. progressDom.addEventListener('touchend', handleEnd);
  254. }
  255. //点击改变播放状态
  256. function handlerClickPlay(){
  257. if (state._plrl.playing) {
  258. state._plrl.pause();
  259. } else {
  260. state._plrl.play();
  261. }
  262. }
  263. /**
  264. * 音频可视化
  265. * @param audioDom
  266. * @param canvasDom
  267. * @param fftSize 2的幂数,最小为32
  268. */
  269. function audioVisualDraw(audioDom: HTMLAudioElement, canvasDom: HTMLCanvasElement, fftSize = 128) {
  270. type propsType = { canvWidth: number; canvHeight: number; canvFillColor: string; lineColor: string; lineGap: number }
  271. // canvas
  272. const canvasCtx = canvasDom.getContext("2d")!
  273. const { width, height } = canvasDom.getBoundingClientRect()
  274. canvasDom.width = width
  275. canvasDom.height = height
  276. // audio
  277. let audioCtx : AudioContext | null = null
  278. let analyser : AnalyserNode | null = null
  279. let source : MediaElementAudioSourceNode | null = null
  280. const dataArray = new Uint8Array(fftSize / 2)
  281. const draw = (data: Uint8Array, ctx: CanvasRenderingContext2D, { lineGap, canvWidth, canvHeight, canvFillColor, lineColor }: propsType) => {
  282. if (!ctx) return
  283. const w = canvWidth
  284. const h = canvHeight
  285. fillCanvasBackground(ctx, w, h, canvFillColor)
  286. // 可视化
  287. const dataLen = data.length
  288. let step = (w / 2 - lineGap * dataLen) / dataLen
  289. step < 1 && (step = 1)
  290. const midX = w / 2
  291. const midY = h / 2
  292. let xLeft = midX
  293. for (let i = 0; i < dataLen; i++) {
  294. const value = data[i]
  295. const percent = value / 255 // 最大值为255
  296. const barHeight = percent * midY
  297. canvasCtx.fillStyle = lineColor
  298. // 中间加间隙
  299. if (i === 0) {
  300. xLeft -= lineGap / 2
  301. }
  302. canvasCtx.fillRect(xLeft - step, midY - barHeight, step, barHeight)
  303. canvasCtx.fillRect(xLeft - step, midY, step, barHeight)
  304. xLeft -= step + lineGap
  305. }
  306. let xRight = midX
  307. for (let i = 0; i < dataLen; i++) {
  308. const value = data[i]
  309. const percent = value / 255 // 最大值为255
  310. const barHeight = percent * midY
  311. canvasCtx.fillStyle = lineColor
  312. if (i === 0) {
  313. xRight += lineGap / 2
  314. }
  315. canvasCtx.fillRect(xRight, midY - barHeight, step, barHeight)
  316. canvasCtx.fillRect(xRight, midY, step, barHeight)
  317. xRight += step + lineGap
  318. }
  319. }
  320. const fillCanvasBackground = (ctx: CanvasRenderingContext2D, w: number, h: number, colors: string) => {
  321. ctx.clearRect(0, 0, w, h)
  322. ctx.fillStyle = colors
  323. ctx.fillRect(0, 0, w, h)
  324. }
  325. const requestAnimationFrameFun = () => {
  326. requestAnimationFrame(() => {
  327. analyser?.getByteFrequencyData(dataArray)
  328. draw(dataArray, canvasCtx, {
  329. lineGap: 2,
  330. canvWidth: width,
  331. canvHeight: height,
  332. canvFillColor: "transparent",
  333. lineColor: "rgba(255, 255, 255, 0.7)"
  334. })
  335. if (!isPause) {
  336. requestAnimationFrameFun()
  337. }
  338. })
  339. }
  340. let isPause = true
  341. const playVisualDraw = () => {
  342. if (!audioCtx) {
  343. audioCtx = new AudioContext()
  344. source = audioCtx.createMediaElementSource(audioDom)
  345. analyser = audioCtx.createAnalyser()
  346. analyser.fftSize = fftSize
  347. source?.connect(analyser)
  348. analyser.connect(audioCtx.destination)
  349. }
  350. //audioCtx.resume() // 重新更新状态 加了暂停和恢复音频音质发生了变化 所以这里取消了
  351. isPause = false
  352. requestAnimationFrameFun()
  353. }
  354. const pauseVisualDraw = () => {
  355. isPause = true
  356. //audioCtx?.suspend() // 暂停 加了暂停和恢复音频音质发生了变化 所以这里取消了
  357. // source?.disconnect()
  358. // analyser?.disconnect()
  359. }
  360. return {
  361. playVisualDraw,
  362. pauseVisualDraw
  363. }
  364. }
  365. function handlerLandscapeScreen(event:any){
  366. event.stopPropagation()
  367. playProgressData.playState = !!state._plrl?.playing
  368. playProgressData.playProgress = state._plrl?.currentTime || 0
  369. router.push({
  370. path:"/playCreation",
  371. query:{
  372. resourceUrl:encodeURIComponent(state.musicDetail?.videoUrl),
  373. videoBgUrl:encodeURIComponent(state.musicDetail?.videoImg || ""),
  374. musicSheetName:encodeURIComponent(state.musicDetail?.musicSheetName),
  375. username:encodeURIComponent(state.musicDetail?.username),
  376. musicSheetId:encodeURIComponent(state.musicDetail?.musicSheetId),
  377. speedRate:encodeURIComponent(staffState.speedRate),
  378. musicRenderType:encodeURIComponent(staffState.musicRenderType),
  379. partIndex:encodeURIComponent(staffState.partIndex),
  380. }
  381. })
  382. }
  383. // 初始化五线谱
  384. function initStaff(){
  385. const src = `${vaildMusicScoreUrl()}/instrument/#/simple-detail?id=${state.musicDetail.musicSheetId}&musicRenderType=${staffState.musicRenderType}&part-index=${staffState.partIndex}`;
  386. //const src = `http://192.168.3.122:3000/instrument.html#/simple-detail?id=${state.musicDetail.musicSheetId}&musicRenderType=${staffState.musicRenderType}&part-index=${staffState.partIndex}`;
  387. staffState.staffSrc = src
  388. window.addEventListener('message', (event) => {
  389. const { api, height } = event.data;
  390. if (api === 'api_musicPage') {
  391. staffState.isShow = true
  392. staffState.height = height + "px"
  393. // 如果是播放中自动开始播放 不是播放 自动跳转到当前位置
  394. if(playProgressData.playState){
  395. handlerClickPlay()
  396. }else{
  397. updateProgressStaff(state._plrl.currentTime)
  398. }
  399. }
  400. });
  401. }
  402. function staffMoveInstance(){
  403. let isPause = true
  404. const requestAnimationFrameFun = () => {
  405. requestAnimationFrame(() => {
  406. staffDom.value?.contentWindow?.postMessage(
  407. {
  408. api: 'api_playProgress',
  409. content: {
  410. currentTime: state._plrl.currentTime * staffState.speedRate
  411. }
  412. },
  413. "*"
  414. )
  415. if (!isPause) {
  416. requestAnimationFrameFun()
  417. }
  418. })
  419. }
  420. const playStaff = () => {
  421. // 没渲染不执行
  422. if(!staffState.isShow) return
  423. isPause = false
  424. staffDom.value?.contentWindow?.postMessage(
  425. {
  426. api: 'api_play'
  427. },
  428. "*"
  429. )
  430. requestAnimationFrameFun()
  431. }
  432. const pauseStaff = () => {
  433. // 没渲染不执行
  434. if(!staffState.isShow) return
  435. isPause = true
  436. staffDom.value?.contentWindow?.postMessage(
  437. {
  438. api: 'api_paused'
  439. },
  440. "*"
  441. )
  442. }
  443. const updateProgressStaff = (currentTime: number) => {
  444. // 没渲染不执行
  445. if(!staffState.isShow) return
  446. staffDom.value?.contentWindow?.postMessage(
  447. {
  448. api: 'api_updateProgress',
  449. content: {
  450. currentTime: currentTime * staffState.speedRate
  451. }
  452. },
  453. "*"
  454. )
  455. }
  456. return {
  457. playStaff,
  458. pauseStaff,
  459. updateProgressStaff
  460. }
  461. }
  462. onMounted(async () => {
  463. setStatusBarTextColor(true)
  464. try {
  465. const res = await api_userMusicDetail(state.id);
  466. // console.log(res);
  467. if (res.code === 999) {
  468. showDialog({
  469. message: res.message,
  470. theme: 'round-button',
  471. confirmButtonColor:
  472. 'linear-gradient(73deg, #5BECFF 0%, #259CFE 100%)'
  473. }).then(() => {
  474. if (browser().isApp) {
  475. postMessage({
  476. api: 'goBack'
  477. });
  478. } else {
  479. router.back();
  480. }
  481. });
  482. return;
  483. }
  484. state.musicDetail = res.data || {};
  485. try{
  486. const jsonConfig = JSON.parse(res.data.jsonConfig)
  487. jsonConfig.speedRate && (staffState.speedRate = jsonConfig.speedRate)
  488. jsonConfig.musicRenderType && (staffState.musicRenderType = jsonConfig.musicRenderType)
  489. jsonConfig.partIndex && (staffState.partIndex = jsonConfig.partIndex)
  490. }catch{
  491. }
  492. // 五线谱
  493. initStaff()
  494. getStarList();
  495. // 判断是视频还是音频
  496. if (res.data.videoUrl.lastIndexOf('mp4') !== -1) {
  497. state.playType = 'Video';
  498. } else {
  499. state.playType = 'Audio';
  500. }
  501. nextTick(()=>{
  502. initMediaPlay()
  503. })
  504. } catch {
  505. //
  506. }
  507. requestAnimationFrame(()=>{
  508. mStickyBottom.value?.onChnageHeight()
  509. mStickyBottom.value?.onChnageHeight()
  510. })
  511. });
  512. onUnmounted(() => {
  513. setStatusBarTextColor(false)
  514. cleanScrollEvent()
  515. state._plrl?.destroy()
  516. });
  517. onBeforeRouteLeave((to, from, next)=>{
  518. if(to.path !== "/playCreation"){
  519. playProgressData.playProgress = 0
  520. playProgressData.playState = false
  521. }
  522. next()
  523. })
  524. return () => (
  525. <div
  526. style={
  527. {
  528. '--barheight':state.heightV + "px"
  529. }
  530. }
  531. class={[
  532. styles.creation,
  533. browser().isTablet && styles.creationTablet,
  534. isScreenScroll.value && styles.isScreenScroll
  535. ]}>
  536. <div class={styles.creationBg}></div>
  537. <MSticky position="top"
  538. onBarHeight={(height: any) => {
  539. console.log(height, 'height', height)
  540. state.heightV = height
  541. }}
  542. >
  543. <MHeader
  544. color={isScreenScroll.value ? "#333333" : "#ffffff"}
  545. background={isScreenScroll.value ? `rgb(255,255,255` : "transparent"}
  546. title={state.musicDetail?.musicSheetName}
  547. border={false}
  548. isBack={route.query.platformType != 'ANALYSIS'}
  549. />
  550. </MSticky>
  551. <div class={styles.singer}>
  552. 演奏:{state.musicDetail?.username}
  553. </div>
  554. <Sticky offsetTop={state.heightV - 1 + "px"}>
  555. <div class={[styles.playSection, plyrState.mediaTimeShow && styles.mediaTimeShow]} id="playMediaSection" onClick={handlerClickPlay}>
  556. {
  557. state.playType === 'Audio' &&
  558. <div class={styles.audioBox}>
  559. <canvas class={styles.audioVisualizer} id="audioVisualizer"></canvas>
  560. <Vue3Lottie ref={lottieDom} class={styles.audioBga} animationData={audioBga} autoPlay={false} loop={true}></Vue3Lottie>
  561. <Vue3Lottie ref={lottieDom1} class={styles.audioBga1} animationData={audioBga1} autoPlay={false} loop={true}></Vue3Lottie>
  562. <Vue3Lottie ref={lottieDom2} class={styles.audioBga2} animationData={audioBga2} autoPlay={false} loop={true}></Vue3Lottie>
  563. <audio
  564. crossorigin="anonymous"
  565. id="audioMediaSrc"
  566. src={state.musicDetail?.videoUrl}
  567. controls="false"
  568. preload="metadata"
  569. playsinline
  570. />
  571. </div>
  572. }
  573. {
  574. state.playType === 'Video' &&
  575. <video
  576. id="videoMediaSrc"
  577. class={styles.videoBox}
  578. src={state.musicDetail?.videoUrl}
  579. data-poster={ state.musicDetail?.videoImg || videobg}
  580. preload="metadata"
  581. playsinline
  582. />
  583. }
  584. <div class={[styles.playLarge, plyrState.playIngShow && styles.playIngShow]}></div>
  585. <div class={styles.mediaTime}>
  586. <div>
  587. {getSecondRPM(plyrState.currentTime)}
  588. </div>
  589. <div class={styles.note}>/</div>
  590. <div class={styles.duration}>
  591. {getSecondRPM(plyrState.duration)}
  592. </div>
  593. </div>
  594. <div class={styles.landscapeScreen} onClick={handlerLandscapeScreen}></div>
  595. {/* 谱面 */}
  596. {
  597. staffState.staffSrc &&
  598. <div
  599. class={[styles.staffBox, staffState.isShow && styles.staffBoxShow]}
  600. style={
  601. {
  602. '--staffBoxHeight':staffState.height
  603. }
  604. }
  605. >
  606. <div class={styles.mask}></div>
  607. <iframe
  608. ref={staffDom}
  609. class={styles.staff}
  610. frameborder="0"
  611. src={staffState.staffSrc}>
  612. </iframe>
  613. </div>
  614. }
  615. </div>
  616. </Sticky>
  617. <div class={styles.musicSection}>
  618. <div class={styles.avatarInfoBox}>
  619. <div class={styles.avatar}>
  620. <Image class={styles.userLogo} src={state.musicDetail.avatar} />
  621. <div class={styles.infoCon}>
  622. <div class={styles.info}>
  623. <span class={styles.userName}>{state.musicDetail?.username}</span>
  624. {state.musicDetail.vipFlag && (
  625. <img src={iconMember} class={styles.iconMember} />
  626. )}
  627. </div>
  628. <div class={styles.sub}>
  629. {state.musicDetail.subjectName}{' '}
  630. {getGradeCh(state.musicDetail.currentGradeNum - 1)}
  631. </div>
  632. </div>
  633. </div>
  634. <div class={styles.linkes}>
  635. <img src={iconZan} class={styles.iconZan} />
  636. <span>{state.musicDetail.likeNum}</span>
  637. </div>
  638. </div>
  639. <TextEllipsis class={styles.textEllipsis} rows={2} content={state.musicDetail?.desc} expand-text="展开" collapse-text="收起" />
  640. </div>
  641. <div class={styles.likeSection}>
  642. <div class={styles.likeTitle}>点赞记录</div>
  643. {state.listState.dataShow ? (
  644. <List
  645. finished={state.listState.finished}
  646. finishedText=" "
  647. onLoad={getStarList}
  648. immediateCheck={false}>
  649. {state.list.map((item: any, index: number) => (
  650. <Cell
  651. class={[styles.likeItem, index===state.list.length-1&&styles.likeItemLast]}
  652. border={false}
  653. >
  654. {{
  655. icon: () => (
  656. <Image src={item.userAvatar} class={styles.userLogo} />
  657. ),
  658. title: () => (
  659. <div class={styles.userInfo}>
  660. <p class={styles.name}>{item.userName}</p>
  661. <p class={styles.sub}>
  662. {item.subjectName}{' '}
  663. {getGradeCh(item.currentGradeNum - 1)}
  664. </p>
  665. </div>
  666. ),
  667. value: () => (
  668. <div class={styles.time}>
  669. {dayjs(item.createTime).format('YYYY-MM-DD HH:mm')}
  670. </div>
  671. )
  672. }}
  673. </Cell>
  674. ))}
  675. </List>
  676. ) : (
  677. <MEmpty class={styles.mEmpty} image={"empty2"} description="暂无点赞记录" />
  678. )}
  679. </div>
  680. {
  681. !isScreenScroll.value &&
  682. <MSticky ref={mStickyUpward} position="bottom" offsetBottom={state.heightB - 1 + "px"} >
  683. <div class={styles.upward}>
  684. <img src={iconUpward} />
  685. </div>
  686. </MSticky>
  687. }
  688. <MSticky ref={mStickyBottom} position="bottom" onBarHeight={(height: any) => {
  689. console.log(height, 'height', height)
  690. state.heightB = height
  691. }}>
  692. <div class={styles.bottomSection}>
  693. <div class={styles.bottomShare}>
  694. <p onClick={onDownload}>
  695. <img src={iconDownload} />
  696. <span>下载</span>
  697. </p>
  698. <p onClick={() => (state.shareStatus = true)}>
  699. <img src={iconShare} />
  700. <span>分享</span>
  701. </p>
  702. <p onClick={() => (state.deleteStatus = true)}>
  703. <img src={iconDelete} />
  704. <span>删除</span>
  705. </p>
  706. </div>
  707. <img src={iconEdit}
  708. class={styles.btnEdit}
  709. onClick={() => {
  710. router.push({
  711. path: '/creation-edit',
  712. query: {
  713. id: state.id
  714. }
  715. });
  716. }}
  717. />
  718. </div>
  719. </MSticky>
  720. <Popup
  721. v-model:show={state.deleteStatus}
  722. overlay-style={
  723. {
  724. backgroundColor:"rgba(0,0,0,.5)"
  725. }
  726. }
  727. round
  728. class={styles.popupContainer}>
  729. <img class={styles.prompt} src={promptImg} />
  730. <div class={styles.deleteBox}>
  731. <p class={styles.popupContent}>确定删除吗?</p>
  732. <div class={styles.popupBtnGroup}>
  733. <img src={canceImg} onClick={() => (state.deleteStatus = false)} />
  734. <img src={confirmImg} onClick={onDelete} />
  735. </div>
  736. </div>
  737. </Popup>
  738. <Popup
  739. position="bottom"
  740. v-model:show={state.shareStatus}
  741. style={{ background: 'transparent' }}>
  742. <ShareModel
  743. playType={state.playType}
  744. musicDetail={state.musicDetail}
  745. onClose={() => (state.shareStatus = false)}
  746. />
  747. </Popup>
  748. {
  749. !staffState.isShow && <Loading></Loading>
  750. }
  751. </div>
  752. );
  753. }
  754. });