Personal.js 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const common_config = require("../../common/config.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. // 添加承诺书相关数据
  8. showPromiseModal: true,
  9. promiseChecked: false,
  10. formData: {
  11. name: "",
  12. gender: "",
  13. threePeriod: "",
  14. birthDate: "",
  15. idCard: "",
  16. political: "",
  17. ethnic: "",
  18. height: "",
  19. weight: "",
  20. nativePlace: "",
  21. residence: "",
  22. marriage: "",
  23. expectedSalary: "",
  24. phone: "",
  25. email: "",
  26. currentAddress: "",
  27. emergencyContact: "",
  28. emergencyPhone: "",
  29. hobby: "",
  30. motto: "",
  31. // 添加应聘来源相关字段
  32. sourceType: "social",
  33. // 默认为社招
  34. socialSource: "",
  35. // 社招来源
  36. otherSocialSource: "",
  37. // 其他社招来源
  38. otherSchoolSource: "",
  39. // 其他学校来源
  40. // 添加技能和培训字段
  41. skills: "",
  42. training: ""
  43. },
  44. genderOptions: ["男", "女"],
  45. genderIndex: -1,
  46. threePeriodOptions: ["无", "孕期", "产期", "哺乳期"],
  47. threePeriodIndex: -1,
  48. politicalOptions: ["群众", "共青团员", "中共党员", "民主党派"],
  49. politicalIndex: -1,
  50. ethnicOptions: ["汉族", "蒙古族", "回族", "藏族", "维吾尔族", "其他"],
  51. ethnicIndex: -1,
  52. marriageOptions: ["未婚", "已婚", "离异", "丧偶"],
  53. marriageIndex: -1,
  54. familyMembers: [],
  55. familyMemberForm: {
  56. relation: "",
  57. name: "",
  58. workplaceOrAddress: "",
  59. position: "",
  60. phone: "",
  61. isEmergencyContact: false
  62. // 添加新字段
  63. },
  64. isEditing: false,
  65. editingIndex: -1,
  66. // 添加教育经历相关数据
  67. educationList: [],
  68. educationForm: {
  69. startTime: "",
  70. endTime: "",
  71. schoolName: "",
  72. major: "",
  73. degree: ""
  74. },
  75. isEditingEducation: false,
  76. editingEducationIndex: -1,
  77. degreeOptions: ["高中", "中专", "大专", "本科", "硕士", "博士"],
  78. degreeIndex: -1,
  79. // 添加工作经历相关数据
  80. workList: [],
  81. workForm: {
  82. startTime: "",
  83. endTime: "",
  84. companyName: "",
  85. department: "",
  86. employeeCount: "",
  87. position: "",
  88. monthlySalary: "",
  89. supervisor: "",
  90. supervisorPhone: ""
  91. },
  92. isEditingWork: false,
  93. editingWorkIndex: -1,
  94. // 添加步骤控制
  95. currentStep: 1,
  96. steps: [
  97. { id: 1, name: "基本信息" },
  98. { id: 3, name: "家庭成员" },
  99. { id: 5, name: "教育经历" },
  100. { id: 6, name: "专业技能" },
  101. { id: 8, name: "工作经历" }
  102. ],
  103. formErrors: {
  104. name: "",
  105. idCard: "",
  106. phone: ""
  107. },
  108. // Add loading state
  109. isLoading: true
  110. };
  111. },
  112. onLoad() {
  113. this.fetchUserData();
  114. },
  115. computed: {
  116. // 添加计算属性来控制按钮显示
  117. showPrevButton() {
  118. return this.currentStep !== 1;
  119. },
  120. showNextButton() {
  121. return this.currentStep !== 8;
  122. },
  123. showSubmitButton() {
  124. return this.currentStep === 8;
  125. },
  126. // 获取当前步骤在数组中的索引
  127. currentStepIndex() {
  128. return this.steps.findIndex((step) => step.id === this.currentStep);
  129. }
  130. },
  131. methods: {
  132. // 添加承诺书相关方法
  133. togglePromiseChecked() {
  134. this.promiseChecked = !this.promiseChecked;
  135. },
  136. confirmPromise() {
  137. if (this.promiseChecked) {
  138. this.showPromiseModal = false;
  139. } else {
  140. common_vendor.index.showToast({
  141. title: "请先阅读并同意承诺书内容",
  142. icon: "none"
  143. });
  144. }
  145. },
  146. bindGenderChange(e) {
  147. this.genderIndex = e.detail.value;
  148. this.formData.gender = this.genderOptions[this.genderIndex];
  149. if (this.formData.gender !== "女") {
  150. this.formData.threePeriod = "";
  151. this.threePeriodIndex = -1;
  152. }
  153. },
  154. bindThreePeriodChange(e) {
  155. this.threePeriodIndex = e.detail.value;
  156. this.formData.threePeriod = this.threePeriodOptions[this.threePeriodIndex];
  157. },
  158. bindPoliticalChange(e) {
  159. this.politicalIndex = e.detail.value;
  160. this.formData.political = this.politicalOptions[this.politicalIndex];
  161. },
  162. bindEthnicChange(e) {
  163. this.ethnicIndex = e.detail.value;
  164. this.formData.ethnic = this.ethnicOptions[this.ethnicIndex];
  165. },
  166. bindMarriageChange(e) {
  167. this.marriageIndex = e.detail.value;
  168. this.formData.marriage = this.marriageOptions[this.marriageIndex];
  169. },
  170. bindDateChange(e) {
  171. this.formData.birthDate = e.detail.value;
  172. },
  173. saveFamilyMember() {
  174. if (!this.familyMemberForm.relation) {
  175. common_vendor.index.showToast({
  176. title: "请输入称谓",
  177. icon: "none"
  178. });
  179. return;
  180. }
  181. if (!this.familyMemberForm.name) {
  182. common_vendor.index.showToast({
  183. title: "请输入姓名",
  184. icon: "none"
  185. });
  186. return;
  187. }
  188. if (!this.familyMemberForm.phone) {
  189. common_vendor.index.showToast({
  190. title: "请输入联系电话",
  191. icon: "none"
  192. });
  193. return;
  194. }
  195. if (this.isEditing) {
  196. if (!this.familyMemberForm.isEmergencyContact && this.familyMembers[this.editingIndex].isEmergencyContact) {
  197. this.formData.emergencyContact = "";
  198. this.formData.emergencyPhone = "";
  199. }
  200. this.familyMembers[this.editingIndex] = { ...this.familyMemberForm };
  201. common_vendor.index.showToast({
  202. title: "修改成功",
  203. icon: "success"
  204. });
  205. this.isEditing = false;
  206. this.editingIndex = -1;
  207. } else {
  208. this.familyMembers.push({ ...this.familyMemberForm });
  209. common_vendor.index.showToast({
  210. title: "添加成功",
  211. icon: "success"
  212. });
  213. }
  214. this.familyMemberForm = {
  215. relation: "",
  216. name: "",
  217. workplaceOrAddress: "",
  218. position: "",
  219. phone: "",
  220. isEmergencyContact: false
  221. };
  222. },
  223. editFamilyMember(index) {
  224. this.isEditing = true;
  225. this.editingIndex = index;
  226. this.familyMemberForm = { ...this.familyMembers[index] };
  227. common_vendor.index.pageScrollTo({
  228. selector: ".family-member-form",
  229. duration: 300
  230. });
  231. },
  232. cancelEdit() {
  233. this.isEditing = false;
  234. this.editingIndex = -1;
  235. this.familyMemberForm = {
  236. relation: "",
  237. name: "",
  238. workplaceOrAddress: "",
  239. position: "",
  240. phone: "",
  241. isEmergencyContact: false
  242. };
  243. },
  244. deleteFamilyMember(index) {
  245. if (this.isEditing && this.editingIndex === index) {
  246. this.cancelEdit();
  247. }
  248. this.familyMembers.splice(index, 1);
  249. common_vendor.index.showToast({
  250. title: "已删除",
  251. icon: "none"
  252. });
  253. },
  254. // 选择应聘来源类型
  255. selectSourceType(type) {
  256. this.formData.sourceType = type;
  257. if (type === "social") {
  258. this.formData.socialSource = "BOSS";
  259. } else {
  260. this.formData.socialSource = "";
  261. }
  262. },
  263. // 选择社招来源
  264. selectSocialSource(source) {
  265. this.formData.sourceType = "social";
  266. this.formData.socialSource = source;
  267. },
  268. // 教育经历相关方法
  269. bindStartTimeChange(e) {
  270. this.educationForm.startTime = e.detail.value;
  271. },
  272. bindEndTimeChange(e) {
  273. this.educationForm.endTime = e.detail.value;
  274. },
  275. bindDegreeChange(e) {
  276. this.degreeIndex = e.detail.value;
  277. this.educationForm.degree = this.degreeOptions[this.degreeIndex];
  278. },
  279. saveEducation() {
  280. if (!this.educationForm.startTime) {
  281. common_vendor.index.showToast({
  282. title: "请选择开始时间",
  283. icon: "none"
  284. });
  285. return;
  286. }
  287. if (!this.educationForm.endTime) {
  288. common_vendor.index.showToast({
  289. title: "请选择结束时间",
  290. icon: "none"
  291. });
  292. return;
  293. }
  294. if (!this.educationForm.schoolName) {
  295. common_vendor.index.showToast({
  296. title: "请输入学校名称",
  297. icon: "none"
  298. });
  299. return;
  300. }
  301. if (!this.educationForm.major) {
  302. common_vendor.index.showToast({
  303. title: "请输入专业",
  304. icon: "none"
  305. });
  306. return;
  307. }
  308. if (!this.educationForm.degree) {
  309. common_vendor.index.showToast({
  310. title: "请选择学历",
  311. icon: "none"
  312. });
  313. return;
  314. }
  315. if (this.isEditingEducation) {
  316. this.educationList[this.editingEducationIndex] = { ...this.educationForm };
  317. common_vendor.index.showToast({
  318. title: "修改成功",
  319. icon: "success"
  320. });
  321. this.isEditingEducation = false;
  322. this.editingEducationIndex = -1;
  323. } else {
  324. this.educationList.push({ ...this.educationForm });
  325. common_vendor.index.showToast({
  326. title: "添加成功",
  327. icon: "success"
  328. });
  329. }
  330. this.educationForm = {
  331. startTime: "",
  332. endTime: "",
  333. schoolName: "",
  334. major: "",
  335. degree: ""
  336. };
  337. this.degreeIndex = -1;
  338. },
  339. editEducation(index) {
  340. this.isEditingEducation = true;
  341. this.editingEducationIndex = index;
  342. this.educationForm = { ...this.educationList[index] };
  343. this.degreeIndex = this.degreeOptions.findIndex((item) => item === this.educationForm.degree);
  344. common_vendor.index.pageScrollTo({
  345. selector: ".education-form",
  346. duration: 300
  347. });
  348. },
  349. cancelEditEducation() {
  350. this.isEditingEducation = false;
  351. this.editingEducationIndex = -1;
  352. this.educationForm = {
  353. startTime: "",
  354. endTime: "",
  355. schoolName: "",
  356. major: "",
  357. degree: ""
  358. };
  359. this.degreeIndex = -1;
  360. },
  361. deleteEducation(index) {
  362. if (this.isEditingEducation && this.editingEducationIndex === index) {
  363. this.cancelEditEducation();
  364. }
  365. this.educationList.splice(index, 1);
  366. common_vendor.index.showToast({
  367. title: "已删除",
  368. icon: "none"
  369. });
  370. },
  371. // 工作经历相关方法
  372. bindWorkStartTimeChange(e) {
  373. this.workForm.startTime = e.detail.value;
  374. },
  375. bindWorkEndTimeChange(e) {
  376. this.workForm.endTime = e.detail.value;
  377. },
  378. saveWork() {
  379. if (!this.workForm.startTime) {
  380. common_vendor.index.showToast({
  381. title: "请选择开始时间",
  382. icon: "none"
  383. });
  384. return;
  385. }
  386. if (!this.workForm.endTime) {
  387. common_vendor.index.showToast({
  388. title: "请选择结束时间",
  389. icon: "none"
  390. });
  391. return;
  392. }
  393. if (!this.workForm.companyName) {
  394. common_vendor.index.showToast({
  395. title: "请输入单位名称",
  396. icon: "none"
  397. });
  398. return;
  399. }
  400. if (!this.workForm.department) {
  401. common_vendor.index.showToast({
  402. title: "请输入任职部门",
  403. icon: "none"
  404. });
  405. return;
  406. }
  407. if (!this.workForm.position) {
  408. common_vendor.index.showToast({
  409. title: "请输入担任职务",
  410. icon: "none"
  411. });
  412. return;
  413. }
  414. if (this.isEditingWork) {
  415. this.workList[this.editingWorkIndex] = { ...this.workForm };
  416. common_vendor.index.showToast({
  417. title: "修改成功",
  418. icon: "success"
  419. });
  420. this.isEditingWork = false;
  421. this.editingWorkIndex = -1;
  422. } else {
  423. this.workList.push({ ...this.workForm });
  424. common_vendor.index.showToast({
  425. title: "添加成功",
  426. icon: "success"
  427. });
  428. }
  429. this.workForm = {
  430. startTime: "",
  431. endTime: "",
  432. companyName: "",
  433. department: "",
  434. employeeCount: "",
  435. position: "",
  436. monthlySalary: "",
  437. supervisor: "",
  438. supervisorPhone: ""
  439. };
  440. },
  441. editWork(index) {
  442. this.isEditingWork = true;
  443. this.editingWorkIndex = index;
  444. this.workForm = { ...this.workList[index] };
  445. common_vendor.index.pageScrollTo({
  446. selector: ".work-form",
  447. duration: 300
  448. });
  449. },
  450. cancelEditWork() {
  451. this.isEditingWork = false;
  452. this.editingWorkIndex = -1;
  453. this.workForm = {
  454. startTime: "",
  455. endTime: "",
  456. companyName: "",
  457. department: "",
  458. employeeCount: "",
  459. position: "",
  460. monthlySalary: "",
  461. supervisor: "",
  462. supervisorPhone: ""
  463. };
  464. },
  465. deleteWork(index) {
  466. if (this.isEditingWork && this.editingWorkIndex === index) {
  467. this.cancelEditWork();
  468. }
  469. this.workList.splice(index, 1);
  470. common_vendor.index.showToast({
  471. title: "已删除",
  472. icon: "none"
  473. });
  474. },
  475. submitForm() {
  476. if (!this.validateCurrentStep()) {
  477. return;
  478. }
  479. const userInfo = common_vendor.index.getStorageSync("userInfo");
  480. if (!userInfo) {
  481. common_vendor.index.showToast({
  482. title: "用户信息获取失败,请重新登录",
  483. icon: "none",
  484. duration: 2e3
  485. });
  486. return;
  487. }
  488. try {
  489. const userData = JSON.parse(userInfo);
  490. const submitData = {
  491. tenant_id: 1,
  492. user_id: userData.id,
  493. personal_info: {
  494. name: this.formData.name,
  495. gender: this.formData.gender,
  496. phone: this.formData.phone,
  497. id_card: this.formData.idCard,
  498. address: this.formData.currentAddress,
  499. professional_skills: this.formData.skills ? this.formData.skills.split(",") : []
  500. },
  501. profile: {
  502. female_status: this.getFemaleStatus(),
  503. marital_status: this.getMaritalStatus(),
  504. height: parseFloat(this.formData.height) || 0,
  505. weight: parseFloat(this.formData.weight) || 0,
  506. ethnicity: this.formData.ethnic,
  507. current_address: this.formData.currentAddress,
  508. expected_salary: parseFloat(this.formData.expectedSalary) || 0
  509. },
  510. educations: this.formatEducations(),
  511. family_members: this.formatFamilyMembers(),
  512. work_experiences: this.formatWorkExperiences()
  513. };
  514. if (!submitData.personal_info.name || !submitData.personal_info.gender || !submitData.personal_info.phone) {
  515. common_vendor.index.showToast({
  516. title: "基本信息不完整",
  517. icon: "none",
  518. duration: 2e3
  519. });
  520. return;
  521. }
  522. this.sendFormData(submitData);
  523. } catch (error) {
  524. console.error("数据处理错误:", error);
  525. common_vendor.index.showToast({
  526. title: "数据处理错误,请重试",
  527. icon: "none",
  528. duration: 2e3
  529. });
  530. }
  531. },
  532. // 辅助方法:发送表单数据
  533. sendFormData(submitData) {
  534. common_vendor.index.showLoading({ title: "提交中..." });
  535. const token = common_vendor.index.getStorageSync("token");
  536. common_vendor.index.request({
  537. url: `${common_config.apiBaseUrl}/wechat/user/profile/update`,
  538. method: "POST",
  539. data: submitData,
  540. header: {
  541. "content-type": "application/json",
  542. "Authorization": token ? `Bearer ${token}` : ""
  543. },
  544. success: (res) => {
  545. common_vendor.index.hideLoading();
  546. if (res.statusCode === 200) {
  547. if (res.data.code === 2e3) {
  548. common_vendor.index.showToast({
  549. title: "提交成功",
  550. icon: "success",
  551. duration: 2e3
  552. });
  553. setTimeout(() => {
  554. common_vendor.index.navigateTo({
  555. url: "/pages/interview-notice/interview-notice"
  556. });
  557. }, 2e3);
  558. } else {
  559. common_vendor.index.showToast({
  560. title: res.data.msg || "提交失败",
  561. icon: "none",
  562. duration: 2e3
  563. });
  564. }
  565. } else {
  566. common_vendor.index.showToast({
  567. title: "服务器响应错误",
  568. icon: "none",
  569. duration: 2e3
  570. });
  571. }
  572. },
  573. fail: (err) => {
  574. console.error("提交失败:", err);
  575. common_vendor.index.hideLoading();
  576. if (err.errMsg.includes("timeout")) {
  577. common_vendor.index.showToast({
  578. title: "请求超时,请检查网络后重试",
  579. icon: "none",
  580. duration: 2e3
  581. });
  582. } else if (err.errMsg.includes("fail")) {
  583. common_vendor.index.showToast({
  584. title: "网络连接失败,请检查网络设置",
  585. icon: "none",
  586. duration: 2e3
  587. });
  588. } else {
  589. common_vendor.index.showToast({
  590. title: "提交失败,请稍后重试",
  591. icon: "none",
  592. duration: 2e3
  593. });
  594. }
  595. },
  596. complete: () => {
  597. }
  598. });
  599. },
  600. // 数据格式化方法
  601. getFemaleStatus() {
  602. if (this.formData.gender !== "女")
  603. return 0;
  604. const statusMap = { "孕期": 1, "产期": 2, "哺乳期": 3 };
  605. return statusMap[this.formData.threePeriod] || 0;
  606. },
  607. getMaritalStatus() {
  608. const statusMap = { "未婚": 0, "已婚": 1, "离异": 2, "丧偶": 3 };
  609. return statusMap[this.formData.marriage] || 0;
  610. },
  611. formatEducations() {
  612. return this.educationList.map((edu, index) => ({
  613. education_type: index === 0 ? 1 : 2,
  614. degree: this.mapDegreeToNumber(edu.degree),
  615. start_date: edu.startTime,
  616. end_date: edu.endTime,
  617. school_name: edu.schoolName,
  618. major: edu.major
  619. }));
  620. },
  621. formatFamilyMembers() {
  622. return this.familyMembers.map((member) => ({
  623. relation: member.relation,
  624. name: member.name,
  625. workplace: member.workplaceOrAddress,
  626. position: member.position,
  627. phone: member.phone
  628. //is_emergency_contact: member.isEmergencyContact||false // 添加紧急联系人标识
  629. }));
  630. },
  631. formatWorkExperiences() {
  632. return this.workList.map((work) => ({
  633. start_date: work.startTime,
  634. end_date: work.endTime,
  635. company_name: work.companyName,
  636. department: work.department,
  637. company_size: work.employeeCount,
  638. position: work.position,
  639. monthly_salary: work.monthlySalary,
  640. supervisor_name: work.supervisor,
  641. supervisor_phone: work.supervisorPhone
  642. }));
  643. },
  644. // 学历映射辅助方法
  645. mapDegreeToNumber(degreeText) {
  646. const degreeMap = {
  647. "高中": 1,
  648. "中专": 1,
  649. "大专": 2,
  650. "本科": 3,
  651. "硕士": 4,
  652. "博士": 5
  653. };
  654. return degreeMap[degreeText] || 6;
  655. },
  656. prevStep() {
  657. const prevIndex = this.currentStepIndex - 1;
  658. if (prevIndex >= 0) {
  659. this.currentStep = this.steps[prevIndex].id;
  660. common_vendor.index.pageScrollTo({
  661. scrollTop: 0,
  662. duration: 300
  663. });
  664. }
  665. },
  666. nextStep() {
  667. if (!this.validateCurrentStep()) {
  668. return;
  669. }
  670. if (this.currentStep === 1) {
  671. this.verifyIdentity();
  672. return;
  673. }
  674. const nextIndex = this.currentStepIndex + 1;
  675. if (nextIndex < this.steps.length) {
  676. this.currentStep = this.steps[nextIndex].id;
  677. common_vendor.index.pageScrollTo({
  678. scrollTop: 0,
  679. duration: 300
  680. });
  681. }
  682. },
  683. // 身份验证方法
  684. verifyIdentity() {
  685. this.formErrors = {
  686. name: "",
  687. idCard: "",
  688. phone: ""
  689. };
  690. common_vendor.index.showLoading({
  691. title: "身份验证中..."
  692. });
  693. common_vendor.index.request({
  694. url: `${common_config.apiBaseUrl}/wechat/identity/verify`,
  695. method: "POST",
  696. data: {
  697. name: this.formData.name,
  698. id_number: this.formData.idCard,
  699. mobile: this.formData.phone
  700. },
  701. header: {
  702. "content-type": "application/x-www-form-urlencoded"
  703. },
  704. success: (res) => {
  705. common_vendor.index.hideLoading();
  706. if (res.data.code === 200) {
  707. const nextIndex = this.currentStepIndex + 1;
  708. if (nextIndex < this.steps.length) {
  709. this.currentStep = this.steps[nextIndex].id;
  710. common_vendor.index.pageScrollTo({
  711. scrollTop: 0,
  712. duration: 300
  713. });
  714. }
  715. } else {
  716. this.handleVerificationError(res.data);
  717. }
  718. },
  719. fail: (err) => {
  720. this.handleRequestError(err);
  721. }
  722. });
  723. },
  724. // 处理验证错误
  725. handleVerificationError(data) {
  726. this.formErrors.name = "姓名验证失败,请检查姓名是否正确";
  727. this.formErrors.idCard = "身份证号验证失败,请检查身份证号是否正确";
  728. this.formErrors.phone = "手机号验证失败,请检查手机号是否正确";
  729. common_vendor.index.showToast({
  730. title: data.msg || "身份验证失败",
  731. icon: "none"
  732. });
  733. },
  734. // 处理请求错误
  735. handleRequestError(err) {
  736. common_vendor.index.hideLoading();
  737. common_vendor.index.showToast({
  738. title: "网络错误,请检查网络连接",
  739. icon: "none",
  740. duration: 2e3
  741. });
  742. console.error("请求失败:", err);
  743. },
  744. // 验证当前步骤的必填项
  745. validateCurrentStep() {
  746. const validations = {
  747. // 第一步:基本信息验证
  748. 1: () => {
  749. const basicChecks = [
  750. { value: this.formData.name, message: "请输入姓名" },
  751. { value: this.formData.gender, message: "请选择性别" },
  752. { value: this.formData.phone, message: "请输入手机号" },
  753. { value: this.formData.idCard, message: "请输入身份证号" }
  754. ];
  755. for (const check of basicChecks) {
  756. if (!check.value) {
  757. common_vendor.index.showToast({ title: check.message, icon: "none" });
  758. return false;
  759. }
  760. }
  761. if (this.formData.gender === "女" && this.threePeriodIndex === -1) {
  762. common_vendor.index.showToast({ title: "请选择是否为三期", icon: "none" });
  763. return false;
  764. }
  765. return true;
  766. },
  767. // 第二步:家庭成员验证
  768. 3: () => {
  769. if (this.familyMembers.length === 0) {
  770. common_vendor.index.showToast({ title: "请至少添加一位家庭成员", icon: "none" });
  771. return false;
  772. }
  773. return true;
  774. },
  775. // 第三步:教育经历验证
  776. 5: () => {
  777. if (this.educationList.length === 0) {
  778. common_vendor.index.showToast({ title: "请至少添加一项教育经历", icon: "none" });
  779. return false;
  780. }
  781. return true;
  782. },
  783. // 第四步:专业技能验证
  784. 6: () => {
  785. if (!this.formData.skills) {
  786. common_vendor.index.showToast({ title: "请描述您的专业技能", icon: "none" });
  787. return false;
  788. }
  789. return true;
  790. },
  791. // 第五步:工作经历验证
  792. 8: () => {
  793. if (this.workList.length === 0) {
  794. common_vendor.index.showToast({ title: "请至少添加一项工作经历", icon: "none" });
  795. return false;
  796. }
  797. for (let i = 0; i < this.workList.length; i++) {
  798. const work = this.workList[i];
  799. const workChecks = [
  800. { value: work.startTime, message: `单位${i + 1}:请选择开始时间` },
  801. { value: work.endTime, message: `单位${i + 1}:请选择结束时间` },
  802. { value: work.companyName, message: `单位${i + 1}:请输入单位名称` },
  803. { value: work.department, message: `单位${i + 1}:请输入任职部门` },
  804. { value: work.position, message: `单位${i + 1}:请输入担任职务` }
  805. ];
  806. for (const check of workChecks) {
  807. if (!check.value) {
  808. common_vendor.index.showToast({ title: check.message, icon: "none" });
  809. return false;
  810. }
  811. }
  812. }
  813. return true;
  814. }
  815. };
  816. return validations[this.currentStep] ? validations[this.currentStep]() : true;
  817. },
  818. // Add method to fetch user data
  819. fetchUserData() {
  820. this.isLoading = true;
  821. const userInfo = common_vendor.index.getStorageSync("userInfo") ? JSON.parse(common_vendor.index.getStorageSync("userInfo")) : {};
  822. const openid = userInfo.openid;
  823. if (!openid) {
  824. common_vendor.index.showToast({
  825. title: "用户信息获取失败,请重新登录",
  826. icon: "none"
  827. });
  828. this.isLoading = false;
  829. return;
  830. }
  831. common_vendor.index.request({
  832. url: `${common_config.apiBaseUrl}/api/wechat/user/get_full_info?tenant_id=1&openid=${openid}`,
  833. method: "GET",
  834. success: (res) => {
  835. this.showPromiseModal = true;
  836. this.populateFormData(res.data.data);
  837. },
  838. fail: (err) => {
  839. },
  840. complete: () => {
  841. this.isLoading = false;
  842. }
  843. });
  844. },
  845. // Add method to populate form data with fetched data
  846. populateFormData(data) {
  847. const { user_info, profile, educations, work_experiences, family_members } = data;
  848. if (user_info) {
  849. this.formData.name = user_info.name || "";
  850. this.formData.gender = user_info.gender_text || "";
  851. this.genderIndex = this.genderOptions.findIndex((item) => item === this.formData.gender);
  852. this.formData.idCard = user_info.id_card || "";
  853. this.formData.phone = user_info.phone || "";
  854. this.formData.email = user_info.email || "";
  855. }
  856. if (profile) {
  857. this.formData.political = profile.political_status || "";
  858. this.politicalIndex = this.politicalOptions.findIndex((item) => item === this.formData.political);
  859. this.formData.ethnic = profile.ethnicity || "";
  860. this.ethnicIndex = this.ethnicOptions.findIndex((item) => item === this.formData.ethnic);
  861. this.formData.height = profile.height || "";
  862. this.formData.weight = profile.weight || "";
  863. this.formData.nativePlace = profile.native_place || "";
  864. this.formData.residence = profile.household_location || "";
  865. this.formData.currentAddress = profile.current_address || "";
  866. this.formData.marriage = profile.marital_status_text || "";
  867. this.marriageIndex = this.marriageOptions.findIndex((item) => item === this.formData.marriage);
  868. if (this.formData.gender === "女" && profile.female_status !== void 0) {
  869. const femaleStatusMap = { 0: "无", 1: "孕期", 2: "产期", 3: "哺乳期" };
  870. this.formData.threePeriod = femaleStatusMap[profile.female_status] || "无";
  871. this.threePeriodIndex = this.threePeriodOptions.findIndex((item) => item === this.formData.threePeriod);
  872. }
  873. this.formData.expectedSalary = profile.expected_salary || "";
  874. this.formData.emergencyContact = profile.emergency_contact || "";
  875. this.formData.emergencyPhone = profile.emergency_phone || "";
  876. this.formData.hobby = profile.specialties || "";
  877. this.formData.motto = profile.life_motto || "";
  878. const sourceTypeMap = {
  879. 1: "school",
  880. 2: "social",
  881. 3: "social",
  882. 4: "social",
  883. 5: "social"
  884. };
  885. const socialSourceMap = {
  886. 2: "BOSS",
  887. 3: "zhilian",
  888. 4: "liepin",
  889. 5: "other"
  890. };
  891. this.formData.sourceType = sourceTypeMap[profile.recruitment_source] || "social";
  892. if (this.formData.sourceType === "social") {
  893. this.formData.socialSource = socialSourceMap[profile.recruitment_source] || "";
  894. if (this.formData.socialSource === "other") {
  895. this.formData.otherSocialSource = profile.recruitment_source_detail || "";
  896. }
  897. } else if (this.formData.sourceType === "school") {
  898. this.formData.otherSchoolSource = profile.recruitment_source_detail || "";
  899. }
  900. }
  901. if (educations && educations.length > 0) {
  902. this.educationList = educations.map((edu) => {
  903. const degreeMap = {
  904. 1: "高中",
  905. 2: "大专",
  906. 3: "本科",
  907. 4: "硕士",
  908. 5: "博士"
  909. };
  910. return {
  911. startTime: edu.start_date || "",
  912. endTime: edu.end_date || "",
  913. schoolName: edu.school_name || "",
  914. major: edu.major || "",
  915. degree: degreeMap[edu.degree] || ""
  916. };
  917. });
  918. }
  919. if (work_experiences && work_experiences.length > 0) {
  920. this.workList = work_experiences.map((work) => {
  921. return {
  922. startTime: work.start_date || "",
  923. endTime: work.end_date || "",
  924. companyName: work.company_name || "",
  925. department: work.department || "",
  926. employeeCount: work.company_size || "",
  927. position: work.position || "",
  928. monthlySalary: work.monthly_salary || "",
  929. supervisor: work.supervisor_name || "",
  930. supervisorPhone: work.supervisor_phone || ""
  931. };
  932. });
  933. }
  934. if (family_members && family_members.length > 0) {
  935. this.familyMembers = family_members.map((member) => {
  936. return {
  937. relation: member.relation || "",
  938. name: member.name || "",
  939. workplaceOrAddress: member.workplace || "",
  940. position: member.position || "",
  941. phone: member.phone || "",
  942. isEmergencyContact: member.isEmergencyContact || false
  943. };
  944. });
  945. }
  946. },
  947. // 处理紧急联系人开关变化
  948. handleEmergencyContactChange(e) {
  949. this.familyMemberForm.isEmergencyContact = e.detail.value;
  950. if (e.detail.value) {
  951. this.formData.emergencyContact = this.familyMemberForm.name;
  952. this.formData.emergencyPhone = this.familyMemberForm.phone;
  953. }
  954. }
  955. },
  956. // 添加监听器来清除错误信息
  957. watch: {
  958. "formData.name": function(newVal) {
  959. if (newVal && this.formErrors.name) {
  960. this.formErrors.name = "";
  961. }
  962. },
  963. "formData.idCard": function(newVal) {
  964. if (newVal && this.formErrors.idCard) {
  965. this.formErrors.idCard = "";
  966. }
  967. },
  968. "formData.phone": function(newVal) {
  969. if (newVal && this.formErrors.phone) {
  970. this.formErrors.phone = "";
  971. }
  972. }
  973. }
  974. };
  975. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  976. return common_vendor.e({
  977. a: $data.isLoading
  978. }, $data.isLoading ? {} : {}, {
  979. b: $data.showPromiseModal
  980. }, $data.showPromiseModal ? {
  981. c: $data.promiseChecked,
  982. d: common_vendor.o((...args) => $options.togglePromiseChecked && $options.togglePromiseChecked(...args)),
  983. e: !$data.promiseChecked,
  984. f: common_vendor.o((...args) => $options.confirmPromise && $options.confirmPromise(...args))
  985. } : {}, {
  986. g: $data.currentStep === 1
  987. }, $data.currentStep === 1 ? common_vendor.e({
  988. h: $data.formErrors.name ? 1 : "",
  989. i: $data.formData.name,
  990. j: common_vendor.o(($event) => $data.formData.name = $event.detail.value),
  991. k: $data.formErrors.name
  992. }, $data.formErrors.name ? {
  993. l: common_vendor.t($data.formErrors.name)
  994. } : {}, {
  995. m: common_vendor.t($data.genderOptions[$data.genderIndex] || "请选择性别"),
  996. n: common_vendor.o((...args) => $options.bindGenderChange && $options.bindGenderChange(...args)),
  997. o: $data.genderIndex,
  998. p: $data.genderOptions,
  999. q: $data.formData.gender === "女"
  1000. }, $data.formData.gender === "女" ? {
  1001. r: common_vendor.t($data.threePeriodOptions[$data.threePeriodIndex] || "请选择"),
  1002. s: common_vendor.o((...args) => $options.bindThreePeriodChange && $options.bindThreePeriodChange(...args)),
  1003. t: $data.threePeriodIndex,
  1004. v: $data.threePeriodOptions
  1005. } : {}, {
  1006. w: $data.formErrors.phone ? 1 : "",
  1007. x: $data.formData.phone,
  1008. y: common_vendor.o(($event) => $data.formData.phone = $event.detail.value),
  1009. z: $data.formErrors.phone
  1010. }, $data.formErrors.phone ? {
  1011. A: common_vendor.t($data.formErrors.phone)
  1012. } : {}, {
  1013. B: $data.formErrors.idCard ? 1 : "",
  1014. C: $data.formData.idCard,
  1015. D: common_vendor.o(($event) => $data.formData.idCard = $event.detail.value),
  1016. E: $data.formErrors.idCard
  1017. }, $data.formErrors.idCard ? {
  1018. F: common_vendor.t($data.formErrors.idCard)
  1019. } : {}, {
  1020. G: common_vendor.t($data.ethnicOptions[$data.ethnicIndex] || "请选择民族"),
  1021. H: common_vendor.o((...args) => $options.bindEthnicChange && $options.bindEthnicChange(...args)),
  1022. I: $data.ethnicIndex,
  1023. J: $data.ethnicOptions,
  1024. K: $data.formData.height,
  1025. L: common_vendor.o(($event) => $data.formData.height = $event.detail.value),
  1026. M: $data.formData.weight,
  1027. N: common_vendor.o(($event) => $data.formData.weight = $event.detail.value),
  1028. O: $data.formData.currentAddress,
  1029. P: common_vendor.o(($event) => $data.formData.currentAddress = $event.detail.value),
  1030. Q: $data.formData.residence,
  1031. R: common_vendor.o(($event) => $data.formData.residence = $event.detail.value),
  1032. S: common_vendor.t($data.marriageOptions[$data.marriageIndex] || "请选择婚育状况"),
  1033. T: common_vendor.o((...args) => $options.bindMarriageChange && $options.bindMarriageChange(...args)),
  1034. U: $data.marriageIndex,
  1035. V: $data.marriageOptions,
  1036. W: $data.formData.expectedSalary,
  1037. X: common_vendor.o(($event) => $data.formData.expectedSalary = $event.detail.value)
  1038. }) : {}, {
  1039. Y: $data.currentStep === 3
  1040. }, $data.currentStep === 3 ? common_vendor.e({
  1041. Z: $data.familyMembers.length > 0
  1042. }, $data.familyMembers.length > 0 ? {
  1043. aa: common_vendor.f($data.familyMembers, (member, index, i0) => {
  1044. return {
  1045. a: common_vendor.t(index + 1),
  1046. b: common_vendor.o(($event) => $options.editFamilyMember(index), index),
  1047. c: common_vendor.o(($event) => $options.deleteFamilyMember(index), index),
  1048. d: common_vendor.t(member.relation),
  1049. e: common_vendor.t(member.name),
  1050. f: common_vendor.t(member.workplaceOrAddress),
  1051. g: common_vendor.t(member.position),
  1052. h: common_vendor.t(member.phone),
  1053. i: common_vendor.t(member.isEmergencyContact ? "是" : "否"),
  1054. j: index
  1055. };
  1056. })
  1057. } : {}, {
  1058. ab: common_vendor.t($data.isEditing ? "编辑家庭成员" : "添加家庭成员"),
  1059. ac: $data.isEditing
  1060. }, $data.isEditing ? {
  1061. ad: common_vendor.o((...args) => $options.cancelEdit && $options.cancelEdit(...args))
  1062. } : {}, {
  1063. ae: $data.familyMemberForm.relation,
  1064. af: common_vendor.o(($event) => $data.familyMemberForm.relation = $event.detail.value),
  1065. ag: $data.familyMemberForm.name,
  1066. ah: common_vendor.o(($event) => $data.familyMemberForm.name = $event.detail.value),
  1067. ai: $data.familyMemberForm.workplaceOrAddress,
  1068. aj: common_vendor.o(($event) => $data.familyMemberForm.workplaceOrAddress = $event.detail.value),
  1069. ak: $data.familyMemberForm.position,
  1070. al: common_vendor.o(($event) => $data.familyMemberForm.position = $event.detail.value),
  1071. am: $data.familyMemberForm.phone,
  1072. an: common_vendor.o(($event) => $data.familyMemberForm.phone = $event.detail.value),
  1073. ao: $data.familyMemberForm.isEmergencyContact,
  1074. ap: common_vendor.o((...args) => $options.handleEmergencyContactChange && $options.handleEmergencyContactChange(...args)),
  1075. aq: common_vendor.t($data.isEditing ? "✓" : "+"),
  1076. ar: common_vendor.o((...args) => $options.saveFamilyMember && $options.saveFamilyMember(...args)),
  1077. as: common_vendor.t($data.isEditing ? "保存修改" : "添加成员")
  1078. }) : {}, {
  1079. at: $data.currentStep === 5
  1080. }, $data.currentStep === 5 ? common_vendor.e({
  1081. av: $data.educationList.length > 0
  1082. }, $data.educationList.length > 0 ? {
  1083. aw: common_vendor.f($data.educationList, (edu, index, i0) => {
  1084. return {
  1085. a: common_vendor.t(index === 0 ? "第一学历" : "最高学历"),
  1086. b: common_vendor.o(($event) => $options.editEducation(index), index),
  1087. c: common_vendor.o(($event) => $options.deleteEducation(index), index),
  1088. d: common_vendor.t(edu.startTime),
  1089. e: common_vendor.t(edu.endTime),
  1090. f: common_vendor.t(edu.schoolName),
  1091. g: common_vendor.t(edu.major),
  1092. h: common_vendor.t(edu.degree),
  1093. i: index
  1094. };
  1095. })
  1096. } : {}, {
  1097. ax: $data.educationList.length < 2 || $data.isEditingEducation
  1098. }, $data.educationList.length < 2 || $data.isEditingEducation ? common_vendor.e({
  1099. ay: common_vendor.t($data.isEditingEducation ? "编辑教育经历" : $data.educationList.length === 0 ? "添加第一学历" : "添加最高学历"),
  1100. az: $data.isEditingEducation
  1101. }, $data.isEditingEducation ? {
  1102. aA: common_vendor.o((...args) => $options.cancelEditEducation && $options.cancelEditEducation(...args))
  1103. } : {}, {
  1104. aB: common_vendor.t($data.educationForm.startTime || "开始时间"),
  1105. aC: $data.educationForm.startTime,
  1106. aD: common_vendor.o((...args) => $options.bindStartTimeChange && $options.bindStartTimeChange(...args)),
  1107. aE: common_vendor.t($data.educationForm.endTime || "结束时间"),
  1108. aF: $data.educationForm.endTime,
  1109. aG: common_vendor.o((...args) => $options.bindEndTimeChange && $options.bindEndTimeChange(...args)),
  1110. aH: $data.educationForm.schoolName,
  1111. aI: common_vendor.o(($event) => $data.educationForm.schoolName = $event.detail.value),
  1112. aJ: $data.educationForm.major,
  1113. aK: common_vendor.o(($event) => $data.educationForm.major = $event.detail.value),
  1114. aL: common_vendor.t($data.degreeOptions[$data.degreeIndex] || "请选择学历"),
  1115. aM: common_vendor.o((...args) => $options.bindDegreeChange && $options.bindDegreeChange(...args)),
  1116. aN: $data.degreeIndex,
  1117. aO: $data.degreeOptions,
  1118. aP: common_vendor.t($data.isEditingEducation ? "✓" : "+"),
  1119. aQ: common_vendor.o((...args) => $options.saveEducation && $options.saveEducation(...args)),
  1120. aR: common_vendor.t($data.isEditingEducation ? "保存修改" : "添加学历")
  1121. }) : {}) : {}, {
  1122. aS: $data.currentStep === 6
  1123. }, $data.currentStep === 6 ? {
  1124. aT: $data.formData.skills,
  1125. aU: common_vendor.o(($event) => $data.formData.skills = $event.detail.value),
  1126. aV: $data.formData.training,
  1127. aW: common_vendor.o(($event) => $data.formData.training = $event.detail.value)
  1128. } : {}, {
  1129. aX: $data.currentStep === 8
  1130. }, $data.currentStep === 8 ? common_vendor.e({
  1131. aY: $data.workList.length > 0
  1132. }, $data.workList.length > 0 ? {
  1133. aZ: common_vendor.f($data.workList, (work, index, i0) => {
  1134. return {
  1135. a: common_vendor.t(index + 1),
  1136. b: common_vendor.o(($event) => $options.editWork(index), index),
  1137. c: common_vendor.o(($event) => $options.deleteWork(index), index),
  1138. d: common_vendor.t(work.startTime),
  1139. e: common_vendor.t(work.endTime),
  1140. f: common_vendor.t(work.companyName),
  1141. g: common_vendor.t(work.department),
  1142. h: common_vendor.t(work.employeeCount),
  1143. i: common_vendor.t(work.position),
  1144. j: common_vendor.t(work.monthlySalary),
  1145. k: common_vendor.t(work.supervisor),
  1146. l: common_vendor.t(work.supervisorPhone),
  1147. m: index
  1148. };
  1149. })
  1150. } : {}, {
  1151. ba: $data.workList.length < 2 || $data.isEditingWork
  1152. }, $data.workList.length < 2 || $data.isEditingWork ? common_vendor.e({
  1153. bb: common_vendor.t($data.isEditingWork ? "编辑工作经历" : "添加工作经历"),
  1154. bc: $data.isEditingWork
  1155. }, $data.isEditingWork ? {
  1156. bd: common_vendor.o((...args) => $options.cancelEditWork && $options.cancelEditWork(...args))
  1157. } : {}, {
  1158. be: common_vendor.t($data.workForm.startTime || "开始时间"),
  1159. bf: $data.workForm.startTime,
  1160. bg: common_vendor.o((...args) => $options.bindWorkStartTimeChange && $options.bindWorkStartTimeChange(...args)),
  1161. bh: common_vendor.t($data.workForm.endTime || "结束时间"),
  1162. bi: $data.workForm.endTime,
  1163. bj: common_vendor.o((...args) => $options.bindWorkEndTimeChange && $options.bindWorkEndTimeChange(...args)),
  1164. bk: $data.workForm.companyName,
  1165. bl: common_vendor.o(($event) => $data.workForm.companyName = $event.detail.value),
  1166. bm: $data.workForm.employeeCount,
  1167. bn: common_vendor.o(($event) => $data.workForm.employeeCount = $event.detail.value),
  1168. bo: $data.workForm.department,
  1169. bp: common_vendor.o(($event) => $data.workForm.department = $event.detail.value),
  1170. bq: $data.workForm.position,
  1171. br: common_vendor.o(($event) => $data.workForm.position = $event.detail.value),
  1172. bs: $data.workForm.monthlySalary,
  1173. bt: common_vendor.o(($event) => $data.workForm.monthlySalary = $event.detail.value),
  1174. bv: $data.workForm.supervisor,
  1175. bw: common_vendor.o(($event) => $data.workForm.supervisor = $event.detail.value),
  1176. bx: $data.workForm.supervisorPhone,
  1177. by: common_vendor.o(($event) => $data.workForm.supervisorPhone = $event.detail.value),
  1178. bz: common_vendor.t($data.isEditingWork ? "✓" : "+"),
  1179. bA: common_vendor.o((...args) => $options.saveWork && $options.saveWork(...args)),
  1180. bB: common_vendor.t($data.isEditingWork ? "保存修改" : "添加工作经历")
  1181. }) : {}) : {}, {
  1182. bC: $options.showPrevButton
  1183. }, $options.showPrevButton ? {
  1184. bD: common_vendor.o((...args) => $options.prevStep && $options.prevStep(...args))
  1185. } : {}, {
  1186. bE: $options.showNextButton
  1187. }, $options.showNextButton ? {
  1188. bF: common_vendor.o((...args) => $options.nextStep && $options.nextStep(...args))
  1189. } : {}, {
  1190. bG: $options.showSubmitButton
  1191. }, $options.showSubmitButton ? {
  1192. bH: common_vendor.o((...args) => $options.submitForm && $options.submitForm(...args))
  1193. } : {});
  1194. }
  1195. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  1196. wx.createPage(MiniProgramPage);