customer.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. var api = require('../../utils/request');
  2. var util = require('../../utils/util');
  3. const app = getApp()
  4. Page({
  5. data: {
  6. loading: true,
  7. page:0,
  8. lists: [],
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. this.getApi();
  15. },
  16. // 下拉刷新
  17. onPullDownRefresh: function () {
  18. var that = this;
  19. that.setData({
  20. page: 0,
  21. loading: true,
  22. lists: []
  23. });
  24. wx.showNavigationBarLoading();
  25. this.getApi();
  26. //停止下拉刷新
  27. setTimeout(function () {
  28. wx.hideNavigationBarLoading();
  29. wx.stopPullDownRefresh();
  30. }, 1500);
  31. },
  32. //下拉
  33. onReachBottom: function () {
  34. var that = this;
  35. that.setData({
  36. loading: true,
  37. });
  38. this.getApi();
  39. },
  40. /**
  41. * 获取活动
  42. */
  43. getApi: function () {
  44. let that = this;
  45. if (that.data.loading) {
  46. var page = that.data.page + 1;
  47. api.Get('openapi/v1/user/levelUser', {page: page }, function (result) {
  48. if (result.code == 200) {
  49. var lists = that.data.lists;
  50. for (let i in result.data) {
  51. lists.push(result.data[i]);
  52. }
  53. that.setData({
  54. lists: lists,
  55. page: page,
  56. });
  57. }
  58. that.setData({
  59. loading: false,
  60. });
  61. })
  62. }
  63. },
  64. })