school.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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.setData({
  30. page:1
  31. })
  32. this.getRecruitList();
  33. },
  34. /**
  35. * 生命周期函数--监听页面隐藏
  36. */
  37. onHide: function () {
  38. },
  39. /**
  40. * 生命周期函数--监听页面卸载
  41. */
  42. onUnload: function () {
  43. },
  44. /**
  45. * 页面相关事件处理函数--监听用户下拉动作
  46. */
  47. onPullDownRefresh: function () {
  48. },
  49. /**
  50. * 页面上拉触底事件的处理函数
  51. */
  52. onReachBottom: function () {
  53. var totalPage = Math.ceil(this.data.count/this.data.pageNum)
  54. console.log('到底了')
  55. var page = this.data.page
  56. page++;
  57. this.setData({
  58. page:page
  59. })
  60. if(page<=totalPage){
  61. this.getRecruitList();
  62. }
  63. },
  64. /**
  65. * 用户点击右上角分享
  66. */
  67. onShareAppMessage: function () {
  68. },
  69. goToInfo:function(e){
  70. var id = e.currentTarget.dataset.id;
  71. wx.navigateTo({
  72. url: '../recruitInfo/recruitInfo?id='+id
  73. })
  74. },
  75. getRecruitList: async function(name='') {
  76. var result = await recruitApi.getRecruitList(name,this.data.type,this.data.page,this.data.pageNum);
  77. console.log(result)
  78. if(this.data.page!=1){
  79. var nowResult = this.data.recruitList.concat(result.list)
  80. }else{
  81. var nowResult = result.list
  82. }
  83. this.setData({
  84. recruitList:nowResult,
  85. count:result.count,
  86. page:result.page
  87. })
  88. },
  89. inputFocus:function(e) {
  90. var recruit = e.detail.value
  91. if(recruit){
  92. this.setData({
  93. showClear:true,
  94. searchinput:recruit
  95. })
  96. }else{
  97. this.setData({
  98. showClear:false,
  99. searchinput:''
  100. })
  101. }
  102. },
  103. clearInput:function() {
  104. this.setData({
  105. showClear:false,
  106. searchinput:''
  107. })
  108. },
  109. searchContents:function() {
  110. var recruit = this.data.searchinput
  111. console.log(recruit)
  112. this.setData({
  113. page:1
  114. })
  115. this.getRecruitList(recruit)
  116. }
  117. })