integralIndex.js 2.7 KB

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