index.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { defineComponent, toRefs, reactive, onMounted, ref, watch } from 'vue'
  2. import classes from './index.module.less'
  3. import hold from './images/hold.png'
  4. import start from './images/start.png'
  5. import lineStart from './images/lineStart.png'
  6. import pan from './images/pan.png'
  7. import player from './images/player.png'
  8. import { useRouter } from 'vue-router'
  9. export default defineComponent({
  10. name: 'albumItem',
  11. props: {
  12. detail: {
  13. type: Object,
  14. default: {
  15. albumCoverUrl: '',
  16. albumDesc: '',
  17. albumFavoriteCount: 0,
  18. albumName: '',
  19. albumStatus: 0,
  20. albumTag: '',
  21. auditVersion: 0,
  22. createBy: 0,
  23. createTime: '',
  24. delFlag: null,
  25. hotFlag: null,
  26. id: 0,
  27. musicSheetCount: 0,
  28. musicTagNames: '',
  29. sortNumber: 0,
  30. topFlag: null,
  31. updateBy: 34,
  32. updateTime: '',
  33. favorite: 0
  34. } as any
  35. }
  36. },
  37. setup(props) {
  38. const state = reactive({
  39. detail: props.detail
  40. })
  41. watch(
  42. () => props.detail,
  43. detail => {
  44. state.detail = detail
  45. }
  46. )
  47. const router = useRouter()
  48. const gotoAlbum = () => {
  49. if (state.detail && state.detail.id) {
  50. router.push({ path: '/albumDetail', query: { id: state.detail.id } })
  51. }
  52. }
  53. return () => (
  54. <>
  55. <div
  56. class={classes.itemWrap}
  57. onClick={() => {
  58. gotoAlbum()
  59. }}
  60. >
  61. {state.detail?.paymentType === 'CHARGE' && (
  62. <span class={classes.albumType}>付费</span>
  63. )}
  64. <img
  65. class={classes.startImage}
  66. src={state.detail?.favorite ? lineStart : start}
  67. alt=""
  68. />
  69. <div class={classes.hold}>
  70. <div class={classes.masker}>
  71. <img src={player} alt="" />
  72. </div>
  73. <img
  74. src={
  75. state.detail?.albumCoverUrl ? state.detail?.albumCoverUrl : hold
  76. }
  77. alt=""
  78. />
  79. </div>
  80. <h2>{state.detail?.albumName}</h2>
  81. <div class={classes.itemBottom}>
  82. <div class={classes.itemBottomL}>
  83. {/* <img src={pan} alt="" /> */}
  84. <span>{state.detail?.musicSheetCount}首</span>
  85. </div>
  86. <div class={classes.itemBottomR}>
  87. {/* <img src={start} alt="" /> */}
  88. <span>{state.detail?.albumFavoriteCount}收藏</span>
  89. </div>
  90. </div>
  91. </div>
  92. </>
  93. )
  94. }
  95. })