index.tsx 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. // import { PaperClipIcon } from '@heroicons/vue/solid'
  2. import { defineComponent, toRefs, reactive, onMounted, ref } from 'vue'
  3. import arrow from '@/components/musicLIstItem/images/arrow.png'
  4. import styles from './index.module.less'
  5. import albumItem from '@/components/albumItem'
  6. import videoDetailItem from '@/components/videoDetailItem'
  7. import musicLIstItem from '@/components/musicLIstItem'
  8. import titleDot from './images/titleDot.png'
  9. import hotSearch from '@/components/hotSearch'
  10. import banner from '@/components/banner'
  11. import moreArrow from './images/moreArrow.png'
  12. import searchIcon from './images/search.png'
  13. import request from '@/helpers/request'
  14. import tagItem from '@/components/tagItem'
  15. import 'swiper/css'
  16. import 'swiper/css/navigation'
  17. import 'swiper/css/pagination'
  18. import 'swiper/css/scrollbar'
  19. import { useRouter } from 'vue-router'
  20. import { ElInput } from 'element-plus'
  21. export default defineComponent({
  22. name: 'home',
  23. components: {
  24. albumItem,
  25. videoDetailItem,
  26. musicLIstItem,
  27. hotSearch,
  28. banner,
  29. tagItem
  30. },
  31. setup() {
  32. const state = reactive({
  33. albumList: [],
  34. videoList: [],
  35. search: '',
  36. tagTree: []
  37. })
  38. const router = useRouter()
  39. const getAlbumList = async () => {
  40. try {
  41. const res = await request.post('/api-website/open/music/album/list', {
  42. data: {
  43. albumStatus: 1,
  44. page: 1,
  45. rows: 8
  46. }
  47. })
  48. state.albumList = res.data.rows
  49. } catch (e) {
  50. console.log(e)
  51. }
  52. }
  53. const getVideoList = async () => {
  54. try {
  55. const res = await request.post(
  56. '/api-website/open/videoLessonGroup/page',
  57. {
  58. data: {
  59. albumStatus: 'PASS',
  60. page: 1,
  61. rows: 3
  62. }
  63. }
  64. )
  65. state.videoList = res.data.rows
  66. } catch (e) {
  67. console.log(e)
  68. }
  69. }
  70. const gotoSearch = (val: string,type:any) => {
  71. router.push({ name: 'searchdetail', params: { search: val,type } })
  72. }
  73. const getTagTree = async () => {
  74. try {
  75. const res = await request.get('/api-website/open/MusicTag/tree', {})
  76. state.tagTree = res.data
  77. // state.hotList = res.data
  78. } catch (e) {
  79. console.log(e)
  80. }
  81. }
  82. const gotoVideoList = () => {
  83. router.push({ path: '/videoDetailList', })
  84. }
  85. //
  86. onMounted(() => {
  87. getAlbumList()
  88. getVideoList()
  89. getTagTree()
  90. })
  91. return () => (
  92. <div>
  93. <banner />
  94. <div class="bg-white">
  95. <div class={styles.w1200}>
  96. <div class={styles.section}>
  97. {/* <hotSearch
  98. searchType="MUSIC"
  99. onHotTag={(val: string) => {
  100. gotoSearch(val)
  101. }}
  102. ></hotSearch> */}
  103. <div class={styles.albumMoudel}>
  104. <div class={styles.albumWrap}>
  105. <div class={[styles.titleWrap, styles.hotAlbum]}>
  106. <div class={[styles.titleWrapLeft]}>
  107. <h4>热门专辑</h4>
  108. <img src={titleDot} class={styles.dotImg} alt="" />
  109. </div>
  110. <div class={[styles.titleWrapMore]} onClick={() => gotoSearch('','album')}>
  111. <span>更多</span>
  112. <img src={moreArrow} alt="" />
  113. </div>
  114. </div>
  115. <div class={styles.albumList}>
  116. {state.albumList.map(item => {
  117. return <albumItem detail={item}></albumItem>
  118. })}
  119. </div>
  120. <div class={styles.line}></div>
  121. </div>
  122. <div class={styles.albumSearch}>
  123. <div class={styles.inputWrap}>
  124. <img
  125. src={searchIcon}
  126. class={styles.searchIcon}
  127. onClick={()=>gotoSearch(state.search,'music')}
  128. alt=""
  129. />
  130. <ElInput
  131. placeholder="搜索你想要的曲目"
  132. v-model={state.search}
  133. // onKeyup={(e:any) => {
  134. // if (e.keyCode === 13) {
  135. // gotoSearch(state.search,'music')
  136. // }
  137. // }}
  138. // onkeyup= { gotoSearch(state.search,'music')}
  139. ></ElInput>
  140. </div>
  141. <div class={styles.chioseLineWrap}>
  142. {state.tagTree.map((tree: any) => {
  143. return (
  144. <div class={styles.chioseRow}>
  145. <p>{tree.name}:</p>
  146. <div class={[styles.chioseTagWrap, 'chioseTagWrap']}>
  147. {tree.children.map((tag: any) => {
  148. return (
  149. // effect={isChiose(tag)}
  150. <tagItem
  151. class={styles.tags}
  152. title={tag.name}
  153. onSearchTag={() => {
  154. gotoSearch(tag.name,'')
  155. }}
  156. >
  157. {/* {} */}
  158. </tagItem>
  159. )
  160. })}
  161. </div>
  162. </div>
  163. )
  164. })}
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. <div class="bg-white">
  172. <div class={styles.w1200}>
  173. <div class={[styles.section,styles.pt41]}>
  174. <div class={[styles.titleWrap]}>
  175. {/* <img src={titleDot} class={styles.dotImg} alt="" /> */}
  176. <div class={[styles.titleWrapLeft]}>
  177. <h4>热门专辑</h4>
  178. <img src={titleDot} class={styles.dotImg} alt="" />
  179. </div>
  180. <div class={[styles.titleWrapMore]} onClick={()=>gotoVideoList()}>
  181. <span>更多</span>
  182. <img src={moreArrow} alt="" />
  183. </div>
  184. </div>
  185. <div class={styles.videoList}>
  186. {state.videoList.map(item => {
  187. return <videoDetailItem detail={item}></videoDetailItem>
  188. })}
  189. </div>
  190. </div>
  191. {/* <musicLIstItem></musicLIstItem> */}
  192. </div>
  193. </div>
  194. </div>
  195. )
  196. }
  197. })