index.js 1.8 KB

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