index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. var api = require('../../utils/request');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. loading: true,
  6. shopping_name:'购物积分',
  7. bank: {
  8. money: 0,
  9. due_money: 0,
  10. lack_money: 0,
  11. income_monney: 0,
  12. shop_money: 0
  13. },
  14. list: [],
  15. today: 0,
  16. page: 0,
  17. loading: true,
  18. types:0
  19. },
  20. /**
  21. * 生命周期函数--监听页面显示
  22. */
  23. onShow: function () {
  24. var that = this;
  25. app.isLogin(function () {
  26. that.getBank();
  27. });
  28. },
  29. /**
  30. * 生命周期函数--监听页面初次渲染完成
  31. */
  32. onReady: function () {
  33. this.setData({
  34. shopping_name: app.globalData.config.shopping_name
  35. })
  36. },
  37. // 下拉刷新
  38. onPullDownRefresh: function () {
  39. var that = this;
  40. that.setData({
  41. page: 0,
  42. loading: true,
  43. list: [],
  44. bank: {
  45. money: 0,
  46. due_money: 0,
  47. lack_money: 0,
  48. income_monney: 0,
  49. shop_money: 0
  50. },
  51. });
  52. wx.showNavigationBarLoading();
  53. this.getBank();
  54. this.getList();
  55. setTimeout(function () {
  56. wx.hideNavigationBarLoading();
  57. wx.stopPullDownRefresh();
  58. }, 1500);
  59. },
  60. //下拉
  61. onReachBottom: function () {
  62. var that = this;
  63. that.setData({
  64. loading: true,
  65. });
  66. this.getList();
  67. },
  68. /**
  69. * 点击切换
  70. */
  71. onChange(event) {
  72. this.setData({
  73. page: 0,
  74. loading: true,
  75. list: [],
  76. types: event.detail.name
  77. });
  78. this.getList();
  79. },
  80. /**
  81. * 读取我的账单
  82. */
  83. getBank: function () {
  84. let that = this;
  85. api.Get("api/v3/fastshop/bank/index", function (result) {
  86. if (result.code == 200){
  87. that.setData({ bank: result.data });
  88. that.getList();
  89. }
  90. })
  91. },
  92. /**
  93. * 获取帐号明细
  94. */
  95. getList: function () {
  96. let that = this;
  97. if (that.data.loading) {
  98. wx.showLoading({ title: '正在加载' });
  99. var page = that.data.page + 1;
  100. var types = that.data.types;
  101. api.Get("api/v3/fastshop/bank/bill", { today: types, page: page }, function (result) {
  102. if (result.code == 200) {
  103. var list = that.data.list;
  104. for (let i in result.data) {
  105. list.push(result.data[i]);
  106. }
  107. that.setData({
  108. list: list,
  109. page: page,
  110. });
  111. }
  112. })
  113. that.setData({
  114. loading: false,
  115. });
  116. wx.hideLoading();
  117. }
  118. },
  119. //点击底部菜单
  120. ontabbar(event) {
  121. var url = event.detail;
  122. wx.navigateTo({
  123. url: url,
  124. })
  125. }
  126. })