index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const util = require("../../../utils/util.js");
  2. Page({
  3. data: {
  4. array: ['全部','待入账','已入账','审核未通过'],
  5. index: 0,
  6. finishedText:'',
  7. finished: false,
  8. pageSize:10,
  9. pageIndex:1,
  10. list: [],
  11. moeny: 0,
  12. },
  13. onLoad: function (options) {
  14. this.getList(true)
  15. this.getMoney()
  16. },
  17. onReachBottom: function () {
  18. var self = this;
  19. if(self.data.finished) return false;
  20. setTimeout(function () {
  21. self.setData({ pageIndex: self.data.pageIndex + 1 });
  22. self.getList(false);
  23. }, 1000);
  24. },
  25. getList(load) {
  26. let that = this;
  27. util.ajax({
  28. func: "v2/userMoney/list",
  29. data: {
  30. pageSize: that.data.pageSize,
  31. pageIndex: that.data.pageIndex,
  32. status: that.data.index - 1,
  33. },
  34. load: true
  35. }, function (res) {
  36. if (res.code == 0) {
  37. res.data.list = res.data.list.map((item) => {
  38. if(item.price.toString().indexOf('-') != -1) {
  39. return {...item, signStatus: false}
  40. } else {
  41. return {...item, signStatus: true}
  42. }
  43. })
  44. let list = load ? res.data.list : [...that.data.list, ...res.data.list];
  45. that.setData({list});
  46. if (that.data.list.length >= res.data.total || that.data.list.length < that.data.pageSize) {
  47. that.setData({ finishedText: that.data.list.length < that.data.pageSize ? '' : "~~已经到底了~~", finished:true})
  48. } else {
  49. }
  50. } else {
  51. util.showTips(res.reason);
  52. }
  53. });
  54. },
  55. getMoney() {
  56. let that = this;
  57. util.ajax({
  58. func: "v2/userMoney/balance",
  59. data: {},
  60. load: false
  61. }, function (res) {
  62. if (res.code == 0) {
  63. that.setData({money:util.toMoney(res.data)})
  64. } else {
  65. util.showTips(res.reason);
  66. }
  67. });
  68. },
  69. bindChildChange(e) {
  70. this.setData({index:e.detail.value,pageIndex: 1})
  71. this.getList(true)
  72. }
  73. })