schoolagent.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. var app = getApp();
  2. var util = require("../../utils/util.js")
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. bottomLeft: app.bottomLeft,
  9. appAssetsUrl2: app.appAssetsUrl2,
  10. nodata: util.nodata(),
  11. query: {
  12. page: 1,
  13. limit: 10
  14. },
  15. noMore: false,
  16. currPage: 1,
  17. totalPage: 1,
  18. listData: [],
  19. load: false
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function(options) {
  25. this.getList()
  26. },
  27. getList() {
  28. let that = this
  29. that.setData({
  30. load: false
  31. })
  32. app._get(`campusagent/page`, {
  33. ...this.data.query
  34. }, res => {
  35. if (res.code === 0) {
  36. let listData = that.data.listData;
  37. listData.push(...res.page.list);
  38. that.setData({
  39. listData,
  40. currPage: res.page.currPage,
  41. totalPage: res.page.totalPage,
  42. noMore: res.page.totalPage == res.page.currPage,
  43. load: true
  44. })
  45. }
  46. })
  47. },
  48. detail(e) {
  49. console.log(e)
  50. wx.navigateTo({
  51. url: '/expert/agentdetail/agentdetail?id=' + e.currentTarget.dataset.id + '&type=校园代理人'
  52. })
  53. },
  54. /**
  55. * 生命周期函数--监听页面初次渲染完成
  56. */
  57. onReady: function() {
  58. },
  59. /**
  60. * 生命周期函数--监听页面显示
  61. */
  62. onShow: function() {
  63. },
  64. /**
  65. * 生命周期函数--监听页面隐藏
  66. */
  67. onHide: function() {},
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh: function() {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function() {
  77. let that = this
  78. if(this.data.currPage >= this.data.totalPage) {
  79. wx.showToast({
  80. title: '没有更多了~',
  81. icon: 'none'
  82. })
  83. return false;
  84. }
  85. this.setData({
  86. currPage: that.data.currPage + 1
  87. })
  88. this.getList()
  89. },
  90. showShareMenu: function() {
  91. wx.showShareMenu();
  92. },
  93. hideShareMenu() {
  94. wx.hideShareMenu();
  95. }
  96. })