"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const api_student = require("../../api/student.js"); const utils_request = require("../../utils/request.js"); if (!Math) { CustomTabbar(); } const CustomTabbar = () => "../../components/custom-tabbar/custom-tabbar.js"; const _sfc_main = { __name: "my", setup(__props) { const navFullHeight = common_vendor.ref(80); const showResumeModal = common_vendor.ref(false); const studentInfo = common_vendor.ref({ id: null, name: "", avatarUrl: "", schoolName: "", education: "", educationLabel: "", jobType: "", jobTypeLabel: "", resumeFile: null, educationList: [] // 教育经历列表 }); const educationLabel = common_vendor.computed(() => { if (studentInfo.value.educationList && studentInfo.value.educationList.length > 0) { const educationLevel = { "初中及以下": 1, "高中": 2, "中专": 2, "大专": 3, "本科": 4, "硕士": 5, "博士": 6 }; let highestEdu = studentInfo.value.educationList[0]; let maxLevel = educationLevel[highestEdu.education] || 0; for (const edu of studentInfo.value.educationList) { const level = educationLevel[edu.education] || 0; if (level > maxLevel) { maxLevel = level; highestEdu = edu; } } return highestEdu.education || ""; } if (studentInfo.value.educationLabel) return studentInfo.value.educationLabel; const val = studentInfo.value.education; if (!val || val === "0" || val === 0) return ""; return /^\d+$/.test(String(val)) ? "" : val; }); const jobTypeMap = { "1": "全职", "2": "实习", "3": "兼职", "全职": "全职", "实习": "实习", "兼职": "兼职" }; const jobTypeLabel = common_vendor.computed(() => { if (studentInfo.value.jobTypeLabel) return studentInfo.value.jobTypeLabel; const val = studentInfo.value.jobType; return jobTypeMap[val] || val || ""; }); const schoolNameLabel = common_vendor.computed(() => { if (studentInfo.value.educationList && studentInfo.value.educationList.length > 0) { const educationLevel = { "初中及以下": 1, "高中": 2, "中专": 2, "大专": 3, "本科": 4, "硕士": 5, "博士": 6 }; let highestEdu = studentInfo.value.educationList[0]; let maxLevel = educationLevel[highestEdu.education] || 0; for (const edu of studentInfo.value.educationList) { const level = educationLevel[edu.education] || 0; if (level > maxLevel) { maxLevel = level; highestEdu = edu; } } return highestEdu.school || ""; } const val = studentInfo.value.schoolName; if (!val || /^\d+$/.test(val)) return ""; return val; }); const hasResume = common_vendor.computed(() => !!studentInfo.value.resumeFile); const loadUserInfo = async () => { const userInfo = common_vendor.index.getStorageSync("userInfo"); if (!userInfo || !userInfo.studentId) return; try { const res = await api_student.getStudent(userInfo.studentId); if (res && res.data) { const data = res.data; studentInfo.value = { id: data.id, name: data.name || userInfo.name || "", avatarUrl: data.avatarUrl || userInfo.avatarUrl || "", schoolName: data.schoolName || "", education: data.education || "", educationLabel: data.educationLabel || "", jobType: data.jobType || "", jobTypeLabel: data.jobTypeLabel || "", resumeFile: data.resumeFile || null, educationList: data.educationList || [] }; } } catch (err) { common_vendor.index.__f__("error", "at pages/my/my.vue:230", "获取用户详情失败", err); } fetchAppendixList(); }; common_vendor.onMounted(async () => { try { const menuButton = common_vendor.index.getMenuButtonBoundingClientRect(); if (menuButton) { navFullHeight.value = menuButton.bottom + 10; } } catch (e) { common_vendor.index.__f__("error", "at pages/my/my.vue:243", "导航栏高度计算失败", e); } const userInfo = common_vendor.index.getStorageSync("userInfo"); if (!userInfo || !userInfo.studentId) { common_vendor.index.reLaunch({ url: "/pages/login/login" }); return; } studentInfo.value.id = userInfo.studentId; studentInfo.value.name = userInfo.name || ""; studentInfo.value.avatarUrl = userInfo.avatarUrl || ""; await loadUserInfo(); }); common_vendor.onShow(async () => { const userInfo = common_vendor.index.getStorageSync("userInfo"); if (userInfo && userInfo.studentId) { await loadUserInfo(); } }); common_vendor.onPullDownRefresh(async () => { await loadUserInfo(); common_vendor.index.stopPullDownRefresh(); }); const fetchAppendixList = async () => { try { const userInfo = common_vendor.index.getStorageSync("userInfo"); if (userInfo && userInfo.studentId) { const res = await api_student.getAppendixList(userInfo.studentId); if (res && res.code === 200) { resumeList.value = res.data.map((item) => ({ id: item.id, name: item.fileName, url: item.url, ossId: item.ossId })); } } } catch (err) { common_vendor.index.__f__("error", "at pages/my/my.vue:292", "获取附件列表失败", err); } }; const handleOnlineResume = () => { if (!hasResume.value) { showResumeModal.value = true; } else { common_vendor.index.navigateTo({ url: "/pages/my/resume_view" }); } }; const confirmToFill = () => { showResumeModal.value = false; common_vendor.index.navigateTo({ url: "/pages/profile/profile?editMode=1" }); }; const navigateTo = (type) => { const routes = { "collection": "/pages/my/favorites", "intention": "/pages/intention/intention?editMode=1", "assessment": "/pages/my/assessment-records", "order": "/pages/my/orders" }; if (routes[type]) { common_vendor.index.navigateTo({ url: routes[type] }); } }; const handleOffer = () => { common_vendor.index.navigateTo({ url: "/pages/my/offer" }); }; const handlePrivacy = () => { common_vendor.index.navigateTo({ url: "/pages/my/privacy_policy" }); }; const resumeList = common_vendor.ref([]); const uploadFromWechat = () => { if (resumeList.value.length >= 3) { common_vendor.index.showToast({ title: "最多上传3份简历", icon: "none" }); return; } common_vendor.index.chooseMessageFile({ count: 1, type: "file", extension: ["pdf"], success: (res) => { const file = res.tempFiles[0]; processUpload(file.name, file.path, file.size); } }); }; const uploadFromLocal = () => { uploadFromWechat(); }; const processUpload = (name, path, size) => { if (!name.toLowerCase().endsWith(".pdf")) { common_vendor.index.showToast({ title: "仅支持 PDF 格式文件", icon: "none" }); return; } common_vendor.index.showLoading({ title: "上传中..." }); const baseUrl = utils_request.UPLOAD_URL; common_vendor.index.uploadFile({ url: baseUrl + "/portal/oss/upload", filePath: path, name: "file", header: { "Authorization": common_vendor.index.getStorageSync("token") ? `Bearer ${common_vendor.index.getStorageSync("token")}` : "", "PLATFORM_CODE": "PINGTAIDUAN" }, success: async (uploadRes) => { const uploadData = JSON.parse(uploadRes.data); if (uploadData.code === 200) { const ossId = uploadData.data.ossId; try { const userInfo = common_vendor.index.getStorageSync("userInfo"); const saveRes = await api_student.addAppendix({ studentId: userInfo.studentId, ossId, fileName: name, fileSize: size }); common_vendor.index.hideLoading(); if (saveRes.code === 200) { common_vendor.index.showToast({ title: "上传成功", icon: "success" }); fetchAppendixList(); } else { common_vendor.index.showToast({ title: saveRes.msg || "保存失败", icon: "none" }); } } catch (e) { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: "服务器异常", icon: "none" }); } } else { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: uploadData.msg || "上传失败", icon: "none" }); } }, fail: (err) => { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: "网络上传失败", icon: "none" }); } }); }; const removeResume = (index) => { const target = resumeList.value[index]; common_vendor.index.showModal({ title: "提示", content: "确定要删除这份简历吗?", success: async (res) => { if (res.confirm) { try { common_vendor.index.showLoading({ title: "删除中..." }); const delRes = await api_student.removeAppendix(target.id); common_vendor.index.hideLoading(); if (delRes.code === 200) { resumeList.value.splice(index, 1); common_vendor.index.showToast({ title: "已删除", icon: "none" }); } else { common_vendor.index.showToast({ title: delRes.msg || "删除失败", icon: "none" }); } } catch (e) { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: "网络异常", icon: "none" }); } } } }); }; const handleLogout = () => { common_vendor.index.showModal({ title: "提示", content: "确定要退出登录吗?", success: (res) => { if (res.confirm) { common_vendor.index.removeStorageSync("token"); common_vendor.index.removeStorageSync("userInfo"); common_vendor.index.reLaunch({ url: "/pages/login/login" }); } } }); }; return (_ctx, _cache) => { return common_vendor.e({ a: navFullHeight.value + "px", b: studentInfo.value.avatarUrl || "/static/images/hr_avatar.svg", c: common_vendor.t(studentInfo.value.name || "加载中..."), d: common_assets._imports_0$10, e: common_assets._imports_0$11, f: common_vendor.o(handleOnlineResume), g: schoolNameLabel.value }, schoolNameLabel.value ? { h: common_vendor.t(schoolNameLabel.value) } : {}, { i: educationLabel.value }, educationLabel.value ? { j: common_vendor.t(educationLabel.value) } : {}, { k: jobTypeLabel.value }, jobTypeLabel.value ? { l: common_vendor.t(jobTypeLabel.value) } : {}, { m: common_assets._imports_2$5, n: common_vendor.o(($event) => navigateTo("collection")), o: common_assets._imports_3$3, p: common_vendor.o(($event) => navigateTo("intention")), q: common_assets._imports_4$1, r: common_vendor.o(($event) => navigateTo("assessment")), s: common_assets._imports_5$1, t: common_vendor.o(($event) => navigateTo("order")), v: common_vendor.t(resumeList.value.length), w: common_vendor.o(uploadFromWechat), x: common_vendor.o(uploadFromLocal), y: resumeList.value.length > 0 }, resumeList.value.length > 0 ? { z: common_vendor.f(resumeList.value, (file, idx, i0) => { return { a: common_vendor.t(file.name), b: common_vendor.o(($event) => removeResume(idx), file.id), c: file.id }; }), A: common_assets._imports_0$9, B: common_assets._imports_7$1 } : {}, { C: common_assets._imports_8, D: common_vendor.o(handleOffer), E: common_assets._imports_8, F: common_vendor.o(handlePrivacy), G: common_vendor.o(handleLogout), H: showResumeModal.value }, showResumeModal.value ? { I: common_vendor.o(($event) => showResumeModal.value = false), J: common_vendor.o(confirmToFill), K: common_vendor.o(() => { }) } : {}, { L: common_vendor.p({ activeIndex: 3 }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2f1ef635"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/my/my.js.map