index.tsx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { Tab, Tabs } from 'vant'
  2. import { defineComponent, onMounted, ref } from 'vue'
  3. import AlbumList from '../album'
  4. import Practice from './practice'
  5. import Personal from './personal'
  6. import Collection from './collection'
  7. import Album from './album'
  8. import AlbumMy from './album-my'
  9. import bgImg from '../../images/bg-image-1.png'
  10. import styles from './index.module.less'
  11. import { getRandomKey } from '../music'
  12. import { useEventTracking } from '@/helpers/hooks'
  13. import TheSticky from '@/components/the-sticky'
  14. import ColHeader from '@/components/col-header'
  15. import TenantAlbum from './tenant-album'
  16. export default defineComponent({
  17. name: 'MusicPersonal',
  18. setup() {
  19. localStorage.setItem('behaviorId', getRandomKey())
  20. const activeTab = ref('train-course')
  21. const personal = ref()
  22. const collection = ref()
  23. const practice = ref()
  24. onMounted(() => {
  25. useEventTracking('我的乐谱')
  26. })
  27. return () => {
  28. return (
  29. <div class={styles.personal}>
  30. <TheSticky position="top">
  31. <ColHeader
  32. background="transparent"
  33. isFixed={false}
  34. border={false}
  35. color="#131415"
  36. />
  37. </TheSticky>
  38. <img class={styles.bgImg} src={bgImg} />
  39. <Practice
  40. ref={practice}
  41. onFavorite={() => {
  42. if (activeTab.value === 'personal') {
  43. personal.value?.reset?.()
  44. } else if (activeTab.value === 'collection') {
  45. collection.value?.reset?.()
  46. }
  47. }}
  48. />
  49. <Tabs
  50. color="var(--van-primary)"
  51. background="transparent"
  52. lineWidth={20}
  53. shrink
  54. v-model:active={activeTab.value}
  55. onChange={val => (activeTab.value = val)}
  56. >
  57. <Tab title="训练教程" name="train-course"></Tab>
  58. <Tab title="我的单曲" name="personal"></Tab>
  59. <Tab title="我的专辑" name="personal-album"></Tab>
  60. <Tab title="收藏单曲" name="collection"></Tab>
  61. <Tab title="收藏专辑" name="album"></Tab>
  62. {/* <Tab title="赠送单曲" name="personal-gift"></Tab>
  63. <Tab title="赠送专辑" name="album-gift"></Tab> */}
  64. </Tabs>
  65. {activeTab.value === 'train-course' && <TenantAlbum />}
  66. {(activeTab.value === 'personal' ||
  67. activeTab.value === 'personal-gift') && (
  68. <Personal
  69. ref={personal}
  70. gift={activeTab.value === 'personal-gift' ? 1 : 0}
  71. onFavorite={() => {
  72. practice.value?.reload?.()
  73. }}
  74. />
  75. )}
  76. {(activeTab.value === 'personal-album' ||
  77. activeTab.value === 'album-gift') && (
  78. <AlbumMy gift={activeTab.value === 'album-gift' ? 1 : 0} />
  79. )}
  80. {activeTab.value === 'collection' && (
  81. <Collection
  82. ref={collection}
  83. onFavorite={() => {
  84. practice.value?.reload?.()
  85. }}
  86. />
  87. )}
  88. {activeTab.value === 'album' && <Album />}
  89. </div>
  90. )
  91. }
  92. }
  93. })