index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // pages/bill-details/index.js
  2. import { getCommissionInfo } from '../../api/user.js';
  3. const app=getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. parameter: {
  10. 'navbar': '1',
  11. 'return': '1',
  12. 'title': '账单明细',
  13. 'color':true,
  14. 'class':'0'
  15. },
  16. loadTitle:'加载更多',
  17. loading:false,
  18. loadend:false,
  19. page:1,
  20. limit:10,
  21. type:0,
  22. userBillList:[],
  23. },
  24. /**
  25. * 授权回调
  26. */
  27. onLoadFun:function(){
  28. this.getUserBillList();
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. this.setData({ type: options.type || 0});
  35. },
  36. /**
  37. * 获取账户明细
  38. */
  39. getUserBillList:function(){
  40. var that=this;
  41. if (that.data.loadend) return;
  42. if (that.data.loading) return;
  43. that.setData({ loading: true, loadTitle: "" });
  44. var data = {
  45. page: that.data.page,
  46. limit: that.data.limit
  47. }
  48. getCommissionInfo(data, that.data.type).then(function(res){
  49. var list=res.data,loadend=list.length < that.data.limit;
  50. that.data.userBillList = app.SplitArray(list,that.data.userBillList);
  51. that.setData({
  52. userBillList:that.data.userBillList,
  53. loadend:loadend,
  54. loading:false,
  55. loadTitle:loadend ? "哼😕~我也是有底线的~": "加载更多",
  56. page:that.data.page+1,
  57. });
  58. },function(res){
  59. that.setData({loading:false,loadTitle:'加载更多'});
  60. });
  61. },
  62. /**
  63. * 切换导航
  64. */
  65. changeType:function(e){
  66. this.setData({ type: e.currentTarget.dataset.type,loadend:false,page:1,userBillList:[]});
  67. this.getUserBillList();
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. this.getUserBillList();
  79. },
  80. })