recruitInfo.js 3.2 KB

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