collection.js 2.0 KB

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