allParticipant.js 883 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const {getAllLotteryUser} = require('../../utils/API.js')
  2. let raw_avatars = []
  3. let cur_page = 1
  4. let has_more = true
  5. Page({
  6. data: {
  7. loading: false,
  8. lottery_user_count: 0,
  9. lottery_user_avatars: []
  10. },
  11. onLoad: function (query) {
  12. const {id} = query
  13. getAllLotteryUser(id)
  14. .then(data => {
  15. const {
  16. lottery_user_count,
  17. lottery_user_avatars
  18. } = data.data
  19. raw_avatars = lottery_user_avatars
  20. this.setData({
  21. lottery_user_count,
  22. lottery_user_avatars: raw_avatars.slice(0, cur_page * 24)
  23. })
  24. })
  25. },
  26. loadMore(){
  27. if(has_more) {
  28. cur_page++
  29. let result = raw_avatars.slice(0, cur_page * 24)
  30. if(result.length === this.data.lottery_user_avatars.length) {
  31. has_more = false
  32. return
  33. }
  34. this.setData({
  35. lottery_user_avatars: result
  36. })
  37. }
  38. }
  39. })