activityList.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // pages/welfareMall/activityList/activityList.js
  2. import WelfareMall from '../../../api/welfareMall';
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. type:2, //1免费 2 收费
  10. page:1,
  11. pageSize:10,
  12. list:[],
  13. init:true,
  14. config:{},
  15. noResult:false
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. this.data.page = 1;
  22. this.data.type = 2;
  23. this.getActivityList()
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. },
  35. /**
  36. * 生命周期函数--监听页面隐藏
  37. */
  38. onHide: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面卸载
  42. */
  43. onUnload: function () {
  44. },
  45. /**
  46. * 页面相关事件处理函数--监听用户下拉动作
  47. */
  48. onPullDownRefresh: function () {
  49. },
  50. /**
  51. * 页面上拉触底事件的处理函数
  52. */
  53. onReachBottom: function () {
  54. console.log(this.data.noMore)
  55. if (this.data.noMore) {
  56. return
  57. }
  58. console.log(1231233)
  59. this.setData({
  60. page: this.data.page + 1
  61. })
  62. this.getActivityList()
  63. },
  64. /**
  65. * 用户点击右上角分享
  66. */
  67. onShareAppMessage: function () {
  68. },
  69. gotoFree:function () {
  70. this.setData({
  71. type:1,
  72. page:1,
  73. noMore: false,
  74. noResult:false,
  75. })
  76. this.getActivityList();
  77. },
  78. gotoPay:function () {
  79. this.setData({
  80. type:2,
  81. page:1,
  82. noMore: false,
  83. noResult:false,
  84. })
  85. this.getActivityList();
  86. },
  87. goCouponDetail:function(e){
  88. let activityId = e.currentTarget.dataset.id
  89. wx.navigateTo({
  90. url: '/pages/welfareMall/activityInfo/activityInfo?activityId='+ activityId,
  91. })
  92. },
  93. // 1是免费,2是收费
  94. getActivityList: async function() {
  95. let res = await WelfareMall.getActivityList(this.data.type,this.data.page,this.data.pageSize)
  96. let init = true;
  97. if(res.data.list.length==0){
  98. init = false;
  99. this.setData({
  100. init: init,
  101. noMore: this.data.page == 1 ? false: true,
  102. noResult:this.data.page == 1 ? true: false,
  103. })
  104. }
  105. if(this.data.page!=1){
  106. var list = this.data.list.concat(...res.data.list)
  107. }else{
  108. var list = res.data.list
  109. }
  110. this.setData({
  111. list:list,
  112. config:res.data.config
  113. })
  114. }
  115. })