exchargeRecord.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var app = getApp();
  2. var util = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list: [],
  9. loadText: '加载中',
  10. loadMore: false,
  11. noData: false,
  12. state: ['提现中', '提现成功', '提现失败']
  13. },
  14. page: 1,
  15. noMore: false,
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function(options) {
  20. var that = this;
  21. if (!util.check_login()) {
  22. this.setData({
  23. needAuth: true
  24. })
  25. } else {
  26. this.getData();
  27. }
  28. },
  29. /**
  30. * 授权成功回调
  31. */
  32. authSuccess: function() {
  33. let that = this;
  34. this.setData({
  35. needAuth: false
  36. }, () => {
  37. that.getData();
  38. })
  39. },
  40. getData: function() {
  41. wx.showLoading();
  42. var token = wx.getStorageSync('token');
  43. let that = this;
  44. app.util.request({
  45. url: 'entry/wxapp/user',
  46. data: {
  47. controller: 'distribution.tixian_record',
  48. token: token,
  49. page: this.page
  50. },
  51. dataType: 'json',
  52. success: function (res) {
  53. wx.hideLoading();
  54. if (res.data.code == 0) {
  55. let list = res.data.data;
  56. let oldList = that.data.list;
  57. list = oldList.concat(list);
  58. that.page++;
  59. that.setData({ list })
  60. } else {
  61. // 无数据
  62. if (that.page == 1) that.setData({ noData: true })
  63. that.noMore = true;
  64. that.setData({ loadMore: false })
  65. }
  66. }
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function() {
  73. },
  74. /**
  75. * 页面相关事件处理函数--监听用户下拉动作
  76. */
  77. onPullDownRefresh: function() {
  78. },
  79. /**
  80. * 页面上拉触底事件的处理函数
  81. */
  82. onReachBottom: function() {
  83. this.noMore || (this.setData({ loadMore: true }), this.getData());
  84. }
  85. })