experience.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const api_student = require("../../api/student.js");
  4. const api_studentEducation = require("../../api/studentEducation.js");
  5. const api_studentExperience = require("../../api/studentExperience.js");
  6. const api_studentProject = require("../../api/studentProject.js");
  7. const common_assets = require("../../common/assets.js");
  8. const StepLayout = () => "../../components/step-layout/step-layout.js";
  9. const _sfc_main = {
  10. components: {
  11. StepLayout
  12. },
  13. setup() {
  14. const educationList = common_vendor.ref([]);
  15. const workList = common_vendor.ref([]);
  16. const projectList = common_vendor.ref([]);
  17. const isEditMode = common_vendor.ref(false);
  18. const loadData = async () => {
  19. const userInfo = common_vendor.index.getStorageSync("userInfo");
  20. const studentId = userInfo ? userInfo.studentId : null;
  21. if (!studentId)
  22. return;
  23. try {
  24. const res = await api_student.getStudent(studentId);
  25. if (res.code === 200 && res.data) {
  26. educationList.value = res.data.educationList || [];
  27. workList.value = res.data.experienceList || [];
  28. projectList.value = res.data.projectList || [];
  29. }
  30. } catch (err) {
  31. common_vendor.index.__f__("error", "at pages/experience/experience.js:32", "加载经历失败", err);
  32. }
  33. };
  34. common_vendor.onMounted(() => {
  35. const options = getCurrentPages()[getCurrentPages().length - 1].options;
  36. if (options && options.editMode === "1") {
  37. isEditMode.value = true;
  38. }
  39. loadData();
  40. common_vendor.index.$on("refresh_experience", () => {
  41. loadData();
  42. });
  43. });
  44. common_vendor.onUnmounted(() => {
  45. common_vendor.index.$off("refresh_experience");
  46. });
  47. const showModal = common_vendor.ref(false);
  48. const modalContent = common_vendor.ref("");
  49. let currentDeleteType = "";
  50. let currentDeleteId = null;
  51. const openModal = (type, content, id) => {
  52. currentDeleteType = type;
  53. modalContent.value = content;
  54. currentDeleteId = id;
  55. showModal.value = true;
  56. };
  57. const closeModal = () => {
  58. showModal.value = false;
  59. };
  60. const confirmDelete = async () => {
  61. common_vendor.index.showLoading({ title: "删除中..." });
  62. try {
  63. if (currentDeleteType === "education") {
  64. await api_studentEducation.delStudentEducation(currentDeleteId);
  65. } else if (currentDeleteType === "work") {
  66. await api_studentExperience.delStudentExperience(currentDeleteId);
  67. } else if (currentDeleteType === "project") {
  68. await api_studentProject.delStudentProject(currentDeleteId);
  69. }
  70. common_vendor.index.showToast({ title: "删除成功", icon: "success" });
  71. loadData();
  72. } catch (err) {
  73. common_vendor.index.showToast({ title: "删除失败", icon: "none" });
  74. } finally {
  75. closeModal();
  76. common_vendor.index.hideLoading();
  77. }
  78. };
  79. const addEducation = () => {
  80. common_vendor.index.navigateTo({ url: "/pages/experience/add-education" });
  81. };
  82. const editEducation = (i) => {
  83. common_vendor.index.setStorageSync("edit_data_education", educationList.value[i]);
  84. common_vendor.index.navigateTo({ url: "/pages/experience/add-education?index=" + i });
  85. };
  86. const deleteEducation = (i) => {
  87. openModal("education", "确定要删除这段教育经历吗?", educationList.value[i].id);
  88. };
  89. const addWork = () => {
  90. common_vendor.index.navigateTo({ url: "/pages/experience/add-work" });
  91. };
  92. const editWork = (i) => {
  93. common_vendor.index.setStorageSync("edit_data_work", workList.value[i]);
  94. common_vendor.index.navigateTo({ url: "/pages/experience/add-work?index=" + i });
  95. };
  96. const deleteWork = (i) => {
  97. openModal("work", "确定要删除这段工作经历吗?", workList.value[i].id);
  98. };
  99. const addProject = () => {
  100. common_vendor.index.navigateTo({ url: "/pages/experience/add-project" });
  101. };
  102. const editProject = (i) => {
  103. common_vendor.index.setStorageSync("edit_data_project", projectList.value[i]);
  104. common_vendor.index.navigateTo({ url: "/pages/experience/add-project?index=" + i });
  105. };
  106. const deleteProject = (i) => {
  107. openModal("project", "确定要删除这段项目经历吗?", projectList.value[i].id);
  108. };
  109. const goNext = () => {
  110. const url = isEditMode.value ? "/pages/intention/intention?editMode=1" : "/pages/intention/intention";
  111. common_vendor.index.navigateTo({ url });
  112. };
  113. const goSkip = () => {
  114. const url = isEditMode.value ? "/pages/intention/intention?editMode=1" : "/pages/intention/intention";
  115. common_vendor.index.navigateTo({ url });
  116. };
  117. return {
  118. educationList,
  119. workList,
  120. projectList,
  121. showModal,
  122. modalContent,
  123. closeModal,
  124. confirmDelete,
  125. addEducation,
  126. editEducation,
  127. deleteEducation,
  128. addWork,
  129. editWork,
  130. deleteWork,
  131. addProject,
  132. editProject,
  133. deleteProject,
  134. goNext,
  135. goSkip,
  136. isEditMode
  137. };
  138. }
  139. };
  140. if (!Array) {
  141. const _easycom_step_layout2 = common_vendor.resolveComponent("step-layout");
  142. _easycom_step_layout2();
  143. }
  144. const _easycom_step_layout = () => "../../components/step-layout/step-layout.js";
  145. if (!Math) {
  146. _easycom_step_layout();
  147. }
  148. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  149. return common_vendor.e({
  150. a: common_vendor.o((...args) => _ctx.addEducation && _ctx.addEducation(...args)),
  151. b: _ctx.educationList.length === 0
  152. }, _ctx.educationList.length === 0 ? {
  153. c: common_assets._imports_0$1
  154. } : {}, {
  155. d: common_vendor.f(_ctx.educationList, (item, index, i0) => {
  156. return common_vendor.e({
  157. a: common_vendor.o(($event) => _ctx.deleteEducation(index), index),
  158. b: common_vendor.t(item.school),
  159. c: common_vendor.t(item.education || item.degree || ""),
  160. d: common_vendor.t((item.education || item.degree) && item.educationType ? "·" : ""),
  161. e: common_vendor.t(item.educationType || ""),
  162. f: common_vendor.t((item.education || item.degree || item.educationType) && item.major ? "·" : ""),
  163. g: common_vendor.t(item.major || ""),
  164. h: item.time || item.startTime
  165. }, item.time || item.startTime ? {
  166. i: common_vendor.t(item.startTime ? item.startTime + "—" + (item.endTime ? item.endTime : "至今") : item.time)
  167. } : {}, {
  168. j: index,
  169. k: common_vendor.o(($event) => _ctx.editEducation(index), index)
  170. });
  171. }),
  172. e: common_vendor.o((...args) => _ctx.addWork && _ctx.addWork(...args)),
  173. f: _ctx.workList.length === 0
  174. }, _ctx.workList.length === 0 ? {
  175. g: common_assets._imports_0$1
  176. } : {}, {
  177. h: common_vendor.f(_ctx.workList, (item, index, i0) => {
  178. return common_vendor.e({
  179. a: common_vendor.o(($event) => _ctx.deleteWork(index), index),
  180. b: common_vendor.t(item.company),
  181. c: item.isHidden === 1 || item.isHidden === true
  182. }, item.isHidden === 1 || item.isHidden === true ? {} : {}, {
  183. d: common_vendor.t(item.positionName || item.position || "工作经历"),
  184. e: item.time || item.startTime
  185. }, item.time || item.startTime ? {
  186. f: common_vendor.t(item.startTime ? item.startTime + "—" + (item.endTime ? item.endTime : "至今") : item.time)
  187. } : {}, {
  188. g: index,
  189. h: common_vendor.o(($event) => _ctx.editWork(index), index)
  190. });
  191. }),
  192. i: common_vendor.o((...args) => _ctx.addProject && _ctx.addProject(...args)),
  193. j: _ctx.projectList.length === 0
  194. }, _ctx.projectList.length === 0 ? {
  195. k: common_assets._imports_0$1
  196. } : {}, {
  197. l: common_vendor.f(_ctx.projectList, (item, index, i0) => {
  198. return common_vendor.e({
  199. a: common_vendor.o(($event) => _ctx.deleteProject(index), index),
  200. b: common_vendor.t(item.name),
  201. c: common_vendor.t(item.role || "项目经历"),
  202. d: item.time || item.startTime
  203. }, item.time || item.startTime ? {
  204. e: common_vendor.t(item.startTime ? item.startTime + "—" + (item.endTime ? item.endTime : "至今") : item.time)
  205. } : {}, {
  206. f: common_vendor.t(item.desc),
  207. g: index,
  208. h: common_vendor.o(($event) => _ctx.editProject(index), index)
  209. });
  210. }),
  211. m: common_vendor.o((...args) => _ctx.closeModal && _ctx.closeModal(...args)),
  212. n: common_vendor.t(_ctx.modalContent),
  213. o: common_vendor.o((...args) => _ctx.closeModal && _ctx.closeModal(...args)),
  214. p: common_vendor.o((...args) => _ctx.confirmDelete && _ctx.confirmDelete(...args)),
  215. q: _ctx.showModal ? 1 : "",
  216. r: common_vendor.o(_ctx.goNext),
  217. s: common_vendor.o(_ctx.goSkip),
  218. t: common_vendor.p({
  219. title: "填写工作经历",
  220. showSkip: !_ctx.isEditMode
  221. })
  222. });
  223. }
  224. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-5164d016"]]);
  225. wx.createPage(MiniProgramPage);
  226. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/experience/experience.js.map