index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // pages/group-list/index.js
  2. import {
  3. getCombinationList
  4. } from '../../../api/activity.js';
  5. import {
  6. openPinkSubscribe
  7. } from '../../../utils/SubscribeMessage.js';
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. parameter: {
  14. 'navbar': '1',
  15. 'return': '1',
  16. 'title': '拼团列表',
  17. 'color': true,
  18. 'class': '0'
  19. },
  20. combinationList: [],
  21. limit: 10,
  22. page: 1,
  23. loading: false,
  24. loadend: false,
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. this.getCombinationList();
  31. },
  32. /**
  33. * 生命周期函数--监听页面初次渲染完成
  34. */
  35. onReady: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面显示
  39. */
  40. onShow: function () {},
  41. openSubcribe: function (e) {
  42. let page = e.currentTarget.dataset.url;
  43. wx.showLoading({
  44. title: '正在加载',
  45. })
  46. openPinkSubscribe().then(res => {
  47. wx.hideLoading();
  48. wx.navigateTo({
  49. url: page,
  50. });
  51. }).catch(() => {
  52. wx.hideLoading();
  53. });
  54. },
  55. getCombinationList: function () {
  56. var that = this;
  57. if (that.data.loadend) return;
  58. if (that.data.loading) return;
  59. var data = {
  60. page: that.data.page,
  61. limit: that.data.limit
  62. };
  63. that.setData({
  64. loading: true
  65. });
  66. getCombinationList(data).then(function (res) {
  67. var combinationList = that.data.combinationList;
  68. var limit = that.data.limit;
  69. that.data.page++;
  70. that.setData({
  71. loadend: limit > res.data.length,
  72. combinationList: combinationList.concat(res.data),
  73. page: that.data.page,
  74. loading: false,
  75. });
  76. }).catch(() => {
  77. that.setData({
  78. loading: false
  79. });
  80. })
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload: function () {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh: function () {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom: function () {
  101. this.getCombinationList();
  102. }
  103. })