invite.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. recordId : "",
  6. isLoadMore: true,
  7. pageSize: 20,
  8. pageIndex: 1,
  9. info:[]
  10. },
  11. onLoad: function (options) {
  12. this.setData({ recordId : options.id });
  13. this.getInfo(true);
  14. },
  15. binderror(e) {
  16. var records = this.data.info, index = e.currentTarget.dataset.index;
  17. info[index].avatar = '/images/default_logo.jpg'
  18. this.setData({ records });
  19. },
  20. getInfo(load){
  21. let self = this;
  22. util.ajax({
  23. func: "coin/inviter/records",
  24. data: { "recordId": self.data.recordId, "pageIndex": self.data.pageIndex, "pageSize": self.data.pageSize},
  25. load: load
  26. },function (res) {
  27. if (res.code == 0){
  28. let isLoadMore = true;
  29. let newData = res.data.records;
  30. let oldData = !load ? newData : [...self.data.info, ...newData];
  31. if (oldData.length >= self.data.pageSize) isLoadMore = false;
  32. for (let i = 0; i < oldData.length - 1; i++) {
  33. oldData[i].priceStats = (oldData[i].price.indexOf("-") == -1 ? 0 : 1);
  34. }
  35. self.setData({ info: oldData, isLoadMore: isLoadMore });
  36. }else
  37. util.showTips(res.reason);
  38. });
  39. },
  40. onPullDownRefresh() {
  41. var self = this;
  42. wx.showNavigationBarLoading();
  43. setTimeout(function () {
  44. self.setData({ pageIndex: 1 });
  45. self.getInfo(false);
  46. wx.hideNavigationBarLoading();
  47. wx.stopPullDownRefresh();
  48. }, 1000);
  49. },
  50. onReachBottom() {
  51. var self = this;
  52. if (self.data.isLoadMore == false) return false;
  53. setTimeout(function () {
  54. self.setData({ pageIndex: self.data.pageIndex + 1 });
  55. self.getInfo(true);
  56. }, 1000);
  57. }
  58. })