index.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. // import { PaperClipIcon } from '@heroicons/vue/solid'
  2. import { defineComponent, toRefs, reactive, onMounted, ref } from 'vue'
  3. import arrow from '@/views/home/images/moreArrow.png'
  4. import styles from './index.module.less'
  5. import albumItem from './modals/albumItem'
  6. import videoDetailItem from '@/components/videoDetailItem'
  7. import musicLIstItem from '@/components/musicLIstItem'
  8. import hotSearch from '@/components/hotSearch'
  9. import { Swiper, SwiperSlide } from 'swiper/vue'
  10. import { Navigation, Pagination, Scrollbar, A11y } from 'swiper'
  11. import request from '@/helpers/request'
  12. import silder from '@/components/silder'
  13. import searchInput from '@/components/searchInput'
  14. import banner from '@/components/banner'
  15. import titleDot from '@/views/home/images/titleDot.png'
  16. import 'swiper/css'
  17. import 'swiper/css/navigation'
  18. import 'swiper/css/pagination'
  19. import 'swiper/css/scrollbar'
  20. import { useRoute, useRouter } from 'vue-router'
  21. import { state as baseState } from '@/state'
  22. import { SubjectEnum, useSubjectId } from '@/helpers/hooks'
  23. export default defineComponent({
  24. name: 'musicLibrary',
  25. components: {
  26. albumItem,
  27. videoDetailItem,
  28. musicLIstItem,
  29. hotSearch,
  30. silder,
  31. searchInput,
  32. banner
  33. },
  34. setup() {
  35. let subjectId = 0
  36. const subjectIds = baseState.user.data?.subjectId || ''
  37. if (subjectIds) {
  38. subjectId = Number(subjectIds.split(',')[0])
  39. }
  40. // 判断是否在默认的声部
  41. const subjects: any = useSubjectId(SubjectEnum.SEARCH)
  42. subjectId = subjects.id || subjectId
  43. const state = reactive({
  44. albumList: [],
  45. musicList: []
  46. })
  47. const router = useRouter()
  48. const getAlbumList = async () => {
  49. try {
  50. const res = await request.post('/api-website/open/music/album/list', {
  51. data: {
  52. albumStatus: 1,
  53. page: 1,
  54. subjectIds: subjectId ? subjectId : null,
  55. rows: 10
  56. }
  57. })
  58. state.albumList = res.data.rows
  59. } catch (e) {
  60. console.log(e)
  61. }
  62. }
  63. const getMusicList = async () => {
  64. try {
  65. const res = await request.post('/api-website/open/music/sheet/list', {
  66. data: {
  67. albumStatus: 'PASS',
  68. subjectIds: subjectId ? subjectId : null,
  69. page: 1,
  70. rows: 5,
  71. state: 1
  72. }
  73. })
  74. // state.musicList = res.data.rows
  75. state.musicList = res.data.rows.map(n => {
  76. if (typeof n.paymentType === 'string')
  77. n.paymentType = n.paymentType.split(',')
  78. return n
  79. })
  80. } catch (e) {
  81. console.log(e)
  82. }
  83. }
  84. const gotoSearch = (val: string | object) => {
  85. if (typeof val == 'string') {
  86. router.push({ name: 'searchdetail', params: { search: val } })
  87. } else {
  88. router.push({ name: 'searchdetail', params: { ...val } })
  89. }
  90. }
  91. const gotoMusic = () => {
  92. router.push({ name: 'searchdetail', params: { type: 'music' } })
  93. }
  94. const gotoAlbum = () => {
  95. router.push({ name: 'searchdetail', params: { type: '' } })
  96. }
  97. onMounted(() => {
  98. getAlbumList()
  99. getMusicList()
  100. })
  101. return () => (
  102. <div>
  103. <banner></banner>
  104. <div class="bg-white">
  105. <div class={styles.w1200}>
  106. <div class={styles.section}>
  107. {/* <div class={styles.titleWrap}>
  108. <img src={titleDot} class={styles.dotImg} alt="" />
  109. <h4>热门专辑</h4>
  110. <img src={titleDot} class={styles.dotImg} alt="" />
  111. </div> */}
  112. <searchInput
  113. isWhile={false}
  114. type="search"
  115. onStartSearch={(val: any) => gotoSearch(val)}
  116. ></searchInput>
  117. <div class={styles.hotSearch}>
  118. <hotSearch
  119. onHotTag={(val: string) => {
  120. gotoSearch(val)
  121. }}
  122. type={''}
  123. ></hotSearch>
  124. </div>
  125. {state.albumList && state.albumList.length > 0 && (
  126. <>
  127. <div class={[styles.videoNav, styles.mt25]}>
  128. <div class={styles.titleWrap}>
  129. <h5 class={styles.hotAlbum}>热门专辑</h5>
  130. <img src={titleDot} class={styles.dotImg} alt="" />
  131. </div>
  132. <div class={styles.wrapRight} onClick={() => gotoAlbum()}>
  133. <span>更多</span>
  134. <img class={styles.arrow} src={arrow} alt="" />
  135. </div>
  136. </div>
  137. <div class={styles.albumList}>
  138. {state.albumList.map(item => {
  139. return <albumItem detail={item}></albumItem>
  140. })}
  141. </div>
  142. </>
  143. )}
  144. </div>
  145. </div>
  146. </div>
  147. <div>
  148. <div class={styles.w1200}>
  149. {state.musicList && state.musicList.length > 0 && (
  150. <>
  151. <div
  152. class={[styles.section, styles.pb40]}
  153. style="padding-top: 0"
  154. >
  155. <div class={styles.videoNav}>
  156. <div class={styles.titleWrap}>
  157. <h5>热门乐谱</h5>
  158. <img src={titleDot} class={styles.dotImg} alt="" />
  159. </div>
  160. <div class={styles.wrapRight} onClick={() => gotoMusic()}>
  161. <span>更多</span>
  162. <img class={styles.arrow} src={arrow} alt="" />
  163. </div>
  164. </div>
  165. <div class={styles.musicList}>
  166. {state.musicList.map(item => {
  167. return <musicLIstItem item={item}></musicLIstItem>
  168. })}
  169. </div>
  170. </div>
  171. </>
  172. )}
  173. {/* <musicLIstItem></musicLIstItem> */}
  174. </div>
  175. </div>
  176. <silder></silder>
  177. </div>
  178. )
  179. }
  180. })