chargemoneylog.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // pages/ucenter/chargemoneylog/chargemoneylog.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. chargemoneylogs: [],
  8. userInfo: {},
  9. isLogin: false,
  10. pagesize:15,
  11. pagenum:1,
  12. total:-1,
  13. loadTotal: 0,
  14. dataLoading: false,
  15. finishedLoadTap: 0,
  16. finishedLoadShowTimes: 0,
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function(options) {
  22. let userInfo = wx.getStorageSync('userInfo');
  23. let isLogin = wx.getStorageSync('isLogin');
  24. this.setData({
  25. userInfo:userInfo,
  26. isLogin:isLogin
  27. });
  28. let that = this;
  29. // 页面显示
  30. if (userInfo && isLogin) {
  31. this.getPage()
  32. }
  33. },
  34. getPage(){
  35. if(this.data.chargemoneylogs.length == this.data.total){
  36. this.setData({
  37. finishedLoadTap:this.data.finishedLoadTap+1
  38. })
  39. if(this.data.finishedLoadTap>0 && this.data.finishedLoadShowTimes==0){
  40. this.setData({
  41. finishedLoadShowTimes:this.data.finishedLoadShowTimes+1
  42. })
  43. wx.showToast({
  44. title: '全部加载完毕',
  45. icon: 'success',
  46. duration: 2000
  47. })
  48. }
  49. return
  50. }
  51. if(this.data.dataLoading){
  52. return
  53. }
  54. this.setData({
  55. dataLoading: true
  56. })
  57. wx.showLoading({
  58. title: '数据加载中....',
  59. })
  60. let that = this;
  61. wx.request({
  62. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/rechargeList',
  63. data: {
  64. userId: wx.getStorageSync('userInfo').userId,
  65. pagenum: this.data.pagenum++,
  66. pagesize: 15,
  67. },
  68. method: 'POST',
  69. success(res) {
  70. console.log(res);
  71. let chargemoneylogs = res.data.rows;
  72. for (var i = 0; i < chargemoneylogs.length ; i++){
  73. chargemoneylogs[i].rechargeTimeDate = chargemoneylogs[i].rechargeTime.split(" ")[0];
  74. chargemoneylogs[i].rechargeTimeTime =chargemoneylogs[i].rechargeTime.split(" ")[1];
  75. }
  76. // that.rechargeTimeOrder(chargemoneylogs);
  77. wx.hideLoading()
  78. that.setData({
  79. chargemoneylogs: that.data.chargemoneylogs.concat(chargemoneylogs),
  80. total: res.data.total,
  81. dataLoading: false
  82. });
  83. }
  84. });
  85. },
  86. rechargeTimeOrder(chargemoneylogs) {
  87. if (chargemoneylogs && 0 != chargemoneylogs.length) {
  88. chargemoneylogs.sort(function(ma, mb) {
  89. return mb.rechargeTime.localeCompare(ma.rechargeTime);
  90. });
  91. }
  92. },
  93. /**
  94. * 生命周期函数--监听页面初次渲染完成
  95. */
  96. onReady: function() {
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow: function() {
  102. },
  103. /**
  104. * 生命周期函数--监听页面隐藏
  105. */
  106. onHide: function() {
  107. },
  108. /**
  109. * 生命周期函数--监听页面卸载
  110. */
  111. onUnload: function() {
  112. },
  113. /**
  114. * 页面相关事件处理函数--监听用户下拉动作
  115. */
  116. onPullDownRefresh: function() {
  117. },
  118. bindScrollTolowerEvent: function(){
  119. this.getPage();
  120. },
  121. /**
  122. * 页面上拉触底事件的处理函数
  123. */
  124. onReachBottom: function() {
  125. },
  126. /**
  127. * 用户点击右上角分享
  128. */
  129. onShareAppMessage: function() {
  130. }
  131. })