chargemoneylog.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // pages/ucenter/chargemoneylog/chargemoneylog.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. chargemoneylogs: [],
  8. userInfo: {},
  9. isLogin: false
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function(options) {
  15. let userInfo = wx.getStorageSync('userInfo');
  16. let isLogin = wx.getStorageSync('isLogin');
  17. this.setData({
  18. userInfo,
  19. isLogin
  20. });
  21. let that = this;
  22. // 页面显示
  23. if (userInfo && isLogin) {
  24. wx.request({
  25. url: getApp().globalData.postHeadAgreement +'/restapi/wechat/rechargeList',
  26. data: {
  27. userId: userInfo.userId
  28. },
  29. method: 'POST',
  30. success(res) {
  31. console.log(res);
  32. let chargemoneylogs = res.data;
  33. for (var i = 0; i < chargemoneylogs.length ; i++){
  34. chargemoneylogs[i].rechargeTimeDate = chargemoneylogs[i].rechargeTime.split(" ")[0];
  35. chargemoneylogs[i].rechargeTimeTime =chargemoneylogs[i].rechargeTime.split(" ")[1];
  36. }
  37. that.rechargeTimeOrder(chargemoneylogs);
  38. that.setData({
  39. chargemoneylogs
  40. });
  41. }
  42. });
  43. }
  44. },
  45. rechargeTimeOrder(chargemoneylogs) {
  46. if (chargemoneylogs && 0 != chargemoneylogs.length) {
  47. chargemoneylogs.sort(function(ma, mb) {
  48. return mb.rechargeTime.localeCompare(ma.rechargeTime);
  49. });
  50. }
  51. },
  52. /**
  53. * 生命周期函数--监听页面初次渲染完成
  54. */
  55. onReady: function() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow: function() {
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function() {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function() {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function() {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function() {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function() {
  86. }
  87. })