list.vue 1.1 KB

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