index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // pages/integral-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. navList:[
  16. { 'name': '分值明细', 'icon':'icon-mingxi'},
  17. { 'name': '分值提升', 'icon': 'icon-tishengfenzhi' }
  18. ],
  19. current:0,
  20. page:1,
  21. limit:10,
  22. integralList:[],
  23. loadend:false,
  24. loading:false,
  25. loadTitle:'加载更多',
  26. },
  27. /**
  28. * 授权回调
  29. */
  30. onLoadFun:function(){
  31. this.getUserInfo();
  32. this.getIntegralList();
  33. },
  34. getUserInfo:function(){
  35. var that=this;
  36. app.baseGet(app.U({ c: 'user_api', a: 'get_my_user_info', q: { isIntegral:1}}),function(res){
  37. that.setData({userInfo:res.data});
  38. });
  39. },
  40. /**
  41. * 获取积分明细
  42. */
  43. getIntegralList:function(){
  44. var that=this;
  45. if(that.data.loading) return;
  46. if(that.data.loadend) return;
  47. that.setData({loading:true,loadTitle:''});
  48. app.baseGet(app.U({ c: 'user_api', a:'user_integral_list',q:{page:that.data.page,limit:that.data.limit}}),function(res){
  49. var list=res.data,loadend=list.length < that.data.limit;
  50. that.data.integralList = app.SplitArray(list,that.data.integralList);
  51. that.setData({
  52. integralList: that.data.integralList,
  53. page:that.data.page+1,
  54. loading:false,
  55. loadend:loadend,
  56. loadTitle:loadend ? '哼~😕我也是有底线的~':"加载更多"
  57. });
  58. },function(res){
  59. that.setData({ loading: false, loadTitle:'加载更多'});
  60. });
  61. },
  62. /**
  63. * 生命周期函数--监听页面加载
  64. */
  65. onLoad: function (options) {
  66. },
  67. nav:function(e){
  68. this.setData({
  69. current: e.currentTarget.dataset.idx
  70. })
  71. },
  72. /**
  73. * 页面上拉触底事件的处理函数
  74. */
  75. onReachBottom: function () {
  76. this.getIntegralList();
  77. }
  78. })