chargemoneylog.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. that.rechargeTimeOrder(chargemoneylogs);
  34. that.setData({
  35. chargemoneylogs
  36. });
  37. }
  38. });
  39. }
  40. },
  41. rechargeTimeOrder(chargemoneylogs) {
  42. if (chargemoneylogs && 0 != chargemoneylogs.length) {
  43. chargemoneylogs.sort(function(ma, mb) {
  44. return mb.rechargeTime.localeCompare(ma.rechargeTime);
  45. });
  46. }
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady: function() {
  52. },
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow: function() {
  57. },
  58. /**
  59. * 生命周期函数--监听页面隐藏
  60. */
  61. onHide: function() {
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload: function() {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh: function() {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function() {
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage: function() {
  82. }
  83. })