record.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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.getList(openId);
  39. },
  40. /**
  41. * 生命周期函数--监听页面隐藏
  42. */
  43. onHide: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面卸载
  47. */
  48. onUnload: function () {
  49. },
  50. /**
  51. * 页面相关事件处理函数--监听用户下拉动作
  52. */
  53. onPullDownRefresh: function () {
  54. },
  55. /**
  56. * 页面上拉触底事件的处理函数
  57. */
  58. onReachBottom: function () {
  59. var totalPage = Math.ceil(this.data.count/this.data.pageNum)
  60. console.log('到底了')
  61. var page = this.data.page
  62. page++;
  63. this.setData({
  64. page:page
  65. })
  66. if(page<=totalPage){
  67. this.getList();
  68. }
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage: function () {
  74. },
  75. getList: async function(openId) {
  76. var result = await recruitApi.getDelivery(openId,this.data.page,this.data.pageNum);
  77. var nowList = this.data.list.concat(result.list)
  78. this.setData({
  79. list:nowList,
  80. count:result.count,
  81. page:result.page
  82. })
  83. },
  84. goToInfo:function(e){
  85. var id = e.currentTarget.dataset.id;
  86. wx.navigateTo({
  87. url: '../recruitInfo/recruitInfo?id='+id
  88. })
  89. },
  90. })