index.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import { CellGroup, Cell, Icon, Image, Popup, Tag, Toast } from 'vant'
  2. import { computed, defineComponent, PropType, ref } from 'vue'
  3. import styles from './index.module.less'
  4. import IconPlay from '@/common/images/icon-play.png'
  5. import { useRouter } from 'vue-router'
  6. import { state } from '@/state'
  7. export const getAssetsHomeFile = (fileName: string) => {
  8. const path = `../images/${fileName}`
  9. const modules = import.meta.globEager('../images/*')
  10. return modules[path].default
  11. }
  12. export default defineComponent({
  13. name: 'TheSong',
  14. props: {
  15. list: {
  16. type: Array as PropType<any[]>,
  17. default: () => []
  18. },
  19. // showMore: {
  20. // type: Boolean,
  21. // default: true
  22. // },
  23. showPlay: {
  24. type: Boolean,
  25. default: true
  26. },
  27. musicNameClass: {
  28. type: String as PropType<unknown>
  29. },
  30. authorClass: {
  31. type: String as PropType<unknown>
  32. }
  33. },
  34. emits: ['detail'],
  35. setup(props, { emit }) {
  36. const isMore = ref<boolean>(false)
  37. const moreData = ref<any>({})
  38. const router = useRouter()
  39. const colors: any = {
  40. FREE: {
  41. color: '#01B84F',
  42. text: '免费'
  43. },
  44. VIP: {
  45. color: '#CD863E',
  46. text: '会员'
  47. },
  48. CHARGE: {
  49. color: '#3591CE',
  50. text: '点播'
  51. }
  52. }
  53. const list = computed(() => {
  54. return props.list.map(n => {
  55. if (typeof n.paymentType === 'string')
  56. n.paymentType = n.paymentType.split(',')
  57. return { ...n }
  58. })
  59. })
  60. return () => {
  61. return (
  62. <div class={styles.theSong}>
  63. {list.value.map((n: any) => (
  64. <div class={styles.item} onClick={() => emit('detail', n)}>
  65. <div class={styles.content}>
  66. <div class={styles.top}>
  67. {n.exquisiteFlag === 1 && (
  68. <Image
  69. class={styles.exquisiteFlag}
  70. src={getAssetsHomeFile('icon_exquisite.png')}
  71. />
  72. )}
  73. {n.albumNums > 0 && (
  74. <Image
  75. class={styles.songAlbum}
  76. src={getAssetsHomeFile('icon_album_active.png')}
  77. />
  78. )}
  79. <span
  80. class={[styles.title, props.musicNameClass, 'van-ellipsis']}
  81. >
  82. {n.musicSheetName}
  83. </span>
  84. <span
  85. class={[styles.singer, props.authorClass, 'van-ellipsis']}
  86. >
  87. -{n.composer}
  88. </span>
  89. </div>
  90. <div class={styles.user}>
  91. {n.favorite === 1 && (
  92. <Image
  93. src={getAssetsHomeFile('collection_active.png')}
  94. class={styles.collection}
  95. />
  96. )}
  97. <span class={[styles.name]}>
  98. {!n.composer
  99. ? `上传者:${n.addName}`
  100. : `作曲:${n.composer}`}
  101. </span>
  102. <div class={styles.tags}>
  103. {n.musicSheetType === 'CONCERT' ? (
  104. <span>合奏</span>
  105. ) : (
  106. n?.subjectNames &&
  107. n?.subjectNames
  108. .split(',')
  109. .map((name: any) => <span>{name}</span>)
  110. )}
  111. </div>
  112. </div>
  113. </div>
  114. <div class={styles.play}>
  115. {props.showPlay && <Icon name={IconPlay} size={28} />}
  116. {/* {props.showMore && (
  117. <span class={styles.moreSection}>
  118. <Icon
  119. name={IconMore}
  120. size={18}
  121. onClick={(e: MouseEvent) => {
  122. e.stopPropagation()
  123. isMore.value = true
  124. moreData.value = n
  125. }}
  126. />
  127. </span>
  128. )} */}
  129. </div>
  130. </div>
  131. ))}
  132. </div>
  133. )
  134. }
  135. }
  136. })