sociology.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import recruitApi from '../../api/recruit'
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. type:1,//社招
  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. if(this.data.page!=1){
  78. var nowResult = this.data.recruitList.concat(result.list)
  79. }else{
  80. var nowResult = result.list
  81. }
  82. this.setData({
  83. recruitList:nowResult,
  84. count:result.count,
  85. page:result.page
  86. })
  87. },
  88. inputFocus:function(e) {
  89. var recruit = e.detail.value
  90. if(recruit){
  91. this.setData({
  92. showClear:true,
  93. searchinput:recruit
  94. })
  95. }else{
  96. this.setData({
  97. showClear:false,
  98. searchinput:''
  99. })
  100. }
  101. },
  102. clearInput:function() {
  103. this.setData({
  104. showClear:false,
  105. searchinput:''
  106. })
  107. },
  108. searchContents:function() {
  109. var recruit = this.data.searchinput
  110. console.log(recruit)
  111. this.setData({
  112. page:1
  113. })
  114. this.getRecruitList(recruit)
  115. }
  116. })