You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
12 KiB

1 week ago
  1. import{r as e,a5 as a,b as l,c as s,w as t,Y as u,a6 as o,_ as n,i as c,o as i,d as f,e as r,u as d,t as v,k as _,m as p,f as m,g as y,F as k,A as x,a2 as w,a7 as b,y as h,j as g,v as C,a3 as T,a4 as I}from"./index-DkGewvWo.js";import{_ as j}from"./u-count-down.IX03siaP.js";import{o as A,r as B}from"./uni-app.es.Bo01BzMV.js";import{_ as z}from"./u-navbar.CwZJfInl.js";import{_ as F}from"./u-icon.x7ElsZU9.js";import{_ as R}from"./u-popup.C1usqomr.js";import{_ as q,a as E,b as N,c as S,d as U,e as V}from"./sc.S7-az16m.js";import{c as D}from"./car.CcI8AEaV.js";import{_ as H}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./u-status-bar.DDNs5qwz.js";import"./u-loading-icon.CdrBTsp-.js";const Q=H({__name:"examQuestions",setup(H){const Q=e("1"),$=e(["单选题","多选题","判断题"]),L=e(0),M=e(0);let O=e(!1),Y=D(),G=e(45),J=e(90);A((e=>{G.value=e.totalExamTime||45,J.value=e.score}));const K=e(!1);function P(){K.value=!1}function W(){K.value=!0}let X=e(!1),Z=e("");function ee(){X.value=!1,Z.value=""}const ae=e({}),le=e([]);let se=e([]),te=e(0);function ue(){ae.value.optionArr=[];["a","b","c","d","e","f"].forEach(((e,a)=>{let l="option"+e;if(ae.value[l]){let s={key:e.toLocaleUpperCase(),text:ae.value[l],index:a+1};ae.value.optionArr.push(s)}})),3==ae.value.types&&(ae.value.optionArr[0].key="true",ae.value.optionArr[1].key="false")}async function oe(e){if(2==ae.value.types&&ie.value.ans){if(ie.value.answer||(ie.value.answer=ie.value.ans),ae.value.answer!=ie.value.ans&&"next"!=ie.value.isNext)return ie.value.isNext="next",ae.value.yes=0,!1;ae.value.answer==ie.value.ans&&(ae.value.yes=1)}ie.value={},ae.value.optionArr=[],te.value=te.value+e,ne()}async function ne(){console.log(te.value),ae.value=le.value[te.value],ie.value={},ae.value.optionArr=[],ie.value.isNext="",ue()}async function ce(){let e=1==ae.value.isCollect?"0":"1";const a={carType:Y.carInfo.carType,isAdd:e,questionId:ae.value.id,stepType:Y.carInfo.stepType};await w(a),ae.value.isCollect=e,console.log(ae.value.isCollect)}!async function(){try{u({title:"正在加载..."});let e={carType:Y.carInfo.carType,stepType:Y.carInfo.stepType,city:Y.carInfo.city,examType:1};const{data:a}=await o(e);n(),ae.value=a.questionBank[0],le.value=a.questionBank,ue(),se.value=a}catch(e){n()}}(),a((()=>le),((e,a)=>{L.value=a.value.filter((e=>e.yes)).length,M.value=a.value.filter((e=>0==e.yes)).length}),{deep:!0});const ie=e({});let fe=e(0),re=e(null);function de(){let e=le.value.filter((e=>null==e.yes));e.length||1*J.value>L.value?(fe.value=e.length,O.value=!0,re.value&&re.value.pause()):_e()}function ve(){O.value=!1,re.value&&re.value.start()}async function _e(){let e=le.value.filter((e=>1!=e.yes)),a=e.map((e=>e.id)).join(","),l={answer:null,carType:Y.carInfo.carType,examId:se.value.id,examType:1,grade:le.value.length-e.length,isEnd:1,pass:1,sort:se.value.sort,stepType:Y.carInfo.stepType,userId:se.value.userId,wrongQuestionIds:a};const s=await b(l);console.log(s),uni.$u.toast("已交卷"),setTimeout((()=>{h()}),1500)}function pe(){uni.$u.toast("考试时间已到,准备自动为您交卷"),setTimeout((()=>{_e()}),1500)}function me(){h()}return(e,a)=>{const u=c,o=B(l("up-count-down"),j),n=B(l("up-navbar"),z),w=B(l("up-icon"),F),b=g,h=C,A=T,D=B(l("up-popup"),R),H=B(l("up-textarea"),q),Y=B(l("up-button"),E);return i(),s(u,{class:"content"},{default:t((()=>[f(n,{leftText:" ",title:"",safeAreaInsetTop:!1,autoBack:!0},{center:t((()=>[f(u,{class:"flex"},{default:t((()=>[f(u,{class:"lastText"},{default:t((()=>[r("剩余时间")])),_:1}),f(u,{class:"lastText",style:{margin:"8rpx 0 0 8rpx"}},{default:t((()=>[f(o,{time:60*d(G)*1e3,format:"mm:ss",onFinish:pe,ref_key:"countDownRef",ref:re},null,8,["time"])])),_:1})])),_:1})])),_:1}),f(u,{class:"top_row flex"},{default:t((()=>[f(u,{class:"itemCount"},{default:t((()=>[f(w,{name:"checkmark-circle-fill",color:"#55ff7f",size:"20"}),f(u,{class:"count"},{default:t((()=>[r(v(L.value),1)])),_:1})])),_:1}),f(u,{class:"itemCount"},{default:t((()=>[f(w,{name:"close-circle-fill",color:"#ff0000",size:"20"}),f(u,{class:"count"},{default:t((()=>[r(v(M.value),1