offer.js 4.2 KB

1
  1. "use strict";const e=require("../../common/vendor.js"),t=require("../../common/assets.js"),a=require("../../api/offer.js"),n=require("../../utils/request.js"),s={__name:"offer",setup(s){const r=e.ref(!1),i=e.ref(!1),o=e.ref(10);let u=null;const d=e.ref(null),l=e.ref([]),c=e.ref(!1),p=e.ref(""),f=async()=>{c.value=!0;try{const e=await a.getOfferList();200===e.code&&(l.value=e.data.map((e=>({id:e.id,jobName:e.postName||"未知岗位",company:e.companyName||"未知企业",fileName:e.offerFileName||"offer.pdf",fileUrl:e.offerFileUrl,studentStatus:e.studentStatus||"pending",enterpriseStatus:e.enterpriseStatus||"pending",statusText:m(e.studentStatus,e.enterpriseStatus),status:"pending"===e.studentStatus?"pending":e.studentStatus,offerTime:e.offerTime,createTime:v(e.createTime)}))))}catch(t){e.index.showToast({title:"获取Offer列表失败",icon:"none"})}finally{c.value=!1}},v=e=>{if(!e)return"--";const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")} ${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`},S=e=>"pending"===e.enterpriseStatus?"审核中":"adopted"===e.enterpriseStatus?"已录用":"rejected"===e.enterpriseStatus?"未通过":"未知",g=e=>{switch(e){case"adopted":return"企业已录用,请确认Offer";case"rejected":return"很遗憾,该岗位暂不匹配";default:return""}},m=(e,t)=>"rejected"===t?"已拒绝":"accepted"===e?"已接受":"rejected"===e?"已拒绝":"待确认",h=()=>{o.value=10,u&&clearInterval(u),u=setInterval((()=>{o.value>0?o.value--:clearInterval(u)}),1e3)},w=async()=>{if(d.value)try{const t=await a.acceptOffer(d.value.id);200===t.code?(e.index.showToast({title:"已接受Offer",icon:"success"}),f()):e.index.showToast({title:t.msg||"操作失败",icon:"none"})}catch(t){e.index.showToast({title:"操作失败,请重试",icon:"none"})}finally{r.value=!1}},x=async()=>{if(d.value)try{const t=await a.rejectOffer(d.value.id);200===t.code?(e.index.showToast({title:"已拒绝Offer",icon:"none"}),f()):e.index.showToast({title:t.msg||"操作失败",icon:"none"})}catch(t){e.index.showToast({title:"操作失败,请重试",icon:"none"})}finally{i.value=!1}};e.onMounted((()=>{(async()=>{try{const e=await n.request({url:"/miniapp/auth/agreement?type=offer",method:"GET"});200===e.code&&e.data&&e.data.content&&(p.value=e.data.content)}catch(e){console.error("获取Offer协议失败",e)}})(),f()}));return(a,n)=>e.e({a:c.value},c.value?{}:0===l.value.length?{c:t._imports_0$12}:{d:e.f(l.value,((a,n,s)=>e.e({a:e.t(a.company),b:e.t(a.jobName),c:e.t(S(a)),d:e.n("pending"===a.enterpriseStatus?"pending":"adopted"===a.enterpriseStatus?"adopted":"rejected"),e:e.t(a.createTime),f:"pending"!==a.enterpriseStatus},"pending"!==a.enterpriseStatus?e.e({g:"adopted"===a.enterpriseStatus},"adopted"===a.enterpriseStatus?{h:t._imports_1$3}:{i:t._imports_2$6},{j:e.t(g(a.enterpriseStatus)),k:e.n(a.enterpriseStatus),l:"adopted"===a.enterpriseStatus&&"pending"===a.studentStatus},"adopted"===a.enterpriseStatus&&"pending"===a.studentStatus?{m:e.o((e=>(e=>{d.value=e,i.value=!0})(a)),n),n:e.o((e=>(e=>{d.value=e,r.value=!0,h()})(a)),n)}:"pending"!==a.studentStatus?{p:e.t(a.statusText),q:e.n(a.studentStatus)}:{},{o:"pending"!==a.studentStatus}):{},{r:"adopted"===a.enterpriseStatus&&a.fileUrl},"adopted"===a.enterpriseStatus&&a.fileUrl?{s:t._imports_0$9,t:e.t(a.fileName),v:e.o((t=>(t=>{if(!t)return void e.index.showToast({title:"文件链接无效",icon:"none"});const a=(e=>{const t=e.match(/\.(\w+)(\?|$)/);return t?t[1].toLowerCase():"pdf"})(t);e.index.showLoading({title:"加载中..."}),e.index.downloadFile({url:t,success:t=>{if(200===t.statusCode){const n=t.tempFilePath;e.index.openDocument({filePath:n,fileType:a,showMenu:!0,success:()=>{e.index.hideLoading()},fail:t=>{e.index.hideLoading(),e.index.showToast({title:"预览失败",icon:"none"})}})}},fail:t=>{e.index.hideLoading(),e.index.showToast({title:"下载失败",icon:"none"})}})})(a.fileUrl)),n)}:{},{w:n})))},{b:0===l.value.length,e:e.o(f),f:r.value},r.value?{g:p.value,h:e.o((e=>r.value=!1)),i:e.t(o.value>0?o.value+"s后确认接受":"已阅读,确认接受"),j:o.value>0,k:e.o(w)}:{},{l:i.value},i.value?{m:e.o((e=>i.value=!1)),n:e.o(x)}:{})}},r=e._export_sfc(s,[["__scopeId","data-v-3f60a5e3"]]);wx.createPage(r);