| 1 |
- "use strict";const e=require("../../common/vendor.js"),o=require("../../common/assets.js"),a=require("../../api/position.js"),t=require("../../api/message.js"),i=require("../../api/collection.js"),n=require("../../api/assessment.js"),s=require("../../api/order.js"),l={__name:"index",setup(l){const d=e.ref(!1),r=e.ref(null),c=e.ref({}),u=e.ref([]),v=e.ref("initial"),g=e.computed((()=>{switch(v.value){case"initial":default:return"咨询";case"paid":return"开始测评";case"assessed":return"投递简历";case"added":return"已投递"}})),p=e.ref(null),m=async()=>{console.log("Checking job state for position:",p.value);const o=e.index.getStorageSync("userInfo");if(!o||!o.studentId||!p.value)return void(v.value="initial");const t=`candidate_applied_${p.value}`;if(e.index.getStorageSync(t))v.value="added";else try{if(!c.value||!c.value.postName){const e=await a.getPositionDetail(p.value);200===e.code&&e.data&&(c.value=e.data)}const t=await n.getAssessmentList({positionId:p.value,pageNum:1,pageSize:100}),l=`audit_paid_pos_${p.value}`,d=!!e.index.getStorageSync(l);let r=200===t.code&&t.rows?t.rows.some((o=>e.index.getStorageSync(`audit_paid_${o.id}`)))||d:d||!!e.index.getStorageSync(`audit_paid_${p.value}`);if(!r)try{const e=await s.listOrder({orderStatus:1,buyerId:o.studentId});200===e.code&&e.rows&&(r=e.rows.some((e=>{var o;const a=e.remark||"",i=(null==(o=c.value)?void 0:o.postName)&&a.includes(c.value.postName),n=t.rows&&t.rows.some((e=>e.evaluationName&&a.includes(e.evaluationName)));return i||n})))}catch(i){console.error("[JobDetail] 订单校验失败:",i)}if(console.log("[JobDetail] 支付状态最终综合判定:",r),200!==t.code||!t.rows||0===t.rows.length)return void(v.value=r?"paid":"initial");linkedAssessmentId.value=t.rows[0].id,console.log("[JobDetail] 关联测评ID:",linkedAssessmentId.value);const u=await n.getAssessmentRecordList(o.studentId);if(200!==u.code||!u.data)return void(v.value=r?"paid":"initial");const g=t.rows.map((e=>e.id)),m=u.data.find((e=>"1"===e.finalResult&&g.includes(e.evaluationId)));v.value=m?"assessed":r?"paid":"initial"}catch(l){console.error("检查状态失败:",l),v.value="initial"}},f=e.ref(31.22863),w=e.ref(121.45039),h=e.ref([]),y=async o=>{console.log("checkCollectionStatus called with id:",o);const a=e.index.getStorageSync("userInfo");if(console.log("checkCollectionStatus userInfo:",a),a&&a.studentId)try{console.log("调用checkCollection API, studentId:",a.studentId,"targetId:",o,"type: job");const e=await i.checkCollection(a.studentId,o,"job");console.log("checkCollection API响应:",e),200===e.code&&e.data?(d.value=!0,r.value=e.data.id,console.log("设置为已收藏, collectionId:",e.data.id)):(d.value=!1,r.value=null,console.log("设置为未收藏"))}catch(t){console.error("检查收藏状态失败",t)}else console.log("checkCollectionStatus: 用户未登录")},I=async()=>{console.log("toggleCollect clicked");const o=e.index.getStorageSync("userInfo");if(console.log("userInfo:",o),!o||!o.studentId)return console.log("用户未登录"),e.index.showToast({title:"请先登录",icon:"none"}),void setTimeout((()=>{e.index.navigateTo({url:"/pages/login/login"})}),1e3);if(c.value.id){console.log("准备发送收藏请求, jobInfo.value.id:",c.value.id),e.index.showLoading({title:d.value?"取消收藏中...":"收藏中..."});try{if(d.value){if(console.log("取消收藏, collectionId:",r.value),r.value){const o=await i.delCollection(r.value);console.log("取消收藏响应:",o),200===o.code&&(d.value=!1,r.value=null,e.index.showToast({title:"已取消收藏",icon:"none"}))}}else{const a={studentId:o.studentId,targetId:c.value.id,type:"job"};console.log("添加收藏请求数据:",a);const t=await i.addCollection(a);console.log("添加收藏响应:",t),200===t.code?(d.value=!0,y(c.value.id),e.index.showToast({title:"收藏成功",icon:"success"})):e.index.showToast({title:t.msg||"收藏失败",icon:"none"})}}catch(a){console.error("操作收藏失败",a),e.index.showToast({title:"操作失败",icon:"none"})}finally{e.index.hideLoading()}}else console.log("jobInfo.value.id 为空:",c.value)};e.onLoad((o=>{o.id&&(p.value=o.id,(async o=>{console.log("fetchDetail called with id:",o),e.index.showLoading({title:"加载中..."});try{const t=await a.getPositionDetail(o);if(console.log("getPositionDetail响应:",t),200===t.code&&t.data){c.value=t.data,p.value=t.data.id;const e=t.data;e.latitude&&e.longitude?(f.value=parseFloat(e.latitude),w.value=parseFloat(e.longitude),h.value=[{id:1,latitude:f.value,longitude:w.value,title:e.postName||"办公地点",iconPath:"/static/icons/location.svg",width:32,height:32,callout:{content:e.workAddress||e.workProvince+e.workCity+e.workDistrict,color:"#333333",fontSize:12,borderRadius:8,padding:8,bgColor:"#ffffff",display:"ALWAYS",boxShadow:"0 4rpx 12rpx rgba(0,0,0,0.1)"}}]):h.value=[];let a=[];e.postTypeLabel&&a.push(e.postTypeLabel),e.schoolRequirementLabel&&a.push(e.schoolRequirementLabel),e.gradeRequirementLabel&&a.push(e.gradeRequirementLabel),e.welfareTags&&a.push(...e.welfareTags.split(",").filter(Boolean)),u.value=a,console.log("准备检查收藏状态, id:",o),y(o)}}catch(t){console.error("获取岗位详情失败:",t)}finally{e.index.hideLoading()}})(o.id)),e.index.$on("payment_done",(e=>{console.log("收到 payment_done 事件:",e),m()})),e.index.$on("resume_delivered",(e=>{console.log("收到 resume_delivered 事件:",e),e&&e.postId==p.value&&(v.value="added")}))})),e.onShow((()=>{p.value&&m()})),e.onUnmounted((()=>{e.index.$off("payment_done"),e.index.$off("resume_delivered")}));const x=async()=>{if("initial"===v.value)try{e.index.showLoading({title:"正在连接客服..."});const o=e.index.getStorageSync("userInfo")||{},a=o.studentId||null,i=o.name||"用户",n=o.avatarUrl||"/static/images/user_avatar.svg",s=await t.createOrGetSession({sessionType:1,fromUserId:a,fromUserName:i,fromUserAvatar:n,sourceId:"job_"+p.value});if(e.index.hideLoading(),s.data){const o=s.data;e.index.navigateTo({url:`/pages/chat/chat?sessionId=${o.sessionId}&sessionNo=${o.sessionNo||""}&fromUserId=${a}&userName=${encodeURIComponent(i)}&jobName=${encodeURIComponent(c.value.postName||"")}&type=job&positionId=${p.value}&salaryRange=${encodeURIComponent(c.value.salaryRange||"")}&companyName=${encodeURIComponent(c.value.companyName||"")}&workCity=${encodeURIComponent(c.value.workCity||"")}&workDistrict=${encodeURIComponent(c.value.workDistrict||"")}`})}else e.index.showToast({title:"创建会话失败",icon:"none"})}catch(o){e.index.hideLoading(),console.error("创建会话失败:",o),e.index.showToast({title:"连接失败,请重试",icon:"none"})}else if("paid"===v.value)e.index.navigateTo({url:`/pages/assessment/remind?family=audit&id=${linkedAssessmentId.value||""}`});else if("assessed"===v.value){if(!(e.index.getStorageSync("userInfo")||{}).studentId)return e.index.showToast({title:"请先登录",icon:"none"}),void setTimeout((()=>{e.index.navigateTo({url:"/pages/login/login"})}),1e3);e.index.navigateTo({url:`/pages/my/select-resume?postId=${p.value}`})}};return(a,t)=>e.e({a:e.t(c.value.postName||""),b:1===c.value.isUrgent},(c.value.isUrgent,{}),{c:e.t(c.value.salaryRange||"面议"),d:o._imports_2$2,e:e.t(c.value.workProvince||""),f:e.t(c.value.workCity?"·"+c.value.workCity:""),g:e.t(c.value.workDistrict?"·"+c.value.workDistrict:""),h:o._imports_0$2,i:e.t(c.value.recruitNum||1),j:o._imports_1$1,k:e.t(c.value.registrationEndDate?c.value.registrationEndDate.split(" ")[0]:"长期有效"),l:c.value.hrAvatar||c.value.companyAvatar||"/static/images/hr_avatar.svg",m:e.t(c.value.companyName||"平台推荐"),n:e.f(u.value,((o,a,t)=>({a:e.t(o),b:o}))),o:c.value.postDescription},c.value.postDescription?{p:c.value.postDescription}:{},{q:f.value,r:w.value,s:h.value,t:c.value.companyAvatar||"/static/images/logo1.png",v:e.t(c.value.companyName||"未知企业"),w:d.value?"/static/icons/star_filled.svg":"/static/icons/star_hollow.svg",x:e.t(d.value?"已收藏":"收藏"),y:e.o(I),z:e.t(g.value),A:e.n(v.value),B:e.o(x)})}},d=e._export_sfc(l,[["__scopeId","data-v-f582c475"]]);wx.createPage(d);
|