index.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { Tab, Tabs } from 'vant'
  2. import { defineComponent, onMounted, ref } from 'vue'
  3. import styles from './index.module.less'
  4. import { useEventTracking } from '@/helpers/hooks'
  5. import { getRandomKey } from '@/views/music/music'
  6. import Personal from '@/views/music/personal/personal'
  7. import Collection from '@/views/music/personal/collection'
  8. import Album from '@/views/music/personal/album'
  9. import AlbumMy from '@/views/music/personal/album-my'
  10. import ColHeader from '@/components/col-header'
  11. import TheSticky from '@/components/the-sticky'
  12. export default defineComponent({
  13. name: 'mySheetMusic',
  14. setup() {
  15. localStorage.setItem('behaviorId', getRandomKey())
  16. const activeTab = ref('personal')
  17. const personal = ref()
  18. const collection = ref()
  19. const practice = ref()
  20. const height = ref<any>('auto')
  21. onMounted(() => {
  22. useEventTracking('我的乐谱')
  23. })
  24. return () => {
  25. return (
  26. <div>
  27. <TheSticky
  28. position="top"
  29. onBarHeight={(h: any) => {
  30. height.value = h
  31. }}
  32. >
  33. <ColHeader />
  34. </TheSticky>
  35. <Tabs
  36. animated
  37. swipeable
  38. color="var(--van-primary)"
  39. lineWidth={20}
  40. v-model:active={activeTab.value}
  41. onChange={val => (activeTab.value = val)}
  42. sticky
  43. offsetTop={height.value}
  44. >
  45. <Tab title="购买单曲" name="personal">
  46. <div class={styles.container}>
  47. <Personal
  48. ref={personal}
  49. onFavorite={() => {
  50. practice.value?.reload?.()
  51. }}
  52. />
  53. </div>
  54. </Tab>
  55. <Tab title="购买专辑" name="personal-album">
  56. <div class={styles.container}>
  57. <AlbumMy />
  58. </div>
  59. </Tab>
  60. <Tab title="收藏单曲" name="collection">
  61. <div class={styles.container}>
  62. <Collection
  63. ref={collection}
  64. onFavorite={() => {
  65. practice.value?.reload?.()
  66. }}
  67. />
  68. </div>
  69. </Tab>
  70. <Tab title="收藏专辑" name="album">
  71. <div class={styles.container}>
  72. <Album />
  73. </div>
  74. </Tab>
  75. </Tabs>
  76. </div>
  77. )
  78. }
  79. }
  80. })