1 |
- import{d as N,U,q as P,r as O,x as M,e as D,y as Q,a8 as H,a as t,S as K,A as c,C as q,V as C,a2 as $,D as g,z as F,_ as z}from"./index-5e5e4ebc.js";import{e as y,Q as f,C as m,D as V,K as j,P as W,i as Y,A as G,a as X,R as J}from"./index-9fd9ceff.js";import{M as L}from"./index-9096eaf6.js";import{E as Z}from"./index-ebaba9ec.js";import{b as ee,u as se,a as te}from"./index-572087e5.js";import{S as ne,a as oe}from"./index-d46a4ad2.js";import{I as ae}from"./index-fa23aaeb.js";import"./index-8fc8f1a6.js";import"./index-cc5b42dd.js";import"./index-4bcfa431.js";const ie="_unitDetail_1xn4x_1",le="_unitSwipe_1xn4x_9",ue="_questionTitle_1xn4x_12",re="_questionNum_1xn4x_21",ce="_questionType_1xn4x_24",de="_wapList_1xn4x_42",pe="_btnSection_1xn4x_48",fe="_prevBtn_1xn4x_53",we="_nextBtn_1xn4x_54",ve="_activePrevBtn_1xn4x_55",ye="_right_1xn4x_78",he="_error_1xn4x_81",be="_primary_1xn4x_84",a={unitDetail:ie,unitSwipe:le,questionTitle:ue,questionNum:re,questionType:ce,wapList:de,btnSection:pe,prevBtn:fe,nextBtn:we,activePrevBtn:ve,right:ye,error:he,primary:be};function xe(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!$(r)}const Se=N({name:"unit-detail",setup(){const r=U(),h=P(),d=O(),e=M({type:r.query.type,knowledgePointIds:r.query.knowledgePointIds,lessonCoursewareId:r.query.lessonCoursewareId,background:"transparent",color:"#fff",visiableError:!1,visiableAnswer:!1,id:r.query.id,currentIndex:0,questionList:[],visiableInfo:{show:!1,operationType:"RESULT",type:"DEFAULT",content:"",showCancelButton:!1,confirmButtonText:"",cancelButtonText:"",title:""},nextStatus:!1,swipeHeight:"auto",answerAnalysis:"",questionTypeCode:"",overResult:{time:"00:00",questionLength:0,errorLength:0,rate:0}}),{counter:I,resume:Ie,pause:_}=ee(1e3,{controls:!0}),B=async()=>{try{const{data:o}=await g.post("/edu-app/studentUnitExamination/queryPracticeModeExam",{data:{lessonCoursewareId:e.lessonCoursewareId,knowledgePointIds:e.knowledgePointIds}}),s=o||{};s.examinationQuestionAdds.forEach(n=>{n.showAnalysis=!1,n.analysis={message:n.answerAnalysis,topic:!0,isAnswer:!1,userResult:!1,disabled:!1},n.userAnswer=[]}),e.questionList=s.examinationQuestionAdds||[]}catch(o){}},E=async()=>{var o,s;try{const n=e.questionList||[];let i=!0;if(!((o=n[e.currentIndex])!=null&&o.analysis.isAnswer)){let u={};n.forEach((l,x)=>{x===e.currentIndex&&(u={questionId:l.id,details:l.userAnswer||[]})});const{data:p}=await g.post("/edu-app/studentUnitExamination/submitTrainingAnswer",{hideLoading:!0,data:u});i=p,n.forEach((l,x)=>{x===e.currentIndex&&(e.answerAnalysis=l.answerAnalysis,e.questionTypeCode=l.questionTypeCode,l.showAnalysis=!0,l.analysis.userResult=p,l.analysis.isAnswer=!0,l.analysis.disabled=!0)})}if(e.questionList.length===e.currentIndex+1){y.emit("unitAudioStop"),e.visiableInfo.show=!0,e.visiableInfo.title="练习完成",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="CONTINUE",e.visiableInfo.cancelButtonText="再等等",e.visiableInfo.confirmButtonText="确认完成",e.visiableInfo.content="确认本次练习的题目都完成了吗?",T();return}i?(s=d.value)==null||s.next():e.visiableError=!0}catch(n){}},A=D(()=>{const o=e.questionList||[];let s=0,n=0,i=0;return o.forEach(u=>{u.showAnalysis&&(s+=1,u.analysis.userResult?n+=1:i+=1)}),{count:s,passCount:n,noPassCount:i}});let b=0;const w=(o=!0)=>{F(()=>{o&&window.scrollTo(0,0),setTimeout(()=>{var p;const s=(p=document.querySelectorAll(".van-swipe-item")[e.currentIndex])==null?void 0:p.querySelector(".swipe-item-question"),n=s==null?void 0:s.querySelectorAll(".answerTitleImg img");let i=!0;n==null||n.forEach(l=>{console.log(l.complete),l.complete||(i=!1)}),!i&&b<3&&setTimeout(()=>{b+=1,w(o)},300),i&&(b=0);const u=z(s);e.swipeHeight=u.height},100)})},S=()=>{e.visiableInfo.operationType==="RESULT"?(e.visiableInfo.show=!1,h.back(),h.back()):e.visiableInfo.operationType==="BACK"?(e.visiableInfo.show=!1,T()):e.visiableInfo.operationType==="CONTINUE"&&R()},k=async()=>{e.visiableInfo.operationType==="RESULT"||(e.visiableInfo.operationType==="BACK"||e.visiableInfo.operationType==="CONTINUE")&&(e.visiableInfo.show=!1,window.history.pushState(null,"",document.URL),window.addEventListener("popstate",v,!1))},R=()=>{const o=A.value;let s=0;o.count>0&&(s=Math.floor(o.passCount/o.count*100));const n=I.value,i=Math.floor(n/60)>=10?Math.floor(n/60):"0"+Math.floor(n/60),u=n%60>=10?n%60:"0"+n%60;e.overResult={time:i+":"+u,questionLength:o.count,errorLength:o.noPassCount,rate:s},_(),I.value=0,e.visiableInfo.show=!0,e.visiableInfo.title="已完成~",e.visiableInfo.showCancelButton=!1,e.visiableInfo.operationType="RESULT",e.visiableInfo.confirmButtonText="确认",e.visiableInfo.content=`<div>您已完成本次测试,答对<span class='${a.right}'>${o.passCount}</span>,答错<span class='${a.error}'>${o.count-o.passCount}</span>,正确率<span class='${a.primary}'>${s}%</span>~</div>`},v=()=>{const o=A.value;e.visiableInfo.show=!0,e.visiableInfo.title="确认退出吗?",e.visiableInfo.showCancelButton=!0,e.visiableInfo.operationType="BACK",e.visiableInfo.cancelButtonText="取消",e.visiableInfo.confirmButtonText="确定",e.visiableInfo.content=`您已经完成${o.passCount+o.noPassCount}道题了,继续做题可以巩固所学知识哦~`,y.emit("unitAudioStop")},T=()=>{window.removeEventListener("popstate",v,!1),h.back()};return Q(async()=>{se(document,"scroll",()=>{const{y:o}=te();o.value>52?(e.background="#fff",e.color="#323333"):(e.background="transparent",e.color="#fff")}),await B(),w(),window.history.pushState(null,"",document.URL),window.addEventListener("popstate",v,!1)}),H(()=>{y.emit("unitAudioStop")}),()=>{let o;return t("div",{class:a.unitDetail},[t(L,{position:"top"},{default:()=>[t(K,{border:!1,background:e.background,color:e.color},null)]}),t(ne,{loop:!1,showIndicators:!1,ref:d,duration:300,touchable:!1,class:a.unitSwipe,style:{paddingBottom:"12px"},lazyRender:!0,height:e.swipeHeight,onChange:s=>{y.emit("unitAudioStop"),e.currentIndex=s,w()}},xe(o=e.questionList.map((s,n)=>t(oe,null,{default:()=>[t("div",{class:"swipe-item-question"},[s.questionTypeCode===f.RADIO&&t(m,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,index:n+1,data:s,type:"radio",showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===f.CHECKBOX&&t(m,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,index:n+1,data:s,type:"checkbox",showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===f.SORT&&t(V,{value:s.userAnswer,"onUpdate:value":[i=>s.userAnswer=i,()=>{const i=!(s.userAnswer&&s.userAnswer.length>0);w(i)}],data:s,index:n+1,showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===f.LINK&&t(j,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,data:s,index:n+1,showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])}),s.questionTypeCode===f.PLAY&&t(W,{value:s.userAnswer,"onUpdate:value":i=>s.userAnswer=i,data:s,index:n+1,unitId:e.id,showAnalysis:s.showAnalysis,analysis:s.analysis},{title:()=>t("div",{class:a.questionTitle},[t("div",{class:a.questionNum},[t("span",null,[e.currentIndex+1]),c("/"),e.questionList.length]),t("div",{class:a.questionType},[t("i",null,null),t("span",null,[s.knowledgePointName])])])})])]})))?o:{default:()=>[o]}),t(L,{position:"bottom"},{default:()=>[t("div",{class:["btnGroup btnMore",a.btnSection]},[t(q,{round:!0,block:!0,class:e.currentIndex>0?a.activePrevBtn:a.prevBtn,disabled:!(e.currentIndex>0),onClick:()=>{var s;(s=d.value)==null||s.prev()}},{default:()=>[c("上一题")]}),t(q,{block:!0,round:!0,class:a.nextBtn,onClick:E,loading:e.nextStatus,disabled:e.nextStatus},{default:()=>[e.questionList.length===e.currentIndex+1?"提交":"下一题"]}),t(ae,{src:Y,class:[a.wapList,"van-haptics-feedback"],onClick:()=>e.visiableAnswer=!0},null)])]}),t(G,{show:e.visiableAnswer,"onUpdate:show":s=>e.visiableAnswer=s,title:"题目列表",safeAreaInsetBottom:!0},{default:()=>[t(X,{value:e.questionList,statusList:[{text:"答对",color:"#1CACF1"},{text:"答错",color:"#FF8486"},{text:"未答",color:"#EAEAEA"}],lookType:"PRACTICE",onSelect:s=>{var n;(n=d.value)==null||n.swipeTo(s,{immediate:!0}),e.visiableAnswer=!1}},null)]}),t(C,{show:e.visiableError,"onUpdate:show":s=>e.visiableError=s,style:{width:"90%"},round:!0,closeOnClickOverlay:!1},{default:()=>[t(Z,{onClose:()=>e.visiableError=!1,answerAnalysis:e.answerAnalysis,questionTypeCode:e.questionTypeCode,onConform:()=>{var s;(s=d.value)==null||s.next(),e.answerAnalysis=""}},null)]}),t(C,{show:e.visiableInfo.show,"onUpdate:show":s=>e.visiableInfo.show=s,closeOnClickOverlay:!1,style:{background:"transparent",width:"100%",maxWidth:"100%",transform:"translateY(-55%)"}},{default:()=>[t(J,{title:e.visiableInfo.title,showCancelButton:e.visiableInfo.showCancelButton,cancelButtonText:e.visiableInfo.cancelButtonText,confirmButtonText:e.visiableInfo.confirmButtonText,status:e.visiableInfo.type,content:e.visiableInfo.content,contentHtml:!0,onConform:S,onClose:k},null)]})])}}});export{Se as default};
|