| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const common_assets = require("../../common/assets.js");
- const api_offer = require("../../api/offer.js");
- const utils_request = require("../../utils/request.js");
- const _sfc_main = {
- __name: "offer",
- setup(__props) {
- const showAcceptModal = common_vendor.ref(false);
- const showRejectModal = common_vendor.ref(false);
- const countdown = common_vendor.ref(10);
- let timer = null;
- const currentOffer = common_vendor.ref(null);
- const offers = common_vendor.ref([]);
- const loading = common_vendor.ref(false);
- const protocolHtml = common_vendor.ref("");
- const loadOfferConfig = async () => {
- try {
- const res = await utils_request.request({ url: "/miniapp/auth/agreement?type=offer", method: "GET" });
- if (res.code === 200 && res.data && res.data.content) {
- protocolHtml.value = res.data.content;
- }
- } catch (e) {
- common_vendor.index.__f__("error", "at pages/my/offer.vue:122", "获取Offer协议失败", e);
- }
- };
- const fetchOfferList = async () => {
- loading.value = true;
- try {
- const res = await api_offer.getOfferList();
- if (res.code === 200) {
- offers.value = res.data.map((item) => ({
- id: item.id,
- jobName: item.postName || "未知岗位",
- company: item.companyName || "未知企业",
- fileName: item.offerFileName || "offer.pdf",
- fileUrl: item.offerFileUrl,
- studentStatus: item.studentStatus || "pending",
- enterpriseStatus: item.enterpriseStatus || "pending",
- statusText: getStatusText(item.studentStatus, item.enterpriseStatus),
- status: item.studentStatus === "pending" ? "pending" : item.studentStatus,
- offerTime: item.offerTime,
- createTime: formatTime(item.createTime)
- }));
- }
- } catch (error) {
- common_vendor.index.showToast({ title: "获取Offer列表失败", icon: "none" });
- } finally {
- loading.value = false;
- }
- };
- const formatTime = (time) => {
- if (!time)
- return "--";
- const d = new Date(time);
- const year = d.getFullYear();
- const month = String(d.getMonth() + 1).padStart(2, "0");
- const day = String(d.getDate()).padStart(2, "0");
- const hour = String(d.getHours()).padStart(2, "0");
- const minute = String(d.getMinutes()).padStart(2, "0");
- return `${year}-${month}-${day} ${hour}:${minute}`;
- };
- const getStatusBadge = (offer) => {
- if (offer.enterpriseStatus === "pending")
- return "审核中";
- if (offer.enterpriseStatus === "adopted")
- return "已录用";
- if (offer.enterpriseStatus === "rejected")
- return "未通过";
- return "未知";
- };
- const getResultDesc = (enterpriseStatus) => {
- switch (enterpriseStatus) {
- case "adopted":
- return "企业已录用,请确认Offer";
- case "rejected":
- return "很遗憾,该岗位暂不匹配";
- default:
- return "";
- }
- };
- const getStatusText = (studentStatus, enterpriseStatus) => {
- if (enterpriseStatus === "rejected")
- return "已拒绝";
- if (studentStatus === "accepted")
- return "已接受";
- if (studentStatus === "rejected")
- return "已拒绝";
- return "待确认";
- };
- const handleAccept = (offer) => {
- currentOffer.value = offer;
- showAcceptModal.value = true;
- startCountdown();
- };
- const handleReject = (offer) => {
- currentOffer.value = offer;
- showRejectModal.value = true;
- };
- const startCountdown = () => {
- countdown.value = 10;
- if (timer)
- clearInterval(timer);
- timer = setInterval(() => {
- if (countdown.value > 0) {
- countdown.value--;
- } else {
- clearInterval(timer);
- }
- }, 1e3);
- };
- const confirmAccept = async () => {
- if (!currentOffer.value)
- return;
- try {
- const res = await api_offer.acceptOffer(currentOffer.value.id);
- if (res.code === 200) {
- common_vendor.index.showToast({ title: "已接受Offer", icon: "success" });
- fetchOfferList();
- } else {
- common_vendor.index.showToast({ title: res.msg || "操作失败", icon: "none" });
- }
- } catch (error) {
- common_vendor.index.showToast({ title: "操作失败,请重试", icon: "none" });
- } finally {
- showAcceptModal.value = false;
- }
- };
- const confirmReject = async () => {
- if (!currentOffer.value)
- return;
- try {
- const res = await api_offer.rejectOffer(currentOffer.value.id);
- if (res.code === 200) {
- common_vendor.index.showToast({ title: "已拒绝Offer", icon: "none" });
- fetchOfferList();
- } else {
- common_vendor.index.showToast({ title: res.msg || "操作失败", icon: "none" });
- }
- } catch (error) {
- common_vendor.index.showToast({ title: "操作失败,请重试", icon: "none" });
- } finally {
- showRejectModal.value = false;
- }
- };
- common_vendor.onMounted(() => {
- loadOfferConfig();
- fetchOfferList();
- });
- const openFile = (url) => {
- if (!url) {
- common_vendor.index.showToast({ title: "文件链接无效", icon: "none" });
- return;
- }
- const getFileType = (fileUrl) => {
- const match = fileUrl.match(/\.(\w+)(\?|$)/);
- return match ? match[1].toLowerCase() : "pdf";
- };
- const fileType = getFileType(url);
- common_vendor.index.showLoading({ title: "加载中..." });
- common_vendor.index.downloadFile({
- url,
- success: (res) => {
- if (res.statusCode === 200) {
- const filePath = res.tempFilePath;
- common_vendor.index.openDocument({
- filePath,
- fileType,
- showMenu: true,
- success: () => {
- common_vendor.index.hideLoading();
- },
- fail: (err) => {
- common_vendor.index.hideLoading();
- common_vendor.index.showToast({ title: "预览失败", icon: "none" });
- }
- });
- }
- },
- fail: (err) => {
- common_vendor.index.hideLoading();
- common_vendor.index.showToast({ title: "下载失败", icon: "none" });
- }
- });
- };
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: loading.value
- }, loading.value ? {} : offers.value.length === 0 ? {
- c: common_assets._imports_0$12
- } : {
- d: common_vendor.f(offers.value, (offer, index, i0) => {
- return common_vendor.e({
- a: common_vendor.t(offer.company),
- b: common_vendor.t(offer.jobName),
- c: common_vendor.t(getStatusBadge(offer)),
- d: common_vendor.n(offer.enterpriseStatus === "pending" ? "pending" : offer.enterpriseStatus === "adopted" ? "adopted" : "rejected"),
- e: common_vendor.t(offer.createTime),
- f: offer.enterpriseStatus !== "pending"
- }, offer.enterpriseStatus !== "pending" ? common_vendor.e({
- g: offer.enterpriseStatus === "adopted"
- }, offer.enterpriseStatus === "adopted" ? {
- h: common_assets._imports_1$3
- } : {
- i: common_assets._imports_2$6
- }, {
- j: common_vendor.t(getResultDesc(offer.enterpriseStatus)),
- k: common_vendor.n(offer.enterpriseStatus),
- l: offer.enterpriseStatus === "adopted" && offer.studentStatus === "pending"
- }, offer.enterpriseStatus === "adopted" && offer.studentStatus === "pending" ? {
- m: common_vendor.o(($event) => handleReject(offer), index),
- n: common_vendor.o(($event) => handleAccept(offer), index)
- } : offer.studentStatus !== "pending" ? {
- p: common_vendor.t(offer.statusText),
- q: common_vendor.n(offer.studentStatus)
- } : {}, {
- o: offer.studentStatus !== "pending"
- }) : {}, {
- r: offer.enterpriseStatus === "adopted" && offer.fileUrl
- }, offer.enterpriseStatus === "adopted" && offer.fileUrl ? {
- s: common_assets._imports_0$9,
- t: common_vendor.t(offer.fileName),
- v: common_vendor.o(($event) => openFile(offer.fileUrl), index)
- } : {}, {
- w: index
- });
- })
- }, {
- b: offers.value.length === 0,
- e: common_vendor.o(fetchOfferList),
- f: showAcceptModal.value
- }, showAcceptModal.value ? {
- g: protocolHtml.value,
- h: common_vendor.o(($event) => showAcceptModal.value = false),
- i: common_vendor.t(countdown.value > 0 ? countdown.value + "s后确认接受" : "已阅读,确认接受"),
- j: countdown.value > 0,
- k: common_vendor.o(confirmAccept)
- } : {}, {
- l: showRejectModal.value
- }, showRejectModal.value ? {
- m: common_vendor.o(($event) => showRejectModal.value = false),
- n: common_vendor.o(confirmReject)
- } : {});
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-644b8877"]]);
- wx.createPage(MiniProgramPage);
- //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/my/offer.js.map
|