"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const api_position = require("../../api/position.js"); const api_dict = require("../../api/dict.js"); if (!Math) { CustomTabbar(); } const CustomTabbar = () => "../../components/custom-tabbar/custom-tabbar.js"; const _sfc_main = { __name: "jobs", setup(__props) { const getStudentId = () => { const userInfo = common_vendor.index.getStorageSync("userInfo"); if (!userInfo) return null; const id = userInfo.id || userInfo.studentId || null; common_vendor.index.__f__("log", "at pages/jobs/jobs.vue:172", "[getStudentId] userInfo:", JSON.stringify(userInfo), "=> id:", id); return id; }; const statusBarHeight = common_vendor.ref(20); const titleBarMargin = common_vendor.ref(8); const menuButtonHeight = common_vendor.ref(32); const keyword = common_vendor.ref(""); const sortType = common_vendor.ref("comprehensive"); const currentJobType = common_vendor.ref(0); const jobTypeTabs = common_vendor.ref(["全部"]); const jobTypeValue = common_vendor.ref([""]); const loadDicts = () => { api_dict.getDicts("main_position_type").then((res) => { if (res.data && res.data.length > 0) { jobTypeTabs.value = ["全部岗位", ...res.data.map((item) => item.dictLabel)]; jobTypeValue.value = ["", ...res.data.map((item) => item.dictValue)]; } else { jobTypeTabs.value = ["全部岗位", "全职", "实习", "兼职"]; jobTypeValue.value = ["", "0", "1", "2"]; } fetchJobs(true); }); }; const jobList = common_vendor.ref([]); const pageNum = common_vendor.ref(1); const pageSize = common_vendor.ref(10); const hasMore = common_vendor.ref(true); const isLoading = common_vendor.ref(false); const showPopup = common_vendor.ref(false); const activeJob = common_vendor.ref(null); const openFeedbackPopup = (job) => { activeJob.value = job; showPopup.value = true; }; const closePopup = () => { showPopup.value = false; }; const handleDislikePosition = () => { if (!activeJob.value) return; const studentId = getStudentId(); const job = activeJob.value; closePopup(); jobList.value = jobList.value.filter((item) => item.id !== job.id); if (studentId) { api_position.dislikePosition(studentId, job.id).catch(() => { }); } common_vendor.index.showToast({ title: "已屏蔽该岗位", icon: "none" }); }; const handleDislikeCompany = () => { if (!activeJob.value) return; const studentId = getStudentId(); const job = activeJob.value; closePopup(); jobList.value = jobList.value.filter((item) => item.rawTenantId !== job.rawTenantId); if (studentId && job.rawTenantId) { api_position.dislikeCompany(studentId, job.rawTenantId).catch(() => { }); } common_vendor.index.showToast({ title: "已屏蔽该公司", icon: "none" }); }; const filterCriteria = common_vendor.ref({ jobType: "", minSalary: 0, maxSalary: 50, experience: "", education: "" }); const activeFilterCount = common_vendor.computed(() => { let count = 0; if (filterCriteria.value.experience) count++; if (filterCriteria.value.education) count++; if (filterCriteria.value.minSalary > 0 || filterCriteria.value.maxSalary < 50) count++; return count; }); const fetchJobs = (reset = false) => { if (isLoading.value) return; if (reset) { pageNum.value = 1; hasMore.value = true; jobList.value = []; } if (!hasMore.value) return; isLoading.value = true; let postTypeStr = jobTypeValue.value[currentJobType.value] || ""; if (!postTypeStr && filterCriteria.value.jobType) { postTypeStr = filterCriteria.value.jobType; } const params = { pageNum: pageNum.value, pageSize: pageSize.value, postName: keyword.value.trim(), postType: postTypeStr, schoolRequirement: filterCriteria.value.education || "", gradeRequirement: filterCriteria.value.experience || "", minSalary: filterCriteria.value.minSalary, maxSalary: filterCriteria.value.maxSalary }; const currentStudentId = getStudentId(); if (currentStudentId) { params.studentId = currentStudentId; } if (sortType.value === "latest") { params.orderByColumn = "createTime"; params.isAsc = "desc"; } api_position.getPositionList(params).then((res) => { if (res.code === 200) { const rows = res.rows || []; let formattedRows = rows.map((item) => ({ id: item.id, title: item.postName, salaryText: item.salaryRange || "面议", // 使用后端翻译好的 Label 字段(如"全职"、"本科"、"3-5年"),而不是原始字典 value tags: [item.workCity, item.educationRequirementLabel || item.educationRequirement, item.gradeRequirementLabel || item.gradeRequirement].filter(Boolean), isUrgent: item.isUrgent === 1, count: item.recruitNum || 1, deadline: item.registrationEndDate ? item.registrationEndDate.split(" ")[0] : "长期有效", isExpiring: false, company: item.companyName || "平台推荐", rawTenantId: item.tenantId, // 保留原始 tenantId 用于屏蔽公司 location: (item.workProvince || "") + (item.workCity ? "·" + item.workCity : ""), logo: item.companyAvatar || "/static/images/default-company.svg" })); jobList.value = reset ? formattedRows : [...jobList.value, ...formattedRows]; if (jobList.value.length >= res.total || rows.length < pageSize.value) { hasMore.value = formattedRows.length >= pageSize.value; } else { pageNum.value++; } } }).finally(() => { isLoading.value = false; }); }; const loadMore = () => { fetchJobs(false); }; const handleSearch = () => { fetchJobs(true); }; const handleSearchConfirm = () => { if (keyword.value.trim()) { let history = common_vendor.index.getStorageSync("search_history"); if (!history) history = []; else history = JSON.parse(history); history = history.filter((item) => item !== keyword.value.trim()); history.unshift(keyword.value.trim()); if (history.length > 10) history = history.slice(0, 10); common_vendor.index.setStorageSync("search_history", JSON.stringify(history)); } fetchJobs(true); }; common_vendor.watch([currentJobType, sortType], () => { fetchJobs(true); }); const goToFilter = () => { common_vendor.index.navigateTo({ url: "/pages/jobs/filter" }); }; const goToDetail = (item) => { common_vendor.index.navigateTo({ url: "/pages/jobdetail/index?id=" + item.id }); }; const scrollTop = common_vendor.computed(() => { const gradientArea = titleBarMargin.value + menuButtonHeight.value + 8; const whiteArea = 82; return statusBarHeight.value + gradientArea + whiteArea; }); common_vendor.onPullDownRefresh(async () => { await fetchJobs(true); common_vendor.index.stopPullDownRefresh(); }); common_vendor.onMounted(() => { common_vendor.index.$on("updateFilters", (params) => { filterCriteria.value = params; if (params.keyword !== void 0) { keyword.value = params.keyword; } fetchJobs(true); }); loadDicts(); try { const sysInfo = common_vendor.index.getSystemInfoSync(); const menuInfo = common_vendor.index.getMenuButtonBoundingClientRect(); if (sysInfo && menuInfo) { statusBarHeight.value = sysInfo.statusBarHeight || 20; titleBarMargin.value = menuInfo.top - sysInfo.statusBarHeight; menuButtonHeight.value = menuInfo.height; } } catch (e) { } }); common_vendor.onUnmounted(() => { common_vendor.index.$off("updateFilters"); }); common_vendor.onPullDownRefresh(async () => { fetchJobs(true); setTimeout(() => { common_vendor.index.stopPullDownRefresh(); }, 800); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_assets._imports_0$3, b: common_vendor.o(handleSearchConfirm), c: common_vendor.o([($event) => keyword.value = $event.detail.value, handleSearch]), d: keyword.value, e: menuButtonHeight.value + "px", f: statusBarHeight.value + titleBarMargin.value + "px", g: common_vendor.f(jobTypeTabs.value, (tab, index, i0) => { return { a: common_vendor.t(tab), b: currentJobType.value === index ? 1 : "", c: index, d: common_vendor.o(($event) => currentJobType.value = index, index) }; }), h: common_vendor.t(activeFilterCount.value > 0 ? "· " + activeFilterCount.value : ""), i: common_vendor.o(goToFilter), j: sortType.value === "comprehensive" ? 1 : "", k: common_vendor.o(($event) => sortType.value = "comprehensive"), l: sortType.value === "latest" ? 1 : "", m: common_vendor.o(($event) => sortType.value = "latest"), n: isLoading.value && jobList.value.length === 0 }, isLoading.value && jobList.value.length === 0 ? {} : common_vendor.e({ o: common_vendor.f(jobList.value, (item, index, i0) => { return common_vendor.e({ a: common_vendor.t(item.title), b: item.isUrgent }, item.isUrgent ? {} : {}, { c: common_vendor.t(item.salaryText), d: common_vendor.f(item.tags, (tag, tagIdx, i1) => { return { a: common_vendor.t(tag), b: tagIdx }; }), e: common_vendor.t(item.count), f: common_vendor.t(item.deadline), g: item.isExpiring }, item.isExpiring ? {} : {}, { h: item.logo, i: common_vendor.t(item.company), j: common_vendor.t(item.location), k: common_vendor.o(($event) => openFeedbackPopup(item), item.id || index), l: item.id || index, m: index === 0 ? 1 : "", n: common_vendor.o(($event) => goToDetail(item), item.id || index) }); }), p: common_assets._imports_0$2, q: common_assets._imports_1$1, r: common_assets._imports_2$1, s: common_assets._imports_3$1, t: jobList.value.length === 0 }, jobList.value.length === 0 ? {} : {}, { v: jobList.value.length > 0 && !hasMore.value }, jobList.value.length > 0 && !hasMore.value ? {} : {}, { w: scrollTop.value + "px", x: common_vendor.o(loadMore) }), { y: common_vendor.p({ activeIndex: 0 }), z: showPopup.value }, showPopup.value ? { A: common_assets._imports_3$1, B: common_vendor.o(closePopup), C: common_vendor.o(($event) => handleDislikePosition()), D: common_vendor.o(($event) => handleDislikeCompany()), E: common_vendor.o(() => { }), F: common_vendor.o(closePopup), G: common_vendor.o(() => { }) } : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ac4b611d"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/jobs/jobs.js.map