resume.js 9.4 KB

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