index.tsx 6.1 KB

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