atHome.js 5.2 KB
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    industry: '',
    categories_id: '',
    jobs: '',
    // 定义绑定跳转的id
    id: '',
    userid: '',
    categories_name: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  regSuccess(e) {

    let that = this;
    let id = e.currentTarget.dataset.id;
    var url = 'index/job/job_apply';
    var params = {

      job_id: id
    }

    var header = {
      'XX-Token': wx.getStorageSync('token')
    }
    app.post(url, params, header).then((res) => {

      wx.showToast({
        title: '报名成功',
        icon: 'none'
      })

      setTimeout(function() {
        wx.navigateTo({
          url: '/pages/regSuccess/regSuccess?id=' + id,
        })
      }, 1500)

    }).catch((err) => {
      console.log(err)
      wx.showToast({
        title: err.data.msg,
        icon: 'none'
      })

      // setTimeout(function () {
      //   wx.switchTab({
      //     url: 'pages/index/index?isresume=' + 1,
      //   })
      // }, 1500)
    })


  },

  // 上架下架
  upshang(e) {
    let that=this;
    let id = e.currentTarget.dataset.id;
    var url = 'index/job/job_up';
    let params = {
      job_id: id,
      type: 2
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      "XX-Device-Type": 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      wx.showToast({
        title: '下架成功',
        icon: "none"
      })

      setTimeout(function() {
        console.log(88889999)
        that.getfabu()
      }, 1500)
      // console.log(res.data)

      // 获取值

      // console.log(that.data.industry)

    }).catch((err) => {

    })
  },
  upxia(e) {
    let that=this;
    let id = e.currentTarget.dataset.id;
    var url = 'index/job/job_up';
    let params = {
      job_id: id,
      type: 1
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      "XX-Device-Type": 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      wx.showToast({
        title: '上架成功',
        icon: "none"
      })

      setTimeout(function() {
        that.getfabu()
      }, 1500)
      // console.log(res.data)

      // 获取值

      // console.log(that.data.industry)

    }).catch((err) => {

    })
  },
  //报名者详情
  // peopledetail(e){
  //   let userid = e.currentTarget.dataset.userid
  // },


  toPosition(e) {
    console.log(e)
    //  绑定id跳转至工作详情
    let that = this;
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/positionDetails/positionDetails?id=' + id,
    })
  },
  // 跳转招聘者信息
  toRecruiter(e) {
    wx.navigateTo({
      url: '/pages/employerDetails/employerDetails?userid=' + e.currentTarget.dataset.userid + '&resumename=' + e.currentTarget.dataset.resumename,
    })
  },
  onLoad: function(options) {
    console.log(options)
    //页面切换,更换页面标题
    wx.setNavigationBarTitle({
      title: options.categories_name
    })
    if (options.categories_id != undefined) {
      this.setData({
        categories_id: options.categories_id,
        categories_name: options.categories_name
      })
    }

    if (options.userid != undefined) {
      this.setData({
        userid: options.userid,
        categories_name: options.categories_name
      })
    }

    // 调用岗位功能参数
    // this.getIndustry()

    if (options.categories_name == '发布岗位') {
      this.getfabu()
    } else {
      this.getJods()
    }

  },

  // 获取多个工作
  getJods() {
    let that = this;
    let url = 'index/job/jobs';

    let params = {
      categories_id: that.data.categories_id,
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      "XX-Device-Type": 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      // console.log(res.data)

      // 获取值
      that.setData({
        jobs: res.data
      })
      // console.log(that.data.industry)

    }).catch((err) => {

    })
  },


  getfabu() {
    let that = this;
    let url = 'index/job/jobs';

    let params = {
      user_id: that.data.userid,
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      "XX-Device-Type": 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      // console.log(res.data)

      // 获取值
      that.setData({
        jobs: res.data
      })
      // console.log(that.data.industry)

    }).catch((err) => {

    })
  },





  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})