positionDetails.js 6.4 KB
// pages/positionDetails/positionDetails.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    share: false,
    job_id: '',
    position: '',
    id: '',
    user_id: '',

    latitude: '',
    longitude: '',
    markers: [{
      id: 1,
      latitude: '',
      longitude: '',
      name: ''
    }],
    covers: [{
      latitude: '',
      longitude: '',
      iconPath: '../../../img/location.png'
    }, {
      latitude: '',
      longitude: '',
      iconPath: '../../../img/location.png'
    }],
    go: ''
    // zpId: '',
  },
  /**
   * 生命周期函数--监听页面加载
   */

  // 点击分享按钮,打开分享提示栏
  toShare() {
    this.setData({
      share: true
    })
  },
  // 关闭分享
  toClose() {
    this.setData({
      share: false
    })
  },

  onLoad: function(options) {
    console.log(options)

    this.setData({
      job_id: options.id
    })
    console.log(options.id)
    this.positionDetails();
    this.getjianli()
  },
  // 收藏
  toCollect(e) {
    let that = this;
    let type=e.currentTarget.dataset.type;
    let collecttype=''
    if(type==0){
       collecttype=1
       wx.showToast({
         title: '收藏成功',
         icon: 'none',
       })
       
    }else{
       collecttype = 2
       wx.showToast({
         title: '取消成功',
         icon: 'none',
       })
    }
    var url = 'index/collect/index';
    var params = {
      job_id: that.data.job_id,
      type: collecttype
    }
    var header = {
      'XX-Token': wx.getStorageSync('token'),
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      if(res.data==''){
        that.positionDetails()
      }
      

    }).catch((err) => {

    })
  },

  //是否填写简历
  getjianli() {
    let that = this;
    var url = 'wxapp/public/is_register_resume';
    var params = {

    }
    var header = {
      'XX-Token': wx.getStorageSync('token'),
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      if (res.msg == "已完成简历") {
        that.setData({
          go: true
        })
      } else {
        that.setData({
          go: false
        })
      }



    }).catch((err) => {

    })
  },
  // 马上报名
  sign() {
    let that = this;
    if (that.data.go == false) {
      wx.showToast({
        title: '请先完善简历',
        icon: 'none'
      })
    } else {
      var url = 'index/job/job_apply';
      var params = {
        job_id: that.data.job_id
      }
      var header = {
        'XX-Token': wx.getStorageSync('token'),

      }
      app.post(url, params, header).then((res) => {
        console.log(res);

        if(res.data==''){
          wx.showToast({
            title: res.msg,
          })


          setTimeout(function(){
            wx.navigateTo({
              url: '/pages/regSuccess/regSuccess',
            })
          })
        }



      }).catch((err) => {

      })
    }

  },


  positionDetails() {
    let that = this;
    let url = 'index/job/job';
    let params = {
      job_id: that.data.job_id
    }
    let header = {
      "XX-Token": wx.getStorageSync('token'),
      "XX-Device-Type": 'wxapp'
    }
    app.post(url, params, header).then((res) => {
      console.log(res);
      let lat = Number(res.data.work_latitude);
      let log = Number(res.data.work_longitude)
      console.log(lat)
      // 获取值
      that.setData({
        position: res.data,
        latitude: lat,
        longitude: log,
        markers: [{
          id: 1,
          latitude: lat,
          longitude: log,
          name: ''
        }],

        covers: [{
          latitude: lat,
          longitude: log,
          iconPath: ''
        }, {
          latitude: lat,
          longitude: log,
          iconPath: ''
        }],
      })

    }).catch((err) => {

    })
  },

  // 跳转招聘者信息
  toRecruiter(e) {
    console.log(e)
    let id = e.currentTarget.dataset.id
    let user_id = e.currentTarget.dataset.user_id
    console.log()
    wx.navigateTo({
      url: '/pages/employerDetails/employerDetails?id=' + id + '&user_id=' + user_id,
    })
  },

  // 打开地图
  // openMap:function(){
  //   var that = this;
  //   // 获取当前位置
  //   wx.getLocation({
  //     type: 'gcj02',
  //     success: function(res) {
  //       console.log(res)
  //       var latitude = res.latitude
  //       var longitude = res.longitude
  //       var speed = res.speed
  //       var accuracy = res.accuracy
  //     },
  //   })
  //   wx.chooseLocation({
  //     success: function(res) {
  //       console.log(res)
  //       var latitude = res.latitude
  //       var longitude = res.longitude
  //       var speed = res.longitude
  //       var accuracy = res.longitude
  //       that.setData({latitude: latitude})
  //       that.setData({longitude: longitude})
  //     },
  //   })
  // },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function(e) {
    this.mapCtx = wx.createMapContext('myMap')
  },
  // getCenterLocation: function () {
  //   this.mapCtx.getCenterLocation({
  //     success: function (res) {
  //       console.log(res.longitude)
  //       console.log(res.latitude)
  //     }
  //   })
  // },
  // moveToLocation: function () {
  //   this.mapCtx.moveToLocation()
  // },
  // translateMarker: function () {
  //   this.mapCtx.translateMarker({
  //     markerId: 1,
  //     autoRotate: true,
  //     duration: 1000,
  //     destination: {
  //       latitude: 23.10229,
  //       longitude: 113.3345211,
  //     },
  //     animationEnd() {
  //       console.log('animation end')
  //     }
  //   })
  // },
  // includePoints: function () {
  //   this.mapCtx.includePoints({
  //     padding: [10],
  //     points: [{
  //       latitude: 23.10229,
  //       longitude: 113.3345211,
  //     }, {
  //       latitude: 23.00229,
  //       longitude: 113.3345211,
  //     }]
  //   })
  // },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})