searchMusic.tsx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 hotSearch from '@/components/hotSearch'
  9. import request from '@/helpers/request'
  10. import silder from '@/components/silder'
  11. import searchInput from '@/components/searchInput'
  12. import pagination from '@/components/pagination'
  13. import 'swiper/css'
  14. import 'swiper/css/navigation'
  15. import 'swiper/css/pagination'
  16. import 'swiper/css/scrollbar'
  17. import ColEmpty from '@/components/col-empty'
  18. import { ElTabPane, ElTabs } from 'element-plus'
  19. import { getUserType } from '@/helpers/utils'
  20. export default defineComponent({
  21. name: 'searchMusic',
  22. components: {
  23. hotSearch,
  24. silder,
  25. searchInput,
  26. albumItem,
  27. musicListItem,
  28. pagination,
  29. ColEmpty
  30. },
  31. setup() {
  32. const state = reactive({
  33. musicList: [],
  34. search: {},
  35. isshowData: false,
  36. pageInfo: {
  37. // 分页规则
  38. limit: 10, // 限制显示条数
  39. page: 1, // 当前页
  40. total: 0, // 总条数
  41. page_size: [5, 10, 20, 40, 50] // 选择限制显示条数
  42. }
  43. })
  44. // const getAlbumList = async () => {
  45. // try {
  46. // const res = await request.post('/api-website/open/music/album/list', {
  47. // data: {
  48. // albumStatus: 1,
  49. // page: 1,
  50. // rows: 10
  51. // }
  52. // })
  53. // state.albumList = res.data.rows
  54. // } catch (e) {
  55. // console.log(e)
  56. // }
  57. // }
  58. const getMusicList = async () => {
  59. try {
  60. const res = await request.post('/api-website/open/music/sheet/list', {
  61. data: {
  62. albumStatus: 'PASS',
  63. ...state.search,
  64. page: state.pageInfo.page,
  65. rows: state.pageInfo.limit,
  66. state: 1,
  67. },
  68. params:{
  69. clientType: getUserType()
  70. }
  71. })
  72. state.musicList = res.data.rows.map(n => {
  73. if (typeof n.paymentType === "string") n.paymentType = n.paymentType.split(',')
  74. return n
  75. })
  76. state.pageInfo.total = res.data.total
  77. if (state.pageInfo.total == 0) {
  78. state.isshowData = true
  79. } else {
  80. state.isshowData = false
  81. }
  82. } catch (e) {
  83. console.log(e)
  84. }
  85. }
  86. const getList = (val: any) => {
  87. state.search = {
  88. subjectIds: val.subject,
  89. musicTagIds: val.albumTagIds,
  90. exquisiteFlag: val.exquisiteFlag,
  91. idAndName: val.search
  92. }
  93. state.pageInfo.page = 1
  94. getMusicList()
  95. }
  96. onMounted(() => {
  97. // getAlbumList()
  98. // getList(state.search)
  99. })
  100. return {
  101. ...toRefs(state),
  102. getList,
  103. getMusicList
  104. }
  105. },
  106. render() {
  107. return (
  108. <div>
  109. <div>
  110. <div class={styles.w1200}>
  111. <div class={styles.section}>
  112. <div class={styles.musicList}>
  113. {this.musicList.map(item => {
  114. return <musicListItem item={item}></musicListItem>
  115. })}
  116. </div>
  117. </div>
  118. </div>
  119. {this.isshowData && <ColEmpty></ColEmpty>}
  120. </div>
  121. <pagination
  122. total={this.pageInfo.total}
  123. v-model:page={this.pageInfo.page}
  124. v-model:limit={this.pageInfo.limit}
  125. pageSizes={this.pageInfo.page_size}
  126. pagination={this.getMusicList}
  127. />
  128. </div>
  129. )
  130. }
  131. })