import recruitApi from '../../api/recruit' const app = getApp() Page({ /** * 页面的初始数据 */ data: { endDate:'', fileColor:"", array: ["保密", "男", "女"], educationArray: ["小学", "初中", "高中","中技(中专、技校、职高)","大专","本科","硕士研究生","MBA","博士研究生","保密"], schoolTypeArray: ["","全国普通高等院校非全日制","全国普通高等院校全日制", "成人高等教育", "统招专升本","其他","自学考试","非统招专升本","海外留学生"], statusArray: ["","正在主动找工作","可以考虑工作机会", "目前不想找工作"], moneyArray: ["","1000以下","1000-2000", "2001-4000", "4001-6000","6001-8000","8001-10000","10001-15000","15001-25000","25001-30000","30001-50000","50001以上","面议"], nowMoneyArray: ["","1000以下","1000-2000", "2001-4000", "4001-6000","6001-8000","8001-10000","10001-15000","15001-25000","25001-30000","30001-50000","50001以上"], type:1,//1保存简历 2保存简历+投递简历) saveTitle:'保存简历', name:'', emali:'', mobile:'', birthday:'1990-01-01', gender:0, nowAddress:'', registeredAddress:'', highestEducation:0, learningModality:0, takeProfessionally:'', jobStatus:0, hopeProfessionally:'', nowSalary:0, hopeSalary:0, resumeFile:'', resumeFileName:'', fileTitle:'在微信聊天中选择附件', isChooseFile:false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(options.type ==2){ this.setData({ saveTitle:'确认投递' }) wx.setNavigationBarTitle({ title: '投递简历' }) }else{ wx.setNavigationBarTitle({ title: '我的简历' }) } var d = new Date(); var endDate = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() this.setData({ endDate:endDate, type:options.type, recruitsId:options.id, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: async function () { const isAuth = await app.isAuth() if (!isAuth) { wx.redirectTo({ url: '/pages/prompt/prompt?page=' + this.route+"?type="+this.data.type, }) return } var openId = wx.getStorageSync("openId") this.setData({ openId:openId }) if(!this.data.isChooseFile){ await this.getUserInfo(openId); }else{ this.setData({ isChooseFile:false }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, bindInputName: function (e) { this.setData({ name: e.detail.value }) }, bindInputEmail: function (e) { this.setData({ email: e.detail.value }) }, bindInputMobile: function (e) { this.setData({ mobile: e.detail.value }) }, bindInputNowAddress: function (e) { this.setData({ nowAddress: e.detail.value }) }, bindInputRegisteredAddress: function (e) { this.setData({ registeredAddress: e.detail.value }) }, changeBirth: function (e) { this.setData({ birthday: e.detail.value }) }, changeSex: function (e) { this.setData({ gender: e.detail.value }) }, changeEducation: function (e) { this.setData({ highestEducation: e.detail.value }) }, changeSchoolType: function (e) { this.setData({ learningModality: e.detail.value }) }, changeStatus:function(e){ this.setData({ jobStatus: e.detail.value }) }, bindInputTakeProfessionally:function(e){ this.setData({ takeProfessionally: e.detail.value }) }, bindInputHopeProfessionally:function(e){ this.setData({ hopeProfessionally: e.detail.value }) }, changeNowMoney:function(e){ this.setData({ nowSalary: e.detail.value }) }, changeExpectMoney:function(e){ this.setData({ hopeSalary: e.detail.value }) }, chooseEnclosure:function(){ this.setData({ isChooseFile:true }) var self =this; wx.chooseMessageFile({ count: 1, type: 'file', success (res) { // tempFilePath可以作为img标签的src属性显示图片 self.uploadFile(res.tempFiles[0].path) self.setData({ resumeFileName:res.tempFiles[0].name, fileTitle:res.tempFiles[0].name }) } }) }, uploadFile: function(temFile){ var self = this; wx.uploadFile({ url: "https://oapi.shpr.top/open/upload/upload-pic", //上传的路径 filePath:temFile, //刚刚在data保存的文件路径 name: 'file', //后台获取的凭据 formData: { 'basePath': 'recruit' }, success (res){ const result = JSON.parse(res.data) console.log(result) console.log(result.data.destPath) self.setData({ resumeFile:result.data.url, fileColor:"#000", }) } }) }, // downloadFile:function(e){ // var url = e.currentTarget.dataset.url; // wx.downloadFile({ // url: url, //仅为示例,并非真实的资源 // success (res) { // // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容 // if (res.statusCode === 200) { // } // } // }) // }, getUserInfo: async function(openId) { var params = {} params['openid'] = openId; var info = await recruitApi.infoUser(params); console.log(info); var highestEducation = info.highestEducation?info.highestEducation:0; var jobStatus = info.jobStatus?info.jobStatus:0; var nowSalary = info.nowSalary?info.nowSalary:0; var hopeSalary = info.hopeSalary?info.hopeSalary:0; var learningModality = info.learningModality?info.learningModality:0; var birthday = info.birthday?info.birthday:'1990-01-01'; var fileColor = info.resumeFileName?'#000':'#c2c6da'; var fileTitle = info.resumeFileName?info.resumeFileName:'在微信聊天中选择附件'; this.setData({ userId:info.userId, name:info.name, email:info.email, mobile:info.mobile, gender:info.gender, birthday:birthday, nowAddress:info.nowAddress, registeredAddress:info.registeredAddress, highestEducation:highestEducation, learningModality:learningModality, takeProfessionally:info.takeProfessionally, jobStatus:jobStatus, hopeProfessionally:info.hopeProfessionally, nowSalary:nowSalary, hopeSalary:hopeSalary, resumeFile:info.resumeFile, resumeFileName:info.resumeFileName, fileTitle:fileTitle, fileColor:fileColor, }) }, saveResume: async function(){ if(!this.data.name){ wx.showToast({ title: '请输入姓名', icon: 'none', duration: 1000 }) return; } if(!this.data.email){ wx.showToast({ title: '请输入邮箱', icon: 'none', duration: 1000 }) return; } if(!this.data.mobile){ wx.showToast({ title: '请输入手机号', icon: 'none', duration: 1000 }) return; } if(!this.data.resumeFile){ wx.showToast({ title: '请上传附件', icon: 'none', duration: 1000 }) return; } console.log(this.data.resumeFile); var params = { userId:this.data.userId, name:this.data.name, email:this.data.email, mobile:this.data.mobile, birthday:this.data.birthday, gender:this.data.gender, nowAddress:this.data.nowAddress, registeredAddress:this.data.registeredAddress, highestEducation:this.data.highestEducation, learningModality:this.data.learningModality, takeProfessionally:this.data.takeProfessionally, jobStatus:this.data.jobStatus, hopeProfessionally:this.data.hopeProfessionally, nowSalary:this.data.nowSalary, hopeSalary:this.data.hopeSalary, resumeFile:this.data.resumeFile, resumeFileName:this.data.resumeFileName, }; await recruitApi.saveUser(params); if(this.data.type ==2){ await recruitApi.deliveryRecruit(this.data.openId,this.data.recruitsId); wx.showToast({ title: '投递成功', icon: 'success', success:function(){ setTimeout(() => { wx.navigateBack({ delta: 2 }) }, 1000); } }) }else{ wx.showToast({ title: '保存成功', icon: 'success', success:function(){ setTimeout(() => { wx.navigateBack({ delta: 2 }) }, 1000); } }) } } })