integralDetail.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // pages/integralDetail/integralDetail.js
  2. var http = require("../../../utils/http.js");
  3. var util = require("../../../utils/util.js");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. pages: 0,
  10. current: 1,
  11. size: 10,
  12. scoreDetails: [], //积分明细列表
  13. isAll: false,
  14. userInfo: {}, //用户积分等级信息
  15. scoreExplain: {}, //积分说明
  16. showPop: false, //攻略弹框显隐
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. //请求积分明细
  23. this.getScoreDetails()
  24. //获取用户积分等级信息
  25. this.getUserScore()
  26. //积分攻略
  27. this.getScoreExplain()
  28. },
  29. /**
  30. * 获取用户积分等级信息
  31. */
  32. getUserScore: function() {
  33. var param = {
  34. url: '/p/user/userInfo',
  35. method: 'GET',
  36. data: {
  37. current: this.data.current,
  38. size: 10
  39. },
  40. callBack: (res) => {
  41. this.setData({
  42. userInfo : res
  43. })
  44. }
  45. }
  46. http.request(param)
  47. },
  48. /**
  49. * 请求积分明细
  50. */
  51. getScoreDetails: function() {
  52. wx.showLoading()
  53. var param = {
  54. url: '/p/score/page',
  55. method: 'GET',
  56. data: {
  57. current: this.data.current,
  58. size: 10
  59. },
  60. callBack: (res) => {
  61. wx.hideLoading()
  62. let list = []
  63. if (res.current == 1) {
  64. list = res.records
  65. } else {
  66. list = this.data.scoreDetails
  67. list = list.concat(res.records)
  68. }
  69. this.setData({
  70. scoreDetails: list,
  71. pages: res.pages,
  72. current: res.current
  73. });
  74. console.log(this.data.scoreDetails)
  75. }
  76. }
  77. http.request(param);
  78. },
  79. /**
  80. * 触底加载下一页
  81. */
  82. getNextPage() {
  83. console.log('触底加载')
  84. if (this.data.pages > this.data.current) {
  85. this.setData({
  86. current: this.data.current + 1
  87. })
  88. this.getScoreDetails()
  89. } else {
  90. this.setData({
  91. isAll: true
  92. })
  93. }
  94. },
  95. /**
  96. * 页面上拉触底事件的处理函数
  97. */
  98. onReachBottom: function () {
  99. console.log('钩子:触底加载')
  100. this.getNextPage()
  101. },
  102. /**
  103. * 积分攻略
  104. */
  105. getScoreExplain: function() {
  106. var param = {
  107. url: '/p/score/getScoreQuestion',
  108. method: 'GET',
  109. data: {},
  110. callBack: (res) => {
  111. res.paramValue = util.formatHtml(res.paramValue);
  112. this.setData({
  113. scoreExplain: res
  114. })
  115. console.log(this.data.scoreExplain)
  116. }
  117. };
  118. http.request(param)
  119. },
  120. /**
  121. * 积分攻略弹框显隐
  122. */
  123. clikcPop: function() {
  124. var showPop = !this.data.showPop
  125. this.setData({
  126. showPop
  127. })
  128. },
  129. /**
  130. * 生命周期函数--监听页面初次渲染完成
  131. */
  132. onReady: function () {
  133. },
  134. /**
  135. * 生命周期函数--监听页面显示
  136. */
  137. onShow: function () {
  138. },
  139. /**
  140. * 生命周期函数--监听页面隐藏
  141. */
  142. onHide: function () {
  143. },
  144. /**
  145. * 生命周期函数--监听页面卸载
  146. */
  147. onUnload: function () {
  148. },
  149. /**
  150. * 页面相关事件处理函数--监听用户下拉动作
  151. */
  152. onPullDownRefresh: function () {
  153. },
  154. /**
  155. * 用户点击右上角分享
  156. */
  157. onShareAppMessage: function () {
  158. }
  159. })