questionBank.vue 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar
  4. class="navbar"
  5. @clickLeft="clickLeft"
  6. left-icon="back"
  7. :statusBar="true"
  8. title="试卷"
  9. ></uni-nav-bar>
  10. <swiper
  11. class="swiper"
  12. :current="current"
  13. @change="swiperChange"
  14. :interval="interval"
  15. >
  16. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  17. <view class="pageContent">
  18. <view class="pad_8 titBox">
  19. <view class="firstLetter">
  20. <view class="leftLetters">
  21. <view class="btnType">
  22. <text v-if="bank.type == 1">单选</text>
  23. <text v-if="bank.type == 2">多选</text>
  24. <text v-if="bank.type == 3">判断</text>
  25. <text v-if="bank.type == 4">案例</text>
  26. <text v-if="bank.type == 5">简答</text>
  27. </view>
  28. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  29. </view>
  30. <view style="color: #666; font-size: 28rpx">{{
  31. countdown(lastTime)
  32. }}</view>
  33. <view class="leftLetters"></view>
  34. </view>
  35. <view class="titles"
  36. ><rich-text :nodes="bank.content"></rich-text
  37. ></view>
  38. </view>
  39. <template v-if="bank.type == 1">
  40. <view class="pad_8 titBox no-margin">
  41. <view v-if="!bank.ques">
  42. <view
  43. v-for="(item, index) in bank.jsonStr"
  44. :key="index"
  45. class="lisSty"
  46. @click="radioSelect(item.optionsId, bankIndex)"
  47. >
  48. <view class="activeTI">{{ ast[index] }}</view>
  49. <view class="flex_auto">{{ item.content }}</view>
  50. </view>
  51. </view>
  52. <view v-if="bank.ques">
  53. <view
  54. v-for="(item, index) in bank.jsonStr"
  55. :key="index"
  56. class="lisSty"
  57. @click="radioSelect(item.optionsId, bankIndex)"
  58. >
  59. <text
  60. :class="{
  61. right:
  62. bankType == 1 && (item.optionsId == bank.ques ||
  63. item.optionsId == bank.ans),
  64. wrong:
  65. bankType == 1 && (item.optionsId == bank.ques && bank.ques != bank.ans),
  66. user_choose: bankType == 2 && (item.optionsId == bank.ques),
  67. }"
  68. class="activeTI"
  69. >
  70. {{ ast[index] }}
  71. </text>
  72. <view class="flex_auto">{{ item.content }}</view>
  73. </view>
  74. </view>
  75. </view>
  76. <view v-if="bankType == 1 && bank.ques">
  77. <view class="pad_8 answer">
  78. <view>正确答案:{{ ast[bank.ans - 1] }}</view>
  79. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  80. </view>
  81. <view class="pad_8 answerInfos">
  82. <view class="answerTitle">答案解析</view>
  83. <view class="answerContent"
  84. ><rich-text :nodes="bank.analysisContent"></rich-text
  85. ></view>
  86. </view>
  87. </view>
  88. </template>
  89. <template v-if="bank.type == 2">
  90. <view class="pad_8 titBox no-margin">
  91. <view v-if="!bank.ques">
  92. <view
  93. v-for="(item, index) in bank.jsonStr"
  94. :key="index"
  95. class="lisSty"
  96. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  97. >
  98. <view :class="{ checked: item.checked }" class="activeTI">{{
  99. ast[index]
  100. }}</view>
  101. <view class="flex_auto">{{ item.content }}</view>
  102. </view>
  103. </view>
  104. <view
  105. v-if="bankType == 2 || (bankType == 1 && !bank.ques)"
  106. class="submit_checkbox"
  107. :class="{ disabled: !isCheckboxChecked(bank.jsonStr) }"
  108. @click="checkboxSubmit(bankIndex)"
  109. >确认答案</view
  110. >
  111. <view v-if="bank.ques">
  112. <view
  113. v-for="(item, index) in bank.jsonStr"
  114. :key="index"
  115. class="lisSty"
  116. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  117. >
  118. <text
  119. :class="{
  120. right:
  121. bankType == 1 && (bank.ques.indexOf(item.optionsId) != -1 ||
  122. bank.ans.indexOf(item.optionsId) != -1),
  123. wrong:
  124. bankType == 1 && (bank.ques.indexOf(item.optionsId) != -1 &&
  125. bank.ans.indexOf(item.optionsId) == -1),
  126. user_choose: bankType == 2 && item.checked,
  127. }"
  128. class="activeTI"
  129. >
  130. {{ ast[index] }}
  131. </text>
  132. <view class="flex_auto">{{ item.content }}</view>
  133. </view>
  134. </view>
  135. </view>
  136. <view v-if="bankType == 1 && bank.ques">
  137. <view class="pad_8 answer">
  138. <view>
  139. 正确答案:
  140. <text
  141. v-for="(ansItem, ansItemIndex) in bank.ans"
  142. :key="ansItemIndex"
  143. >{{ ast[ansItem - 1] }}</text
  144. >
  145. </view>
  146. <view>
  147. 我的答案:
  148. <text
  149. v-for="(quesItem, quesItemIndex) in bank.ques"
  150. :key="quesItemIndex"
  151. >{{ ast[quesItem - 1] }}</text
  152. >
  153. </view>
  154. </view>
  155. <view class="pad_8 answerInfos">
  156. <view class="answerTitle">答案解析</view>
  157. <view class="answerContent"
  158. ><rich-text :nodes="bank.analysisContent"></rich-text
  159. ></view>
  160. </view>
  161. </view>
  162. </template>
  163. <template v-if="bank.type == 3">
  164. <view class="pad_8 titBox no-margin">
  165. <view v-if="!bank.ques">
  166. <view
  167. v-for="(item, index) in judge"
  168. :key="index"
  169. class="lisSty"
  170. @click="judgeSelect(index, bankIndex)"
  171. >
  172. <view class="activeTI">{{ ast[index] }}</view>
  173. <view class="flex_auto">
  174. {{ item }}
  175. </view>
  176. </view>
  177. </view>
  178. <view v-if="bank.ques">
  179. <view
  180. v-for="(item, index) in judge"
  181. :key="index"
  182. class="lisSty"
  183. @click="judgeSelect(index, bankIndex)"
  184. >
  185. <text
  186. :class="{
  187. right: bankType == 1 && (index == (bank.ques == 1 ? 0 : 1) || index != bank.ans),
  188. wrong: bankType == 1 && (index == (bank.ques == 1 ? 0 : 1) && bank.ques != bank.ans),
  189. user_choose: bankType == 2 && (index == (bank.ques == 1 ? 0 : 1)),
  190. }"
  191. class="activeTI"
  192. >
  193. {{ ast[index] }}
  194. </text>
  195. <view class="flex_auto">
  196. {{ item }}
  197. </view>
  198. </view>
  199. </view>
  200. </view>
  201. <view v-if="bankType == 1 && bank.ques">
  202. <view class="pad_8 answer">
  203. <view>正确答案:{{ ast[bank.ans == 1 ? 0 : 1] }}</view>
  204. <view>我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view>
  205. </view>
  206. <view class="pad_8 answerInfos">
  207. <view class="answerTitle">答案解析</view>
  208. <view class="answerContent"
  209. ><rich-text :nodes="bank.analysisContent"></rich-text
  210. ></view>
  211. </view>
  212. </view>
  213. </template>
  214. <!-- 简答题 -->
  215. <template v-if="bank.type == 5">
  216. <view class="pad_8 titBox">
  217. <view class="ans">
  218. <view
  219. class="ans_input"
  220. v-if="
  221. bankType == 2 || (bankType == 1 && (!bank.ques ||
  222. (!bank.ques.imageList.length && !bank.ques.text)))
  223. "
  224. >
  225. <view class="top flex">
  226. <image
  227. :data-index="bankIndex"
  228. class="icon"
  229. @click="chooseImg(bankIndex)"
  230. src="/static/camera.png"
  231. mode=""
  232. ></image>
  233. <view class="progress"
  234. >{{ bank.ansText.imageList.length || "0" }}/4</view
  235. >
  236. <view
  237. class="submit"
  238. :class="{ disabled: !bank.ansText.text && hasImgs(bank) }"
  239. @click="submitAns(bankIndex)"
  240. >确认答案</view
  241. >
  242. </view>
  243. <view class="textarea">
  244. <textarea
  245. v-model="bank.ansText.text"
  246. placeholder="在此输入答案"
  247. ></textarea>
  248. </view>
  249. <view class="imgs">
  250. <view
  251. class="img"
  252. v-for="(img, imgIndex) in bank.ansText.imageList"
  253. :key="imgIndex"
  254. >
  255. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  256. <image :src="$method.splitImgHost(img, true)"></image>
  257. </view>
  258. </view>
  259. </view>
  260. <view
  261. class="ans_submit answerInfos"
  262. v-if="bankType == 1 && (bank.ques.text || bank.ques.imageList.length)"
  263. >
  264. <view class="answerTitle">我的答案:</view>
  265. {{ bank.ques.text }}
  266. <view class="imgs"
  267. ><image
  268. class="img"
  269. v-for="(ques, quesIndex) in bank.ques.imageList"
  270. :key="quesIndex"
  271. :src="$method.splitImgHost(ques, true)"
  272. ></image
  273. ></view>
  274. </view>
  275. </view>
  276. </view>
  277. <view
  278. v-if="bankType == 1 && bank.ques && (bank.ques.text || bank.ques.imageList.length)"
  279. >
  280. <view class="pad_8 answerInfos">
  281. <view class="answerTitle">答案解析:</view>
  282. <view class="answerContent"
  283. ><rich-text :nodes="bank.analysisContent"></rich-text
  284. ></view>
  285. </view>
  286. </view>
  287. </template>
  288. <!-- 案例题 -->
  289. <template v-if="bank.type == 4">
  290. <view class="tabs">
  291. <view
  292. class="tab"
  293. :class="{ current: tabIndex == bank.current }"
  294. :key="tabIndex"
  295. v-for="(tab, tabIndex) in bank.jsonStr"
  296. @click="tabSelect(tabIndex, bankIndex)"
  297. >
  298. 问题{{ tabIndex + 1 }}
  299. </view>
  300. </view>
  301. <view
  302. v-for="(ansItem, ansIndex) in bank.jsonStr"
  303. v-if="bank.current == ansIndex"
  304. :key="ansIndex"
  305. >
  306. <template v-if="ansItem.type == 1">
  307. <view class="pad_8 titBox">
  308. <view class="leftLetters">
  309. <view class="btnType">
  310. <text>单选</text>
  311. </view>
  312. </view>
  313. <view class="titles">
  314. <rich-text :nodes="ansItem.content"></rich-text>
  315. </view>
  316. <view v-if="!bank.ques[ansIndex]">
  317. <view
  318. v-for="(option, childIndex) in ansItem.optionsList"
  319. :key="childIndex"
  320. class="lisSty"
  321. @click="
  322. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  323. "
  324. >
  325. <view class="activeTI">{{ ast[childIndex] }}</view>
  326. <view class="flex_auto">
  327. <rich-text
  328. class="textChild"
  329. :nodes="option.content"
  330. ></rich-text>
  331. </view>
  332. </view>
  333. </view>
  334. <view v-if="bank.ques[ansIndex]">
  335. <view
  336. v-for="(option, childIndex) in ansItem.optionsList"
  337. :key="childIndex"
  338. class="lisSty"
  339. @click="
  340. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  341. "
  342. >
  343. <text
  344. :class="{
  345. right:
  346. bankType == 1 && (option.optionsId == bank.ques[ansIndex] ||
  347. option.optionsId == bank.ans[ansIndex]),
  348. wrong:
  349. bankType == 1 && (option.optionsId == bank.ques[ansIndex] &&
  350. bank.ques[ansIndex] != bank.ans[ansIndex]),
  351. user_choose: bankType == 2 && (option.optionsId == bank.ques[ansIndex]),
  352. }"
  353. class="activeTI"
  354. >
  355. {{ ast[childIndex] }}
  356. </text>
  357. <view class="flex_auto">
  358. <rich-text :nodes="option.content"></rich-text>
  359. </view>
  360. </view>
  361. </view>
  362. </view>
  363. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  364. <view class="pad_8 answer">
  365. <view>正确答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  366. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  367. </view>
  368. <view class="pad_8 answerInfos">
  369. <view class="answerTitle">答案解析</view>
  370. <view class="answerContent"
  371. ><rich-text :nodes="option.analysisContent"></rich-text
  372. ></view>
  373. </view>
  374. </view>
  375. </template>
  376. <template v-if="ansItem.type == 2">
  377. <view class="pad_8 titBox">
  378. <view class="leftLetters">
  379. <view class="btnType">
  380. <text>多选</text>
  381. </view>
  382. </view>
  383. <view class="titles">
  384. <rich-text :nodes="ansItem.content"></rich-text>
  385. </view>
  386. <view v-if="!bank.ques[ansIndex]">
  387. <view
  388. v-for="(option, childindex) in ansItem.optionsList"
  389. :key="childindex"
  390. class="lisSty"
  391. @click="
  392. checkboxSelectChild(bankIndex, ansIndex, childindex)
  393. "
  394. >
  395. <view
  396. :class="{ checked: option.checked }"
  397. class="activeTI"
  398. >{{ ast[childindex] }}</view
  399. >
  400. <view class="flex_auto">
  401. <rich-text :nodes="option.content"></rich-text>
  402. </view>
  403. </view>
  404. </view>
  405. <view
  406. v-if="bankType == 2 || (bankType == 1 && !bank.ques[ansIndex])"
  407. class="submit_checkbox"
  408. :class="{
  409. disabled: !isCheckboxChecked(ansItem.optionsList),
  410. }"
  411. @click="checkboxSubmitChild(bankIndex, ansIndex)"
  412. >确认答案</view
  413. >
  414. <view v-if="bank.ques && bank.ques[ansIndex]">
  415. <view
  416. v-for="(option, childindex) in ansItem.optionsList"
  417. :key="childindex"
  418. class="lisSty"
  419. @click="
  420. checkboxSelectChild(bankIndex, ansIndex, childindex)
  421. "
  422. >
  423. <text
  424. :class="{
  425. right: bankType == 1 && right(bankIndex, ansIndex, option),
  426. wrong: bankType == 1 && wrong(bankIndex, ansIndex, option),
  427. user_choose: bankType == 2 && option.checked,
  428. }"
  429. class="activeTI"
  430. >
  431. {{ ast[childindex] }}
  432. </text>
  433. <view class="flex_auto">
  434. <rich-text :nodes="option.content"></rich-text>
  435. </view>
  436. </view>
  437. </view>
  438. </view>
  439. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  440. <view class="pad_8 answer">
  441. <view>
  442. 正确答案:
  443. <text
  444. :key="ansItemIndex1"
  445. v-for="(ansItem1, ansItemIndex1) in bank.ans[ansIndex]"
  446. >{{ ast[ansItem1 - 1] }}</text
  447. >
  448. </view>
  449. <view>
  450. 我的答案:
  451. <text
  452. :key="quesItemIndex"
  453. v-for="(quesItem, quesItemIndex) in bank.ques[ansIndex]"
  454. >{{ ast[quesItem - 1] }}</text
  455. >
  456. </view>
  457. </view>
  458. <view class="pad_8 answerInfos">
  459. <view class="answerTitle">答案解析</view>
  460. <view class="answerContent"
  461. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  462. ></view>
  463. </view>
  464. </view>
  465. </template>
  466. <template v-if="ansItem.type == 3">
  467. <view class="pad_8 titBox">
  468. <view class="leftLetters">
  469. <view class="btnType">
  470. <text>判断</text>
  471. </view>
  472. </view>
  473. <view class="titles">
  474. <rich-text :nodes="ansItem.content"></rich-text>
  475. </view>
  476. <view v-if="!bank.ques[ansIndex]">
  477. <view
  478. v-for="(option, childindex) in judge"
  479. :key="childindex"
  480. class="lisSty"
  481. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  482. >
  483. <view class="activeTI">{{ ast[childindex] }}</view>
  484. <view class="flex_auto">
  485. {{ option }}
  486. </view>
  487. </view>
  488. </view>
  489. <view v-if="bank.ques[ansIndex]">
  490. <view
  491. v-for="(option, childindex) in judge"
  492. :key="childindex"
  493. class="lisSty"
  494. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  495. >
  496. <text
  497. :class="{
  498. right:
  499. bankType == 1 && (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
  500. childindex != bank.ans[ansIndex]),
  501. wrong:
  502. bankType == 1 && (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
  503. bank.ques[ansIndex] != bank.ans[ansIndex]),
  504. user_choose: bankType == 2 && (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1)),
  505. }"
  506. class="activeTI"
  507. >
  508. {{ ast[childindex] }}
  509. </text>
  510. <view class="flex_auto">
  511. {{ option }}
  512. </view>
  513. </view>
  514. </view>
  515. </view>
  516. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  517. <view class="pad_8 answer">
  518. <view>正确答案:{{ ast[bank.ans[ansIndex] == 1 ? 0 : 1] }}</view>
  519. <view>我的答案:{{ ast[bank.ques[ansIndex] == 1 ? 0 : 1] }}</view>
  520. </view>
  521. <view class="pad_8 answerInfos">
  522. <view class="answerTitle">答案解析</view>
  523. <view class="answerContent"
  524. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  525. ></view>
  526. </view>
  527. </view>
  528. </template>
  529. <!-- 简答题 -->
  530. <template v-if="ansItem.type == 5">
  531. <view class="pad_8 titBox_title">
  532. <view class="leftLetters">
  533. <view class="btnType">
  534. <text>简答</text>
  535. </view>
  536. </view>
  537. <view class="titles">
  538. <rich-text :nodes="ansItem.content"></rich-text>
  539. </view>
  540. </view>
  541. <view class="pad_8 titBox_title">
  542. <view class="ans">
  543. <view
  544. class="ans_input"
  545. v-if="
  546. bankType == 2 || (bankType == 1 &&
  547. (!bank.ques[ansIndex] ||
  548. (!bank.ques[ansIndex].text &&
  549. !bank.ques[ansIndex].imageList.length)))
  550. "
  551. >
  552. <view class="top flex">
  553. <image
  554. class="icon"
  555. @click="chooseImgChild(bankIndex, ansIndex)"
  556. src="/static/08-10_032.jpg"
  557. mode=""
  558. ></image>
  559. <view class="progress"
  560. >{{ ansItem.ansText.imageList.length || "0" }}/4</view
  561. >
  562. <view
  563. class="submit"
  564. @click="submitAnsChild(bankIndex, ansIndex)"
  565. >确认答案</view
  566. >
  567. </view>
  568. <view class="textarea">
  569. <textarea
  570. v-model="ansItem.ansText.text"
  571. placeholder="在此输入答案"
  572. ></textarea>
  573. </view>
  574. <view class="imgs">
  575. <view
  576. class="img"
  577. :key="imgIndex"
  578. v-for="(img, imgIndex) in ansItem.ansText.imageList"
  579. >
  580. <text
  581. @click="
  582. deleteImgChild(imgIndex, bankIndex, ansIndex)
  583. "
  584. >x</text
  585. >
  586. <image :src="$method.splitImgHost(img, true)"></image>
  587. </view>
  588. </view>
  589. </view>
  590. <view
  591. class="ans_submit answerInfos"
  592. v-if="bankType == 1 && bank.ques[ansIndex]"
  593. >
  594. <view class="answerTitle">我的答案</view>
  595. {{ bank.ques[ansIndex].text }}
  596. <view class="imgs">
  597. <image
  598. class="img"
  599. :key="quesIndex"
  600. v-for="(ques, quesIndex) in bank.ques[ansIndex]
  601. .imageList"
  602. :src="$method.splitImgHost(ques, true)"
  603. ></image>
  604. </view>
  605. </view>
  606. </view>
  607. </view>
  608. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  609. <view class="pad_8 answerInfos">
  610. <view class="answerTitle">答案解析</view>
  611. <view class="answerContent"
  612. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  613. ></view>
  614. </view>
  615. </view>
  616. </template>
  617. </view>
  618. </template>
  619. <view class="footer_btn">
  620. <!-- <view class="collect">
  621. <view v-if="collectList[bankIndex]">
  622. <image src="/static/icon/collected.png" mode=""></image>
  623. <view>取消收藏</view>
  624. </view>
  625. </view> -->
  626. <view
  627. class="collect show"
  628. @click="collect(collectList[bankIndex], bankIndex)"
  629. >
  630. <view v-if="collectList[bankIndex]">
  631. <image src="/static/icon/collected.png" mode=""></image>
  632. <view>取消收藏</view>
  633. </view>
  634. <view v-if="!collectList[bankIndex]">
  635. <image src="/static/icon/collect.png" mode=""></image>
  636. <view>收藏</view>
  637. </view>
  638. </view>
  639. <view class="flex_center" @click="openFooterTab">
  640. <view class="up-icon">
  641. <image src="/static/up.png"></image>
  642. </view>
  643. 答题卡
  644. </view>
  645. <view class="collect show" @click="pdsubmit">
  646. <view>
  647. <image src="/static/jj.png" mode=""></image>
  648. <view>交卷</view>
  649. </view>
  650. </view>
  651. </view>
  652. </view>
  653. </swiper-item>
  654. </swiper>
  655. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  656. <view class="popupView">
  657. <view class="popupTops">
  658. <view class="topIcon"></view>
  659. 点击编号即可跳转至对应题目
  660. </view>
  661. <view class="popupContent">
  662. <scroll-view scroll-y="true" style="height: 506rpx">
  663. <view class="boxSty">
  664. <view
  665. v-for="(item, index) in questionList"
  666. :key="index"
  667. @click="changeIndex(index)"
  668. :class="{
  669. isRight: bankType == 1 && isRight(item, index),
  670. isWrong: bankType == 1 && isWrong(item, index),
  671. isPart: bankType == 1 && isPart(item, index),
  672. isOver: bankType == 1 && isOver(item, index),
  673. check_ans: bankType == 2 && isCheck(item, index),
  674. }"
  675. class="liListSty"
  676. >
  677. {{ index + 1 }}
  678. </view>
  679. </view>
  680. </scroll-view>
  681. </view>
  682. </view>
  683. </u-popup>
  684. <view class="dialog" v-if="showDialog">
  685. <view class="text">左右滑动切换上下题</view>
  686. <view class="btn" @click="hideDialog">我知道了</view>
  687. </view>
  688. <view class="dialog-arrow" v-if="showArrow">
  689. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  690. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  691. <view class="btn" @click="showArrow = false">我知道了</view>
  692. </view>
  693. <view class="dialog_wrap" v-if="testOver">
  694. <view class="bg"></view>
  695. <view class="dialog">
  696. <view class="title">温馨提示</view>
  697. <view class="content">
  698. <view>您已完成所有题目,</view>
  699. <view>快去交卷吧!</view>
  700. </view>
  701. <view class="btns">
  702. <view class="btn" @click="noSubmit()">暂不交卷</view>
  703. <view class="btn active" @click="submitNow()">立即交卷</view>
  704. </view>
  705. </view>
  706. </view>
  707. <view class="dialog_wrap" v-if="isLastCount">
  708. <view class="bg"></view>
  709. <view class="dialog">
  710. <view class="title">温馨提示</view>
  711. <view class="content">
  712. <view
  713. >您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view
  714. >
  715. </view>
  716. <view class="btns">
  717. <view class="btn" @click="noLeave()">暂不离开</view>
  718. <view class="btn active" @click="leaveNow()">继续离开</view>
  719. </view>
  720. </view>
  721. </view>
  722. <u-popup
  723. v-model="showpopups"
  724. mode="center"
  725. border-radius="24"
  726. height="439rpx"
  727. width="640rpx"
  728. :mask-close-able="false"
  729. >
  730. <view class="popboxs">
  731. <view class="classTops">温馨提示</view>
  732. <view class="textStys">
  733. {{
  734. cgType === 7
  735. ? "您还未交卷,确定结束做题吗?"
  736. : cgType === 8
  737. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  738. : cgType === 6
  739. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  740. : cgType == 9
  741. ? `您已完成所有题目,快去交卷吧!`
  742. : ""
  743. }}
  744. </view>
  745. <view class="classFootsty" v-if="cgType === 6">
  746. <view class="btnsty btns1" @click="submit()">立即交卷</view>
  747. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  748. </view>
  749. <view class="classFootsty" v-if="cgType === 7">
  750. <view class="btnsty btns1" @click="showpopups = false">下次继续</view>
  751. <view class="btnsty btns2" @click="backPages">结束做题</view>
  752. </view>
  753. <view class="classFootsty" v-if="cgType === 8">
  754. <view class="btnsty btns1" @click="leaveNow()">下次继续</view>
  755. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  756. </view>
  757. <view class="classFootsty" v-if="cgType === 9">
  758. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  759. <view class="btnsty btns2" @click="submit()">立即交卷</view>
  760. </view>
  761. </view>
  762. </u-popup>
  763. <!-- 节卷不需要拍照 -->
  764. <u-mask :show="examType != 2 && photoPopup">
  765. <!-- 播放前拍照start -->
  766. <view
  767. v-if="examType != 2 && photoPopup"
  768. :mask-close-able="false"
  769. style="bottom: 0; position: fixed; width: 100%; z-index: 999"
  770. >
  771. <view class="photoBox">
  772. <view class="photoTop">
  773. <view class="sqzz" v-if="false"
  774. ><u-icon
  775. name="close"
  776. color="#333333"
  777. size="30"
  778. @click="closePhoto"
  779. ></u-icon
  780. ></view>
  781. <view class="centersq">请正视手机屏幕</view>
  782. <view class="sqzz"></view>
  783. </view>
  784. <view class="photoCenter">
  785. <view
  786. class="center_camera"
  787. v-if="photoPopup && isTaking"
  788. >
  789. <camera
  790. device-position="front"
  791. flash="off"
  792. @error="error"
  793. style="width: 100%; height: 100%"
  794. >
  795. <!-- 加人脸框 -->
  796. <cover-view class="head_take">
  797. <cover-view class="headTake_up color"></cover-view>
  798. <cover-view class="headTake_minddle">
  799. <cover-view class="min_left color"></cover-view>
  800. <cover-view class="min_img"></cover-view>
  801. <cover-view class="min_right color"></cover-view>
  802. </cover-view>
  803. <cover-view class="headTake_down color"></cover-view>
  804. </cover-view>
  805. </camera>
  806. </view>
  807. <view class="custom" v-if="!isTaking"
  808. ><image :src="avatarUrl" mode=""></image
  809. ></view>
  810. </view>
  811. <view class="photoBoxbtns">
  812. <view class="btnResult" v-if="isTaking" @click="takePhoto"
  813. >拍照</view
  814. >
  815. <view class="btnResult" v-if="!isTaking" @click="reTake">重拍</view>
  816. <view class="btnResult" v-if="!isTaking" @click="submitPhoto"
  817. >确认</view
  818. >
  819. </view>
  820. </view>
  821. </view>
  822. </u-mask>
  823. </view>
  824. </template>
  825. <script>
  826. export default {
  827. data() {
  828. return {
  829. photoPopup: false,
  830. showpopups: false,
  831. id: "",
  832. current: 0,
  833. questionList: [],
  834. ast: ["A", "B", "C", "D", "E", "F", "G"],
  835. judge: ["正确", "错误"],
  836. ans: [],
  837. ques: [],
  838. show: false,
  839. showDialog: false,
  840. bankList: [],
  841. collectList: [],
  842. goodsId: "",
  843. recordId: "",
  844. isSubmit: false,
  845. lastTime: 0, //剩余考试时长
  846. allTimes: 0, //总考试时长
  847. timer: null,
  848. wrongList: [],
  849. bankType: 0, //试卷类型
  850. needBack: false, //是否是考试
  851. testOver: false,
  852. isLastCount: false, //是否有未答题目
  853. lastCount: 0, //剩余没有回答的题目数
  854. chapterId: 0,
  855. moduleId: 0,
  856. sectionId: 0,
  857. showArrow: false, //退出提示
  858. isFromVideo: "",
  859. gradeId: "",
  860. courseId: 0,
  861. cgType: 0, //对应设计稿弹窗编码,
  862. avatarUrl: "",
  863. ossAvatarUrl: "",
  864. goodsDetail: {},
  865. isTakePhoto: false,
  866. orderGoodsId: 0,
  867. isTaking: true, //是否正在拍照
  868. needPhoto: false, //是否需要拍照
  869. examType: 0, // 3-模块,1-章,2-节
  870. compareFaceData: 0, // 拍照匹配相似度
  871. learning: -1, // 1合格,0不合格
  872. originShowDialog: false,
  873. uploadLock: false, //上传图片
  874. };
  875. },
  876. watch: {
  877. photoPopup(n) {
  878. // 拍照弹窗和showDialog同时出现时,先展示拍照弹窗再展示showDialog弹窗
  879. if (n) {
  880. this.showDialog && (this.showDialog = false)
  881. } else {
  882. this.originShowDialog && (this.showDialog = true)
  883. }
  884. }
  885. },
  886. async onLoad(option) {
  887. this.examType = option.type
  888. this.id = option.id;
  889. this.goodsId = option.goodsid;
  890. this.chapterId = option.chapterId;
  891. this.courseId = option.courseId;
  892. this.sectionId = option.sectionId
  893. this.moduleId = option.moduleId;
  894. this.isFromVideo = option.isFromVideo || "";
  895. this.gradeId = option.gradeId || "";
  896. this.orderGoodsId = Number(option.orderGoodsId);
  897. this.learning = option.learning
  898. console.log('learning:', this.learning)
  899. let isBack = option.isback;
  900. let showDialog = uni.getStorageSync("showDialog");
  901. if (showDialog) {
  902. this.showDialog = false;
  903. } else {
  904. this.showDialog = true;
  905. this.originShowDialog = true
  906. uni.setStorageSync("showDialog", "1");
  907. }
  908. //考试时候用手势或者返回键 被迫返回做题
  909. if (isBack) {
  910. console.log(getApp());
  911. let app = getApp();
  912. let globalData = app.globalData;
  913. for (var k in globalData.bankData) {
  914. this[k] = globalData.bankData[k];
  915. }
  916. this.showArrow = true;
  917. //需要拍没拍过直接弹出摄像头
  918. if (this.needPhoto && !this.isTakePhoto) {
  919. if (this.learning != 1) {
  920. this.photoPopup = true;
  921. this.isTaking = true;
  922. this.avatarUrl = "";
  923. }
  924. } else {
  925. //不需要拍照
  926. if (this.lastTime) {
  927. this.timer = setInterval(() => {
  928. if (this.lastTime <= 0) {
  929. clearInterval(this.timer);
  930. uni.showToast({
  931. icon: "none",
  932. mask: true,
  933. title: "考试时间已到,系统将自动交卷",
  934. duration: 10000,
  935. });
  936. this.submit();
  937. return;
  938. }
  939. this.lastTime--;
  940. }, 1000);
  941. }
  942. }
  943. } else {
  944. await this.getGoodsDetail();
  945. // 请求题目列表
  946. this.goodsQuestionList();
  947. this.bankExam();
  948. }
  949. },
  950. onUnload() {
  951. if (this.isSubmit) {
  952. clearInterval(this.timer);
  953. return;
  954. }
  955. if (this.needPhoto && !this.isTakePhoto) {
  956. return;
  957. }
  958. //考试试卷 阻止ios手势返回,自动跳回答题页
  959. if (this.needBack) {
  960. let app = getApp();
  961. app.globalData.bankData = this.$data;
  962. clearInterval(this.timer);
  963. uni.navigateTo({
  964. url:
  965. "/pages2/class/questionBank?id=" +
  966. this.id +
  967. "&goodsid=" +
  968. this.goodsId +
  969. "&isback=true&orderGoodsId=" +
  970. this.orderGoodsId,
  971. });
  972. } else {
  973. //点击返回按钮确认允许退出,交卷
  974. clearInterval(this.timer);
  975. this.examRecordEdit();
  976. }
  977. },
  978. methods: {
  979. getGoodsDetail() {
  980. return new Promise((resolve) => {
  981. let self = this;
  982. this.$api.goodsDetail(this.goodsId).then((res) => {
  983. self.goodsDetail = res.data.data;
  984. if (self.goodsDetail.goodsPhotoExamConfig) {
  985. let goodsPhotoExamConfig = JSON.parse(
  986. self.goodsDetail.goodsPhotoExamConfig
  987. );
  988. if (goodsPhotoExamConfig.photograph > 0) {
  989. self.needPhoto = true;
  990. }
  991. }
  992. resolve();
  993. });
  994. });
  995. },
  996. reTake() {
  997. this.isTaking = true;
  998. },
  999. postStudyRecord() {
  1000. let self = this;
  1001. let data = {
  1002. photo: self.ossAvatarUrl,
  1003. recordId: self.recordId,
  1004. };
  1005. if (this.ossAvatarUrl) {
  1006. data.similarity = this.compareFaceData // 相似度
  1007. }
  1008. // console.log(data, "拍照提交");
  1009. this.$api.studyExamPhotoRecord(data).then((res) => {
  1010. // console.log(res, "拍照提交结果");
  1011. if (res.data.code != 200) {
  1012. uni.showToast({
  1013. icon: "none",
  1014. mask: true,
  1015. title: res.data.msg,
  1016. duration: 10000,
  1017. });
  1018. return;
  1019. }
  1020. self.ossAvatarUrl = "";
  1021. self.isTakePhoto = true;
  1022. //拍照
  1023. if (this.lastTime) {
  1024. this.timer = setInterval(() => {
  1025. if (this.lastTime <= 0) {
  1026. clearInterval(this.timer);
  1027. uni.showToast({
  1028. icon: "none",
  1029. mask: true,
  1030. title: "考试时间已到,系统将自动交卷",
  1031. duration: 10000,
  1032. });
  1033. this.submit();
  1034. return;
  1035. }
  1036. this.lastTime--;
  1037. }, 1000);
  1038. }
  1039. });
  1040. },
  1041. uploadFile(options, int) {
  1042. var self = this;
  1043. return new Promise((resolve, reject) => {
  1044. var data = {
  1045. imageStatus: int,
  1046. gradeId: this.gradeId,
  1047. };
  1048. self.$api.aliyunpolicy(data).then((res) => {
  1049. if (res.data.code != 200) {
  1050. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  1051. return;
  1052. }
  1053. var ossToken = res.data.data.resultContent;
  1054. if (ossToken.host == null || ossToken.host == undefined) {
  1055. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  1056. return;
  1057. }
  1058. uni.uploadFile({
  1059. url: ossToken.host,
  1060. name: "file",
  1061. filePath: options,
  1062. fileType: "image",
  1063. header: {
  1064. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1065. },
  1066. formData: {
  1067. key: ossToken.dir,
  1068. OSSAccessKeyId: ossToken.accessid,
  1069. policy: ossToken.policy,
  1070. Signature: ossToken.signature,
  1071. callback: ossToken.callback,
  1072. success_action_status: 200,
  1073. },
  1074. success: (result) => {
  1075. // if (result.statusCode === 200) {
  1076. self.ossAvatarUrl = ossToken.dir;
  1077. resolve(ossToken.dir);
  1078. // } else {
  1079. // uni.showToast({
  1080. // title: "上传失败",
  1081. // icon: "none",
  1082. // });
  1083. // return;
  1084. // }
  1085. },
  1086. fail: (error) => {
  1087. uni.showToast({
  1088. title: "上传接口报错" + error,
  1089. icon: "none",
  1090. });
  1091. this.uploadLock = false
  1092. this.openPhoto()
  1093. return;
  1094. },
  1095. });
  1096. });
  1097. });
  1098. },
  1099. imageInfos() {
  1100. var self = this;
  1101. return new Promise((resolve, reject) => {
  1102. uni.getImageInfo({
  1103. src: self.avatarUrl,
  1104. success: async (res) => {
  1105. let canvasWidth = res.width; //图片原始长宽
  1106. let canvasHeight = res.height;
  1107. if (canvasWidth > 2000 || canvasHeight > 2000) {
  1108. uni.compressImage({
  1109. src: self.avatarUrl,
  1110. quality: 75,
  1111. width: "35%",
  1112. height: "35%",
  1113. success: async (rest) => {
  1114. const waitUpload = await self.uploadFile(
  1115. rest.tempFilePath,
  1116. 0
  1117. );
  1118. resolve(waitUpload);
  1119. },
  1120. });
  1121. } else if (canvasWidth > 1000 || canvasHeight > 1000) {
  1122. uni.compressImage({
  1123. src: self.avatarUrl,
  1124. quality: 75,
  1125. width: "50%",
  1126. height: "50%",
  1127. success: async (rest) => {
  1128. const waitUpload = await self.uploadFile(
  1129. rest.tempFilePath,
  1130. 0
  1131. );
  1132. resolve(waitUpload);
  1133. },
  1134. });
  1135. } else {
  1136. console.log("无需压缩");
  1137. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  1138. resolve(waitUpload);
  1139. }
  1140. },
  1141. });
  1142. });
  1143. },
  1144. /**
  1145. * 人脸匹配
  1146. */
  1147. faceRecognition() {
  1148. return new Promise((resolve) => {
  1149. let fileSystem = uni.getFileSystemManager();
  1150. fileSystem.readFile({
  1151. filePath: `${this.avatarUrl}`,
  1152. encoding: "base64",
  1153. position: 0,
  1154. success: (res) => {
  1155. let base64 = "data:image/jpg;base64," + res.data;
  1156. console.log('试卷-base64Data人脸识别参数:', {
  1157. imageA: base64,
  1158. orderGoodsId: this.orderGoodsId,
  1159. gradeId: this.gradeId,
  1160. })
  1161. let timer = setTimeout(() => {
  1162. uni.showToast({
  1163. icon: "none",
  1164. title: '拍照超时,请重新拍照',
  1165. success: () => {
  1166. setTimeout(() => {
  1167. uni.navigateBack()
  1168. }, 1000)
  1169. }
  1170. })
  1171. }, 10 * 1000)
  1172. this.$api
  1173. .faceCertificationCompareFace({
  1174. imageA: base64,
  1175. orderGoodsId: this.orderGoodsId,
  1176. gradeId: this.gradeId,
  1177. })
  1178. .then((res) => {
  1179. clearTimeout(timer)
  1180. resolve(res.data.data);
  1181. }).catch((err) => {
  1182. clearTimeout(timer)
  1183. // 当前网络延迟,
  1184. console.log('人脸识别错误:', err)
  1185. uni.showModal({
  1186. content: "当前网络延迟",
  1187. showCancel: false,
  1188. success: (resultst) => {
  1189. if (resultst.confirm) {
  1190. uni.navigateBack()
  1191. }
  1192. },
  1193. })
  1194. })
  1195. },
  1196. fail(err) {
  1197. console.error(err, "err");
  1198. },
  1199. });
  1200. });
  1201. },
  1202. async submitPhoto() {
  1203. if (this.uploadLock) {
  1204. return
  1205. }
  1206. this.uploadLock = true
  1207. let compareFaceData = await this.faceRecognition();
  1208. this.compareFaceData = compareFaceData
  1209. // if (compareFaceData == 0) {
  1210. // uni.showToast({
  1211. // title: "人脸匹配不通过,请重新拍照上传",
  1212. // icon: "none",
  1213. // duration: 2000,
  1214. // });
  1215. // // setTimeout(() => {
  1216. // // this.uploadLock = false;
  1217. // // this.openPhoto();
  1218. // // }, 2000);
  1219. // return;
  1220. // }
  1221. if (compareFaceData >= 80) {
  1222. const waitYS = await this.imageInfos();
  1223. this.postStudyRecord(); //提交记录
  1224. this.photoPopup = false;
  1225. } else {
  1226. uni.showToast({
  1227. title: "人脸匹配不通过,请重新拍照上传",
  1228. icon: "none",
  1229. duration: 2000,
  1230. });
  1231. setTimeout(() => {
  1232. this.uploadLock = false
  1233. this.openPhoto()
  1234. }, 2000);
  1235. }
  1236. },
  1237. //拍照
  1238. openPhoto() {
  1239. // this.enableAutoRotation = false;
  1240. this.photoPopup = true;
  1241. this.isTaking = true;
  1242. uni.setKeepScreenOn({
  1243. keepScreenOn: true,
  1244. });
  1245. uni.authorize({
  1246. scope: "scope.camera",
  1247. success() {},
  1248. });
  1249. },
  1250. //确认拍照
  1251. takePhoto() {
  1252. var self = this;
  1253. const ctx = uni.createCameraContext();
  1254. ctx.takePhoto({
  1255. quality: "high",
  1256. success: (res) => {
  1257. console.log(res.tempImagePath);
  1258. self.avatarUrl = res.tempImagePath;
  1259. // self.submitPhoto();
  1260. this.isTaking = false;
  1261. },
  1262. fail: (err) => {
  1263. console.log(err);
  1264. },
  1265. });
  1266. },
  1267. /**
  1268. * 是否有上传图片
  1269. */
  1270. hasImgs(bank) {
  1271. return bank.ansText.imageList.length == 0;
  1272. },
  1273. /**
  1274. * 获取试卷类型2考试,1练习
  1275. */
  1276. bankExam() {
  1277. this.$api.bankExam(this.id).then((res) => {
  1278. this.bankType = res.data.data.doType;
  1279. if (this.bankType == 2) {
  1280. this.needBack = true;
  1281. }
  1282. });
  1283. },
  1284. /**
  1285. * 点击后退按钮
  1286. */
  1287. clickLeft() {
  1288. //需要拍照没有拍直接返回
  1289. if (this.needPhoto && !this.isTakePhoto) {
  1290. this.isSubmit = true;
  1291. uni.navigateBack({
  1292. delta: 1,
  1293. });
  1294. return;
  1295. }
  1296. if (this.bankType == 1) {
  1297. let ansCount = this.questionOverNum(); //已答题数
  1298. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1299. //所有题目答完
  1300. if (this.lastCount == 0) {
  1301. // this.testOver = true;
  1302. this.cgType = 7;
  1303. //未答完
  1304. } else {
  1305. this.cgType = 8;
  1306. // this.isLastCount = true;
  1307. }
  1308. this.showpopups = true;
  1309. } else if (this.bankType == 2) {
  1310. let ansCount = this.questionOverNum(); //已答题数
  1311. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1312. //所有题目答完
  1313. if (this.lastCount == 0) {
  1314. this.testOver = true;
  1315. //未答完
  1316. } else {
  1317. this.isLastCount = true;
  1318. }
  1319. }
  1320. },
  1321. /**
  1322. * 返回上一页
  1323. */
  1324. backPages() {
  1325. this.needBack = false;
  1326. uni.navigateBack({
  1327. delta: 1,
  1328. });
  1329. },
  1330. /**
  1331. * 获取已经回答的题目数
  1332. * hasSpecail (是否包含简答和案例)
  1333. */
  1334. questionOverNum(hasSpecail) {
  1335. let count = 0;
  1336. this.questionList.forEach((item) => {
  1337. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1338. if (item.ques) {
  1339. count++;
  1340. }
  1341. } else if (item.type == 4) {
  1342. //案例题
  1343. if (hasSpecail) {
  1344. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1345. if (
  1346. jsonItem.type == 1 ||
  1347. jsonItem.type == 2 ||
  1348. jsonItem.type == 3
  1349. ) {
  1350. if (item.ques[indexs]) {
  1351. return true;
  1352. } else {
  1353. return false;
  1354. }
  1355. } else if (jsonItem.type == 5) {
  1356. console.log(jsonItem, 111);
  1357. if (
  1358. item.ques[indexs] &&
  1359. (item.ques[indexs].text.length ||
  1360. item.ques[indexs].imageList.length)
  1361. ) {
  1362. return true;
  1363. } else {
  1364. return false;
  1365. }
  1366. }
  1367. });
  1368. if (isOver) {
  1369. count++;
  1370. console.log(item, 444);
  1371. }
  1372. }
  1373. } else if (item.type == 5) {
  1374. //简答题
  1375. if (hasSpecail) {
  1376. if (
  1377. item.ques &&
  1378. (item.ques.text.length || item.ques.imageList.length)
  1379. ) {
  1380. count++;
  1381. }
  1382. }
  1383. }
  1384. });
  1385. return count;
  1386. },
  1387. /**
  1388. * 是否做完所有题目
  1389. */
  1390. isDoOver() {
  1391. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1392. if (this.questionList.length == questionOverNum) {
  1393. //全部做完弹窗
  1394. this.cgType = 9;
  1395. this.showpopups = true;
  1396. }
  1397. },
  1398. /**
  1399. * 暂不交卷
  1400. */
  1401. noSubmit() {
  1402. //设为允许退出页面
  1403. this.needBack = false;
  1404. uni.navigateBack({
  1405. delta: 1,
  1406. });
  1407. },
  1408. /**
  1409. * 不离开
  1410. */
  1411. noLeave() {
  1412. this.isLastCount = false;
  1413. },
  1414. /**
  1415. * 立即离开并交卷
  1416. */
  1417. leaveNow() {
  1418. this.isSubmit = true;
  1419. uni.navigateBack({
  1420. delta: 1,
  1421. });
  1422. //需要拍照没有拍,返回不扣次数
  1423. if (this.needPhoto && !this.isTakePhoto) {
  1424. return;
  1425. }
  1426. this.submit('leaveNow')
  1427. return
  1428. let score = 0; //计算总分
  1429. let reportStatus = 0;
  1430. let number = 0;
  1431. let doQuestionIds = []; //做过的题目id
  1432. let doQuestionNum = 0; //做过的题目数量
  1433. let passScore = 0;
  1434. let allScore = 0; //总分
  1435. this.questionList.forEach((item, index) => {
  1436. passScore = item.passScore;
  1437. if (item.type == 1) {
  1438. if (item.ques == item.ans) {
  1439. item.scoreResult = item.score;
  1440. score += item.score;
  1441. number++;
  1442. } else {
  1443. item.scoreResult = 0;
  1444. }
  1445. if (item.ques) {
  1446. doQuestionNum++;
  1447. doQuestionIds.push(item.questionId);
  1448. }
  1449. allScore += item.score;
  1450. } else if (item.type == 2) {
  1451. let isRight =
  1452. item.ques &&
  1453. item.ques.every((quesItem, quesIndex) => {
  1454. return item.ques[quesIndex] == item.ans[quesIndex];
  1455. });
  1456. if (isRight) {
  1457. //全对
  1458. item.scoreResult = item.score;
  1459. score += item.score;
  1460. number++;
  1461. } else {
  1462. let hasPart = false;
  1463. let checkboxScore = 1; //获取单题总分数
  1464. item.ques &&
  1465. item.ques.forEach((ques, quesIndex) => {
  1466. //选错一个全扣
  1467. if (item.ques) {
  1468. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1469. checkboxScore = 0;
  1470. }
  1471. } else {
  1472. checkboxScore = 0;
  1473. }
  1474. });
  1475. //没选错
  1476. if (checkboxScore) {
  1477. checkboxScore = 0;
  1478. item.ans.forEach((ans, quesIndex) => {
  1479. //漏选扣一部分,对n题给n X partScore 分
  1480. if (item.ques) {
  1481. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  1482. checkboxScore += item.partScore;
  1483. hasPart = true;
  1484. }
  1485. } else {
  1486. checkboxScore = 0;
  1487. }
  1488. });
  1489. }
  1490. if (!hasPart) {
  1491. item.scoreResult = 0;
  1492. } else {
  1493. item.scoreResult = checkboxScore;
  1494. }
  1495. score += checkboxScore;
  1496. }
  1497. if (item.ques && item.ques.length) {
  1498. doQuestionNum++;
  1499. doQuestionIds.push(item.questionId);
  1500. }
  1501. allScore += item.score;
  1502. } else if (item.type == 3) {
  1503. if (item.ques == item.ans) {
  1504. item.scoreResult = item.score;
  1505. score += item.score;
  1506. number++;
  1507. } else {
  1508. item.scoreResult = 0;
  1509. }
  1510. if (item.ques) {
  1511. doQuestionNum++;
  1512. doQuestionIds.push(item.questionId);
  1513. }
  1514. allScore += item.score;
  1515. } else {
  1516. allScore += item.score;
  1517. }
  1518. });
  1519. if (score >= passScore) {
  1520. reportStatus = 1;
  1521. } else {
  1522. reportStatus = 0;
  1523. }
  1524. this.$api
  1525. .bankRecordEdit({
  1526. moduleId: this.moduleId || 0,
  1527. chapterId: this.chapterId || 0,
  1528. sectionId: this.sectionId || 0,
  1529. gradeId: this.gradeId,
  1530. courseId: this.courseId,
  1531. orderGoodsId: this.orderGoodsId,
  1532. goodsId: this.goodsId,
  1533. examId: this.id,
  1534. recordId: this.recordId,
  1535. reportStatus: reportStatus,
  1536. rightQuestionNum: number,
  1537. doQuestionNum: doQuestionNum,
  1538. status: 1,
  1539. doQuestionIds: doQuestionIds.join(","),
  1540. performance: score,
  1541. totalScore: allScore,
  1542. type: this.examType,
  1543. // examTime: parseInt(this.allTimes),
  1544. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1545. // historyExamJson: JSON.stringify(this.questionList)
  1546. })
  1547. .then((res) => {});
  1548. },
  1549. /**
  1550. * 立即交卷
  1551. */
  1552. submitNow() {
  1553. this.showpopups = false;
  1554. this.needBack = false;
  1555. this.submit();
  1556. },
  1557. /**
  1558. * 离开页面统计回答正确题数
  1559. */
  1560. examRecordEdit() {
  1561. if (!this.isSubmit) {
  1562. this.submit('leave')
  1563. return
  1564. let number = 0;
  1565. let score = 0;
  1566. let doQuestionNum = 0;
  1567. let reportStatus = 0;
  1568. let lessQuestionNum = 0;
  1569. this.questionList.forEach((item, index) => {
  1570. if (item.type == 1) {
  1571. if (item.ques == item.ans) {
  1572. score += item.score;
  1573. number++;
  1574. }
  1575. if (item.ques) {
  1576. doQuestionNum++;
  1577. }
  1578. } else if (item.type == 2) {
  1579. let isRight =
  1580. item.ques &&
  1581. item.ques.every((quesItem, quesIndex) => {
  1582. return item.ques[quesIndex] == item.ans[quesIndex];
  1583. });
  1584. if (isRight) {
  1585. score += item.score;
  1586. number++;
  1587. } else {
  1588. let hasPart = false;
  1589. let checkboxScore = 1; //获取单题总分数
  1590. item.ques.forEach((ques, quesIndex) => {
  1591. //选错一个全扣
  1592. if (item.ques) {
  1593. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1594. checkboxScore = 0;
  1595. }
  1596. } else {
  1597. checkboxScore = 0;
  1598. }
  1599. });
  1600. //没选错
  1601. if (checkboxScore) {
  1602. checkboxScore = 0;
  1603. item.ans.forEach((ans, quesIndex) => {
  1604. //漏选扣一部分
  1605. if (item.ques) {
  1606. if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1607. checkboxScore += item.partScore;
  1608. hasPart = true;
  1609. }
  1610. } else {
  1611. checkboxScore = 0;
  1612. }
  1613. });
  1614. }
  1615. if (!hasPart) {
  1616. item.scoreResult = 0;
  1617. } else {
  1618. lessQuestionNum++
  1619. item.scoreResult = checkboxScore;
  1620. score += checkboxScore;
  1621. // number++;
  1622. }
  1623. }
  1624. if (item.ques && item.ques.length) {
  1625. doQuestionNum++;
  1626. }
  1627. } else if (item.type == 3) {
  1628. if (item.ques == item.ans) {
  1629. score += item.score;
  1630. number++;
  1631. }
  1632. if (item.ques) {
  1633. doQuestionNum++;
  1634. }
  1635. } else if (item == 4) {
  1636. if (item.ques.length) {
  1637. doQuestionNum++;
  1638. }
  1639. } else if (item.type == 5) {
  1640. if (item.ques) {
  1641. doQuestionNum++;
  1642. }
  1643. }
  1644. });
  1645. if (score >= 60) {
  1646. reportStatus = 1;
  1647. }
  1648. this.$api
  1649. .bankRecordEdit({
  1650. moduleId: this.moduleId || 0,
  1651. chapterId: this.chapterId || 0,
  1652. sectionId: this.sectionId || 0,
  1653. gradeId: this.gradeId,
  1654. courseId: this.courseId,
  1655. orderGoodsId: this.orderGoodsId,
  1656. goodsId: this.goodsId,
  1657. examId: this.id,
  1658. recordId: this.recordId,
  1659. lessQuestionNum:lessQuestionNum,
  1660. performance: score,
  1661. reportStatus: reportStatus,
  1662. status: 1,
  1663. type: this.examType,
  1664. // historyExamJson: JSON.stringify(this.questionList)
  1665. })
  1666. .then((res) => {});
  1667. }
  1668. },
  1669. /**
  1670. * @param {Object} second倒计时过滤器
  1671. */
  1672. countdown(second) {
  1673. if (second) {
  1674. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1675. let m = parseInt((second / 60) % 60); // 计算分数
  1676. let s = parseInt(second % 60); // 计算当前秒数
  1677. if (h < 10) h = "0" + h;
  1678. if (m < 10) m = "0" + m;
  1679. if (s < 10) s = "0" + s;
  1680. return h + ":" + m + ":" + s;
  1681. } else {
  1682. return "";
  1683. }
  1684. },
  1685. /**
  1686. * 请求题目列表
  1687. */
  1688. goodsQuestionList() {
  1689. this.$api
  1690. .goodsQuestionList({
  1691. examId: this.id,
  1692. })
  1693. .then(async (res) => {
  1694. if (!res.data.data.length) {
  1695. this.hideDialog();
  1696. uni.showModal({
  1697. showCancel: false,
  1698. content: "该试卷暂无题目",
  1699. success: function (k) {
  1700. if (k.confirm) {
  1701. uni.navigateBack();
  1702. }
  1703. },
  1704. });
  1705. return;
  1706. }
  1707. this.allTimes = res.data.data[0].answerTime * 60;
  1708. this.lastTime =
  1709. res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  1710. res.data.data.forEach((item, index) => {
  1711. if (typeof item.jsonStr == "string") {
  1712. item.jsonStr = JSON.parse(item.jsonStr);
  1713. if (item.type == 2) {
  1714. //多选
  1715. item.jsonStr.forEach((str) => {
  1716. str.optionsId = "" + str.optionsId;
  1717. });
  1718. let arr = item.answerQuestion.split(",");
  1719. arr.forEach((a, i) => {
  1720. arr[i] = "" + a;
  1721. });
  1722. item.ans = arr;
  1723. item.analysisContent &&
  1724. (item.analysisContent = item.analysisContent.replace(
  1725. /<img/gi,
  1726. '<img style="max-width:100%;"'
  1727. ));
  1728. item.content &&
  1729. (item.content = item.content.replace(
  1730. /<img/gi,
  1731. '<img style="max-width:100%;"'
  1732. ));
  1733. return;
  1734. } else if (item.type == 5) {
  1735. //简答题
  1736. item.ansText = {
  1737. text: "",
  1738. imageList: [],
  1739. };
  1740. item.ques = {
  1741. text: "",
  1742. imageList: [],
  1743. };
  1744. item.analysisContent &&
  1745. (item.analysisContent = item.analysisContent.replace(
  1746. /<img/gi,
  1747. '<img style="max-width:100%;"'
  1748. ));
  1749. item.content &&
  1750. (item.content = item.content.replace(
  1751. /<img/gi,
  1752. '<img style="max-width:100%;"'
  1753. ));
  1754. } else if (item.type == 4) {
  1755. //案例题
  1756. console.log(item.jsonStr);
  1757. item.ques = [];
  1758. item.current = 0;
  1759. let ansArr = [];
  1760. item.jsonStr.forEach((json, index) => {
  1761. if (json.type == 1) {
  1762. ansArr[index] = json.answerQuestion;
  1763. json.content &&
  1764. (json.content = json.content.replace(
  1765. /<img/gi,
  1766. '<img style="max-width:100%;"'
  1767. ));
  1768. } else if (json.type == 2) {
  1769. json.optionsList.forEach((str) => {
  1770. str.optionsId = "" + str.optionsId;
  1771. });
  1772. let arr = json.answerQuestion.split(",");
  1773. arr.forEach((a, i) => {
  1774. arr[i] = "" + a;
  1775. });
  1776. ansArr[index] = arr;
  1777. json.content &&
  1778. (json.content = json.content.replace(
  1779. /<img/gi,
  1780. '<img style="max-width:100%;"'
  1781. ));
  1782. } else if (json.type == 3) {
  1783. ansArr[index] = json.answerQuestion;
  1784. json.content &&
  1785. (json.content = json.content.replace(
  1786. /<img/gi,
  1787. '<img style="max-width:100%;"'
  1788. ));
  1789. } else if (json.type == 5) {
  1790. ansArr[index] = {
  1791. text: "",
  1792. imageList: [],
  1793. };
  1794. json.ansText = {
  1795. text: "",
  1796. imageList: [],
  1797. };
  1798. json.content &&
  1799. (json.content = json.content.replace(
  1800. /<img/gi,
  1801. '<img style="max-width:100%;"'
  1802. ));
  1803. }
  1804. });
  1805. item.analysisContent &&
  1806. (item.analysisContent = item.analysisContent.replace(
  1807. /<img/gi,
  1808. '<img style="max-width:100%;"'
  1809. ));
  1810. item.content &&
  1811. (item.content = item.content.replace(
  1812. /<img/gi,
  1813. '<img style="max-width:100%;"'
  1814. ));
  1815. item.ans = ansArr;
  1816. return;
  1817. }
  1818. item.content &&
  1819. (item.content = item.content.replace(
  1820. /<img/gi,
  1821. '<img style="max-width:100%;"'
  1822. ));
  1823. item.ans = item.answerQuestion;
  1824. }
  1825. });
  1826. this.questionList = res.data.data;
  1827. this.lastCount = this.questionList.length;
  1828. this.getCollectInfo(this.current)
  1829. await this.examRecord();
  1830. });
  1831. },
  1832. /**
  1833. * 记录总题数,获取recordId
  1834. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1835. */
  1836. examRecord(hasSpecial) {
  1837. return new Promise((resolve) => {
  1838. let questionList = 0;
  1839. // if(!hasSpecial) {
  1840. this.questionList.forEach((item, index) => {
  1841. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1842. questionList++;
  1843. }
  1844. });
  1845. // } else {
  1846. // questionList = this.questionList.length;
  1847. // }
  1848. this.$api
  1849. .bankRecord({
  1850. courseId: this.courseId,
  1851. // chapterExamId: this.chapterId || 0,
  1852. // moduleExamId: this.moduleId || 0,
  1853. chapterId: this.chapterId || 0,
  1854. moduleId: this.moduleId || 0,
  1855. sectionId: this.sectionId || 0,
  1856. examId: this.id,
  1857. goodsId: this.goodsId,
  1858. orderGoodsId: this.orderGoodsId,
  1859. gradeId: this.gradeId,
  1860. totalQuestionNum: questionList,
  1861. allQuestionNum: this.questionList.length,
  1862. type: this.examType,
  1863. })
  1864. .then((res) => {
  1865. this.recordId = res.data.data;
  1866. if (this.needPhoto) {
  1867. if (this.learning != 1) {
  1868. this.photoPopup = true; //拍照
  1869. this.isTaking = true;
  1870. }
  1871. } else {
  1872. if (this.lastTime) {
  1873. this.timer = setInterval(() => {
  1874. if (this.lastTime <= 0) {
  1875. clearInterval(this.timer);
  1876. uni.showToast({
  1877. icon: "none",
  1878. mask: true,
  1879. title: "考试时间已到,系统将自动交卷",
  1880. duration: 10000,
  1881. });
  1882. this.submit();
  1883. return;
  1884. }
  1885. this.lastTime--;
  1886. }, 1000);
  1887. }
  1888. resolve();
  1889. }
  1890. });
  1891. });
  1892. },
  1893. /**
  1894. * @param {Object} e单选点击
  1895. */
  1896. radioSelect(optionsId, bindex) {
  1897. // if (this.questionList[bindex].ques) return;
  1898. if (this.questionList[bindex].ques && this.bankType == 1) {
  1899. return
  1900. }
  1901. this.$set(this.questionList[bindex], "ques", optionsId);
  1902. // if ((bindex + 1) < this.questionList.length) {
  1903. // this.current = bindex + 1
  1904. // }
  1905. this.isDoOver();
  1906. },
  1907. /**
  1908. * @param {Object} e案例单选点击
  1909. */
  1910. radioSelectChild(optionsId, ansIndex, bindex) {
  1911. // if (this.questionList[bindex].ques[ansIndex]) return;
  1912. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1913. return
  1914. }
  1915. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1916. this.isDoOver();
  1917. },
  1918. /**
  1919. * @param {Object} 多选点击
  1920. */
  1921. checkboxSelect(optionsId, bindex, index) {
  1922. if (this.questionList[bindex].ques && this.bankType == 1) {
  1923. return
  1924. }
  1925. this.$set(
  1926. this.questionList[bindex].jsonStr[index],
  1927. "checked",
  1928. !this.questionList[bindex].jsonStr[index].checked
  1929. );
  1930. console.log('this.questionList[bindex].jsonStr:', this.questionList[bindex].jsonStr[index])
  1931. },
  1932. /**
  1933. * @param {Object} 案例多选点击
  1934. */
  1935. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1936. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1937. return
  1938. }
  1939. this.$set(
  1940. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1941. "checked",
  1942. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1943. .checked
  1944. );
  1945. },
  1946. isCheckboxChecked(arr) {
  1947. return arr.some((item) => {
  1948. if (item.checked) {
  1949. return true;
  1950. }
  1951. });
  1952. },
  1953. /**
  1954. * @param {Object} 多选确认
  1955. */
  1956. checkboxSubmit(bindex) {
  1957. // if (this.questionList[bindex].ques) return;
  1958. if (this.questionList[bindex].ques && this.bankType == 1) {
  1959. return
  1960. }
  1961. let arr = [];
  1962. this.questionList[bindex].jsonStr.forEach((item) => {
  1963. if (item.checked) {
  1964. arr.push(item.optionsId);
  1965. }
  1966. });
  1967. if (!arr.length) {
  1968. delete this.questionList[bindex].ques
  1969. uni.showToast({
  1970. title: "请选择答案",
  1971. icon: "none",
  1972. });
  1973. return;
  1974. }
  1975. this.$set(this.questionList[bindex], "ques", arr);
  1976. this.$u.toast('已确认答案')
  1977. this.isDoOver();
  1978. // let isWrong = this.questionList[bindex].ques.some(
  1979. // (quesItem, quesIndex) => {
  1980. // return (
  1981. // this.questionList[bindex].ques[quesIndex] !=
  1982. // this.questionList[bindex].ans[quesIndex]
  1983. // );
  1984. // }
  1985. // );
  1986. // let isWrong = this.questionList[bindex].ques.some((item, i) => {
  1987. // return this.questionList[bindex].ans.indexOf(item) == -1;
  1988. // })
  1989. },
  1990. /**
  1991. * @param {Object} 案例多选确认
  1992. */
  1993. checkboxSubmitChild(bindex, ansIndex) {
  1994. // if (this.questionList[bindex].ques[ansIndex]) return;
  1995. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1996. return
  1997. }
  1998. let arr = [];
  1999. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  2000. (item) => {
  2001. if (item.checked) {
  2002. arr.push(item.optionsId);
  2003. }
  2004. }
  2005. );
  2006. if (!arr.length) {
  2007. delete this.questionList[bindex].ques[ansIndex]
  2008. uni.showToast({
  2009. title: "请选择答案",
  2010. icon: "none",
  2011. });
  2012. return;
  2013. }
  2014. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  2015. this.$u.toast('已确认答案')
  2016. this.isDoOver();
  2017. },
  2018. /**
  2019. * @param {Object} index
  2020. * @param {Object} bindex
  2021. * 判断题
  2022. */
  2023. judgeSelect(index, bindex) {
  2024. // if (this.questionList[bindex].ques) return;
  2025. if (this.questionList[bindex].ques && this.bankType == 1) {
  2026. return
  2027. }
  2028. this.$set(this.questionList[bindex], "ques", index == 0 ? '1' : '0');
  2029. this.isDoOver();
  2030. },
  2031. /**
  2032. * @param {Object} ansindex
  2033. * @param {Object} childindex
  2034. * @param {Object} bindex
  2035. * 案例判断题
  2036. */
  2037. judgeSelectChild(ansindex, childindex, bindex) {
  2038. // if (this.questionList[bindex].ques[ansindex]) return;
  2039. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  2040. return
  2041. }
  2042. this.$set(this.questionList[bindex].ques, ansindex, childindex == 0 ? '1' : '0');
  2043. this.isDoOver();
  2044. },
  2045. openFooterTab() {
  2046. this.show = true;
  2047. },
  2048. hideDialog() {
  2049. this.showDialog = false;
  2050. },
  2051. changeIndex(index) {
  2052. this.current = index;
  2053. },
  2054. swiperChange(e) {
  2055. this.current = e.detail.current;
  2056. this.getCollectInfo(this.current)
  2057. },
  2058. /**
  2059. * @param {Object} current
  2060. * 获取收藏信息
  2061. */
  2062. getCollectInfo(current) {
  2063. this.$api
  2064. .getCollectInfo({
  2065. examId: this.id,
  2066. questionId: this.questionList[current].questionId,
  2067. goodsId: this.goodsId,
  2068. orderGoodsId: this.orderGoodsId,
  2069. })
  2070. .then((res) => {
  2071. if (res.data.code == 500) {
  2072. this.$set(this.collectList, current, false);
  2073. } else if (res.data.code == 200) {
  2074. this.$set(this.collectList, current, res.data.data);
  2075. }
  2076. });
  2077. },
  2078. /**
  2079. * @param {Object} state
  2080. * @param {Object} index
  2081. * 收藏
  2082. */
  2083. collect(state, index) {
  2084. if (!state) {
  2085. this.$api.collectQuestion({
  2086. examId: this.id,
  2087. questionId: this.questionList[index].questionId,
  2088. goodsId: this.goodsId || "",
  2089. orderGoodsId: this.orderGoodsId,
  2090. })
  2091. .then((res) => {
  2092. if (res.data.code == 200) {
  2093. this.$set(this.collectList, index, true);
  2094. uni.showToast({
  2095. title: "收藏成功",
  2096. duration: 2000,
  2097. icon: "none",
  2098. });
  2099. this.getCollectInfo(index);
  2100. }
  2101. });
  2102. } else {
  2103. this.$api
  2104. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2105. .then((res) => {
  2106. if (res.data.code == 200) {
  2107. this.$set(this.collectList, index, false);
  2108. uni.showToast({
  2109. title: "取消收藏成功",
  2110. duration: 2000,
  2111. icon: "none",
  2112. });
  2113. }
  2114. });
  2115. }
  2116. return;
  2117. },
  2118. pdsubmit() {
  2119. let ansCount = this.questionOverNum(true); //已答题数
  2120. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2121. //没有答完
  2122. if (this.lastCount !== 0) {
  2123. this.cgType = 6;
  2124. this.showpopups = true;
  2125. return;
  2126. }
  2127. if (this.bankType == 2) {
  2128. if (this.lastTime > 0) {
  2129. let lastTime = this.countdown(this.lastTime);
  2130. uni.showModal({
  2131. title: "提示",
  2132. content: `时间还剩余${lastTime},确定交卷吗?`,
  2133. confirmText: "交卷",
  2134. cancelText: "继续答题",
  2135. success: (res) => {
  2136. if (res.confirm) {
  2137. //确定
  2138. this.submit();
  2139. } else {
  2140. //取消
  2141. }
  2142. },
  2143. });
  2144. return;
  2145. }
  2146. }
  2147. this.submit();
  2148. },
  2149. /**
  2150. * 交卷
  2151. */
  2152. submit(typesubmit) {
  2153. console.log('交卷', typesubmit)
  2154. let score = 0; //计算总分
  2155. let reportStatus = 0;
  2156. let number = 0; //做对的题目数量
  2157. let doQuestionNum = 0; //做过的题目数量
  2158. let allScore = 0; //总分
  2159. let passScore = 0;
  2160. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  2161. let doQuestionIds = []; //做过的题目id
  2162. let rightQuestionIds = []; //做对的题目id
  2163. let lessQuestionNum = 0;
  2164. this.questionList.forEach((item, index) => {
  2165. passScore = item.passScore;
  2166. if (item.type == 1) {
  2167. //正确
  2168. if (item.ques == item.ans) {
  2169. item.scoreResult = item.score;
  2170. score += item.score;
  2171. number++;
  2172. rightQuestionIds.push(item.questionId);
  2173. } else {
  2174. //错误
  2175. item.scoreResult = 0;
  2176. if (item.ques) {
  2177. doWrongQuestionIds.push(item.questionId);
  2178. }
  2179. }
  2180. allScore += item.score;
  2181. if (item.ques) {
  2182. doQuestionNum++;
  2183. doQuestionIds.push(item.questionId);
  2184. }
  2185. } else if (item.type == 2) {
  2186. let isRight =
  2187. item.ans &&
  2188. item.ans.every((quesItem, quesIndex) => {
  2189. if (item.ques) {
  2190. return item.ques[quesIndex] == item.ans[quesIndex];
  2191. } else {
  2192. return false;
  2193. }
  2194. });
  2195. if (isRight) {
  2196. score += item.score;
  2197. number++;
  2198. item.scoreResult = item.score;
  2199. rightQuestionIds.push(item.questionId);
  2200. } else {
  2201. let hasPart = false;
  2202. let checkboxScore = 1; //获取单题总分数
  2203. item.ques &&
  2204. item.ques.forEach((ques, quesIndex) => {
  2205. //选错一个全扣
  2206. if (item.ques) {
  2207. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  2208. checkboxScore = 0;
  2209. }
  2210. } else {
  2211. checkboxScore = 0;
  2212. }
  2213. });
  2214. console.log(checkboxScore);
  2215. //没选错
  2216. if (checkboxScore) {
  2217. checkboxScore = 0;
  2218. item.ans.forEach((ans, quesIndex) => {
  2219. //漏选扣一部分,对n题给n X partScore 分
  2220. if (item.ques) {
  2221. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  2222. checkboxScore += item.partScore;
  2223. hasPart = true;
  2224. }
  2225. } else {
  2226. checkboxScore = 0;
  2227. }
  2228. });
  2229. }
  2230. if (!hasPart) {
  2231. //0分
  2232. item.scoreResult = 0;
  2233. if (item.ques) {
  2234. doWrongQuestionIds.push(item.questionId);
  2235. }
  2236. } else {
  2237. //部分分
  2238. // number++;
  2239. // doWrongQuestionIds.push(item.questionId);
  2240. lessQuestionNum++
  2241. item.scoreResult = checkboxScore;
  2242. score += checkboxScore;
  2243. // rightQuestionIds.push(item.questionId)
  2244. }
  2245. }
  2246. allScore += item.score;
  2247. if (item.ques && item.ques.length) {
  2248. doQuestionNum++;
  2249. doQuestionIds.push(item.questionId);
  2250. }
  2251. } else if (item.type == 3) {
  2252. if (item.ques == item.ans) {
  2253. item.scoreResult = item.score;
  2254. score += item.score;
  2255. number++;
  2256. rightQuestionIds.push(item.questionId);
  2257. } else {
  2258. item.scoreResult = 0;
  2259. if (item.ques) {
  2260. doWrongQuestionIds.push(item.questionId);
  2261. }
  2262. }
  2263. allScore += item.score;
  2264. if (item.ques) {
  2265. doQuestionNum++;
  2266. doQuestionIds.push(item.questionId);
  2267. }
  2268. } else if (item.type == 4) {
  2269. allScore += item.score;
  2270. if (item.ques && item.ques.length) {
  2271. doQuestionNum++;
  2272. doQuestionIds.push(item.questionId);
  2273. }
  2274. } else if (item.type == 5) {
  2275. allScore += item.score;
  2276. if (item.ques && (item.ques.imageList || item.ques.text)) {
  2277. doQuestionNum++;
  2278. doQuestionIds.push(item.questionId);
  2279. }
  2280. }
  2281. });
  2282. //大于分及格
  2283. if (score >= passScore) {
  2284. reportStatus = 1;
  2285. } else {
  2286. reportStatus = 0;
  2287. }
  2288. clearInterval(this.timer);
  2289. //交卷
  2290. this.$api
  2291. .bankRecordEdit({
  2292. moduleId: this.moduleId || 0,
  2293. chapterId: this.chapterId || 0,
  2294. sectionId: this.sectionId || 0,
  2295. gradeId: this.gradeId,
  2296. examId: this.id,
  2297. goodsId: this.goodsId,
  2298. orderGoodsId: this.orderGoodsId,
  2299. reportStatus: reportStatus,
  2300. recordId: this.recordId,
  2301. courseId: this.courseId,
  2302. rightQuestionNum: number,
  2303. lessQuestionNum: lessQuestionNum,
  2304. status: 1,
  2305. doQuestionIds: doQuestionIds.join(","),
  2306. rightQuestionIds: rightQuestionIds.join(','),
  2307. doQuestionNum: doQuestionNum,
  2308. performance: score,
  2309. totalScore: allScore,
  2310. type: this.examType,
  2311. examTime: parseInt(this.allTimes),
  2312. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2313. historyExamJson: JSON.stringify(this.questionList)
  2314. })
  2315. .then((res) => {
  2316. this.isSubmit = true;
  2317. if (res.data.code == 200) {
  2318. uni.showToast({
  2319. title: "交卷成功",
  2320. duration: 1000,
  2321. mask: true,
  2322. icon: "none",
  2323. });
  2324. if (!typesubmit) {
  2325. console.log('跳转----')
  2326. setTimeout(() => {
  2327. uni.redirectTo({
  2328. url:
  2329. "/pages2/class/question_report?rightQuestionNum=" +
  2330. number +
  2331. "&doWrongQuestionNum=" +
  2332. doWrongQuestionIds.length +
  2333. "&score=" +
  2334. score +
  2335. "&totalScore=" +
  2336. allScore +
  2337. "&reportStatus=" +
  2338. reportStatus +
  2339. "&lessQuestionNum=" +
  2340. lessQuestionNum +
  2341. "&examId=" + this.id + '&recordId=' + this.recordId + '&type=' + this.examType + '&orderGoodsId='+ this.orderGoodsId,
  2342. });
  2343. }, 1000);
  2344. }
  2345. }
  2346. });
  2347. //错题集id提交(客观题)
  2348. this.$api
  2349. .examWrongRecord({
  2350. moduleId: this.moduleId || 0,
  2351. chapterId: this.chapterId || 0,
  2352. sectionId: this.sectionId || 0,
  2353. gradeId: this.gradeId,
  2354. courseId: this.courseId,
  2355. examId: this.id,
  2356. goodsId: this.goodsId,
  2357. orderGoodsId: this.orderGoodsId,
  2358. questionIds: doWrongQuestionIds,
  2359. recordId: this.recordId,
  2360. type: 2, // 视频课程的传2
  2361. })
  2362. .then((res) => {})
  2363. .catch((err) => {})
  2364. },
  2365. /**
  2366. * @param {Object} imgIndex
  2367. * @param {Object} bankIndex
  2368. * 删除简答图片
  2369. */
  2370. deleteImg(imgIndex, bankIndex) {
  2371. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2372. },
  2373. /**
  2374. * @param {Object} imgIndex
  2375. * @param {Object} bankIndex
  2376. * @param {Object} ansIndex
  2377. * 删除案例题简答图片
  2378. */
  2379. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2380. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2381. imgIndex,
  2382. 1
  2383. );
  2384. },
  2385. /**
  2386. * @param {Object} bankindex
  2387. * 选择上传图片
  2388. */
  2389. chooseImg(bankindex) {
  2390. if (
  2391. this.questionList[bankindex] &&
  2392. this.questionList[bankindex].ansText &&
  2393. this.questionList[bankindex].ansText.imageList.length >= 4
  2394. ) {
  2395. uni.showToast({
  2396. icon: "none",
  2397. title: "最多选择4张",
  2398. });
  2399. return;
  2400. }
  2401. uni.chooseImage({
  2402. count: 1, //默认9
  2403. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2404. sourceType: ["album", "camera"], //从相册选择
  2405. success: (res) => {
  2406. let self = this;
  2407. // console.log(JSON.stringify(res.tempFilePaths));
  2408. let img = res.tempFilePaths[0];
  2409. uni.getImageInfo({
  2410. src: img,
  2411. success: async (res) => {
  2412. let canvasWidth = res.width; //图片原始长宽
  2413. let canvasHeight = res.height;
  2414. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2415. uni.compressImage({
  2416. src: img,
  2417. quality: 75,
  2418. width: "50%",
  2419. height: "50%",
  2420. success: async (rest) => {
  2421. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2422. this.questionList[bankindex].ansText.imageList.push(dir);
  2423. },
  2424. });
  2425. } else {
  2426. const dir = await self.uploadFile(img, 0);
  2427. this.questionList[bankindex].ansText.imageList.push(dir);
  2428. }
  2429. },
  2430. });
  2431. },
  2432. });
  2433. },
  2434. /**
  2435. * @param {Object} bankindex
  2436. * @param {Object} ansindex
  2437. * 案例题选择上传图片
  2438. */
  2439. chooseImgChild(bankindex, ansindex) {
  2440. uni.chooseImage({
  2441. count: 1, //默认9
  2442. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2443. sourceType: ["album", "camera"], //从相册选择
  2444. success: (res) => {
  2445. let self = this;
  2446. // console.log(JSON.stringify(res.tempFilePaths));
  2447. let img = res.tempFilePaths[0];
  2448. uni.getImageInfo({
  2449. src: img,
  2450. success: async (res) => {
  2451. let canvasWidth = res.width; //图片原始长宽
  2452. let canvasHeight = res.height;
  2453. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2454. uni.compressImage({
  2455. src: img,
  2456. quality: 75,
  2457. width: "50%",
  2458. height: "50%",
  2459. success: async (rest) => {
  2460. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2461. this.questionList[bankindex].jsonStr[
  2462. ansindex
  2463. ].ansText.imageList.push(dir);
  2464. },
  2465. });
  2466. } else {
  2467. const dir = await self.uploadFile(img, 0);
  2468. this.questionList[bankindex].jsonStr[
  2469. ansindex
  2470. ].ansText.imageList.push(dir);
  2471. }
  2472. },
  2473. });
  2474. },
  2475. });
  2476. },
  2477. /**
  2478. * @param {Object} type
  2479. * @param {Object} bankindex
  2480. * 简答题答案确认
  2481. */
  2482. submitAns(bankindex) {
  2483. console.log(this.questionList[bankindex]);
  2484. if (
  2485. !this.questionList[bankindex].ansText.text &&
  2486. !this.questionList[bankindex].ansText.imageList.length
  2487. ) {
  2488. uni.showToast({
  2489. title: "请输入内容或上传图片",
  2490. duration: 2000,
  2491. icon: "none",
  2492. });
  2493. return;
  2494. }
  2495. this.$set(this.questionList[bankindex], "ques", {
  2496. imageList: this.questionList[bankindex].ansText.imageList,
  2497. text: this.questionList[bankindex].ansText.text,
  2498. });
  2499. this.isDoOver();
  2500. },
  2501. /**
  2502. * @param {Object} bankindex
  2503. * @param {Object} ansindex
  2504. * 案例题简答答案确认
  2505. */
  2506. submitAnsChild(bankindex, ansindex) {
  2507. if (
  2508. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2509. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2510. ) {
  2511. uni.showToast({
  2512. title: "请输入内容或上传图片",
  2513. duration: 2000,
  2514. icon: "none",
  2515. });
  2516. return;
  2517. }
  2518. this.$set(this.questionList[bankindex].ques, ansindex, {
  2519. imageList:
  2520. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  2521. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  2522. });
  2523. this.isDoOver();
  2524. },
  2525. isCheck(item, index) {
  2526. if (this.questionList[index].ques) {
  2527. return true
  2528. }
  2529. },
  2530. isRight(item, index) {
  2531. //单选
  2532. if (this.questionList[index].ques) {
  2533. if (item.type == 1) {
  2534. return this.questionList[index].ques == this.questionList[index].ans;
  2535. //多选
  2536. } else if (item.type == 2) {
  2537. //每一项都相等
  2538. return this.questionList[index].ans.every((item, i) => {
  2539. return item == this.questionList[index].ques[i];
  2540. });
  2541. //判断
  2542. } else if (item.type == 3) {
  2543. return this.questionList[index].ques == this.questionList[index].ans;
  2544. // } else if (item.type == 5) {
  2545. // if(this.questionList[index].ques.text){
  2546. // return true
  2547. // }else{
  2548. // return false
  2549. // }
  2550. } else {
  2551. return false;
  2552. }
  2553. } else {
  2554. return false;
  2555. }
  2556. },
  2557. right(bankIndex, ansIndex, option) {
  2558. if (
  2559. this.questionList[bankIndex].ques[ansIndex] &&
  2560. this.questionList[bankIndex].ans[ansIndex]
  2561. ) {
  2562. if (
  2563. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2564. option.optionsId
  2565. ) != -1 ||
  2566. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2567. option.optionsId
  2568. ) != -1
  2569. ) {
  2570. return true;
  2571. } else {
  2572. return false;
  2573. }
  2574. } else {
  2575. return false;
  2576. }
  2577. },
  2578. wrong(bankIndex, ansIndex, option) {
  2579. if (
  2580. this.questionList[bankIndex].ques[ansIndex] &&
  2581. this.questionList[bankIndex].ans[ansIndex]
  2582. ) {
  2583. if (
  2584. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2585. option.optionsId
  2586. ) != -1 &&
  2587. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2588. option.optionsId
  2589. ) == -1
  2590. ) {
  2591. return true;
  2592. } else {
  2593. return false;
  2594. }
  2595. } else {
  2596. return false;
  2597. }
  2598. },
  2599. isWrong(item, index) {
  2600. if (this.questionList[index].ques) {
  2601. //单选
  2602. if (item.type == 1) {
  2603. return this.questionList[index].ques != this.questionList[index].ans;
  2604. //多选
  2605. } else if (item.type == 2) {
  2606. //每一项都相等
  2607. return this.questionList[index].ques.some((item, i) => {
  2608. return this.questionList[index].ans.indexOf(item) == -1;
  2609. });
  2610. //判断
  2611. } else if (item.type == 3) {
  2612. return this.questionList[index].ques != this.questionList[index].ans;
  2613. } else {
  2614. return false;
  2615. }
  2616. } else {
  2617. return false;
  2618. }
  2619. },
  2620. isPart(item, index) {
  2621. if (this.questionList[index].ques) {
  2622. if (item.type == 2) {
  2623. let isWrong = this.questionList[index].ques.some((item, i) => {
  2624. return this.questionList[index].ans.indexOf(item) == -1;
  2625. });
  2626. let isRight = this.questionList[index].ans.every((item, i) => {
  2627. return item == this.questionList[index].ques[i];
  2628. });
  2629. if (!isRight && !isWrong) {
  2630. return true;
  2631. }
  2632. }
  2633. } else {
  2634. return false;
  2635. }
  2636. },
  2637. isOver(item, index) {
  2638. if (this.questionList[index].ques) {
  2639. if (item.type == 4) {
  2640. //案例题
  2641. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2642. if (
  2643. jsonItem.type == 1 ||
  2644. jsonItem.type == 2 ||
  2645. jsonItem.type == 3
  2646. ) {
  2647. if (item.ques[indexs]) {
  2648. return true;
  2649. } else {
  2650. return false;
  2651. }
  2652. } else if (jsonItem.type == 5) {
  2653. if (
  2654. item.ques[indexs] &&
  2655. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2656. ) {
  2657. console.log("chil");
  2658. return true;
  2659. } else {
  2660. return false;
  2661. }
  2662. }
  2663. });
  2664. if (isOver) {
  2665. return true;
  2666. } else {
  2667. return false;
  2668. }
  2669. } else if (item.type == 5) {
  2670. //简答题
  2671. //每一项都相等
  2672. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2673. return true;
  2674. }
  2675. //判断
  2676. } else {
  2677. return false;
  2678. }
  2679. } else {
  2680. return false;
  2681. }
  2682. },
  2683. tabSelect(index, bankindex) {
  2684. this.$set(this.questionList[bankindex], "current", index);
  2685. },
  2686. },
  2687. };
  2688. </script>
  2689. <style lang="scss" scoped>
  2690. .photoBox {
  2691. width: 100%;
  2692. // background-color: #ffffff;
  2693. // border-radius: 24px 24px 0px 0px;
  2694. .photoTop {
  2695. width: 100%;
  2696. height: 74rpx;
  2697. border-radius: 20px 20px 0px 0px;
  2698. background-color: #ffffff;
  2699. display: flex;
  2700. align-items: center;
  2701. justify-content: center;
  2702. padding: 0rpx 38rpx;
  2703. .sqzz {
  2704. width: 28rpx;
  2705. height: 28rpx;
  2706. display: flex;
  2707. align-items: center;
  2708. justify-content: center;
  2709. }
  2710. .centersq {
  2711. color: #333;
  2712. font-size: 30rpx;
  2713. font-weight: 500;
  2714. }
  2715. }
  2716. .photoCenter {
  2717. width: 750rpx;
  2718. height: 75vh;
  2719. position: relative;
  2720. .center_camera {
  2721. width: 100%;
  2722. height: 75vh;
  2723. // position: fixed;
  2724. .head_take {
  2725. width: 100%;
  2726. height: 75vh;
  2727. display: flex;
  2728. flex-direction: column;
  2729. }
  2730. .headTake_up {
  2731. width: 100%;
  2732. height: 100rpx;
  2733. }
  2734. .headTake_minddle {
  2735. display: flex;
  2736. .min_img {
  2737. width: 500rpx;
  2738. height: 550rpx;
  2739. }
  2740. .min_left, .min_right {
  2741. flex: 1;
  2742. height: 550rpx;
  2743. }
  2744. }
  2745. .headTake_down {
  2746. width: 100%;
  2747. flex: 1;
  2748. }
  2749. .color {
  2750. background-color: #333;
  2751. opacity: 0.5;
  2752. }
  2753. }
  2754. .custom {
  2755. width: 750rpx;
  2756. height: 75vh;
  2757. position: absolute;
  2758. z-index: 1000;
  2759. top: 0;
  2760. left: 0;
  2761. image {
  2762. width: 100%;
  2763. height: 100%;
  2764. }
  2765. }
  2766. }
  2767. .photoBoxbtns {
  2768. display: flex;
  2769. .btnResult {
  2770. height: 100rpx;
  2771. width: 100%;
  2772. background-color: #07c160;
  2773. text-align: center;
  2774. line-height: 100rpx;
  2775. color: #fff;
  2776. font-size: 32rpx;
  2777. font-weight: bold;
  2778. }
  2779. }
  2780. }
  2781. .navbar {
  2782. position: relative;
  2783. z-index: 20000;
  2784. }
  2785. .questionBank {
  2786. width: 100%;
  2787. height: 100vh;
  2788. display: flex;
  2789. flex-direction: column;
  2790. }
  2791. .swiper {
  2792. width: 100%;
  2793. flex: 1;
  2794. }
  2795. .lisSty {
  2796. margin-bottom: 16rpx;
  2797. display: flex;
  2798. .flex_auto {
  2799. flex: 1;
  2800. }
  2801. }
  2802. .activeTI {
  2803. vertical-align: middle;
  2804. display: inline-block;
  2805. border: 1rpx solid #eee;
  2806. border-radius: 50rpx;
  2807. height: 48rpx;
  2808. line-height: 46rpx;
  2809. text-align: center;
  2810. width: 48rpx;
  2811. margin-right: 15rpx;
  2812. color: #666;
  2813. font-size: 30rpx;
  2814. &.right {
  2815. color: #fff;
  2816. background: #36c75a;
  2817. }
  2818. &.wrong {
  2819. color: #fff;
  2820. background: #ff3b30;
  2821. }
  2822. &.checked, &.user_choose {
  2823. color: #fff;
  2824. background: #007aff;
  2825. }
  2826. }
  2827. .submit_checkbox {
  2828. position: fixed;
  2829. left: 0;
  2830. right: 0;
  2831. bottom: 120rpx;
  2832. margin: 20rpx auto;
  2833. width: 526rpx;
  2834. height: 80rpx;
  2835. background: rgba(0, 122, 255, 1);
  2836. color: #fff;
  2837. text-align: center;
  2838. line-height: 80rpx;
  2839. font-size: 30rpx;
  2840. border-radius: 40rpx;
  2841. &.disabled {
  2842. opacity: 0.6;
  2843. }
  2844. }
  2845. .titles {
  2846. overflow: hidden;
  2847. margin-bottom: 24rpx;
  2848. }
  2849. .titBox {
  2850. padding: 41rpx 25rpx 24rpx 25rpx;
  2851. }
  2852. .titBox_title {
  2853. padding: 21rpx;
  2854. }
  2855. .tabs {
  2856. margin: 10rpx;
  2857. display: flex;
  2858. .tab {
  2859. margin: 0 4rpx;
  2860. padding: 10rpx 13rpx;
  2861. text-align: center;
  2862. color: #007aff;
  2863. font-size: 28rpx;
  2864. border-radius: 16rpx;
  2865. background: #fff;
  2866. &.current {
  2867. color: #fff;
  2868. background: #007aff;
  2869. }
  2870. }
  2871. }
  2872. .ans {
  2873. margin: 8rpx 8rpx 8rpx;
  2874. .ans_input {
  2875. border-radius: 16rpx;
  2876. background: #fff;
  2877. .top {
  2878. border-bottom: 1rpx solid #eeeeee;
  2879. padding: 16rpx;
  2880. display: flex;
  2881. align-items: center;
  2882. .icon {
  2883. margin-right: 20rpx;
  2884. width: 40rpx;
  2885. height: 38rpx;
  2886. }
  2887. .progress {
  2888. flex: 1;
  2889. }
  2890. .submit {
  2891. width: 168rpx;
  2892. height: 48rpx;
  2893. line-height: 48rpx;
  2894. text-align: center;
  2895. color: #fff;
  2896. font-size: 30rpx;
  2897. background: #007aff;
  2898. border-radius: 24rpx;
  2899. &.disabled {
  2900. opacity: 0.6;
  2901. }
  2902. }
  2903. }
  2904. .textarea {
  2905. textarea {
  2906. width: 100%;
  2907. height: 287rpx;
  2908. padding: 10rpx;
  2909. }
  2910. }
  2911. .imgs {
  2912. overflow: hidden;
  2913. display: flex;
  2914. width: 100%;
  2915. .img {
  2916. width: 104rpx;
  2917. height: 104rpx;
  2918. border-radius: 8rpx;
  2919. position: relative;
  2920. margin: 20rpx;
  2921. text {
  2922. position: absolute;
  2923. right: -15rpx;
  2924. top: -15rpx;
  2925. width: 30rpx;
  2926. height: 30rpx;
  2927. text-align: center;
  2928. line-height: 30rpx;
  2929. color: #fff;
  2930. background: #ff3b30;
  2931. border-radius: 50%;
  2932. }
  2933. image {
  2934. width: 100%;
  2935. height: 100%;
  2936. }
  2937. }
  2938. }
  2939. }
  2940. .ans_submit {
  2941. padding: 16rpx;
  2942. border-radius: 16rpx;
  2943. background: #fff;
  2944. .imgs {
  2945. overflow: hidden;
  2946. display: flex;
  2947. width: 100%;
  2948. .img {
  2949. width: 104rpx;
  2950. height: 104rpx;
  2951. border-radius: 8rpx;
  2952. position: relative;
  2953. margin: 20rpx;
  2954. image {
  2955. width: 100%;
  2956. height: 100%;
  2957. }
  2958. }
  2959. }
  2960. }
  2961. }
  2962. .leftLetters {
  2963. display: flex;
  2964. align-items: center;
  2965. width: 220rpx;
  2966. .btnType {
  2967. padding: 5rpx 10rpx;
  2968. border: 1rpx solid #007aff;
  2969. border-radius: 10rpx;
  2970. background-color: rgba(0, 122, 255, 0.1);
  2971. font-size: 28rpx;
  2972. color: #007aff;
  2973. margin-right: 15rpx;
  2974. }
  2975. }
  2976. .firstLetter {
  2977. display: flex;
  2978. justify-content: space-between;
  2979. align-items: center;
  2980. margin-bottom: 30rpx;
  2981. }
  2982. .popupView {
  2983. height: 100%;
  2984. padding-bottom: 100rpx;
  2985. .popupTops {
  2986. height: 77rpx;
  2987. border-bottom: 1rpx solid #eee;
  2988. text-align: center;
  2989. line-height: 77rpx;
  2990. font-size: 24rpx;
  2991. color: #999;
  2992. position: relative;
  2993. .topIcon {
  2994. position: absolute;
  2995. top: 10rpx;
  2996. left: 50%;
  2997. transform: translateX(-50%);
  2998. width: 80rpx;
  2999. height: 8rpx;
  3000. background-color: #999;
  3001. border-radius: 4rpx;
  3002. }
  3003. }
  3004. .popupContent {
  3005. }
  3006. }
  3007. .pageContent {
  3008. position: relative;
  3009. background-color: #eaeef1;
  3010. height: 100%;
  3011. padding-top: 8rpx;
  3012. padding-bottom: 100rpx;
  3013. overflow-y: scroll;
  3014. }
  3015. .pad_8 {
  3016. background-color: #fff;
  3017. margin: 0rpx 8rpx 8rpx;
  3018. border-radius: 16rpx;
  3019. &.no-margin {
  3020. margin-top: -16rpx;
  3021. border-radius: 0 0 16rpx 16rpx;
  3022. }
  3023. }
  3024. .answer {
  3025. height: 80rpx;
  3026. line-height: 80rpx;
  3027. padding: 0rpx 24rpx;
  3028. display: flex;
  3029. align-items: center;
  3030. justify-content: space-between;
  3031. color: #666;
  3032. font-size: 30rpx;
  3033. }
  3034. .footer_btn {
  3035. background-color: #fff;
  3036. z-index: 10078;
  3037. position: fixed;
  3038. bottom: 0rpx;
  3039. display: flex;
  3040. align-items: center;
  3041. justify-content: space-between;
  3042. width: 100%;
  3043. height: 98rpx;
  3044. padding: 0rpx 38rpx;
  3045. border-top: 1rpx solid #eee;
  3046. .flex_center {
  3047. flex: 1;
  3048. display: flex;
  3049. justify-content: center;
  3050. align-items: center;
  3051. flex-direction: column;
  3052. margin: 0 200rpx;
  3053. font-size: 24rpx;
  3054. color: #999999;
  3055. .up-icon {
  3056. margin-bottom: 18rpx;
  3057. width: 100%;
  3058. display: flex;
  3059. justify-content: center;
  3060. image {
  3061. width: 58rpx;
  3062. height: 21rpx;
  3063. }
  3064. }
  3065. }
  3066. .collect {
  3067. visibility: hidden;
  3068. width: 100rpx;
  3069. &.show {
  3070. visibility: visible;
  3071. }
  3072. > view {
  3073. display: flex;
  3074. flex-direction: column;
  3075. align-items: center;
  3076. justify-content: center;
  3077. image {
  3078. width: 32rpx;
  3079. height: 32rpx;
  3080. margin-bottom: 6rpx;
  3081. }
  3082. view {
  3083. font-size: 24rpx;
  3084. color: #999999;
  3085. }
  3086. }
  3087. }
  3088. }
  3089. .boxSty {
  3090. padding: 44rpx 41rpx 0rpx;
  3091. }
  3092. .liListSty {
  3093. border: 1rpx solid #eeeeee;
  3094. width: 88rpx;
  3095. height: 88rpx;
  3096. border-radius: 32rpx;
  3097. text-align: center;
  3098. line-height: 88rpx;
  3099. color: #333;
  3100. font-size: 32rpx;
  3101. float: left;
  3102. margin: 20rpx 23rpx;
  3103. &.isRight {
  3104. border: 1rpx solid #eeeeee;
  3105. color: #fff;
  3106. background: #36c75a;
  3107. }
  3108. &.isWrong {
  3109. border: 1rpx solid #eeeeee;
  3110. color: #fff;
  3111. background: #ff3b30;
  3112. }
  3113. &.isPart {
  3114. border: 1rpx solid #eeeeee;
  3115. color: #fff;
  3116. background: #FFC53D;
  3117. }
  3118. &.isOver {
  3119. border: 1rpx solid #eeeeee;
  3120. color: #fff;
  3121. background: blue;
  3122. }
  3123. &.check_ans {
  3124. border: 1rpx solid #eeeeee;
  3125. color: #fff;
  3126. background: #007aff;
  3127. }
  3128. }
  3129. .answerInfos {
  3130. padding: 25rpx 25rpx 25rpx 23rpx;
  3131. }
  3132. .answerTitle {
  3133. margin-bottom: 28rpx;
  3134. color: #666;
  3135. font-size: 30rpx;
  3136. }
  3137. .answerContent {
  3138. font-size: 30rpx;
  3139. color: #666;
  3140. }
  3141. .textChild {
  3142. display: inline-block;
  3143. vertical-align: middle;
  3144. }
  3145. .dialog {
  3146. position: fixed;
  3147. left: 0;
  3148. top: 0;
  3149. width: 100%;
  3150. height: 100%;
  3151. background-color: rgba(0, 0, 0, 0.8);
  3152. display: flex;
  3153. flex-direction: column;
  3154. align-items: center;
  3155. justify-content: center;
  3156. z-index: 20000;
  3157. .text {
  3158. font-size: 32rpx;
  3159. color: #ffffff;
  3160. text-align: center;
  3161. }
  3162. .btn {
  3163. width: 242rpx;
  3164. height: 82rpx;
  3165. border: 2rpx solid #ffffff;
  3166. border-radius: 16rpx;
  3167. text-align: center;
  3168. line-height: 82rpx;
  3169. margin: 41rpx auto;
  3170. color: #fff;
  3171. font-size: 32rpx;
  3172. }
  3173. }
  3174. .dialog-arrow {
  3175. padding-top: 124rpx;
  3176. position: fixed;
  3177. left: 0;
  3178. top: 0;
  3179. width: 100%;
  3180. height: 100%;
  3181. background-color: rgba(0, 0, 0, 0.8);
  3182. z-index: 20000;
  3183. .pointer {
  3184. margin-left: 87rpx;
  3185. display: block;
  3186. width: 95rpx;
  3187. height: 98rpx;
  3188. }
  3189. .text {
  3190. padding-left: 177rpx;
  3191. font-size: 32rpx;
  3192. color: #ffffff;
  3193. }
  3194. .btn {
  3195. width: 242rpx;
  3196. height: 82rpx;
  3197. border: 2rpx solid #ffffff;
  3198. border-radius: 16rpx;
  3199. text-align: center;
  3200. line-height: 82rpx;
  3201. margin: 500rpx auto 0;
  3202. color: #fff;
  3203. font-size: 32rpx;
  3204. }
  3205. }
  3206. .dialog_wrap {
  3207. position: fixed;
  3208. left: 0;
  3209. top: 0;
  3210. width: 100%;
  3211. height: 100%;
  3212. z-index: 9999999999;
  3213. .bg {
  3214. background: rgba(0, 0, 0, 0.3);
  3215. position: absolute;
  3216. left: 0;
  3217. top: 0;
  3218. width: 100%;
  3219. height: 100%;
  3220. }
  3221. .dialog {
  3222. position: absolute;
  3223. left: 50%;
  3224. top: 50%;
  3225. transform: translate3D(-50%, -50%, 0);
  3226. width: 640rpx;
  3227. height: 439rpx;
  3228. background: #ffffff;
  3229. border-radius: 24rpx;
  3230. .title {
  3231. font-size: 30rpx;
  3232. font-weight: bold;
  3233. color: #333333;
  3234. line-height: 48rpx;
  3235. text-align: center;
  3236. margin-top: 40rpx;
  3237. }
  3238. .content {
  3239. margin: 35rpx 35rpx 0;
  3240. font-size: 30rpx;
  3241. color: #666666;
  3242. line-height: 48rpx;
  3243. }
  3244. .btns {
  3245. margin-top: 35rpx;
  3246. display: flex;
  3247. align-items: center;
  3248. justify-content: center;
  3249. .btn {
  3250. width: 200rpx;
  3251. height: 80rpx;
  3252. line-height: 80rpx;
  3253. text-align: center;
  3254. background: #f5f5f5;
  3255. border-radius: 40rpx;
  3256. font-size: 30rpx;
  3257. color: rgba(0, 122, 255, 1);
  3258. background: #f5f5f5;
  3259. margin: 0 20rpx;
  3260. &.active {
  3261. color: #f5f5f5;
  3262. background: rgba(0, 122, 255, 1);
  3263. }
  3264. }
  3265. }
  3266. }
  3267. }
  3268. .popboxs {
  3269. width: 100%;
  3270. height: 100%;
  3271. display: flex;
  3272. flex-direction: column;
  3273. align-items: center;
  3274. }
  3275. .classTops {
  3276. flex-shrink: 0;
  3277. padding: 39rpx 0rpx 4rpx;
  3278. font-weight: bold;
  3279. color: #333;
  3280. font-size: 30rpx;
  3281. }
  3282. .textStys {
  3283. width: 100%;
  3284. flex: 1;
  3285. padding: 36rpx;
  3286. }
  3287. .classFootsty {
  3288. flex-shrink: 0;
  3289. display: flex;
  3290. align-items: center;
  3291. justify-content: center;
  3292. padding: 10rpx 0rpx 40rpx;
  3293. .btnsty {
  3294. width: 200rpx;
  3295. height: 80rpx;
  3296. border-radius: 40rpx;
  3297. font-weight: bold;
  3298. font-size: 30rpx;
  3299. text-align: center;
  3300. line-height: 80rpx;
  3301. }
  3302. .btns1 {
  3303. background-color: #f5f5f5;
  3304. color: #007aff;
  3305. }
  3306. .btns2 {
  3307. margin-left: 40rpx;
  3308. background-color: #007aff;
  3309. color: #ffffff;
  3310. }
  3311. }
  3312. </style>