free.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. episodes: []
  24. }
  25. },
  26. computed: {},
  27. methods: {
  28. getFree() {
  29. this.loading = true
  30. this.$api.episode.vipFree({ limit: this.limit, page: this.page }).then(res => {
  31. this.loading = false
  32. if (res.data.length) {
  33. this.episodes = this.episodes.concat(res.data)
  34. } else {
  35. this.isMore = false
  36. }
  37. })
  38. }
  39. },
  40. onLoad() {
  41. this.getFree()
  42. },
  43. onReachBottom(e) {
  44. if (!this.isMore) return
  45. this.page += 1
  46. this.getFree()
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. .free-container {
  52. padding: 20rpx;
  53. }
  54. </style>