income-details.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. // pages/income-details/income-details.js
  2. var http = require("../../utils/http.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. "unsettledAmount": 0, // 待结算金额
  9. "settledAmount": 0, // 可提现金额
  10. "invalidAmount": 0, // 已失效金额
  11. "addupAmount": 0, // 累计收益
  12. "monthAmount": 0, // 本月收益
  13. "todayAmount": 0, // 今日收益
  14. records: [],
  15. loadingMsg: "正在加载..",
  16. emptyMsg: "",
  17. totalPage: 1,
  18. pageNum: 1,
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function(options) {
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function() {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function() {
  34. // 获取钱包数据
  35. this.getDisWalletData()
  36. // 获取收益数据
  37. this.getDisIncomeData()
  38. // 获取收益列表
  39. this.loadPageData(1)
  40. },
  41. /**
  42. * 生命周期函数--监听页面隐藏
  43. */
  44. onHide: function() {
  45. },
  46. /**
  47. * 生命周期函数--监听页面卸载
  48. */
  49. onUnload: function() {
  50. },
  51. /**
  52. * 页面相关事件处理函数--监听用户下拉动作
  53. */
  54. onPullDownRefresh: function() {
  55. },
  56. /**
  57. * 页面上拉触底事件的处理函数
  58. */
  59. onReachBottom: function() {
  60. if (this.data.pageNum < this.data.totalPage) {
  61. this.loadPageData(this.data.pageNum + 1);
  62. }
  63. },
  64. /**
  65. * 用户点击右上角分享
  66. */
  67. onShareAppMessage: function() {
  68. },
  69. /**
  70. * 获取我的钱包信息
  71. */
  72. getDisWalletData: function() {
  73. var ths = this
  74. wx.showLoading();
  75. var params = {
  76. url: "/p/distribution/wallet/info",
  77. method: "GET",
  78. // data: {
  79. // shopId: 1
  80. // },
  81. callBack: function(res) {
  82. wx.hideLoading();
  83. ths.setData({
  84. "unsettledAmount": res.unsettledAmount,
  85. "settledAmount": res.settledAmount,
  86. "invalidAmount": res.invalidAmount,
  87. "addupAmount": res.addupAmount
  88. });
  89. }
  90. };
  91. http.request(params);
  92. },
  93. /**
  94. * 获取用户本月收益和今日收益
  95. */
  96. getDisIncomeData: function() {
  97. var ths = this
  98. wx.showLoading();
  99. var params = {
  100. url: "/p/distribution/income/statistics",
  101. method: "GET",
  102. // data: {
  103. // shopId: 1
  104. // },
  105. callBack: function(res) {
  106. wx.hideLoading();
  107. ths.setData({
  108. "todayAmount": res.todayAmount,
  109. "monthAmount": res.monthAmount
  110. });
  111. }
  112. };
  113. http.request(params);
  114. },
  115. /**
  116. * 收入列表
  117. */
  118. loadPageData: function (pageNum) {
  119. var ths = this;
  120. var params = {
  121. url: "/p/distribution/income/page",
  122. method: "GET",
  123. data: {
  124. // shopId: 1,
  125. current: pageNum,
  126. size: 20
  127. },
  128. callBack: (res) => {
  129. wx.hideLoading();
  130. var records = [];
  131. if (res.current == 1) {
  132. records = res.records;
  133. } else {
  134. records = this.data.records;
  135. Array.prototype.push.apply(records, res.records);
  136. }
  137. var loadingMsg = this.data.loadingMsg;
  138. if (pageNum == res.pages) {
  139. loadingMsg = "没有更多了~";
  140. }
  141. console.log(res)
  142. ths.setData({
  143. records: records,
  144. totalPage: res.pages,
  145. pageNum: pageNum,
  146. loadingMsg: loadingMsg,
  147. emptyMsg: "今天还没有收益哦~"
  148. });
  149. }
  150. };
  151. http.request(params);
  152. }
  153. })