search.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view class="free-container dir-left-wrap">
  3. <episode
  4. v-for="(episode,index) in episodes"
  5. :key="index"
  6. :episode="episode"
  7. :custom-style="{
  8. marginRight: ((index+1) % 3 !== 0 ? '20rpx' :''),
  9. }"
  10. />
  11. </view>
  12. </template>
  13. <script>
  14. import Episode from '../../components/Episode/index'
  15. export default {
  16. name: 'Free',
  17. components: { Episode },
  18. data() {
  19. return {
  20. limit: 30,
  21. page: 1,
  22. isMore: true,
  23. keywords: '',
  24. episodes: []
  25. }
  26. },
  27. computed: {},
  28. methods: {
  29. getSearch() {
  30. this.loading = true
  31. this.$api.episode.search({ limit: this.limit, page: this.page, keywords: this.keywords }).then(res => {
  32. this.loading = false
  33. if (res.data.length) {
  34. this.episodes = this.episodes.concat(res.data)
  35. } else {
  36. this.isMore = false
  37. }
  38. })
  39. }
  40. },
  41. onLoad(options) {
  42. this.keywords = options?.keywords
  43. this.getSearch()
  44. },
  45. onReachBottom(e) {
  46. if (!this.isMore) return
  47. this.page += 1
  48. this.getSearch()
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .free-container {
  54. padding: 20rpx;
  55. }
  56. </style>