take-notes.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // pages/take-notes/take-notes.js
  2. var http = require("../../utils/http.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. totalWithdrawCash: 0,
  9. records: [],
  10. loadingMsg: "正在加载..",
  11. emptyMsg: "",
  12. totalPage: 1,
  13. pageNum: 1,
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function(options) {
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady: function() {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow: function() {
  29. this.getTotalWithdrawCash();
  30. this.loadPageData(1);
  31. },
  32. /**
  33. * 生命周期函数--监听页面隐藏
  34. */
  35. onHide: function() {
  36. },
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function() {
  41. },
  42. /**
  43. * 页面相关事件处理函数--监听用户下拉动作
  44. */
  45. onPullDownRefresh: function() {
  46. if (this.data.current < this.data.pages) {
  47. this.setData({
  48. current: this.data.current +1
  49. })
  50. this.getWithdrawCashPage();
  51. }
  52. },
  53. /**
  54. * 页面上拉触底事件的处理函数
  55. */
  56. onReachBottom: function() {
  57. if (this.data.pageNum < this.data.totalPage) {
  58. this.loadPageData(this.data.pageNum + 1);
  59. }
  60. },
  61. /**
  62. * 获取提现总金额
  63. */
  64. getTotalWithdrawCash: function() {
  65. var ths = this;
  66. wx.showLoading();
  67. var params = {
  68. url: "/p/distribution/withdrawCash/totalWithdrawCash",
  69. method: "GET",
  70. // data: {
  71. // shopId: 1
  72. // },
  73. callBack: function(res) {
  74. wx.hideLoading();
  75. ths.setData({
  76. totalWithdrawCash: res
  77. });
  78. }
  79. };
  80. http.request(params);
  81. },
  82. /**
  83. * 分页获取提现记录
  84. */
  85. loadPageData: function (pageNum) {
  86. var ths = this;
  87. wx.showLoading();
  88. var params = {
  89. url: "/p/distribution/withdrawCash/page",
  90. method: "GET",
  91. data: {
  92. // shopId: 1,
  93. current: pageNum,
  94. size: 20
  95. },
  96. callBack: (res)=>{
  97. wx.hideLoading();
  98. var records = [];
  99. if (res.current == 1) {
  100. records = res.records;
  101. } else {
  102. records = this.data.records;
  103. Array.prototype.push.apply(records, res.records);
  104. }
  105. var loadingMsg = this.data.loadingMsg;
  106. if (pageNum == res.pages) {
  107. loadingMsg = "没有更多了~";
  108. }
  109. console.log(res)
  110. ths.setData({
  111. records: records,
  112. totalPage: res.pages,
  113. pageNum: pageNum,
  114. loadingMsg: loadingMsg,
  115. emptyMsg: "还没有提现记录哦~"
  116. });
  117. }
  118. };
  119. http.request(params);
  120. }
  121. })