integral-con.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // pages/integral-con/integral-con.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. userInfo:[],
  9. integralInfo:[],
  10. first:0,
  11. limit:8,
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. app.setBarColor();
  18. app.setUserInfo();
  19. this.getUserInfo();
  20. this.getList();
  21. },//user_integral_list
  22. getList:function(){
  23. var that = this;
  24. wx.request({
  25. url: app.globalData.url + '/routine/auth_api/user_integral_list?uid=' + app.globalData.uid,
  26. method: 'GET',
  27. data:{
  28. first: that.data.first,
  29. limit: that.data.limit,
  30. },
  31. success: function (res) {
  32. that.setData({
  33. integralInfo: res.data.data,
  34. })
  35. }
  36. });
  37. },
  38. getUserInfo:function(){
  39. var that = this;
  40. wx.request({
  41. url: app.globalData.url + '/routine/auth_api/my?uid=' + app.globalData.uid,
  42. method: 'POST',
  43. success: function (res) {
  44. that.setData({
  45. userInfo: res.data.data,
  46. })
  47. console.log(that.data.userInfo);
  48. }
  49. });
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload: function () {
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh: function () {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom: function () {
  80. var that = this;
  81. var first = that.data.first;
  82. var limit = that.data.limit;
  83. if (!first) first = 1;
  84. var startpage = limit * first;
  85. wx.request({
  86. url: app.globalData.url + '/routine/auth_api/user_integral_list?uid=' + app.globalData.uid,
  87. method: 'GET',
  88. data: {
  89. first: startpage,
  90. limit: that.data.limit,
  91. },
  92. success: function (res) {
  93. var len = res.data.data.length;
  94. for (var i = 0; i < len; i++) {
  95. that.data.integralInfo.push(res.data.data[i])
  96. }
  97. that.setData({
  98. first: first + 1,
  99. integralInfo: that.data.integralInfo
  100. });
  101. }
  102. });
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage: function () {
  108. }
  109. })