index.js 2.2 KB

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