"use strict";const e=require("../../common/vendor.js"),a=require("../../api/assessment.js"),t={__name:"remind",setup(t){const o=e.ref(""),s=e.ref(""),i=e.ref(!0),n=e.ref({position:"",questionTypes:"",totalTime:0,totalScore:0,passMark:0,abilityPassDesc:""}),l=e.ref("");e.onLoad((async e=>{e.source&&(o.value=e.source),e.id&&(s.value=e.id),await r()}));const r=async()=>{i.value=!0;try{let e=null;if(s.value){const t=await a.getAssessmentDetail(s.value);200===t.code&&t.data&&(e=t.data)}if(!e){const t=await a.getAssessmentList({pageNum:1,pageSize:1});if(200===t.code&&Array.isArray(t.rows)&&t.rows.length>0){const o=await a.getAssessmentDetail(t.rows[0].id);200===o.code&&o.data&&(e=o.data,s.value||(s.value=t.rows[0].id,console.log("使用兜底测评ID:",s.value)))}}if(e){n.value.position=e.position||e.evaluationName||"—";const a=Array.isArray(e.abilityConfigs)?e.abilityConfigs:[];if(a.length>0){const e=a.reduce(((e,a)=>e+(a.thirdExamTime||0)),0);n.value.totalTime=e;const t=a.reduce(((e,a)=>e+(a.thirdExamTotalScore||0)),0);n.value.totalScore=t;const o=a.reduce(((e,a)=>e+(a.thirdExamPassMark||0)),0);if(n.value.passMark=o,a.length>1){const e=a.map((e=>`${e.abilityName||e.thirdExamName||"能力"}及格${e.thirdExamPassMark||0}分`));n.value.abilityPassDesc=e.join(",")}n.value.questionTypes="单选/多选/问答";const s=a.find((e=>e&&e.thirdExamLink));s&&(l.value=s.thirdExamLink)}}}catch(e){console.error("加载测评信息失败:",e)}finally{i.value=!1}},u=async()=>{try{if(!l.value&&!s.value)return void e.index.showToast({title:"未配置考试链接",icon:"none"});const o=(e.index.getStorageSync("userInfo")||{}).studentId;if(!o)return void e.index.showToast({title:"请先登录",icon:"none"});if(s.value)try{e.index.showLoading({title:"创建测评申请..."}),console.log("准备创建测评申请,evaluationId:",s.value,"studentId:",o);const t=await a.createExamApply(s.value,o);if(console.log("测评申请创建结果:",t),e.index.hideLoading(),200!==t.code)return void e.index.showToast({title:t.msg||"创建测评申请失败",icon:"none"});console.log("测评申请创建成功,申请ID:",t.data.id)}catch(t){e.index.hideLoading(),console.error("创建测评申请失败:",t),console.warn("测评申请创建失败,但仍允许进入考试")}e.index.navigateTo({url:`/pages/common/webview?mode=kaoshixing&assessmentId=${encodeURIComponent(s.value||"")}&fallbackUrl=${encodeURIComponent(l.value||"")}`})}catch(o){console.error("打开考试链接失败:",o),e.index.showToast({title:"打开考试链接失败",icon:"none"})}};return(a,t)=>e.e({a:i.value},i.value?{}:e.e({b:e.t(n.value.position||"—"),c:n.value.questionTypes},n.value.questionTypes?{d:e.t(n.value.questionTypes)}:{},{e:n.value.totalTime},n.value.totalTime?{f:e.t(n.value.totalTime)}:{},{g:n.value.passMark},n.value.passMark?e.e({h:e.t(n.value.totalScore),i:e.t(n.value.passMark),j:n.value.abilityPassDesc},n.value.abilityPassDesc?{k:e.t(n.value.abilityPassDesc)}:{}):{}),{l:e.o(u),m:i.value})}},o=e._export_sfc(t,[["__scopeId","data-v-903fa735"]]);wx.createPage(o);