"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const api_student = require("../../api/student.js"); const api_assessment = require("../../api/assessment.js"); const _sfc_main = { __name: "select-resume", setup(__props) { const isLoading = common_vendor.ref(true); const delivering = common_vendor.ref(false); const resumeList = common_vendor.ref([]); const selectedOssId = common_vendor.ref(null); const postId = common_vendor.ref(null); common_vendor.onLoad((options) => { if (options.postId) { postId.value = options.postId; } fetchResumeList(); }); const fetchResumeList = async () => { try { isLoading.value = true; const userInfo = common_vendor.index.getStorageSync("userInfo"); if (!userInfo || !userInfo.studentId) { common_vendor.index.showToast({ title: "请先登录", icon: "none" }); setTimeout(() => { common_vendor.index.navigateTo({ url: "/pages/login/login" }); }, 1e3); return; } 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, fileSize: item.fileSize })); if (resumeList.value.length > 0) { selectedOssId.value = resumeList.value[0].ossId; } } } catch (err) { common_vendor.index.__f__("error", "at pages/my/select-resume.vue:107", "获取简历列表失败:", err); common_vendor.index.showToast({ title: "获取简历列表失败", icon: "none" }); } finally { isLoading.value = false; } }; const selectResume = (item) => { selectedOssId.value = item.ossId; }; const formatFileSize = (size) => { if (!size) return ""; if (size < 1024) return size + "B"; if (size < 1024 * 1024) return (size / 1024).toFixed(1) + "KB"; return (size / (1024 * 1024)).toFixed(1) + "MB"; }; const handleDeliver = async () => { if (!selectedOssId.value || delivering.value) return; const userInfo = common_vendor.index.getStorageSync("userInfo"); if (!userInfo || !userInfo.studentId) { common_vendor.index.showToast({ title: "请先登录", icon: "none" }); return; } try { delivering.value = true; common_vendor.index.showLoading({ title: "投递中..." }); const res = await api_assessment.applyPosition({ postId: postId.value, resumeOssId: selectedOssId.value }); common_vendor.index.hideLoading(); if (res.code === 200) { common_vendor.index.setStorageSync(`candidate_applied_${postId.value}`, true); common_vendor.index.showToast({ title: "投递成功", icon: "success" }); setTimeout(() => { const pages = getCurrentPages(); if (pages.length > 1) { common_vendor.index.$emit("resume_delivered", { postId: postId.value }); common_vendor.index.navigateBack(); } }, 1500); } else if (res.msg && res.msg.includes("已投递")) { common_vendor.index.setStorageSync(`candidate_applied_${postId.value}`, true); common_vendor.index.showToast({ title: "您已投递过该岗位", icon: "none" }); setTimeout(() => { common_vendor.index.$emit("resume_delivered", { postId: postId.value }); common_vendor.index.navigateBack(); }, 1500); } else { common_vendor.index.showToast({ title: res.msg || "投递失败", icon: "none" }); } } catch (err) { common_vendor.index.hideLoading(); common_vendor.index.__f__("error", "at pages/my/select-resume.vue:166", "投递失败:", err); const errMsg = String((err == null ? void 0 : err.msg) || (err == null ? void 0 : err.message) || ""); if (errMsg.includes("已投递")) { common_vendor.index.setStorageSync(`candidate_applied_${postId.value}`, true); common_vendor.index.showToast({ title: "您已投递过该岗位", icon: "none" }); setTimeout(() => { common_vendor.index.$emit("resume_delivered", { postId: postId.value }); common_vendor.index.navigateBack(); }, 1500); } else { common_vendor.index.showToast({ title: "网络错误,投递失败", icon: "none" }); } } finally { delivering.value = false; } }; const goToUpload = () => { common_vendor.index.navigateBack(); }; return (_ctx, _cache) => { return common_vendor.e({ a: isLoading.value }, isLoading.value ? {} : resumeList.value.length > 0 ? { c: common_vendor.f(resumeList.value, (item, idx, i0) => { return common_vendor.e({ a: common_vendor.t(item.name), b: item.fileSize }, item.fileSize ? { c: common_vendor.t(formatFileSize(item.fileSize)) } : {}, { d: selectedOssId.value === item.ossId }, selectedOssId.value === item.ossId ? {} : {}, { e: selectedOssId.value === item.ossId ? 1 : "", f: item.id, g: common_vendor.o(($event) => selectResume(item), item.id) }); }), d: common_assets._imports_0$9 } : common_vendor.e({}, { f: common_vendor.o(goToUpload) }), { b: resumeList.value.length > 0, g: resumeList.value.length > 0 }, resumeList.value.length > 0 ? { h: common_vendor.t(delivering.value ? "投递中..." : "确认投递"), i: !selectedOssId.value ? 1 : "", j: common_vendor.o(handleDeliver) } : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4778e1e1"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/my/select-resume.js.map