"use strict";const e=require("../../common/vendor.js"),a=require("../../common/assets.js"),t=require("../../api/assessment.js"),l=require("../../api/dict.js"),s=require("../../api/message.js");Math||i();const i=()=>"../../components/custom-tabbar/custom-tabbar.js",n={__name:"assessment",setup(i){const n=e.ref(20),o=e.ref(8),u=e.ref(32),r=e.ref(0),d=e.ref(""),v=e.ref([]),c=e.ref([]),p=e.ref(!1),g=e.ref(!1),m=e.ref(new Set),f=e.ref(new Set),h=e.ref(new Set),b=(e,a="")=>{let t=e.remark||e.description||e.desc;return!t&&e.detail&&(t=/^[A-Za-z0-9+/=]+$/.test(e.detail)?(e=>{if(!e||"string"!=typeof e)return"";try{const a=atob(e),t=Array.from(a,(e=>e.charCodeAt(0)));return decodeURIComponent(t.map((e=>`%${e.toString(16).padStart(2,"0")}`)).join(""))}catch(a){return e}})(e.detail):e.detail),t||a},y=e.computed((()=>0===r.value?"测评记录":"培训记录")),x=async()=>{if(!p.value){p.value=!0;try{const a=(e.index.getStorageSync("userInfo")||{}).studentId||null;if(a){const e=await t.getAssessmentRecordList(a);if(200===e.code&&e.data){const a=e.data;m.value=new Set(a.filter((e=>"1"===e.finalResult)).map((e=>e.evaluationId))),f.value=new Set(a.map((e=>e.evaluationId))),h.value=new Set(a.filter((e=>"1"===e.finalResult||"2"===e.finalResult)).map((e=>e.evaluationId)))}}const l=S.value[0].selectedValue,s=S.value[1].selectedValue,i={pageNum:1,pageSize:20};d.value&&(i.evaluationName=d.value),l&&(i.positionType=l),s&&(i.grade=s);const n=await t.getAssessmentList(i);200===n.code&&n.rows&&(console.log("测评API返回数据:",n.rows[0]),v.value=n.rows.filter((e=>"1"===e.status)).map((a=>{let t=a.evaluationName||a.name||a.title||"未知测评";const l=b(a,"专业技能评估,助力职业发展"),s=!0===e.index.getStorageSync(`audit_paid_${a.id}`),i=a.positionId,n=!!i&&!0===e.index.getStorageSync(`candidate_applied_${i}`);return{id:a.id,title:t,level:a.gradeLabel||a.grade||"",type:a.positionTypeLabel||a.positionType||"",category:a.positionLabel||a.position||"",desc:l,cover:a.mainImageUrl||a.coverImage||"/static/images/assessment_default.svg",tags:a.tags?a.tags.split(","):[],price:a.price||"",isCollected:!1,collectionId:null,isPassed:m.value.has(a.id),hasRecord:f.value.has(a.id),isCompleted:h.value.has(a.id),hasPaid:s,postId:i,isApplied:n}})))}catch(a){console.error("获取测评列表失败",a),e.index.showToast({title:"加载失败,请重试",icon:"none"})}finally{p.value=!1}}},_=async()=>{if(!g.value){g.value=!0;try{const e=L.value[0].selectedValue,a=L.value[1].selectedValue,l=L.value[2].selectedValue,s={pageNum:1,pageSize:20,status:1};e&&(s.trainingType=e),a&&(s.jobType=a),l&&(s.job=l),d.value&&(s.name=d.value);const i=await t.getTrainingList(s);200===i.code&&i.rows&&(console.log("培训API返回数据:",i.rows[0]),c.value=i.rows.map((e=>{console.log("培训单项数据:",e);let a=e.name||e.trainingName||e.title;if(!a||""===a.trim()||a.startsWith("test_")){a=`${e.job||e.position||"专业技能"}培训课程`}const t=b(e,"提升专业技能,助力职业发展");let l="";if("offline"===e.trainingType){l=`${e.city||""}${e.area||""}${e.addressDetail||""}`.replace(/undefined|null/g,"").trim(),l||(l="线下培训")}else l="线上培训";const s=e.trainingStartTime?e.trainingStartTime.split(" ")[0]+(e.trainingEndTime?" 至 "+e.trainingEndTime.split(" ")[0]:""):"",i=e.applyEndTime?e.applyEndTime.split(" ")[0]:"";return{id:e.id,title:a,trainingType:e.trainingType||"offline",type:e.jobType||"",category:e.job||"",tags:e.tags?e.tags.split(","):[],location:l,organizer:e.organizer||"平台推荐",trainingTime:s,deadline:i,isEnding:!1,cover:e.thumbnailUrl||"/static/images/training_default.svg",views:e.learnCount||"0",duration:e.duration||"",status:1===e.status?"published":"not-started",spectators:e.participantCount||"0",desc:t}})))}catch(e){console.error("获取培训列表失败",e)}finally{g.value=!1}}},T=e=>{r.value=e,0===e&&0===v.value.length?x():1===e&&0===c.value.length&&_()};e.watch(r,(e=>{0===e&&0===v.value.length?x():1===e&&0===c.value.length&&_()}));const w=()=>{e.index.showToast({title:y.value,icon:"none"})},$=a=>{e.index.navigateTo({url:`/pages/assessment/detail?id=${a.id}`})},I=e.ref(-1),S=e.ref([{label:"岗位类型",selectedLabel:"",selectedValue:"",options:[{label:"全部",value:""}]},{label:"岗位等级",selectedLabel:"",selectedValue:"",options:[{label:"全部",value:""}]},{label:"岗位名称",selectedLabel:"",selectedValue:"",options:[{label:"全部",value:""},{label:"审计岗位",value:"audit"},{label:"咨询岗位",value:"consult"},{label:"税务岗位",value:"tax"}]}]),L=e.ref([{label:"培训类型",selectedLabel:"线下培训",selectedValue:"offline",options:[{label:"线下培训",value:"offline"},{label:"视频培训",value:"video"},{label:"直播培训",value:"live"}]},{label:"职位类型",selectedLabel:"",selectedValue:"",options:[{label:"全部",value:""},{label:"全职",value:"full-time"},{label:"兼职",value:"part-time"},{label:"实习",value:"intern"}]},{label:"岗位",selectedLabel:"",selectedValue:"",options:[{label:"全部",value:""},{label:"审计",value:"audit"},{label:"咨询",value:"consult"},{label:"税务",value:"tax"}]}]),R=e.computed((()=>0===r.value?S.value:L.value)),P=e.computed((()=>-1===I.value?[]:R.value[I.value].options)),V=()=>{I.value=-1},j=e=>({"full-time":"全职","part-time":"兼职",intern:"实习"}[e]||e),A=e=>({audit:"审计",consult:"咨询",tax:"税务"}[e]||e),C=e.computed((()=>v.value)),U=e.computed((()=>c.value)),N=a=>{e.index.navigateTo({url:`/pages/assessment/training-detail?type=${a.trainingType}&title=${a.title}&status=${a.status||""}&views=${a.views||""}&duration=${a.duration||""}&spectators=${a.spectators||""}`})},q=e.computed((()=>n.value+o.value+u.value+e.index.upx2px(20)+e.index.upx2px(158)));return e.onMounted((()=>{try{const a=e.index.getSystemInfoSync(),t=e.index.getMenuButtonBoundingClientRect();a&&t&&(n.value=a.statusBarHeight||20,o.value=t.top-a.statusBarHeight,u.value=t.height)}catch(a){}console.log("assessment onMounted triggered"),(async()=>{try{const[e,a]=await Promise.all([l.getDicts("main_position_type"),l.getDicts("main_position_level")]);if(200===e.code){const a=[{label:"全部",value:""},...e.data.map((e=>({label:e.dictLabel,value:e.dictValue})))];S.value[0].options=a,L.value[1].options=a}200===a.code&&(S.value[1].options=[{label:"全部",value:""},...a.data.map((e=>({label:e.dictLabel,value:e.dictValue})))])}catch(a){console.error("加载字典失败",a)}})()})),e.onLoad((()=>{console.log("assessment onLoad triggered")})),e.onShow((()=>{console.log("assessment onShow triggered"),x(),_()})),e.onPullDownRefresh((async()=>{e.index.stopPullDownRefresh()})),(t,l)=>e.e({a:a._imports_0$3,b:e.o(x),c:d.value,d:e.o((e=>d.value=e.detail.value)),e:u.value+"px",f:n.value+o.value+"px",g:0===r.value?1:"",h:e.o((e=>T(0))),i:1===r.value?1:"",j:e.o((e=>T(1))),k:e.t(y.value),l:e.o(w),m:e.f(R.value,((a,t,l)=>({a:e.t(a.selectedLabel||a.label),b:I.value===t?1:"",c:t,d:I.value===t?1:"",e:e.o((e=>(e=>{I.value===e?I.value=-1:I.value=e})(t)),t)}))),n:a._imports_1$2,o:-1!==I.value},-1!==I.value?{p:e.o(V),q:e.f(P.value,((t,l,s)=>e.e({a:e.t(t.label),b:R.value[I.value].selectedValue===t.value},R.value[I.value].selectedValue===t.value?{c:a._imports_2$4}:{},{d:l,e:R.value[I.value].selectedValue===t.value?1:"",f:e.o((e=>(e=>{const a=R.value[I.value];a.selectedValue=e.value,a.selectedLabel=""===e.value?"":e.label,V(),0===r.value?x():_()})(t)),l)})))}:{},{r:p.value&&0===v.value.length&&0===r.value},(p.value&&0===v.value.length&&r.value,{}),{s:0===r.value&&(!p.value||v.value.length>0)},0===r.value&&(!p.value||v.value.length>0)?e.e({t:e.f(C.value,((a,t,l)=>e.e({a:a.cover,b:e.t(a.title),c:e.t(a.level),d:e.t(j(a.type)),e:e.t(A(a.category)),f:e.f(a.tags,((a,t,l)=>({a:e.t(a),b:t}))),g:e.t(a.desc),h:a.isPassed&&!a.isApplied},a.isPassed&&!a.isApplied?{i:e.o((t=>(a=>{if(!a.postId)return void e.index.showToast({title:"该测评未关联岗位,无法投递",icon:"none"});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=${a.postId}`})})(a)),t)}:{},{j:a.isPassed&&a.isApplied},(a.isPassed&&a.isApplied,{}),{k:a.hasRecord&&!a.isPassed},a.hasRecord&&!a.isPassed?{l:a.isCompleted?"":1,m:e.o((t=>(a=>{a.isCompleted&&e.index.navigateTo({url:`/pages/assessment/report?id=${a.id}`})})(a)),t)}:{},{n:a.hasRecord&&!a.isPassed},a.hasRecord&&!a.isPassed?{o:e.o((e=>$(a)),t)}:{},{p:!a.hasRecord},a.hasRecord?{}:{q:e.o((t=>(async a=>{const t=e.index.getStorageSync("userInfo")||{},l=t.studentId||null;if(!l)return e.index.showToast({title:"请先登录",icon:"none"}),void setTimeout((()=>{e.index.navigateTo({url:"/pages/login/login"})}),1e3);try{e.index.showLoading({title:"正在连接客服..."});const i=t.name||"用户",n=t.avatarUrl||"/static/images/user_avatar.svg",o=await s.createOrGetSession({sessionType:1,fromUserId:l,fromUserName:i,fromUserAvatar:n,sourceId:"assessment_"+((null==a?void 0:a.id)||"")});if(e.index.hideLoading(),o.data){const t=o.data,s=encodeURIComponent(a&&a.title||""),n=encodeURIComponent(a&&a.cover||""),u=a&&a.id||"",r=encodeURIComponent(a&&a.level||""),d=a&&a.price||"";e.index.navigateTo({url:`/pages/chat/chat?sessionId=${t.sessionId}&sessionNo=${t.sessionNo||""}&fromUserId=${l}&userName=${encodeURIComponent(i)}&type=assessment&title=${s}&cover=${n}&assessmentId=${u}&level=${r}&price=${d}`})}else e.index.showToast({title:"创建会话失败",icon:"none"})}catch(i){e.index.hideLoading(),console.error("创建会话失败:",i),e.index.showToast({title:"连接失败,请重试",icon:"none"})}})(a)),t)},{r:a.hasPaid&&!a.hasRecord},a.hasPaid&&!a.hasRecord?{s:e.o((e=>$(a)),t)}:{},{t:t,v:e.o((e=>$(a)),t)}))),v:0===C.value.length},0===C.value.length?{w:a._imports_3$2}:{},{x:q.value+"px"}):{},{y:g.value&&0===c.value.length&&1===r.value},(g.value&&0===c.value.length&&r.value,{}),{z:1===r.value&&(!g.value||c.value.length>0)},1===r.value&&(!g.value||c.value.length>0)?e.e({A:e.f(U.value,((t,l,s)=>e.e({a:"offline"===t.trainingType},"offline"===t.trainingType?e.e({b:e.t(t.title),c:e.t(j(t.type)),d:e.t(A(t.category)),e:e.f(t.tags,((a,t,l)=>({a:e.t(a),b:t}))),f:a._imports_2$2,g:e.t(t.location),h:a._imports_0$2,i:e.t(t.organizer),j:a._imports_1$1,k:e.t(t.trainingTime),l:a._imports_1$1,m:e.t(t.deadline),n:t.isEnding},(t.isEnding,{}),{o:e.o((e=>N(t)),l)}):e.e({p:t.cover,q:a._imports_7,r:e.t(t.views),s:a._imports_8$1,t:e.t(t.duration),v:"live"===t.trainingType},"live"===t.trainingType?{w:e.t("streaming"===t.status?"直播中":"upcoming"===t.status?"即将开始":"not-started"===t.status?"未开始":"finished"===t.status?"已结束":"直播"),x:e.n(t.status)}:{},{y:e.t(t.title),z:"live"===t.trainingType},"live"===t.trainingType?{A:a._imports_9,B:e.t(t.spectators)}:{},{C:e.o((e=>N(t)),l)}),{D:l}))),B:0===U.value.length},0===U.value.length?{C:a._imports_3$2}:{},{D:q.value+"px"}):{},{E:e.p({activeIndex:1})})}},o=e._export_sfc(n,[["__scopeId","data-v-a88e4b18"]]);wx.createPage(o);