index.tsx 4.3 KB

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