resume.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. import recruitApi from '../../api/recruit'
  2. import request from '../../utils/request'
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. endDate:'',
  10. fileColor:"",
  11. array: ["保密", "男", "女"],
  12. educationArray: ["小学", "初中", "高中","中技(中专、技校、职高)","大专","本科","硕士研究生","MBA","博士研究生","保密"],
  13. schoolTypeArray: ["","全国普通高等院校非全日制","全国普通高等院校全日制", "成人高等教育", "统招专升本","其他","自学考试","非统招专升本","海外留学生"],
  14. statusArray: ["","正在主动找工作","可以考虑工作机会", "目前不想找工作"],
  15. moneyArray: ["","1000以下","1000-2000", "2001-4000", "4001-6000","6001-8000","8001-10000","10001-15000","15001-25000","25001-30000","30001-50000","50001以上","面议"],
  16. nowMoneyArray: ["","1000以下","1000-2000", "2001-4000", "4001-6000","6001-8000","8001-10000","10001-15000","15001-25000","25001-30000","30001-50000","50001以上"],
  17. type:1,//1保存简历 2保存简历+投递简历)
  18. saveTitle:'保存简历',
  19. name:'',
  20. emali:'',
  21. mobile:'',
  22. birthday:'1990-01-01',
  23. gender:1,
  24. nowAddress:'',
  25. registeredAddress:'',
  26. highestEducation:0,
  27. learningModality:0,
  28. takeProfessionally:'',
  29. jobStatus:0,
  30. hopeProfessionally:'',
  31. nowSalary:0,
  32. hopeSalary:0,
  33. resumeFile:'',
  34. resumeFileName:'',
  35. fileTitle:'在微信聊天中选择附件',
  36. isChooseFile:false,
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad: function (options) {
  42. if(options.type ==2){
  43. this.setData({
  44. saveTitle:'确认投递'
  45. })
  46. wx.setNavigationBarTitle({
  47. title: '投递简历'
  48. })
  49. }else{
  50. wx.setNavigationBarTitle({
  51. title: '我的简历'
  52. })
  53. }
  54. var d = new Date();
  55. var endDate = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
  56. this.setData({
  57. endDate:endDate,
  58. type:options.type,
  59. recruitsId:options.id,
  60. })
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: async function () {
  71. const isAuth = await app.isAuth()
  72. if (!isAuth) {
  73. wx.redirectTo({
  74. url: '/pages/prompt/prompt?page=' + this.route+"?type="+this.data.type,
  75. })
  76. return
  77. }
  78. var openId = wx.getStorageSync("openId")
  79. this.setData({
  80. openId:openId
  81. })
  82. if(!this.data.isChooseFile){
  83. await this.getUserInfo(openId);
  84. }else{
  85. this.setData({
  86. isChooseFile:false
  87. })
  88. }
  89. },
  90. /**
  91. * 生命周期函数--监听页面隐藏
  92. */
  93. onHide: function () {
  94. },
  95. /**
  96. * 生命周期函数--监听页面卸载
  97. */
  98. onUnload: function () {
  99. },
  100. /**
  101. * 页面相关事件处理函数--监听用户下拉动作
  102. */
  103. onPullDownRefresh: function () {
  104. },
  105. /**
  106. * 页面上拉触底事件的处理函数
  107. */
  108. onReachBottom: function () {
  109. },
  110. /**
  111. * 用户点击右上角分享
  112. */
  113. onShareAppMessage: function () {
  114. },
  115. bindInputName: function (e) {
  116. this.setData({
  117. name: e.detail.value
  118. })
  119. },
  120. bindInputEmail: function (e) {
  121. this.setData({
  122. email: e.detail.value
  123. })
  124. },
  125. bindInputMobile: function (e) {
  126. this.setData({
  127. mobile: e.detail.value
  128. })
  129. },
  130. bindInputNowAddress: function (e) {
  131. this.setData({
  132. nowAddress: e.detail.value
  133. })
  134. },
  135. bindInputRegisteredAddress: function (e) {
  136. this.setData({
  137. registeredAddress: e.detail.value
  138. })
  139. },
  140. changeBirth: function (e) {
  141. this.setData({
  142. birthday: e.detail.value
  143. })
  144. },
  145. // changeSex: function (e) {
  146. // this.setData({
  147. // gender: e.detail.value
  148. // })
  149. // },
  150. chooseSex:function(e){
  151. let gender = e.currentTarget.dataset.gender;
  152. this.setData({
  153. gender: gender
  154. })
  155. },
  156. changeEducation: function (e) {
  157. this.setData({
  158. highestEducation: e.detail.value
  159. })
  160. },
  161. changeSchoolType: function (e) {
  162. this.setData({
  163. learningModality: e.detail.value
  164. })
  165. },
  166. changeStatus:function(e){
  167. this.setData({
  168. jobStatus: e.detail.value
  169. })
  170. },
  171. bindInputTakeProfessionally:function(e){
  172. this.setData({
  173. takeProfessionally: e.detail.value
  174. })
  175. },
  176. bindInputHopeProfessionally:function(e){
  177. this.setData({
  178. hopeProfessionally: e.detail.value
  179. })
  180. },
  181. changeNowMoney:function(e){
  182. this.setData({
  183. nowSalary: e.detail.value
  184. })
  185. },
  186. changeExpectMoney:function(e){
  187. this.setData({
  188. hopeSalary: e.detail.value
  189. })
  190. },
  191. chooseEnclosure:function(){
  192. this.setData({
  193. isChooseFile:true
  194. })
  195. var self =this;
  196. wx.chooseMessageFile({
  197. count: 1,
  198. type: 'file',
  199. success (res) {
  200. // tempFilePath可以作为img标签的src属性显示图片
  201. self.uploadFile(res.tempFiles[0].path)
  202. self.setData({
  203. resumeFileName:res.tempFiles[0].name,
  204. fileTitle:res.tempFiles[0].name
  205. })
  206. }
  207. })
  208. },
  209. uploadFile: function(temFile){
  210. // console.log(temFile)
  211. // console.log(request.BASE_URL)
  212. var self = this;
  213. wx.uploadFile({
  214. url:request.BASE_URL+"open/upload/upload-pic", //上传的路径
  215. filePath:temFile, //刚刚在data保存的文件路径
  216. name: 'file', //后台获取的凭据
  217. formData: {
  218. 'basePath': 'recruit'
  219. },
  220. success (res){
  221. const result = JSON.parse(res.data)
  222. // console.log(result)
  223. // console.log(result.data.destPath)
  224. self.setData({
  225. resumeFile:result.data.url,
  226. fileColor:"#000",
  227. })
  228. }
  229. })
  230. },
  231. // downloadFile:function(e){
  232. // var url = e.currentTarget.dataset.url;
  233. // wx.downloadFile({
  234. // url: url, //仅为示例,并非真实的资源
  235. // success (res) {
  236. // // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  237. // if (res.statusCode === 200) {
  238. // }
  239. // }
  240. // })
  241. // },
  242. getUserInfo: async function(openId) {
  243. var params = {}
  244. params['openid'] = openId;
  245. var info = await recruitApi.infoUser(params);
  246. console.log(info);
  247. var highestEducation = info.highestEducation?info.highestEducation:0;
  248. var jobStatus = info.jobStatus?info.jobStatus:0;
  249. var nowSalary = info.nowSalary?info.nowSalary:0;
  250. var hopeSalary = info.hopeSalary?info.hopeSalary:0;
  251. var learningModality = info.learningModality?info.learningModality:0;
  252. var birthday = info.birthday?info.birthday:'1990-01-01';
  253. var fileColor = info.resumeFileName?'#000':'#c2c6da';
  254. var fileTitle = info.resumeFileName?info.resumeFileName:'在微信聊天中选择附件';
  255. this.setData({
  256. userId:info.userId,
  257. name:info.name,
  258. email:info.email,
  259. mobile:info.mobile,
  260. gender:info.gender,
  261. birthday:birthday,
  262. nowAddress:info.nowAddress,
  263. registeredAddress:info.registeredAddress,
  264. highestEducation:highestEducation,
  265. learningModality:learningModality,
  266. takeProfessionally:info.takeProfessionally,
  267. jobStatus:jobStatus,
  268. hopeProfessionally:info.hopeProfessionally,
  269. nowSalary:nowSalary,
  270. hopeSalary:hopeSalary,
  271. resumeFile:info.resumeFile,
  272. resumeFileName:info.resumeFileName,
  273. fileTitle:fileTitle,
  274. fileColor:fileColor,
  275. })
  276. },
  277. saveResume: async function(){
  278. if(!this.data.name){
  279. wx.showToast({
  280. title: '请输入姓名',
  281. icon: 'none',
  282. duration: 1000
  283. })
  284. return;
  285. }
  286. if(!this.data.email){
  287. wx.showToast({
  288. title: '请输入邮箱',
  289. icon: 'none',
  290. duration: 1000
  291. })
  292. return;
  293. }
  294. if(!this.data.mobile){
  295. wx.showToast({
  296. title: '请输入手机号',
  297. icon: 'none',
  298. duration: 1000
  299. })
  300. return;
  301. }
  302. if(!this.data.resumeFile){
  303. wx.showToast({
  304. title: '请上传附件',
  305. icon: 'none',
  306. duration: 1000
  307. })
  308. return;
  309. }
  310. console.log(this.data.resumeFile);
  311. var params = {
  312. userId:this.data.userId,
  313. name:this.data.name,
  314. email:this.data.email,
  315. mobile:this.data.mobile,
  316. birthday:this.data.birthday,
  317. gender:this.data.gender,
  318. nowAddress:this.data.nowAddress,
  319. registeredAddress:this.data.registeredAddress,
  320. highestEducation:this.data.highestEducation,
  321. learningModality:this.data.learningModality,
  322. takeProfessionally:this.data.takeProfessionally,
  323. jobStatus:this.data.jobStatus,
  324. hopeProfessionally:this.data.hopeProfessionally,
  325. nowSalary:this.data.nowSalary,
  326. hopeSalary:this.data.hopeSalary,
  327. resumeFile:this.data.resumeFile,
  328. resumeFileName:this.data.resumeFileName,
  329. };
  330. await recruitApi.saveUser(params);
  331. if(this.data.type ==2){
  332. await recruitApi.deliveryRecruit(this.data.openId,this.data.recruitsId);
  333. wx.showToast({
  334. title: '投递成功',
  335. icon: 'success',
  336. success:function(){
  337. setTimeout(() => {
  338. wx.navigateBack({
  339. delta: 2
  340. })
  341. }, 1000);
  342. }
  343. })
  344. }else{
  345. wx.showToast({
  346. title: '保存成功',
  347. icon: 'success',
  348. success:function(){
  349. setTimeout(() => {
  350. wx.navigateBack({
  351. delta: 2
  352. })
  353. }, 1000);
  354. }
  355. })
  356. }
  357. }
  358. })