myResume.js 7.1 KB
// pages/myResume/myResume.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    images: '',
    date: '',

    educationArray: [],
    // objectArray: [
    //   {
    //     id: 0,
    //     name: '美国'
    //   },
    //   {
    //     id: 1,
    //     name: '中国'
    //   },
    //   {
    //     id: 2,
    //     name: '巴西'
    //   },
    //   {
    //     id: 3,
    //     name: '日本'
    //   }
    // ],
    educationIndex: 0,

    workYearArray: ['1年', '2年', '3年', '4年', '5年'],
    // objectArray: [
    //   {
    //     id: 0,
    //     name: '美国'
    //   },
    //   {
    //     id: 1,
    //     name: '中国'
    //   },
    //   {
    //     id: 2,
    //     name: '巴西'
    //   },
    //   {
    //     id: 3,
    //     name: '日本'
    //   }
    // ],
    workYearIndex: 0,
    resume:'',
    //头像
    avatar:'',
    //学历名称
    educationtitle:'请选择',
    workexp:'请选择工作年限',
    resume_brief:"",
    contentlen:0,
    resume_sex:1,
    //在职离职
    resume_is_bejob:1,
    resume_name:'',
    //家乡
    resume_home:'',
    educationid:25,
    user_nickname:''
  },
  //性别
  man(){
    this.setData({
      resume_sex:1
    })
  },
  woman(){
    this.setData({
      resume_sex:2
    })
  },

  // 出生日期
  bindDateChange: function (e) {
    console.log('picker发送选择改变,携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },


//家乡
  resume_home(){
    this.setData({
      resume_home:e.detail.value
    })
  },
  //获取学历
  geteducation(){
    let that = this;
    var url = 'index/category/education';
    var params = {
      

    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.setData({
        educationArray:res.data
      })



    }).catch((err) => {

    })
  },
  // 学历
  education: function (e) {
    console.log('picker发送选择改变,携带值为', e.detail.value)
    this.setData({
      educationIndex: e.detail.value,
      educationtitle: this.data.educationArray[e.detail.value].education_name,
      educationid: this.data.educationArray[e.detail.value].id
    })
  },
  // 工作年限
  workYear: function (e) {
    console.log('picker发送选择改变,携带值为', e.detail.value)
    this.setData({
      workYearIndex: e.detail.value,
      workexp: this.data.workYearArray[e.detail.value]
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      date: app.newnowDate()
    })
    this.geteducation()
    this.getResume2();
  },
  //姓名
  entername(e){
    this.setData({
      resume_name:e.detail.value
    })
  },
  //手机号
  entermobile(e){
    this.setData({
      resume_mobile:e.detail.value
    })
  },

  // 选择图片
  chooseImage: function () {
    // 选择图片
    wx.chooseImage({
      count: 3, // 默认9
      sizeType: ['compressed'],
      sourceType: ['album', 'camera'],
      // 可以指定来源是相册还是相机,默认二者都有
      success: function (res) {
        console.log(res)
        // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
        var tempFilePaths = res.tempFilePaths;
          that.setData({
            images: that.data.image.concat(tempFilePaths)
          })
        console.log(images)
        // if (that.data.companyortrue == true) {
        //   that.setData({
        //     companyimages: that.data.companyimages.concat(tempFilePaths)
        //   });
        // } else {
        //   that.setData({
        //     images: that.data.images.concat(tempFilePaths)
        //   });
        // }

      }
    })
  },
//家乡
  enterhome(e){
    this.setData({
      resume_home:e.detail.value
    })
  },
  //输入简介
  enterword(e){
    this.setData({
      contentlen:e.detail.value.length,
      resume_brief:e.detail.value
    })
  },

  //在职离职
  atjob(){
    this.setData({
      resume_is_bejob:1
    })
  },
  noatjob(){
    this.setData({
      resume_is_bejob:2
    })
  },
  //获取
  getResume2() {

    let that = this;
    let url = 'index/user/me_resume';
    let params = {

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

      if (res.data.resume_brief!=null){
        that.setData({

        })
     }  

      if (res.data.resume_name!=null){
        console.log(12345678)
          // 获取值
        that.setData({
          resume: res.data,
          date: res.data.resume_birthday,
          avatar: res.data.avatar,
          educationtitle: res.data.education_name,
          workexp: res.data.resume_exp,
          resume_brief: res.data.resume_brief,
          // contentlen: res.data.resume_brief.length,
          resume_sex: res.data.resume_sex,
          resume_is_bejob: res.data.resume_is_bejob,
          resume_name: res.data.resume_name,
          resume_mobile: res.data.resume_mobile,
          resume_home: res.data.resume_home,
          educationid: res.data.resume_education_id
        })
      }
    
      

    console.log(that.data.resume);
      console.log(that.data.avatar)




    }).catch((err) => {

    })
  },

  //更新简历
  changeresume(){
    let that = this;
    let reg = reg = /^[1][3,4,5,7,8][0-9]{9}$/
    if (!reg.test(that.data.resume_mobile)) {
      wx.showToast({
        title: '请输入正确的手机号',
        icon: 'none'
      })
      return false
    }
    var url = 'index/user/save_resume';
    var params = {
      resume_name: that.data.resume_name,
      resume_sex: that.data.resume_sex,
      resume_mobile: that.data.resume_mobile,
      resume_birthday:that.data.date,
      resume_education_id:that.data.educationid,
      resume_exp: that.data.workexp,
      resume_is_bejob: that.data.resume_is_bejob,
      resume_brief: that.data.resume_brief,
      resume_home: that.data.resume_home

    }
    var header={
      'XX-Token': wx.getStorageSync('token'),
    }
    app.post(url, params,header).then((res) => {
      console.log(res);
      if(res.data==''){
        wx.showToast({
          title: '发布成功',
          icon:'none'
        })

        setTimeout(function(){
          wx.navigateBack({
            checked:true
          })
        },1500)
      }



    }).catch((err) => {

    })
  },


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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})