recruitInfo.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import recruitApi from '../../api/recruit'
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl:'/images/icons/like_no.png',
  9. recruitInfo:[],
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: async function (options) {
  15. console.log(options)
  16. this.setData({
  17. id:options.id
  18. })
  19. await this.getRecruitInfo(options.id)
  20. },
  21. /**
  22. * 生命周期函数--监听页面初次渲染完成
  23. */
  24. onReady: function () {
  25. },
  26. /**
  27. * 生命周期函数--监听页面显示
  28. */
  29. onShow: function () {
  30. var openid = wx.getStorageSync('openId');
  31. if(openid){
  32. this.getRecruitLikeInfo(openid);
  33. }
  34. },
  35. /**
  36. * 生命周期函数--监听页面隐藏
  37. */
  38. onHide: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面卸载
  42. */
  43. onUnload: function () {
  44. },
  45. /**
  46. * 页面相关事件处理函数--监听用户下拉动作
  47. */
  48. onPullDownRefresh: function () {
  49. },
  50. /**
  51. * 页面上拉触底事件的处理函数
  52. */
  53. onReachBottom: function () {
  54. },
  55. /**
  56. * 用户点击右上角分享
  57. */
  58. onShareAppMessage: function () {
  59. let url = encodeURIComponent('pages/recruitInfo/recruitInfo?id=' + this.data.id);
  60. return {
  61. title: "招聘详情",
  62. path:`/pages/index/index?url=${url}`
  63. }
  64. },
  65. saveLike: async function(){
  66. const isAuth = await app.isAuth()
  67. if (!isAuth) {
  68. wx.redirectTo({
  69. url: '/pages/prompt/prompt?page=' + this.route+"&id="+this.data.id,
  70. })
  71. return
  72. }
  73. var id = this.data.id;
  74. var openid = wx.getStorageSync('openId');
  75. var result = await recruitApi.collectionRecruit(openid,id);
  76. var imgUrl = '/images/icons/like_no.png';
  77. if(result.isDelete !=1){
  78. imgUrl = '/images/icons/like_yes.png';
  79. wx.showToast({
  80. title: '已收藏',
  81. image:imgUrl,
  82. duration: 2000
  83. })
  84. }
  85. this.setData({
  86. imgUrl:imgUrl
  87. })
  88. },
  89. //投递简历
  90. saveResume:function(){
  91. var self= this
  92. wx.showModal({
  93. title: '提示',
  94. // content: '您可申请2个社招职位,还剩2个,是否继续投递',
  95. content: '您确认投递此职位吗?',
  96. confirmText:'确认投递',
  97. confirmColor:'#1296db',
  98. success (res) {
  99. if (res.confirm) {
  100. wx.navigateTo({
  101. url: '../resume/resume?type=2&id='+self.data.id,
  102. })
  103. console.log('用户点击确定')
  104. } else if (res.cancel) {
  105. console.log('用户点击取消')
  106. }
  107. }
  108. })
  109. },
  110. getRecruitInfo: async function(id) {
  111. var result = await recruitApi.getRecruitInfo(id);
  112. this.setData({
  113. recruitInfo:result
  114. })
  115. },
  116. getRecruitLikeInfo: async function(openid) {
  117. var id = this.data.id;
  118. var result = await recruitApi.getRecruitLikeInfo(id,openid);
  119. var imgUrl = '/images/icons/like_no.png';
  120. if(result){
  121. imgUrl = '/images/icons/like_yes.png';
  122. }
  123. this.setData({
  124. imgUrl:imgUrl
  125. })
  126. }
  127. })