follow.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // pages/follow/follow.js
  2. const $api = require('../../utils/api.js').API;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. list:[],
  9. page: 1,
  10. total: 0,
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. wx.showLoading({
  17. title: '正在加载',
  18. })
  19. this.getFollow()
  20. },
  21. next: function () {
  22. if (this.data.list.length < this.data.total) {
  23. const page = this.data.page + 1
  24. this.setData({
  25. page: page
  26. })
  27. this.getFollow()
  28. }
  29. },
  30. getFollow() {
  31. var list = this.data.list
  32. $api.getMyFollow({
  33. page: this.data.page, page_size: 20
  34. }).then(res => {
  35. wx.hideLoading()
  36. res.data.data.list.forEach(item => {
  37. list.push(item)
  38. })
  39. this.setData({
  40. list: list,
  41. total: res.data.data.total
  42. })
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面隐藏
  57. */
  58. onHide: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面卸载
  62. */
  63. onUnload: function () {
  64. },
  65. /**
  66. * 页面相关事件处理函数--监听用户下拉动作
  67. */
  68. onPullDownRefresh: function () {
  69. },
  70. /**
  71. * 页面上拉触底事件的处理函数
  72. */
  73. onReachBottom: function () {
  74. },
  75. /**
  76. * 用户点击右上角分享
  77. */
  78. onShareAppMessage: function () {
  79. }
  80. })