index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <v-container fill-height fluid style="padding-left: 24px; padding-right: 24px">
  3. <div v-infinite-scroll="loadMore" infinite-scroll-disabled="true" infinite-scroll-distance="10">
  4. <v-row no-gutters>
  5. <v-col
  6. v-for="item in videoList"
  7. :key="item.id"
  8. >
  9. <VideoCared :video="item" />
  10. </v-col>
  11. </v-row>
  12. </div>
  13. </v-container>
  14. </template>
  15. <script>
  16. import { videoRecommend } from '@/api/media/video'
  17. import VideoCared from '@/components/card/video-card.vue'
  18. export default {
  19. name: 'Index',
  20. components: {
  21. VideoCared
  22. },
  23. data() {
  24. return {
  25. videoList: [],
  26. busy: false,
  27. page: 1
  28. }
  29. },
  30. created() {
  31. this.getRecommendVideo(this.page)
  32. },
  33. methods: {
  34. loadMore: function() {
  35. this.busy = true
  36. setTimeout(() => {
  37. this.getRecommendVideo(this.page)
  38. }, 1000)
  39. },
  40. getRecommendVideo(page) {
  41. videoRecommend(page)
  42. .then(res => {
  43. if (res.code === 0) {
  44. for (const item of res.data.list) {
  45. this.videoList.push(item)
  46. }
  47. this.page += 1
  48. this.busy = false
  49. } else {
  50. console.error(res.msg)
  51. }
  52. })
  53. .catch(error => {
  54. console.error(error.message)
  55. })
  56. }
  57. }
  58. }
  59. </script>
  60. <style>
  61. a {
  62. text-decoration: none;
  63. }
  64. </style>