| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- "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$9,
- e: common_assets._imports_0$10,
- 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$4,
- 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_3$3,
- 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
|