index.js 829 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. loading: true,
  8. page: 0,
  9. item: [],
  10. },
  11. //生命周期函数--监听页面加载
  12. onLoad: function () {
  13. this.getApi();
  14. },
  15. //上拉加载
  16. onReachBottom: function () {
  17. var that = this;
  18. that.setData({
  19. loading: true,
  20. });
  21. that.getApi();
  22. },
  23. //读取团购数据
  24. getApi: function () {
  25. let that = this;
  26. if (that.data.loading) {
  27. var page = that.data.page + 1;
  28. app.api().Get('api/v3/fastshop/group/index', {page: page}, function (result) {
  29. var item = that.data.item;
  30. for (let i in result.data) {
  31. item.push(result.data[i]);
  32. }
  33. that.setData({
  34. item: item,
  35. page: page,
  36. loading: false,
  37. });
  38. })
  39. }
  40. },
  41. })