chargemoneylog.js 2.9 KB

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