index.js 1.9 KB

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