resume_view.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const common_assets = require("../../common/assets.js");
  4. const api_student = require("../../api/student.js");
  5. const _sfc_main = {
  6. __name: "resume_view",
  7. setup(__props) {
  8. const studentData = common_vendor.ref({
  9. name: "",
  10. mobile: "",
  11. email: "",
  12. gender: "",
  13. genderLabel: "",
  14. idCardNumber: "",
  15. avatarUrl: "",
  16. schoolName: "",
  17. education: "",
  18. educationLabel: "",
  19. availabilityLabel: "",
  20. jobType: "",
  21. jobTypeLabel: "",
  22. availability: "",
  23. jobIntention: "",
  24. educationList: [],
  25. experienceList: [],
  26. projectList: []
  27. });
  28. const isLoading = common_vendor.ref(true);
  29. const educationMap = {
  30. "1": "初中及以下",
  31. "2": "高中/中专",
  32. "3": "大专",
  33. "4": "本科",
  34. "5": "硕士",
  35. "6": "博士"
  36. };
  37. const jobTypeMap = {
  38. "1": "全职",
  39. "2": "实习",
  40. "3": "兼职"
  41. };
  42. const genderMap = {
  43. "0": "男",
  44. "1": "女",
  45. "2": "未知"
  46. };
  47. const normalizeGenderValue = (value) => {
  48. if (value === void 0 || value === null || value === "")
  49. return "";
  50. const gender = String(value).trim().toUpperCase();
  51. if (gender === "M")
  52. return "0";
  53. if (gender === "F")
  54. return "1";
  55. return gender;
  56. };
  57. const educationLabel = common_vendor.computed(() => {
  58. if (studentData.value.educationList && studentData.value.educationList.length > 0) {
  59. const educationLevel = { "初中及以下": 1, "高中": 2, "中专": 2, "大专": 3, "本科": 4, "硕士": 5, "博士": 6 };
  60. let highestEdu = studentData.value.educationList[0];
  61. let maxLevel = educationLevel[highestEdu.education] || 0;
  62. for (const edu of studentData.value.educationList) {
  63. const level = educationLevel[edu.education] || 0;
  64. if (level > maxLevel) {
  65. maxLevel = level;
  66. highestEdu = edu;
  67. }
  68. }
  69. const label = highestEdu.education || "";
  70. return label + (highestEdu.educationType ? " · " + highestEdu.educationType : "");
  71. }
  72. if (studentData.value.educationLabel)
  73. return studentData.value.educationLabel;
  74. const val = studentData.value.education;
  75. if (!val || val === "0" || val === 0)
  76. return "";
  77. return educationMap[val] || (/^\d+$/.test(String(val)) ? "" : val);
  78. });
  79. const jobTypeLabel = common_vendor.computed(() => {
  80. if (studentData.value.jobTypeLabel)
  81. return studentData.value.jobTypeLabel;
  82. const val = studentData.value.jobType;
  83. if (!val)
  84. return "";
  85. return jobTypeMap[val] || val;
  86. });
  87. const availabilityLabel = common_vendor.computed(() => {
  88. return studentData.value.availabilityLabel || studentData.value.availability || "";
  89. });
  90. const genderLabel = common_vendor.computed(() => {
  91. if (studentData.value.genderLabel)
  92. return studentData.value.genderLabel;
  93. const g = normalizeGenderValue(studentData.value.gender);
  94. if (!g)
  95. return "";
  96. return genderMap[g] || g;
  97. });
  98. const jobIntentions = common_vendor.computed(() => {
  99. if (!studentData.value.jobIntention)
  100. return [];
  101. const items = studentData.value.jobIntention.split(",").filter((item) => item.trim());
  102. const intentionMap = { "1": "审计", "2": "咨询", "3": "税务", "4": "财务", "5": "评估" };
  103. return items.map((item) => intentionMap[item.trim()] || item.trim());
  104. });
  105. const birthDate = common_vendor.computed(() => {
  106. if (!studentData.value.idCardNumber || studentData.value.idCardNumber.length < 14)
  107. return "";
  108. const year = studentData.value.idCardNumber.substring(6, 10);
  109. const month = studentData.value.idCardNumber.substring(10, 12);
  110. const day = studentData.value.idCardNumber.substring(12, 14);
  111. return `${year}-${month}-${day}`;
  112. });
  113. const workYears = common_vendor.computed(() => {
  114. if (!studentData.value.experienceList || studentData.value.experienceList.length === 0)
  115. return 0;
  116. let totalMonths = 0;
  117. studentData.value.experienceList.forEach((exp) => {
  118. if (exp.startTime && exp.endTime) {
  119. const start = new Date(exp.startTime);
  120. const end = exp.endTime === "至今" ? /* @__PURE__ */ new Date() : new Date(exp.endTime);
  121. const months = (end.getFullYear() - start.getFullYear()) * 12 + (end.getMonth() - start.getMonth());
  122. totalMonths += months;
  123. }
  124. });
  125. return Math.floor(totalMonths / 12);
  126. });
  127. const hasPersonalInfo = common_vendor.computed(() => {
  128. return studentData.value.gender || birthDate.value || educationLabel.value || studentData.value.schoolName;
  129. });
  130. const maskPhone = (phone) => {
  131. if (!phone || phone.length < 11)
  132. return phone;
  133. return phone.substring(0, 3) + "****" + phone.substring(7);
  134. };
  135. const formatTimeRange = (start, end) => {
  136. if (!start)
  137. return "";
  138. const formatDate = (dateStr) => {
  139. if (!dateStr)
  140. return "";
  141. if (dateStr === "至今")
  142. return "至今";
  143. const date = new Date(dateStr);
  144. return `${date.getFullYear()}.${String(date.getMonth() + 1).padStart(2, "0")}`;
  145. };
  146. return `${formatDate(start)} - ${formatDate(end) || "至今"}`;
  147. };
  148. const getEducationLabel = (education) => {
  149. return educationMap[education] || education || "";
  150. };
  151. const handleEditResume = () => {
  152. common_vendor.index.navigateTo({ url: "/pages/profile/profile?editMode=1" });
  153. };
  154. const fetchResumeData = async () => {
  155. const userInfo = common_vendor.index.getStorageSync("userInfo");
  156. if (!userInfo || !userInfo.studentId) {
  157. common_vendor.index.showToast({ title: "请先登录", icon: "none" });
  158. setTimeout(() => {
  159. common_vendor.index.reLaunch({ url: "/pages/login/login" });
  160. }, 1500);
  161. return;
  162. }
  163. try {
  164. isLoading.value = true;
  165. const res = await api_student.getStudent(userInfo.studentId);
  166. if (res && res.data) {
  167. studentData.value = {
  168. ...studentData.value,
  169. ...res.data,
  170. educationList: res.data.educationList || [],
  171. experienceList: res.data.experienceList || [],
  172. projectList: res.data.projectList || []
  173. };
  174. } else {
  175. common_vendor.index.showToast({ title: "获取简历数据失败", icon: "none" });
  176. }
  177. } catch (err) {
  178. common_vendor.index.__f__("error", "at pages/my/resume_view.vue:314", "获取简历数据异常", err);
  179. common_vendor.index.showToast({ title: "网络异常,请重试", icon: "none" });
  180. } finally {
  181. isLoading.value = false;
  182. common_vendor.index.hideLoading();
  183. }
  184. };
  185. common_vendor.onMounted(() => {
  186. fetchResumeData();
  187. });
  188. common_vendor.onShow(() => {
  189. fetchResumeData();
  190. });
  191. return (_ctx, _cache) => {
  192. return common_vendor.e({
  193. a: isLoading.value
  194. }, isLoading.value ? {} : common_vendor.e({
  195. b: common_vendor.t(studentData.value.name || "加载中..."),
  196. c: jobTypeLabel.value && availabilityLabel.value
  197. }, jobTypeLabel.value && availabilityLabel.value ? {
  198. d: common_vendor.t(jobTypeLabel.value),
  199. e: common_vendor.t(availabilityLabel.value)
  200. } : {}, {
  201. f: workYears.value || studentData.value.education || studentData.value.schoolName
  202. }, workYears.value || studentData.value.education || studentData.value.schoolName ? common_vendor.e({
  203. g: workYears.value
  204. }, workYears.value ? {
  205. h: common_vendor.t(workYears.value)
  206. } : {}, {
  207. i: workYears.value && educationLabel.value
  208. }, workYears.value && educationLabel.value ? {} : {}, {
  209. j: educationLabel.value
  210. }, educationLabel.value ? {
  211. k: common_vendor.t(educationLabel.value)
  212. } : {}, {
  213. l: (workYears.value || educationLabel.value) && studentData.value.schoolName
  214. }, (workYears.value || educationLabel.value) && studentData.value.schoolName ? {} : {}, {
  215. m: studentData.value.schoolName
  216. }, studentData.value.schoolName ? {
  217. n: common_vendor.t(studentData.value.schoolName)
  218. } : {}) : {}, {
  219. o: studentData.value.avatarUrl || "/static/images/hr_avatar.svg",
  220. p: studentData.value.mobile
  221. }, studentData.value.mobile ? {
  222. q: common_assets._imports_0$13,
  223. r: common_vendor.t(maskPhone(studentData.value.mobile))
  224. } : {}, {
  225. s: studentData.value.email
  226. }, studentData.value.email ? {
  227. t: common_assets._imports_1$4,
  228. v: common_vendor.t(studentData.value.email)
  229. } : {}, {
  230. w: hasPersonalInfo.value
  231. }, hasPersonalInfo.value ? common_vendor.e({
  232. x: studentData.value.gender
  233. }, studentData.value.gender ? {
  234. y: common_vendor.t(genderLabel.value)
  235. } : {}, {
  236. z: birthDate.value
  237. }, birthDate.value ? {
  238. A: common_vendor.t(birthDate.value)
  239. } : {}, {
  240. B: educationLabel.value
  241. }, educationLabel.value ? {
  242. C: common_vendor.t(educationLabel.value)
  243. } : {}, {
  244. D: studentData.value.schoolName
  245. }, studentData.value.schoolName ? {
  246. E: common_vendor.t(studentData.value.schoolName)
  247. } : {}) : {}, {
  248. F: jobIntentions.value.length > 0
  249. }, jobIntentions.value.length > 0 ? {
  250. G: common_vendor.f(jobIntentions.value, (intent, idx, i0) => {
  251. return {
  252. a: common_vendor.t(intent),
  253. b: idx
  254. };
  255. })
  256. } : {}, {
  257. H: studentData.value.experienceList && studentData.value.experienceList.length > 0
  258. }, studentData.value.experienceList && studentData.value.experienceList.length > 0 ? {
  259. I: common_vendor.f(studentData.value.experienceList, (exp, idx, i0) => {
  260. return common_vendor.e({
  261. a: common_vendor.t(formatTimeRange(exp.startTime, exp.endTime)),
  262. b: common_vendor.t(exp.isHidden === 1 ? "***(已屏蔽)" : exp.company),
  263. c: common_vendor.t(exp.jobTitle),
  264. d: exp.isInternship === 1
  265. }, exp.isInternship === 1 ? {} : {}, {
  266. e: exp.workContent
  267. }, exp.workContent ? {
  268. f: common_vendor.t(exp.workContent)
  269. } : {}, {
  270. g: exp.id || idx
  271. });
  272. })
  273. } : {}, {
  274. J: studentData.value.projectList && studentData.value.projectList.length > 0
  275. }, studentData.value.projectList && studentData.value.projectList.length > 0 ? {
  276. K: common_vendor.f(studentData.value.projectList, (proj, idx, i0) => {
  277. return common_vendor.e({
  278. a: common_vendor.t(proj.projectName),
  279. b: common_vendor.t(formatTimeRange(proj.startTime, proj.endTime)),
  280. c: proj.role
  281. }, proj.role ? {
  282. d: common_vendor.t(proj.role)
  283. } : {}, {
  284. e: proj.description
  285. }, proj.description ? {
  286. f: common_vendor.t(proj.description)
  287. } : {}, {
  288. g: proj.achievement
  289. }, proj.achievement ? {
  290. h: common_vendor.t(proj.achievement)
  291. } : {}, {
  292. i: proj.id || idx
  293. });
  294. })
  295. } : {}, {
  296. L: studentData.value.educationList && studentData.value.educationList.length > 0
  297. }, studentData.value.educationList && studentData.value.educationList.length > 0 ? {
  298. M: common_vendor.f(studentData.value.educationList, (edu, idx, i0) => {
  299. return common_vendor.e({
  300. a: common_vendor.t(edu.school),
  301. b: common_vendor.t(formatTimeRange(edu.startTime, edu.endTime)),
  302. c: edu.major
  303. }, edu.major ? {
  304. d: common_vendor.t(edu.major)
  305. } : {}, {
  306. e: edu.major && (edu.education || edu.educationType)
  307. }, edu.major && (edu.education || edu.educationType) ? {} : {}, {
  308. f: edu.education
  309. }, edu.education ? {
  310. g: common_vendor.t(getEducationLabel(edu.education))
  311. } : {}, {
  312. h: edu.education && edu.educationType
  313. }, edu.education && edu.educationType ? {} : {}, {
  314. i: edu.educationType
  315. }, edu.educationType ? {
  316. j: common_vendor.t(edu.educationType)
  317. } : {}, {
  318. k: edu.campusExperience
  319. }, edu.campusExperience ? {
  320. l: common_vendor.t(edu.campusExperience)
  321. } : {}, {
  322. m: edu.id || idx
  323. });
  324. })
  325. } : {}), {
  326. N: common_vendor.o(handleEditResume)
  327. });
  328. };
  329. }
  330. };
  331. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1763c966"]]);
  332. wx.createPage(MiniProgramPage);
  333. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/my/resume_view.js.map