points.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { PropType, defineComponent, reactive, watch } from 'vue';
  2. import styles from './point.module.less';
  3. import iconMulv from '../image/icon-mulv.svg';
  4. import iconZhibo from '../image/icon-load.gif';
  5. import iconImage from '../image/icon-image.svg';
  6. import iconImageActive from '../image/icon-image-active.svg';
  7. import iconVideo from '../image/icon-video.svg';
  8. import iconVideoActive from '../image/icon-video-active.svg';
  9. import iconSong from '../image/icon-song.svg';
  10. import iconSongActive from '../image/icon-song-active.svg';
  11. import { Icon } from 'vant';
  12. export default defineComponent({
  13. name: 'points',
  14. props: {
  15. data: {
  16. type: Array as PropType<any[]>,
  17. default: () => []
  18. },
  19. itemActive: {
  20. type: String,
  21. default: ''
  22. }
  23. },
  24. emits: ['handleSelect'],
  25. setup(props, { emit }) {
  26. const types: { [_: string]: string } = {
  27. SONG: '乐谱',
  28. VIDEO: '视频',
  29. IMG: '图片',
  30. AUDIO: '音频'
  31. };
  32. // 获取对应图片
  33. const getImage = (item: any) => {
  34. if (item.type === 'VIDEO') {
  35. return props.itemActive == item.id ? iconVideoActive : iconVideo;
  36. } else if (['IMAGE', 'IMG'].includes(item.type)) {
  37. return props.itemActive == item.id ? iconImageActive : iconImage;
  38. } else if (item.type === 'SONG') {
  39. return props.itemActive == item.id ? iconSongActive : iconSong;
  40. } else {
  41. return props.itemActive == item.id ? iconVideoActive : iconVideo;
  42. }
  43. };
  44. return () => (
  45. <div class={styles.container}>
  46. <div class={styles.pointHead}>
  47. <img src={iconMulv} />
  48. 第一单元 我愿住在童话里
  49. </div>
  50. <div class={styles.content}>
  51. {props.data.map((item, index: number) => {
  52. return (
  53. <div
  54. class={[
  55. styles.item,
  56. props.itemActive == item.id ? styles.itemActive : ''
  57. ]}
  58. onClick={() => {
  59. emit('handleSelect', {
  60. itemActive: item.id
  61. });
  62. }}>
  63. <div class={styles.cover}>
  64. {item.type === 'VIDEO' && (
  65. <img src="https://daya.ks3-cn-beijing.ksyuncs.com/1687681877690iShot2023-06-25_16.31.11.png" />
  66. )}
  67. {item.type === 'IMG' && <img src={item.content} />}
  68. {item.type === 'AUDIO' && <img src={item.content} />}
  69. {item.type === 'SONG' && (
  70. <img src="https://cloud-coach.ks3-cn-beijing.ksyuncs.com/music-sheet-first/1687673062603-1.png" />
  71. )}
  72. </div>
  73. <div class={styles.title}>
  74. <div class={styles.tag}>{types[item.type]}</div>
  75. <div>{item.name}</div>
  76. <Icon name={iconZhibo} />
  77. </div>
  78. </div>
  79. );
  80. })}
  81. </div>
  82. </div>
  83. );
  84. }
  85. });