| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- "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_message = require("../../api/message.js");
- const api_collection = require("../../api/collection.js");
- const api_assessment = require("../../api/assessment.js");
- const _sfc_main = {
- __name: "index",
- setup(__props) {
- const isCollected = common_vendor.ref(false);
- const collectionId = common_vendor.ref(null);
- const jobInfo = common_vendor.ref({});
- const tags = common_vendor.ref([]);
- const jobState = common_vendor.ref("initial");
- const btnText = common_vendor.computed(() => {
- switch (jobState.value) {
- case "initial":
- return "咨询";
- case "paid":
- return "开始测评";
- case "assessed":
- return "投递简历";
- case "added":
- return "已投递";
- default:
- return "咨询";
- }
- });
- const positionId = common_vendor.ref(null);
- const checkState = async () => {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:139", "Checking job state for position:", positionId.value);
- const userInfo = common_vendor.index.getStorageSync("userInfo");
- if (!userInfo || !userInfo.studentId || !positionId.value) {
- jobState.value = "initial";
- return;
- }
- const appliedKey = `candidate_applied_${positionId.value}`;
- if (common_vendor.index.getStorageSync(appliedKey)) {
- jobState.value = "added";
- return;
- }
- try {
- const evalRes = await api_assessment.getAssessmentList({ positionId: positionId.value, pageNum: 1, pageSize: 100 });
- const isAnyEvalPaid = evalRes.code === 200 && evalRes.rows ? evalRes.rows.some((e) => common_vendor.index.getStorageSync(`audit_paid_${e.id}`)) : common_vendor.index.getStorageSync(`audit_paid_${positionId.value}`);
- if (evalRes.code !== 200 || !evalRes.rows || evalRes.rows.length === 0) {
- jobState.value = isAnyEvalPaid ? "paid" : "initial";
- return;
- }
- const recordRes = await api_assessment.getAssessmentRecordList(userInfo.studentId);
- if (recordRes.code !== 200 || !recordRes.data) {
- jobState.value = isAnyEvalPaid ? "paid" : "initial";
- return;
- }
- const evaluationIds = evalRes.rows.map((e) => e.id);
- const passedRecord = recordRes.data.find(
- (r) => r.finalResult === "1" && evaluationIds.includes(r.evaluationId)
- );
- if (passedRecord) {
- jobState.value = "assessed";
- } else if (isAnyEvalPaid) {
- jobState.value = "paid";
- } else {
- jobState.value = "initial";
- }
- } catch (err) {
- common_vendor.index.__f__("error", "at pages/jobdetail/index.vue:191", "检查状态失败:", err);
- jobState.value = "initial";
- }
- };
- const latitude = common_vendor.ref(31.22863);
- const longitude = common_vendor.ref(121.45039);
- const markers = common_vendor.ref([]);
- const fetchDetail = async (id) => {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:201", "fetchDetail called with id:", id);
- common_vendor.index.showLoading({ title: "加载中..." });
- try {
- const res = await api_position.getPositionDetail(id);
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:205", "getPositionDetail响应:", res);
- if (res.code === 200 && res.data) {
- jobInfo.value = res.data;
- positionId.value = res.data.id;
- const data = res.data;
- if (data.latitude && data.longitude) {
- latitude.value = parseFloat(data.latitude);
- longitude.value = parseFloat(data.longitude);
- markers.value = [{
- id: 1,
- latitude: latitude.value,
- longitude: longitude.value,
- title: data.postName || "办公地点",
- iconPath: "/static/icons/location.svg",
- width: 32,
- height: 32,
- callout: {
- content: data.workAddress || data.workProvince + data.workCity + data.workDistrict,
- color: "#333333",
- fontSize: 12,
- borderRadius: 8,
- padding: 8,
- bgColor: "#ffffff",
- display: "ALWAYS",
- boxShadow: "0 4rpx 12rpx rgba(0,0,0,0.1)"
- }
- }];
- } else {
- markers.value = [];
- }
- let t = [];
- if (data.postTypeLabel)
- t.push(data.postTypeLabel);
- if (data.schoolRequirementLabel)
- t.push(data.schoolRequirementLabel);
- if (data.gradeRequirementLabel)
- t.push(data.gradeRequirementLabel);
- if (data.welfareTags) {
- t.push(...data.welfareTags.split(",").filter(Boolean));
- }
- tags.value = t;
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:249", "准备检查收藏状态, id:", id);
- checkCollectionStatus(id);
- }
- } catch (err) {
- common_vendor.index.__f__("error", "at pages/jobdetail/index.vue:253", "获取岗位详情失败:", err);
- } finally {
- common_vendor.index.hideLoading();
- }
- };
- const checkCollectionStatus = async (id) => {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:261", "checkCollectionStatus called with id:", id);
- const userInfo = common_vendor.index.getStorageSync("userInfo");
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:263", "checkCollectionStatus userInfo:", userInfo);
- if (!userInfo || !userInfo.studentId) {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:265", "checkCollectionStatus: 用户未登录");
- return;
- }
- try {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:270", "调用checkCollection API, studentId:", userInfo.studentId, "targetId:", id, "type: job");
- const res = await api_collection.checkCollection(userInfo.studentId, id, "job");
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:272", "checkCollection API响应:", res);
- if (res.code === 200 && res.data) {
- isCollected.value = true;
- collectionId.value = res.data.id;
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:276", "设置为已收藏, collectionId:", res.data.id);
- } else {
- isCollected.value = false;
- collectionId.value = null;
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:280", "设置为未收藏");
- }
- } catch (err) {
- common_vendor.index.__f__("error", "at pages/jobdetail/index.vue:283", "检查收藏状态失败", err);
- }
- };
- const toggleCollect = async () => {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:289", "toggleCollect clicked");
- const userInfo = common_vendor.index.getStorageSync("userInfo");
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:291", "userInfo:", userInfo);
- if (!userInfo || !userInfo.studentId) {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:294", "用户未登录");
- common_vendor.index.showToast({ title: "请先登录", icon: "none" });
- setTimeout(() => {
- common_vendor.index.navigateTo({ url: "/pages/login/login" });
- }, 1e3);
- return;
- }
- if (!jobInfo.value.id) {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:303", "jobInfo.value.id 为空:", jobInfo.value);
- return;
- }
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:307", "准备发送收藏请求, jobInfo.value.id:", jobInfo.value.id);
- common_vendor.index.showLoading({ title: isCollected.value ? "取消收藏中..." : "收藏中..." });
- try {
- if (isCollected.value) {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:313", "取消收藏, collectionId:", collectionId.value);
- if (collectionId.value) {
- const res = await api_collection.delCollection(collectionId.value);
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:316", "取消收藏响应:", res);
- if (res.code === 200) {
- isCollected.value = false;
- collectionId.value = null;
- common_vendor.index.showToast({ title: "已取消收藏", icon: "none" });
- }
- }
- } else {
- const requestData = {
- studentId: userInfo.studentId,
- targetId: jobInfo.value.id,
- type: "job"
- };
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:330", "添加收藏请求数据:", requestData);
- const res = await api_collection.addCollection(requestData);
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:332", "添加收藏响应:", res);
- if (res.code === 200) {
- isCollected.value = true;
- checkCollectionStatus(jobInfo.value.id);
- common_vendor.index.showToast({ title: "收藏成功", icon: "success" });
- } else {
- common_vendor.index.showToast({ title: res.msg || "收藏失败", icon: "none" });
- }
- }
- } catch (err) {
- common_vendor.index.__f__("error", "at pages/jobdetail/index.vue:343", "操作收藏失败", err);
- common_vendor.index.showToast({ title: "操作失败", icon: "none" });
- } finally {
- common_vendor.index.hideLoading();
- }
- };
- common_vendor.onLoad((options) => {
- if (options.id) {
- positionId.value = options.id;
- fetchDetail(options.id);
- }
- common_vendor.index.$on("payment_done", (data) => {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:357", "收到 payment_done 事件:", data);
- checkState();
- });
- common_vendor.index.$on("resume_delivered", (data) => {
- common_vendor.index.__f__("log", "at pages/jobdetail/index.vue:362", "收到 resume_delivered 事件:", data);
- if (data && data.postId == positionId.value) {
- jobState.value = "added";
- }
- });
- });
- common_vendor.onShow(() => {
- if (positionId.value) {
- checkState();
- }
- });
- common_vendor.onUnmounted(() => {
- common_vendor.index.$off("payment_done");
- common_vendor.index.$off("resume_delivered");
- });
- const handleMainAction = async () => {
- if (jobState.value === "initial") {
- try {
- common_vendor.index.showLoading({ title: "正在连接客服..." });
- const userInfo = common_vendor.index.getStorageSync("userInfo") || {};
- const userId = userInfo.studentId || null;
- const userName = userInfo.name || "用户";
- const userAvatar = userInfo.avatarUrl || "/static/images/user_avatar.svg";
- const res = await api_message.createOrGetSession({
- sessionType: 1,
- fromUserId: userId,
- fromUserName: userName,
- fromUserAvatar: userAvatar,
- sourceId: "job_" + positionId.value
- });
- common_vendor.index.hideLoading();
- if (res.data) {
- const session = res.data;
- common_vendor.index.navigateTo({
- url: `/pages/chat/chat?sessionId=${session.sessionId}&sessionNo=${session.sessionNo || ""}&fromUserId=${userId}&userName=${encodeURIComponent(userName)}&jobName=${encodeURIComponent(jobInfo.value.postName || "")}&type=job&positionId=${positionId.value}&salaryRange=${encodeURIComponent(jobInfo.value.salaryRange || "")}&companyName=${encodeURIComponent(jobInfo.value.companyName || "")}&workCity=${encodeURIComponent(jobInfo.value.workCity || "")}`
- });
- } else {
- common_vendor.index.showToast({ title: "创建会话失败", icon: "none" });
- }
- } catch (err) {
- common_vendor.index.hideLoading();
- common_vendor.index.__f__("error", "at pages/jobdetail/index.vue:411", "创建会话失败:", err);
- common_vendor.index.showToast({ title: "连接失败,请重试", icon: "none" });
- }
- } else if (jobState.value === "paid") {
- common_vendor.index.navigateTo({
- url: "/pages/assessment/remind?family=audit"
- });
- } else if (jobState.value === "assessed") {
- const userInfo = common_vendor.index.getStorageSync("userInfo") || {};
- if (!userInfo.studentId) {
- common_vendor.index.showToast({ title: "请先登录", icon: "none" });
- setTimeout(() => {
- common_vendor.index.navigateTo({ url: "/pages/login/login" });
- }, 1e3);
- return;
- }
- common_vendor.index.navigateTo({
- url: `/pages/my/select-resume?postId=${positionId.value}`
- });
- }
- };
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.t(jobInfo.value.postName || ""),
- b: jobInfo.value.isUrgent === 1
- }, jobInfo.value.isUrgent === 1 ? {} : {}, {
- c: common_vendor.t(jobInfo.value.salaryRange || "面议"),
- d: common_assets._imports_2$2,
- e: common_vendor.t(jobInfo.value.workProvince || ""),
- f: common_vendor.t(jobInfo.value.workCity ? "·" + jobInfo.value.workCity : ""),
- g: common_vendor.t(jobInfo.value.workDistrict ? "·" + jobInfo.value.workDistrict : ""),
- h: common_assets._imports_0$2,
- i: common_vendor.t(jobInfo.value.recruitNum || 1),
- j: common_assets._imports_1$1,
- k: common_vendor.t(jobInfo.value.registrationEndDate ? jobInfo.value.registrationEndDate.split(" ")[0] : "长期有效"),
- l: jobInfo.value.companyAvatar || "/static/images/hr_avatar.svg",
- m: common_vendor.t(jobInfo.value.companyName || "平台推荐"),
- n: common_vendor.f(tags.value, (tag, k0, i0) => {
- return {
- a: common_vendor.t(tag),
- b: tag
- };
- }),
- o: jobInfo.value.postDescription
- }, jobInfo.value.postDescription ? {
- p: jobInfo.value.postDescription
- } : {}, {
- q: latitude.value,
- r: longitude.value,
- s: markers.value,
- t: jobInfo.value.companyAvatar || "/static/images/logo1.png",
- v: common_vendor.t(jobInfo.value.companyName || "未知企业"),
- w: isCollected.value ? "/static/icons/star_filled.svg" : "/static/icons/star_hollow.svg",
- x: common_vendor.t(isCollected.value ? "已收藏" : "收藏"),
- y: common_vendor.o(toggleCollect),
- z: common_vendor.t(btnText.value),
- A: common_vendor.n(jobState.value),
- B: common_vendor.o(handleMainAction)
- });
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-dc9d1727"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/jobdetail/index.js.map
|