integralIndex.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // pages/integralIndex/integralIndex.js
  2. var http = require('../../../utils/http.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. current: 1,
  9. scoreProdList: [],
  10. scoreInfo:{},
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function(options) {
  16. this.getScoreProdList()
  17. },
  18. /**
  19. * 生命周期函数--监听页面初次渲染完成
  20. */
  21. onReady: function() {
  22. },
  23. /**
  24. * 生命周期函数--监听页面显示
  25. */
  26. onShow: function() {
  27. // 获取当前积分信息
  28. this.getScoreInfo()
  29. },
  30. /**
  31. * 跳转
  32. */
  33. navigateTo(e) {
  34. const path = e.currentTarget.dataset.path
  35. if (path == 'scoreDet') {
  36. wx.navigateTo({
  37. url: '/packageMemberIntegral/pages/integralDetail/integralDetail',
  38. })
  39. } else if (path == 'scoreIndex') {
  40. wx.navigateTo({
  41. url: '/packageMemberIntegral/pages/memberIndex/memberIndex',
  42. })
  43. }
  44. },
  45. /**
  46. * 获取当前积分信息
  47. */
  48. getScoreInfo() {
  49. var params = {
  50. url: '/p/score/scoreInfo',
  51. method: 'GET',
  52. data: {
  53. platform:1
  54. },
  55. callBack: res => {
  56. this.setData({
  57. scoreInfo: res
  58. })
  59. }
  60. }
  61. http.request(params)
  62. },
  63. /**
  64. * 获取积分商品列表
  65. */
  66. getScoreProdList() {
  67. var param = {
  68. url: "/p/score/page",
  69. method: "GET",
  70. data: {
  71. current: this.data.current,
  72. size: 10,
  73. platform:1
  74. },
  75. callBack: (res) => {
  76. wx.hideLoading()
  77. var scoreProdList = []
  78. if (this.data.current == 1) {
  79. this.setData({
  80. scoreProdList: res.records,
  81. pages: res.pages,
  82. current: res.current
  83. });
  84. } else {
  85. scoreProdList = this.data.scoreProdList
  86. scoreProdList.push(...res.records)
  87. this.setData({
  88. scoreProdList
  89. })
  90. }
  91. }
  92. };
  93. http.request(param);
  94. },
  95. /**
  96. * 跳转积分商品详情
  97. */
  98. toScoreProdDet(e) {
  99. console.log(e)
  100. const prodId = e.currentTarget.dataset.scoreprodid
  101. wx.navigateTo({
  102. url: '/packageMemberIntegral/pages/convertProdDet/convertProdDet?prodId=' + prodId,
  103. })
  104. },
  105. /**
  106. * 生命周期函数--监听页面隐藏
  107. */
  108. onHide: function() {
  109. },
  110. /**
  111. * 生命周期函数--监听页面卸载
  112. */
  113. onUnload: function() {
  114. },
  115. /**
  116. * 页面相关事件处理函数--监听用户下拉动作
  117. */
  118. onPullDownRefresh: function() {
  119. },
  120. /**
  121. * 页面上拉触底事件的处理函数
  122. */
  123. onReachBottom: function() {
  124. if (this.data.current < this.data.pages) {
  125. this.setData({
  126. current: this.data.current + 1
  127. })
  128. this.getScoreProdList()
  129. }
  130. },
  131. /**
  132. * 用户点击右上角分享
  133. */
  134. onShareAppMessage: function() {
  135. }
  136. })