positionDetails.js 3.5 KB
// pages/positionDetails/positionDetails.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    share:false,
    latitude: 23.099994,
    longitude: 113.324520,
    job_id: '',
    position: '',
    id: '',
    user_id: '',
    // 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()
  },

  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);
      // 获取值
      that.setData({
        position: res.data
      })

    }).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('myapp')
  },
  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 () {

  }
})