school.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import recruitApi from '../../api/recruit'
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. type:2,
  8. recruitList:[],
  9. showClear:false,
  10. searchinput:'',
  11. page:1,
  12. pageNum:10,
  13. count:0
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. },
  20. /**
  21. * 生命周期函数--监听页面初次渲染完成
  22. */
  23. onReady: function () {
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow: function () {
  29. this.getRecruitList();
  30. },
  31. /**
  32. * 生命周期函数--监听页面隐藏
  33. */
  34. onHide: function () {
  35. },
  36. /**
  37. * 生命周期函数--监听页面卸载
  38. */
  39. onUnload: function () {
  40. },
  41. /**
  42. * 页面相关事件处理函数--监听用户下拉动作
  43. */
  44. onPullDownRefresh: function () {
  45. },
  46. /**
  47. * 页面上拉触底事件的处理函数
  48. */
  49. onReachBottom: function () {
  50. var totalPage = Math.ceil(this.data.count/this.data.pageNum)
  51. console.log('到底了')
  52. var page = this.data.page
  53. page++;
  54. this.setData({
  55. page:page
  56. })
  57. if(page<=totalPage){
  58. this.getRecruitList();
  59. }
  60. },
  61. /**
  62. * 用户点击右上角分享
  63. */
  64. onShareAppMessage: function () {
  65. },
  66. goToInfo:function(e){
  67. var id = e.currentTarget.dataset.id;
  68. wx.navigateTo({
  69. url: '../recruitInfo/recruitInfo?id='+id
  70. })
  71. },
  72. getRecruitList: async function(name='') {
  73. var result = await recruitApi.getRecruitList(name,this.data.type,this.data.page,this.data.pageNum);
  74. console.log(result)
  75. var nowResult = this.data.recruitList.concat(result.list)
  76. this.setData({
  77. recruitList:nowResult,
  78. count:result.count,
  79. page:result.page
  80. })
  81. },
  82. inputFocus:function(e) {
  83. var recruit = e.detail.value
  84. if(recruit){
  85. this.setData({
  86. showClear:true
  87. })
  88. }else{
  89. this.setData({
  90. showClear:false
  91. })
  92. }
  93. },
  94. clearInput:function() {
  95. this.setData({
  96. showClear:false,
  97. searchinput:''
  98. })
  99. },
  100. searchContents:function(e) {
  101. var recruit = e.detail.value
  102. this.getRecruitList(recruit)
  103. }
  104. })