index.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { defineComponent, toRefs, reactive, onMounted, ref } from 'vue'
  2. // import classes from './index.module.less'
  3. import styles from './index.module.less'
  4. import hotSearch from '@/components/hotSearch'
  5. import searchInput from '@/components/searchInput'
  6. import videoDetailItem from './modals/videoDetailItem'
  7. import request from '@/helpers/request'
  8. import pagination from '@/components/pagination'
  9. import { useRoute } from 'vue-router'
  10. import ColEmpty from '@/components/col-empty'
  11. import banner from '@/components/banner'
  12. import 'swiper/css'
  13. import 'swiper/css/navigation'
  14. import 'swiper/css/pagination'
  15. import 'swiper/css/scrollbar'
  16. export default defineComponent({
  17. name: 'videoDetailList',
  18. props: {
  19. title: {
  20. type: String,
  21. default: ''
  22. }
  23. },
  24. components: {
  25. banner,
  26. hotSearch,
  27. searchInput,
  28. videoDetailItem,
  29. pagination,
  30. ColEmpty
  31. },
  32. setup(props, conent) {
  33. const state = reactive({
  34. title: props.title,
  35. videoList: [],
  36. searchs: { search: '', lessonSubject: '' },
  37. pageInfo: {
  38. // 分页规则
  39. limit: 9, // 限制显示条数
  40. page: 1, // 当前页
  41. total: 0, // 总条数
  42. page_size: [9, 18, 36, 45] // 选择限制显示条数
  43. },
  44. isshowData: false
  45. })
  46. const route = useRoute()
  47. const getVideoList = async () => {
  48. console.log('请求接口')
  49. try {
  50. const res = await request.post(
  51. '/api-website/open/videoLessonGroup/page',
  52. {
  53. data: {
  54. ...state.searchs,
  55. albumStatus: 'PASS',
  56. page: state.pageInfo.page,
  57. rows: state.pageInfo.limit
  58. }
  59. }
  60. )
  61. state.videoList = res.data.rows
  62. state.pageInfo.total = res.data.total
  63. if (state.pageInfo.total == 0) {
  64. state.isshowData = true
  65. } else {
  66. state.isshowData = false
  67. }
  68. } catch (e) {
  69. console.log(e)
  70. }
  71. }
  72. const startSearch = (val: any) => {
  73. state.searchs = {
  74. ...state.searchs,
  75. lessonSubject: val.subject,
  76. search: val.search
  77. }
  78. getVideoList()
  79. }
  80. const gotoSearch = (val: string) => {
  81. state.searchs.search = val
  82. startSearch(state.searchs)
  83. }
  84. onMounted(() => {
  85. if (route.query.search) {
  86. state.searchs.search = route.query.search as string
  87. }
  88. if (route.query.subject) {
  89. state.searchs.lessonSubject = route.query.subject as string
  90. }
  91. getVideoList()
  92. })
  93. return () => (
  94. <>
  95. <banner />
  96. <div>
  97. <div class={styles.w1200}>
  98. <div class={styles.section}>
  99. <searchInput
  100. isWhile={true}
  101. searchVal={state.searchs}
  102. holder="搜一搜你想看的视频课"
  103. onStartSearch={(val: any) => {
  104. startSearch(val)
  105. }}
  106. ></searchInput>
  107. <div class={styles.hotSearchWrap}>
  108. <hotSearch
  109. searchType="COURSE"
  110. onHotTag={(val: string) => {
  111. gotoSearch(val)
  112. }}
  113. type={''}
  114. isChiose={true}
  115. ></hotSearch>
  116. </div>
  117. </div>
  118. <div class={styles.videoList}>
  119. {state.videoList.map(item => {
  120. return <videoDetailItem detail={item}></videoDetailItem>
  121. })}
  122. </div>
  123. {state.isshowData && <ColEmpty></ColEmpty>}
  124. <pagination
  125. total={state.pageInfo.total}
  126. v-model:page={state.pageInfo.page}
  127. v-model:limit={state.pageInfo.limit}
  128. pageSizes={state.pageInfo.page_size}
  129. pagination={getVideoList}
  130. />
  131. </div>
  132. </div>
  133. </>
  134. )
  135. }
  136. })