integral.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. isLoadMore:true,
  6. pageSize: 10,
  7. pageIndex: 1,
  8. info:[],
  9. childInfo:{
  10. integral: 0
  11. }
  12. },
  13. onLoad: function (childInfo) {
  14. this.setData({ childInfo });
  15. if (util.isObjEmpty(childInfo) || util.isEmpty(childInfo.campId) || util.isEmpty(childInfo.playerId)){
  16. util.showTips("缺少参数。");
  17. return false;
  18. }
  19. this.getIntegral(true);
  20. },
  21. getIntegral(load){
  22. let self = this;
  23. util.ajax({
  24. func: "v2/course/score/list",
  25. data: { "campId": self.data.childInfo.campId, "playerId": self.data.childInfo.playerId, "pageIndex": self.data.pageIndex, "pageSize": self.data.pageSize },
  26. load: load
  27. }, function(res) {
  28. if (res.code == 0) {
  29. let isLoadMore = true;
  30. let newData = res.data.list;
  31. let oldData = !load ? newData : [...self.data.info, ...newData];
  32. if (oldData.length >= self.data.pageSize) isLoadMore = false;
  33. self.setData({ info: oldData, isLoadMore });
  34. } else
  35. util.showTips(res.reason);
  36. });
  37. },
  38. onPullDownRefresh() {
  39. var self = this;
  40. wx.showNavigationBarLoading();
  41. setTimeout(()=> {
  42. self.setData({ pageIndex: 1 });
  43. self.getIntegral(false);
  44. wx.hideNavigationBarLoading();
  45. wx.stopPullDownRefresh();
  46. }, 1000);
  47. },
  48. onReachBottom() {
  49. var self = this;
  50. if (self.data.isLoadMore == false) return false;
  51. setTimeout(() => {
  52. self.setData({ pageIndex: self.data.pageIndex + 1 });
  53. self.getIntegral(true);
  54. }, 1000);
  55. }
  56. })