resume.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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:0,
  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. changeEducation: function (e) {
  150. this.setData({
  151. highestEducation: e.detail.value
  152. })
  153. },
  154. changeSchoolType: function (e) {
  155. this.setData({
  156. learningModality: e.detail.value
  157. })
  158. },
  159. changeStatus:function(e){
  160. this.setData({
  161. jobStatus: e.detail.value
  162. })
  163. },
  164. bindInputTakeProfessionally:function(e){
  165. this.setData({
  166. takeProfessionally: e.detail.value
  167. })
  168. },
  169. bindInputHopeProfessionally:function(e){
  170. this.setData({
  171. hopeProfessionally: e.detail.value
  172. })
  173. },
  174. changeNowMoney:function(e){
  175. this.setData({
  176. nowSalary: e.detail.value
  177. })
  178. },
  179. changeExpectMoney:function(e){
  180. this.setData({
  181. hopeSalary: e.detail.value
  182. })
  183. },
  184. chooseEnclosure:function(){
  185. this.setData({
  186. isChooseFile:true
  187. })
  188. var self =this;
  189. wx.chooseMessageFile({
  190. count: 1,
  191. type: 'file',
  192. success (res) {
  193. // tempFilePath可以作为img标签的src属性显示图片
  194. self.uploadFile(res.tempFiles[0].path)
  195. self.setData({
  196. resumeFileName:res.tempFiles[0].name,
  197. fileTitle:res.tempFiles[0].name
  198. })
  199. }
  200. })
  201. },
  202. uploadFile: function(temFile){
  203. var self = this;
  204. wx.uploadFile({
  205. url: "https://oapi.shpr.top/open/upload/upload-pic", //上传的路径
  206. filePath:temFile, //刚刚在data保存的文件路径
  207. name: 'file', //后台获取的凭据
  208. formData: {
  209. 'basePath': 'recruit'
  210. },
  211. success (res){
  212. const result = JSON.parse(res.data)
  213. console.log(result)
  214. console.log(result.data.destPath)
  215. self.setData({
  216. resumeFile:result.data.url,
  217. fileColor:"#000",
  218. })
  219. }
  220. })
  221. },
  222. // downloadFile:function(e){
  223. // var url = e.currentTarget.dataset.url;
  224. // wx.downloadFile({
  225. // url: url, //仅为示例,并非真实的资源
  226. // success (res) {
  227. // // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  228. // if (res.statusCode === 200) {
  229. // }
  230. // }
  231. // })
  232. // },
  233. getUserInfo: async function(openId) {
  234. var params = {}
  235. params['openid'] = openId;
  236. var info = await recruitApi.infoUser(params);
  237. console.log(info);
  238. var highestEducation = info.highestEducation?info.highestEducation:0;
  239. var jobStatus = info.jobStatus?info.jobStatus:0;
  240. var nowSalary = info.nowSalary?info.nowSalary:0;
  241. var hopeSalary = info.hopeSalary?info.hopeSalary:0;
  242. var learningModality = info.learningModality?info.learningModality:0;
  243. var birthday = info.birthday?info.birthday:'1990-01-01';
  244. var fileColor = info.resumeFileName?'#000':'#c2c6da';
  245. var fileTitle = info.resumeFileName?info.resumeFileName:'在微信聊天中选择附件';
  246. this.setData({
  247. userId:info.userId,
  248. name:info.name,
  249. email:info.email,
  250. mobile:info.mobile,
  251. gender:info.gender,
  252. birthday:birthday,
  253. nowAddress:info.nowAddress,
  254. registeredAddress:info.registeredAddress,
  255. highestEducation:highestEducation,
  256. learningModality:learningModality,
  257. takeProfessionally:info.takeProfessionally,
  258. jobStatus:jobStatus,
  259. hopeProfessionally:info.hopeProfessionally,
  260. nowSalary:nowSalary,
  261. hopeSalary:hopeSalary,
  262. resumeFile:info.resumeFile,
  263. resumeFileName:info.resumeFileName,
  264. fileTitle:fileTitle,
  265. fileColor:fileColor,
  266. })
  267. },
  268. saveResume: async function(){
  269. if(!this.data.name){
  270. wx.showToast({
  271. title: '请输入姓名',
  272. icon: 'none',
  273. duration: 1000
  274. })
  275. return;
  276. }
  277. if(!this.data.email){
  278. wx.showToast({
  279. title: '请输入邮箱',
  280. icon: 'none',
  281. duration: 1000
  282. })
  283. return;
  284. }
  285. if(!this.data.mobile){
  286. wx.showToast({
  287. title: '请输入手机号',
  288. icon: 'none',
  289. duration: 1000
  290. })
  291. return;
  292. }
  293. if(!this.data.resumeFile){
  294. wx.showToast({
  295. title: '请上传附件',
  296. icon: 'none',
  297. duration: 1000
  298. })
  299. return;
  300. }
  301. console.log(this.data.resumeFile);
  302. var params = {
  303. userId:this.data.userId,
  304. name:this.data.name,
  305. email:this.data.email,
  306. mobile:this.data.mobile,
  307. birthday:this.data.birthday,
  308. gender:this.data.gender,
  309. nowAddress:this.data.nowAddress,
  310. registeredAddress:this.data.registeredAddress,
  311. highestEducation:this.data.highestEducation,
  312. learningModality:this.data.learningModality,
  313. takeProfessionally:this.data.takeProfessionally,
  314. jobStatus:this.data.jobStatus,
  315. hopeProfessionally:this.data.hopeProfessionally,
  316. nowSalary:this.data.nowSalary,
  317. hopeSalary:this.data.hopeSalary,
  318. resumeFile:this.data.resumeFile,
  319. resumeFileName:this.data.resumeFileName,
  320. };
  321. await recruitApi.saveUser(params);
  322. if(this.data.type ==2){
  323. await recruitApi.deliveryRecruit(this.data.openId,this.data.recruitsId);
  324. wx.showToast({
  325. title: '投递成功',
  326. icon: 'success',
  327. success:function(){
  328. setTimeout(() => {
  329. wx.navigateBack({
  330. delta: 2
  331. })
  332. }, 1000);
  333. }
  334. })
  335. }else{
  336. wx.showToast({
  337. title: '保存成功',
  338. icon: 'success',
  339. success:function(){
  340. setTimeout(() => {
  341. wx.navigateBack({
  342. delta: 2
  343. })
  344. }, 1000);
  345. }
  346. })
  347. }
  348. }
  349. })