index.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { Grid, GridItem, Icon, Image, Loading } from 'vant'
  2. import { defineComponent, PropType } from 'vue'
  3. import styles from './index.module.less'
  4. import IconXin from '../images/icon-xin2.png'
  5. export default defineComponent({
  6. name: 'TheMusicGrid',
  7. props: {
  8. isHiddenTag: {
  9. type: Boolean,
  10. default: false
  11. },
  12. showLight: {
  13. type: Boolean,
  14. default: false
  15. },
  16. /** 需要高亮的文案 */
  17. lightText: {
  18. type: String,
  19. default: ''
  20. },
  21. list: {
  22. type: Array as any,
  23. default: () => []
  24. }
  25. },
  26. emits: ['goto'],
  27. setup(props, { emit }) {
  28. return () => (
  29. <div class={styles.theMusicGrid}>
  30. <Grid border={false} columnNum={3}>
  31. {props.list.map((n: any) => {
  32. let name = ''
  33. console.log(props.lightText, 'props.lightText')
  34. if (props.lightText) {
  35. name = n.albumName.replace(
  36. props.lightText,
  37. `<span style="color: #FE2451">${props.lightText}</span>`
  38. )
  39. } else {
  40. name = n.albumName
  41. }
  42. return (
  43. <GridItem>
  44. <div class={styles.item} onClick={() => emit('goto', n)}>
  45. <div class={styles.imgWrap}>
  46. {n.paymentType === 'CHARGE' && !props.isHiddenTag && (
  47. <span class={styles.albumType}>付费</span>
  48. )}
  49. <Image
  50. class={styles.image}
  51. width="100%"
  52. height="100%"
  53. fit="cover"
  54. src={n.albumCoverUrl}
  55. />
  56. <div class={styles.model}>
  57. <Icon name={IconXin} />
  58. <span class={styles.num}>{n.albumFavoriteCount}人</span>
  59. </div>
  60. </div>
  61. <div class={styles.title} v-html={name}></div>
  62. {/* <div class={styles.des}>共{n.musicSheetCount}首</div> */}
  63. </div>
  64. </GridItem>
  65. )
  66. })}
  67. </Grid>
  68. </div>
  69. )
  70. }
  71. })