index.tsx 3.8 KB

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