questionBank.vue 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473
  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="examData.examName"
  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. examData: {},
  875. };
  876. },
  877. watch: {
  878. photoPopup(n) {
  879. // 拍照弹窗和showDialog同时出现时,先展示拍照弹窗再展示showDialog弹窗
  880. if (n) {
  881. this.showDialog && (this.showDialog = false)
  882. } else {
  883. this.originShowDialog && (this.showDialog = true)
  884. }
  885. }
  886. },
  887. async onLoad(option) {
  888. this.examType = option.type
  889. this.id = option.id;
  890. this.goodsId = option.goodsid;
  891. this.chapterId = option.chapterId;
  892. this.courseId = option.courseId;
  893. this.sectionId = option.sectionId
  894. this.moduleId = option.moduleId;
  895. this.isFromVideo = option.isFromVideo || "";
  896. this.gradeId = option.gradeId || "";
  897. this.orderGoodsId = Number(option.orderGoodsId);
  898. this.learning = option.learning
  899. console.log('learning:', this.learning)
  900. let isBack = option.isback;
  901. let showDialog = uni.getStorageSync("showDialog");
  902. if (showDialog) {
  903. this.showDialog = false;
  904. } else {
  905. this.showDialog = true;
  906. this.originShowDialog = true
  907. uni.setStorageSync("showDialog", "1");
  908. }
  909. //考试时候用手势或者返回键 被迫返回做题
  910. if (isBack) {
  911. console.log(getApp());
  912. let app = getApp();
  913. let globalData = app.globalData;
  914. for (var k in globalData.bankData) {
  915. this[k] = globalData.bankData[k];
  916. }
  917. this.showArrow = true;
  918. //需要拍没拍过直接弹出摄像头
  919. if (this.needPhoto && !this.isTakePhoto) {
  920. if (this.learning != 1) {
  921. this.photoPopup = true;
  922. this.isTaking = true;
  923. this.avatarUrl = "";
  924. }
  925. } else {
  926. //不需要拍照
  927. if (this.lastTime) {
  928. this.timer = setInterval(() => {
  929. if (this.lastTime <= 0) {
  930. clearInterval(this.timer);
  931. uni.showToast({
  932. icon: "none",
  933. mask: true,
  934. title: "考试时间已到,系统将自动交卷",
  935. duration: 10000,
  936. });
  937. this.submit();
  938. return;
  939. }
  940. this.lastTime--;
  941. }, 1000);
  942. }
  943. }
  944. } else {
  945. await this.getGoodsDetail();
  946. // 请求题目列表
  947. this.goodsQuestionList();
  948. this.bankExam();
  949. }
  950. },
  951. onUnload() {
  952. if (this.isSubmit) {
  953. clearInterval(this.timer);
  954. return;
  955. }
  956. if (this.needPhoto && !this.isTakePhoto) {
  957. return;
  958. }
  959. //考试试卷 阻止ios手势返回,自动跳回答题页
  960. if (this.needBack) {
  961. let app = getApp();
  962. app.globalData.bankData = this.$data;
  963. clearInterval(this.timer);
  964. uni.navigateTo({
  965. url:
  966. "/pages2/class/questionBank?id=" +
  967. this.id +
  968. "&goodsid=" +
  969. this.goodsId +
  970. "&isback=true&orderGoodsId=" +
  971. this.orderGoodsId,
  972. });
  973. } else {
  974. //点击返回按钮确认允许退出,交卷
  975. clearInterval(this.timer);
  976. this.examRecordEdit();
  977. }
  978. },
  979. methods: {
  980. getGoodsDetail() {
  981. return new Promise((resolve) => {
  982. let self = this;
  983. this.$api.goodsDetail(this.goodsId).then((res) => {
  984. self.goodsDetail = res.data.data;
  985. if (self.goodsDetail.goodsPhotoExamConfig) {
  986. let goodsPhotoExamConfig = JSON.parse(
  987. self.goodsDetail.goodsPhotoExamConfig
  988. );
  989. if (goodsPhotoExamConfig.photograph > 0) {
  990. self.needPhoto = true;
  991. }
  992. }
  993. resolve();
  994. });
  995. });
  996. },
  997. reTake() {
  998. this.isTaking = true;
  999. },
  1000. postStudyRecord() {
  1001. let self = this;
  1002. let data = {
  1003. photo: self.ossAvatarUrl,
  1004. recordId: self.recordId,
  1005. };
  1006. if (this.ossAvatarUrl) {
  1007. data.similarity = this.compareFaceData // 相似度
  1008. }
  1009. // console.log(data, "拍照提交");
  1010. this.$api.studyExamPhotoRecord(data).then((res) => {
  1011. // console.log(res, "拍照提交结果");
  1012. if (res.data.code != 200) {
  1013. uni.showToast({
  1014. icon: "none",
  1015. mask: true,
  1016. title: res.data.msg,
  1017. duration: 10000,
  1018. });
  1019. return;
  1020. }
  1021. self.ossAvatarUrl = "";
  1022. self.isTakePhoto = true;
  1023. //拍照
  1024. if (this.lastTime) {
  1025. this.timer = setInterval(() => {
  1026. if (this.lastTime <= 0) {
  1027. clearInterval(this.timer);
  1028. uni.showToast({
  1029. icon: "none",
  1030. mask: true,
  1031. title: "考试时间已到,系统将自动交卷",
  1032. duration: 10000,
  1033. });
  1034. this.submit();
  1035. return;
  1036. }
  1037. this.lastTime--;
  1038. }, 1000);
  1039. }
  1040. });
  1041. },
  1042. uploadFile(options, int) {
  1043. var self = this;
  1044. return new Promise((resolve, reject) => {
  1045. var data = {
  1046. imageStatus: int,
  1047. gradeId: this.gradeId,
  1048. };
  1049. self.$api.aliyunpolicy(data).then((res) => {
  1050. if (res.data.code != 200) {
  1051. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  1052. return;
  1053. }
  1054. var ossToken = res.data.data.resultContent;
  1055. if (ossToken.host == null || ossToken.host == undefined) {
  1056. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  1057. return;
  1058. }
  1059. uni.uploadFile({
  1060. url: ossToken.host,
  1061. name: "file",
  1062. filePath: options,
  1063. fileType: "image",
  1064. header: {
  1065. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1066. },
  1067. formData: {
  1068. key: ossToken.dir,
  1069. OSSAccessKeyId: ossToken.accessid,
  1070. policy: ossToken.policy,
  1071. Signature: ossToken.signature,
  1072. callback: ossToken.callback,
  1073. success_action_status: 200,
  1074. },
  1075. success: (result) => {
  1076. // if (result.statusCode === 200) {
  1077. self.ossAvatarUrl = ossToken.dir;
  1078. resolve(ossToken.dir);
  1079. // } else {
  1080. // uni.showToast({
  1081. // title: "上传失败",
  1082. // icon: "none",
  1083. // });
  1084. // return;
  1085. // }
  1086. },
  1087. fail: (error) => {
  1088. uni.showToast({
  1089. title: "上传接口报错" + error,
  1090. icon: "none",
  1091. });
  1092. this.uploadLock = false
  1093. this.openPhoto()
  1094. return;
  1095. },
  1096. });
  1097. });
  1098. });
  1099. },
  1100. imageInfos() {
  1101. var self = this;
  1102. return new Promise((resolve, reject) => {
  1103. uni.getImageInfo({
  1104. src: self.avatarUrl,
  1105. success: async (res) => {
  1106. let canvasWidth = res.width; //图片原始长宽
  1107. let canvasHeight = res.height;
  1108. if (canvasWidth > 2000 || canvasHeight > 2000) {
  1109. uni.compressImage({
  1110. src: self.avatarUrl,
  1111. quality: 75,
  1112. width: "35%",
  1113. height: "35%",
  1114. success: async (rest) => {
  1115. const waitUpload = await self.uploadFile(
  1116. rest.tempFilePath,
  1117. 0
  1118. );
  1119. resolve(waitUpload);
  1120. },
  1121. });
  1122. } else if (canvasWidth > 1000 || canvasHeight > 1000) {
  1123. uni.compressImage({
  1124. src: self.avatarUrl,
  1125. quality: 75,
  1126. width: "50%",
  1127. height: "50%",
  1128. success: async (rest) => {
  1129. const waitUpload = await self.uploadFile(
  1130. rest.tempFilePath,
  1131. 0
  1132. );
  1133. resolve(waitUpload);
  1134. },
  1135. });
  1136. } else {
  1137. console.log("无需压缩");
  1138. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  1139. resolve(waitUpload);
  1140. }
  1141. },
  1142. });
  1143. });
  1144. },
  1145. /**
  1146. * 人脸匹配
  1147. */
  1148. faceRecognition() {
  1149. return new Promise((resolve) => {
  1150. let fileSystem = uni.getFileSystemManager();
  1151. fileSystem.readFile({
  1152. filePath: `${this.avatarUrl}`,
  1153. encoding: "base64",
  1154. position: 0,
  1155. success: (res) => {
  1156. let base64 = "data:image/jpg;base64," + res.data;
  1157. console.log('试卷-base64Data人脸识别参数:', {
  1158. imageA: base64,
  1159. orderGoodsId: this.orderGoodsId,
  1160. gradeId: this.gradeId,
  1161. })
  1162. let timer = setTimeout(() => {
  1163. uni.showToast({
  1164. icon: "none",
  1165. title: '拍照超时,请重新拍照',
  1166. success: () => {
  1167. setTimeout(() => {
  1168. uni.navigateBack()
  1169. }, 1000)
  1170. }
  1171. })
  1172. }, 10 * 1000)
  1173. this.$api
  1174. .faceCertificationCompareFace({
  1175. imageA: base64,
  1176. orderGoodsId: this.orderGoodsId,
  1177. gradeId: this.gradeId,
  1178. })
  1179. .then((res) => {
  1180. clearTimeout(timer)
  1181. resolve(res.data.data);
  1182. }).catch((err) => {
  1183. clearTimeout(timer)
  1184. // 当前网络延迟,
  1185. console.log('人脸识别错误:', err)
  1186. uni.showModal({
  1187. content: "当前网络延迟",
  1188. showCancel: false,
  1189. success: (resultst) => {
  1190. if (resultst.confirm) {
  1191. uni.navigateBack()
  1192. }
  1193. },
  1194. })
  1195. })
  1196. },
  1197. fail(err) {
  1198. console.error(err, "err");
  1199. },
  1200. });
  1201. });
  1202. },
  1203. async submitPhoto() {
  1204. if (this.uploadLock) {
  1205. return
  1206. }
  1207. this.uploadLock = true
  1208. let compareFaceData = await this.faceRecognition();
  1209. this.compareFaceData = compareFaceData
  1210. // if (compareFaceData == 0) {
  1211. // uni.showToast({
  1212. // title: "人脸匹配不通过,请重新拍照上传",
  1213. // icon: "none",
  1214. // duration: 2000,
  1215. // });
  1216. // // setTimeout(() => {
  1217. // // this.uploadLock = false;
  1218. // // this.openPhoto();
  1219. // // }, 2000);
  1220. // return;
  1221. // }
  1222. if (compareFaceData >= 80) {
  1223. const waitYS = await this.imageInfos();
  1224. this.postStudyRecord(); //提交记录
  1225. this.photoPopup = false;
  1226. } else {
  1227. uni.showToast({
  1228. title: "人脸匹配不通过,请重新拍照上传",
  1229. icon: "none",
  1230. duration: 2000,
  1231. });
  1232. setTimeout(() => {
  1233. this.uploadLock = false
  1234. this.openPhoto()
  1235. }, 2000);
  1236. }
  1237. },
  1238. //拍照
  1239. openPhoto() {
  1240. // this.enableAutoRotation = false;
  1241. this.photoPopup = true;
  1242. this.isTaking = true;
  1243. uni.setKeepScreenOn({
  1244. keepScreenOn: true,
  1245. });
  1246. uni.authorize({
  1247. scope: "scope.camera",
  1248. success() {},
  1249. });
  1250. },
  1251. //确认拍照
  1252. takePhoto() {
  1253. var self = this;
  1254. const ctx = uni.createCameraContext();
  1255. ctx.takePhoto({
  1256. quality: "high",
  1257. success: (res) => {
  1258. console.log(res.tempImagePath);
  1259. self.avatarUrl = res.tempImagePath;
  1260. // self.submitPhoto();
  1261. this.isTaking = false;
  1262. },
  1263. fail: (err) => {
  1264. console.log(err);
  1265. },
  1266. });
  1267. },
  1268. /**
  1269. * 是否有上传图片
  1270. */
  1271. hasImgs(bank) {
  1272. return bank.ansText.imageList.length == 0;
  1273. },
  1274. /**
  1275. * 获取试卷类型2考试,1练习
  1276. */
  1277. bankExam() {
  1278. this.$api.bankExam(this.id).then((res) => {
  1279. this.bankType = res.data.data.doType;
  1280. this.examData = res.data.data
  1281. if (this.bankType == 2) {
  1282. this.needBack = true;
  1283. }
  1284. });
  1285. },
  1286. /**
  1287. * 点击后退按钮
  1288. */
  1289. clickLeft() {
  1290. //需要拍照没有拍直接返回
  1291. if (this.needPhoto && !this.isTakePhoto) {
  1292. this.isSubmit = true;
  1293. uni.navigateBack({
  1294. delta: 1,
  1295. });
  1296. return;
  1297. }
  1298. if (this.bankType == 1) {
  1299. let ansCount = this.questionOverNum(); //已答题数
  1300. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1301. //所有题目答完
  1302. if (this.lastCount == 0) {
  1303. // this.testOver = true;
  1304. this.cgType = 7;
  1305. //未答完
  1306. } else {
  1307. this.cgType = 8;
  1308. // this.isLastCount = true;
  1309. }
  1310. this.showpopups = true;
  1311. } else if (this.bankType == 2) {
  1312. let ansCount = this.questionOverNum(); //已答题数
  1313. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1314. //所有题目答完
  1315. if (this.lastCount == 0) {
  1316. this.testOver = true;
  1317. //未答完
  1318. } else {
  1319. this.isLastCount = true;
  1320. }
  1321. }
  1322. },
  1323. /**
  1324. * 返回上一页
  1325. */
  1326. backPages() {
  1327. this.needBack = false;
  1328. uni.navigateBack({
  1329. delta: 1,
  1330. });
  1331. },
  1332. /**
  1333. * 获取已经回答的题目数
  1334. * hasSpecail (是否包含简答和案例)
  1335. */
  1336. questionOverNum(hasSpecail) {
  1337. let count = 0;
  1338. this.questionList.forEach((item) => {
  1339. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1340. if (item.ques) {
  1341. count++;
  1342. }
  1343. } else if (item.type == 4) {
  1344. //案例题
  1345. if (hasSpecail) {
  1346. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1347. if (
  1348. jsonItem.type == 1 ||
  1349. jsonItem.type == 2 ||
  1350. jsonItem.type == 3
  1351. ) {
  1352. if (item.ques[indexs]) {
  1353. return true;
  1354. } else {
  1355. return false;
  1356. }
  1357. } else if (jsonItem.type == 5) {
  1358. console.log(jsonItem, 111);
  1359. if (
  1360. item.ques[indexs] &&
  1361. (item.ques[indexs].text.length ||
  1362. item.ques[indexs].imageList.length)
  1363. ) {
  1364. return true;
  1365. } else {
  1366. return false;
  1367. }
  1368. }
  1369. });
  1370. if (isOver) {
  1371. count++;
  1372. console.log(item, 444);
  1373. }
  1374. }
  1375. } else if (item.type == 5) {
  1376. //简答题
  1377. if (hasSpecail) {
  1378. if (
  1379. item.ques &&
  1380. (item.ques.text.length || item.ques.imageList.length)
  1381. ) {
  1382. count++;
  1383. }
  1384. }
  1385. }
  1386. });
  1387. return count;
  1388. },
  1389. /**
  1390. * 是否做完所有题目
  1391. */
  1392. isDoOver() {
  1393. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1394. if (this.questionList.length == questionOverNum) {
  1395. //全部做完弹窗
  1396. this.cgType = 9;
  1397. this.showpopups = true;
  1398. }
  1399. },
  1400. /**
  1401. * 暂不交卷
  1402. */
  1403. noSubmit() {
  1404. //设为允许退出页面
  1405. this.needBack = false;
  1406. uni.navigateBack({
  1407. delta: 1,
  1408. });
  1409. },
  1410. /**
  1411. * 不离开
  1412. */
  1413. noLeave() {
  1414. this.isLastCount = false;
  1415. },
  1416. /**
  1417. * 立即离开并交卷
  1418. */
  1419. leaveNow() {
  1420. this.isSubmit = true;
  1421. uni.navigateBack({
  1422. delta: 1,
  1423. });
  1424. //需要拍照没有拍,返回不扣次数
  1425. if (this.needPhoto && !this.isTakePhoto) {
  1426. return;
  1427. }
  1428. this.submit('leaveNow')
  1429. return
  1430. let score = 0; //计算总分
  1431. let reportStatus = 0;
  1432. let number = 0;
  1433. let doQuestionIds = []; //做过的题目id
  1434. let doQuestionNum = 0; //做过的题目数量
  1435. let passScore = 0;
  1436. let allScore = 0; //总分
  1437. this.questionList.forEach((item, index) => {
  1438. passScore = item.passScore;
  1439. if (item.type == 1) {
  1440. if (item.ques == item.ans) {
  1441. item.scoreResult = item.score;
  1442. score += item.score;
  1443. number++;
  1444. } else {
  1445. item.scoreResult = 0;
  1446. }
  1447. if (item.ques) {
  1448. doQuestionNum++;
  1449. doQuestionIds.push(item.questionId);
  1450. }
  1451. allScore += item.score;
  1452. } else if (item.type == 2) {
  1453. let isRight =
  1454. item.ques &&
  1455. item.ques.every((quesItem, quesIndex) => {
  1456. return item.ques[quesIndex] == item.ans[quesIndex];
  1457. });
  1458. if (isRight) {
  1459. //全对
  1460. item.scoreResult = item.score;
  1461. score += item.score;
  1462. number++;
  1463. } else {
  1464. let hasPart = false;
  1465. let checkboxScore = 1; //获取单题总分数
  1466. item.ques &&
  1467. item.ques.forEach((ques, quesIndex) => {
  1468. //选错一个全扣
  1469. if (item.ques) {
  1470. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1471. checkboxScore = 0;
  1472. }
  1473. } else {
  1474. checkboxScore = 0;
  1475. }
  1476. });
  1477. //没选错
  1478. if (checkboxScore) {
  1479. checkboxScore = 0;
  1480. item.ans.forEach((ans, quesIndex) => {
  1481. //漏选扣一部分,对n题给n X partScore 分
  1482. if (item.ques) {
  1483. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  1484. checkboxScore += item.partScore;
  1485. hasPart = true;
  1486. }
  1487. } else {
  1488. checkboxScore = 0;
  1489. }
  1490. });
  1491. }
  1492. if (!hasPart) {
  1493. item.scoreResult = 0;
  1494. } else {
  1495. item.scoreResult = checkboxScore;
  1496. }
  1497. score += checkboxScore;
  1498. }
  1499. if (item.ques && item.ques.length) {
  1500. doQuestionNum++;
  1501. doQuestionIds.push(item.questionId);
  1502. }
  1503. allScore += item.score;
  1504. } else if (item.type == 3) {
  1505. if (item.ques == item.ans) {
  1506. item.scoreResult = item.score;
  1507. score += item.score;
  1508. number++;
  1509. } else {
  1510. item.scoreResult = 0;
  1511. }
  1512. if (item.ques) {
  1513. doQuestionNum++;
  1514. doQuestionIds.push(item.questionId);
  1515. }
  1516. allScore += item.score;
  1517. } else {
  1518. allScore += item.score;
  1519. }
  1520. });
  1521. if (score >= passScore) {
  1522. reportStatus = 1;
  1523. } else {
  1524. reportStatus = 0;
  1525. }
  1526. this.$api
  1527. .bankRecordEdit({
  1528. moduleId: this.moduleId || 0,
  1529. chapterId: this.chapterId || 0,
  1530. sectionId: this.sectionId || 0,
  1531. gradeId: this.gradeId,
  1532. courseId: this.courseId,
  1533. orderGoodsId: this.orderGoodsId,
  1534. goodsId: this.goodsId,
  1535. examId: this.id,
  1536. recordId: this.recordId,
  1537. reportStatus: reportStatus,
  1538. rightQuestionNum: number,
  1539. doQuestionNum: doQuestionNum,
  1540. status: 1,
  1541. doQuestionIds: doQuestionIds.join(","),
  1542. performance: score,
  1543. totalScore: allScore,
  1544. type: this.examType,
  1545. // examTime: parseInt(this.allTimes),
  1546. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1547. // historyExamJson: JSON.stringify(this.questionList)
  1548. })
  1549. .then((res) => {});
  1550. },
  1551. /**
  1552. * 立即交卷
  1553. */
  1554. submitNow() {
  1555. this.showpopups = false;
  1556. this.needBack = false;
  1557. this.submit();
  1558. },
  1559. /**
  1560. * 离开页面统计回答正确题数
  1561. */
  1562. examRecordEdit() {
  1563. if (!this.isSubmit) {
  1564. this.submit('leave')
  1565. return
  1566. let number = 0;
  1567. let score = 0;
  1568. let doQuestionNum = 0;
  1569. let reportStatus = 0;
  1570. let lessQuestionNum = 0;
  1571. this.questionList.forEach((item, index) => {
  1572. if (item.type == 1) {
  1573. if (item.ques == item.ans) {
  1574. score += item.score;
  1575. number++;
  1576. }
  1577. if (item.ques) {
  1578. doQuestionNum++;
  1579. }
  1580. } else if (item.type == 2) {
  1581. let isRight =
  1582. item.ques &&
  1583. item.ques.every((quesItem, quesIndex) => {
  1584. return item.ques[quesIndex] == item.ans[quesIndex];
  1585. });
  1586. if (isRight) {
  1587. score += item.score;
  1588. number++;
  1589. } else {
  1590. let hasPart = false;
  1591. let checkboxScore = 1; //获取单题总分数
  1592. item.ques.forEach((ques, quesIndex) => {
  1593. //选错一个全扣
  1594. if (item.ques) {
  1595. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1596. checkboxScore = 0;
  1597. }
  1598. } else {
  1599. checkboxScore = 0;
  1600. }
  1601. });
  1602. //没选错
  1603. if (checkboxScore) {
  1604. checkboxScore = 0;
  1605. item.ans.forEach((ans, quesIndex) => {
  1606. //漏选扣一部分
  1607. if (item.ques) {
  1608. if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1609. checkboxScore += item.partScore;
  1610. hasPart = true;
  1611. }
  1612. } else {
  1613. checkboxScore = 0;
  1614. }
  1615. });
  1616. }
  1617. if (!hasPart) {
  1618. item.scoreResult = 0;
  1619. } else {
  1620. lessQuestionNum++
  1621. item.scoreResult = checkboxScore;
  1622. score += checkboxScore;
  1623. // number++;
  1624. }
  1625. }
  1626. if (item.ques && item.ques.length) {
  1627. doQuestionNum++;
  1628. }
  1629. } else if (item.type == 3) {
  1630. if (item.ques == item.ans) {
  1631. score += item.score;
  1632. number++;
  1633. }
  1634. if (item.ques) {
  1635. doQuestionNum++;
  1636. }
  1637. } else if (item == 4) {
  1638. if (item.ques.length) {
  1639. doQuestionNum++;
  1640. }
  1641. } else if (item.type == 5) {
  1642. if (item.ques) {
  1643. doQuestionNum++;
  1644. }
  1645. }
  1646. });
  1647. if (score >= 60) {
  1648. reportStatus = 1;
  1649. }
  1650. this.$api
  1651. .bankRecordEdit({
  1652. moduleId: this.moduleId || 0,
  1653. chapterId: this.chapterId || 0,
  1654. sectionId: this.sectionId || 0,
  1655. gradeId: this.gradeId,
  1656. courseId: this.courseId,
  1657. orderGoodsId: this.orderGoodsId,
  1658. goodsId: this.goodsId,
  1659. examId: this.id,
  1660. recordId: this.recordId,
  1661. lessQuestionNum:lessQuestionNum,
  1662. performance: score,
  1663. reportStatus: reportStatus,
  1664. status: 1,
  1665. type: this.examType,
  1666. // historyExamJson: JSON.stringify(this.questionList)
  1667. })
  1668. .then((res) => {});
  1669. }
  1670. },
  1671. /**
  1672. * @param {Object} second倒计时过滤器
  1673. */
  1674. countdown(second) {
  1675. if (second) {
  1676. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1677. let m = parseInt((second / 60) % 60); // 计算分数
  1678. let s = parseInt(second % 60); // 计算当前秒数
  1679. if (h < 10) h = "0" + h;
  1680. if (m < 10) m = "0" + m;
  1681. if (s < 10) s = "0" + s;
  1682. return h + ":" + m + ":" + s;
  1683. } else {
  1684. return "";
  1685. }
  1686. },
  1687. /**
  1688. * 请求题目列表
  1689. */
  1690. goodsQuestionList() {
  1691. this.$api
  1692. .goodsQuestionList({
  1693. examId: this.id,
  1694. })
  1695. .then(async (res) => {
  1696. if (!res.data.data.length) {
  1697. this.hideDialog();
  1698. uni.showModal({
  1699. showCancel: false,
  1700. content: "该试卷暂无题目",
  1701. success: function (k) {
  1702. if (k.confirm) {
  1703. uni.navigateBack();
  1704. }
  1705. },
  1706. });
  1707. return;
  1708. }
  1709. this.allTimes = res.data.data[0].answerTime * 60;
  1710. this.lastTime =
  1711. res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  1712. res.data.data.forEach((item, index) => {
  1713. if (typeof item.jsonStr == "string") {
  1714. item.jsonStr = JSON.parse(item.jsonStr);
  1715. if (item.type == 2) {
  1716. //多选
  1717. item.jsonStr.forEach((str) => {
  1718. str.optionsId = "" + str.optionsId;
  1719. });
  1720. let arr = item.answerQuestion.split(",");
  1721. arr.forEach((a, i) => {
  1722. arr[i] = "" + a;
  1723. });
  1724. item.ans = arr;
  1725. item.analysisContent &&
  1726. (item.analysisContent = item.analysisContent.replace(
  1727. /<img/gi,
  1728. '<img style="max-width:100%;"'
  1729. ));
  1730. item.content &&
  1731. (item.content = item.content.replace(
  1732. /<img/gi,
  1733. '<img style="max-width:100%;"'
  1734. ));
  1735. return;
  1736. } else if (item.type == 5) {
  1737. //简答题
  1738. item.ansText = {
  1739. text: "",
  1740. imageList: [],
  1741. };
  1742. item.ques = {
  1743. text: "",
  1744. imageList: [],
  1745. };
  1746. item.analysisContent &&
  1747. (item.analysisContent = item.analysisContent.replace(
  1748. /<img/gi,
  1749. '<img style="max-width:100%;"'
  1750. ));
  1751. item.content &&
  1752. (item.content = item.content.replace(
  1753. /<img/gi,
  1754. '<img style="max-width:100%;"'
  1755. ));
  1756. } else if (item.type == 4) {
  1757. //案例题
  1758. console.log(item.jsonStr);
  1759. item.ques = [];
  1760. item.current = 0;
  1761. let ansArr = [];
  1762. item.jsonStr.forEach((json, index) => {
  1763. if (json.type == 1) {
  1764. ansArr[index] = json.answerQuestion;
  1765. json.content &&
  1766. (json.content = json.content.replace(
  1767. /<img/gi,
  1768. '<img style="max-width:100%;"'
  1769. ));
  1770. } else if (json.type == 2) {
  1771. json.optionsList.forEach((str) => {
  1772. str.optionsId = "" + str.optionsId;
  1773. });
  1774. let arr = json.answerQuestion.split(",");
  1775. arr.forEach((a, i) => {
  1776. arr[i] = "" + a;
  1777. });
  1778. ansArr[index] = arr;
  1779. json.content &&
  1780. (json.content = json.content.replace(
  1781. /<img/gi,
  1782. '<img style="max-width:100%;"'
  1783. ));
  1784. } else if (json.type == 3) {
  1785. ansArr[index] = json.answerQuestion;
  1786. json.content &&
  1787. (json.content = json.content.replace(
  1788. /<img/gi,
  1789. '<img style="max-width:100%;"'
  1790. ));
  1791. } else if (json.type == 5) {
  1792. ansArr[index] = {
  1793. text: "",
  1794. imageList: [],
  1795. };
  1796. json.ansText = {
  1797. text: "",
  1798. imageList: [],
  1799. };
  1800. json.content &&
  1801. (json.content = json.content.replace(
  1802. /<img/gi,
  1803. '<img style="max-width:100%;"'
  1804. ));
  1805. }
  1806. });
  1807. item.analysisContent &&
  1808. (item.analysisContent = item.analysisContent.replace(
  1809. /<img/gi,
  1810. '<img style="max-width:100%;"'
  1811. ));
  1812. item.content &&
  1813. (item.content = item.content.replace(
  1814. /<img/gi,
  1815. '<img style="max-width:100%;"'
  1816. ));
  1817. item.ans = ansArr;
  1818. return;
  1819. }
  1820. item.content &&
  1821. (item.content = item.content.replace(
  1822. /<img/gi,
  1823. '<img style="max-width:100%;"'
  1824. ));
  1825. item.ans = item.answerQuestion;
  1826. }
  1827. });
  1828. this.questionList = res.data.data;
  1829. this.lastCount = this.questionList.length;
  1830. this.getCollectInfo(this.current)
  1831. await this.examRecord();
  1832. });
  1833. },
  1834. /**
  1835. * 记录总题数,获取recordId
  1836. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1837. */
  1838. examRecord(hasSpecial) {
  1839. return new Promise((resolve) => {
  1840. let questionList = 0;
  1841. // if(!hasSpecial) {
  1842. this.questionList.forEach((item, index) => {
  1843. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1844. questionList++;
  1845. }
  1846. });
  1847. // } else {
  1848. // questionList = this.questionList.length;
  1849. // }
  1850. this.$api
  1851. .bankRecord({
  1852. courseId: this.courseId,
  1853. // chapterExamId: this.chapterId || 0,
  1854. // moduleExamId: this.moduleId || 0,
  1855. chapterId: this.chapterId || 0,
  1856. moduleId: this.moduleId || 0,
  1857. sectionId: this.sectionId || 0,
  1858. examId: this.id,
  1859. goodsId: this.goodsId,
  1860. orderGoodsId: this.orderGoodsId,
  1861. gradeId: this.gradeId,
  1862. totalQuestionNum: questionList,
  1863. allQuestionNum: this.questionList.length,
  1864. type: this.examType,
  1865. })
  1866. .then((res) => {
  1867. this.recordId = res.data.data;
  1868. if (this.needPhoto) {
  1869. if (this.learning != 1) {
  1870. this.photoPopup = true; //拍照
  1871. this.isTaking = true;
  1872. }
  1873. } else {
  1874. if (this.lastTime) {
  1875. this.timer = setInterval(() => {
  1876. if (this.lastTime <= 0) {
  1877. clearInterval(this.timer);
  1878. uni.showToast({
  1879. icon: "none",
  1880. mask: true,
  1881. title: "考试时间已到,系统将自动交卷",
  1882. duration: 10000,
  1883. });
  1884. this.submit();
  1885. return;
  1886. }
  1887. this.lastTime--;
  1888. }, 1000);
  1889. }
  1890. resolve();
  1891. }
  1892. });
  1893. });
  1894. },
  1895. /**
  1896. * @param {Object} e单选点击
  1897. */
  1898. radioSelect(optionsId, bindex) {
  1899. // if (this.questionList[bindex].ques) return;
  1900. if (this.questionList[bindex].ques && this.bankType == 1) {
  1901. return
  1902. }
  1903. this.$set(this.questionList[bindex], "ques", optionsId);
  1904. // if ((bindex + 1) < this.questionList.length) {
  1905. // this.current = bindex + 1
  1906. // }
  1907. this.isDoOver();
  1908. },
  1909. /**
  1910. * @param {Object} e案例单选点击
  1911. */
  1912. radioSelectChild(optionsId, ansIndex, bindex) {
  1913. // if (this.questionList[bindex].ques[ansIndex]) return;
  1914. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1915. return
  1916. }
  1917. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1918. this.isDoOver();
  1919. },
  1920. /**
  1921. * @param {Object} 多选点击
  1922. */
  1923. checkboxSelect(optionsId, bindex, index) {
  1924. if (this.questionList[bindex].ques && this.bankType == 1) {
  1925. return
  1926. }
  1927. this.$set(
  1928. this.questionList[bindex].jsonStr[index],
  1929. "checked",
  1930. !this.questionList[bindex].jsonStr[index].checked
  1931. );
  1932. console.log('this.questionList[bindex].jsonStr:', this.questionList[bindex].jsonStr[index])
  1933. },
  1934. /**
  1935. * @param {Object} 案例多选点击
  1936. */
  1937. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1938. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1939. return
  1940. }
  1941. this.$set(
  1942. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1943. "checked",
  1944. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1945. .checked
  1946. );
  1947. },
  1948. isCheckboxChecked(arr) {
  1949. return arr.some((item) => {
  1950. if (item.checked) {
  1951. return true;
  1952. }
  1953. });
  1954. },
  1955. /**
  1956. * @param {Object} 多选确认
  1957. */
  1958. checkboxSubmit(bindex) {
  1959. // if (this.questionList[bindex].ques) return;
  1960. if (this.questionList[bindex].ques && this.bankType == 1) {
  1961. return
  1962. }
  1963. let arr = [];
  1964. this.questionList[bindex].jsonStr.forEach((item) => {
  1965. if (item.checked) {
  1966. arr.push(item.optionsId);
  1967. }
  1968. });
  1969. if (!arr.length) {
  1970. delete this.questionList[bindex].ques
  1971. uni.showToast({
  1972. title: "请选择答案",
  1973. icon: "none",
  1974. });
  1975. return;
  1976. }
  1977. this.$set(this.questionList[bindex], "ques", arr);
  1978. this.$u.toast('已确认答案')
  1979. this.isDoOver();
  1980. // let isWrong = this.questionList[bindex].ques.some(
  1981. // (quesItem, quesIndex) => {
  1982. // return (
  1983. // this.questionList[bindex].ques[quesIndex] !=
  1984. // this.questionList[bindex].ans[quesIndex]
  1985. // );
  1986. // }
  1987. // );
  1988. // let isWrong = this.questionList[bindex].ques.some((item, i) => {
  1989. // return this.questionList[bindex].ans.indexOf(item) == -1;
  1990. // })
  1991. },
  1992. /**
  1993. * @param {Object} 案例多选确认
  1994. */
  1995. checkboxSubmitChild(bindex, ansIndex) {
  1996. // if (this.questionList[bindex].ques[ansIndex]) return;
  1997. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1998. return
  1999. }
  2000. let arr = [];
  2001. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  2002. (item) => {
  2003. if (item.checked) {
  2004. arr.push(item.optionsId);
  2005. }
  2006. }
  2007. );
  2008. if (!arr.length) {
  2009. delete this.questionList[bindex].ques[ansIndex]
  2010. uni.showToast({
  2011. title: "请选择答案",
  2012. icon: "none",
  2013. });
  2014. return;
  2015. }
  2016. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  2017. this.$u.toast('已确认答案')
  2018. this.isDoOver();
  2019. },
  2020. /**
  2021. * @param {Object} index
  2022. * @param {Object} bindex
  2023. * 判断题
  2024. */
  2025. judgeSelect(index, bindex) {
  2026. // if (this.questionList[bindex].ques) return;
  2027. if (this.questionList[bindex].ques && this.bankType == 1) {
  2028. return
  2029. }
  2030. this.$set(this.questionList[bindex], "ques", index == 0 ? '1' : '0');
  2031. this.isDoOver();
  2032. },
  2033. /**
  2034. * @param {Object} ansindex
  2035. * @param {Object} childindex
  2036. * @param {Object} bindex
  2037. * 案例判断题
  2038. */
  2039. judgeSelectChild(ansindex, childindex, bindex) {
  2040. // if (this.questionList[bindex].ques[ansindex]) return;
  2041. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  2042. return
  2043. }
  2044. this.$set(this.questionList[bindex].ques, ansindex, childindex == 0 ? '1' : '0');
  2045. this.isDoOver();
  2046. },
  2047. openFooterTab() {
  2048. this.show = true;
  2049. },
  2050. hideDialog() {
  2051. this.showDialog = false;
  2052. },
  2053. changeIndex(index) {
  2054. this.current = index;
  2055. },
  2056. swiperChange(e) {
  2057. this.current = e.detail.current;
  2058. this.getCollectInfo(this.current)
  2059. },
  2060. /**
  2061. * @param {Object} current
  2062. * 获取收藏信息
  2063. */
  2064. getCollectInfo(current) {
  2065. this.$api
  2066. .getCollectInfo({
  2067. examId: this.id,
  2068. questionId: this.questionList[current].questionId,
  2069. goodsId: this.goodsId,
  2070. orderGoodsId: this.orderGoodsId,
  2071. })
  2072. .then((res) => {
  2073. if (res.data.code == 500) {
  2074. this.$set(this.collectList, current, false);
  2075. } else if (res.data.code == 200) {
  2076. this.$set(this.collectList, current, res.data.data);
  2077. }
  2078. });
  2079. },
  2080. /**
  2081. * @param {Object} state
  2082. * @param {Object} index
  2083. * 收藏
  2084. */
  2085. collect(state, index) {
  2086. if (!state) {
  2087. this.$api.collectQuestion({
  2088. examId: this.id,
  2089. questionId: this.questionList[index].questionId,
  2090. goodsId: this.goodsId || "",
  2091. orderGoodsId: this.orderGoodsId,
  2092. })
  2093. .then((res) => {
  2094. if (res.data.code == 200) {
  2095. this.$set(this.collectList, index, true);
  2096. uni.showToast({
  2097. title: "收藏成功",
  2098. duration: 2000,
  2099. icon: "none",
  2100. });
  2101. this.getCollectInfo(index);
  2102. }
  2103. });
  2104. } else {
  2105. this.$api
  2106. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2107. .then((res) => {
  2108. if (res.data.code == 200) {
  2109. this.$set(this.collectList, index, false);
  2110. uni.showToast({
  2111. title: "取消收藏成功",
  2112. duration: 2000,
  2113. icon: "none",
  2114. });
  2115. }
  2116. });
  2117. }
  2118. return;
  2119. },
  2120. pdsubmit() {
  2121. let ansCount = this.questionOverNum(true); //已答题数
  2122. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2123. //没有答完
  2124. if (this.lastCount !== 0) {
  2125. this.cgType = 6;
  2126. this.showpopups = true;
  2127. return;
  2128. }
  2129. if (this.bankType == 2) {
  2130. if (this.lastTime > 0) {
  2131. let lastTime = this.countdown(this.lastTime);
  2132. uni.showModal({
  2133. title: "提示",
  2134. content: `时间还剩余${lastTime},确定交卷吗?`,
  2135. confirmText: "交卷",
  2136. cancelText: "继续答题",
  2137. success: (res) => {
  2138. if (res.confirm) {
  2139. //确定
  2140. this.submit();
  2141. } else {
  2142. //取消
  2143. }
  2144. },
  2145. });
  2146. return;
  2147. }
  2148. }
  2149. this.submit();
  2150. },
  2151. /**
  2152. * 交卷
  2153. */
  2154. submit(typesubmit) {
  2155. console.log('交卷', typesubmit)
  2156. let score = 0; //计算总分
  2157. let reportStatus = 0;
  2158. let number = 0; //做对的题目数量
  2159. let doQuestionNum = 0; //做过的题目数量
  2160. let allScore = 0; //总分
  2161. let passScore = 0;
  2162. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  2163. let doQuestionIds = []; //做过的题目id
  2164. let rightQuestionIds = []; //做对的题目id
  2165. let lessQuestionNum = 0;
  2166. this.questionList.forEach((item, index) => {
  2167. passScore = item.passScore;
  2168. if (item.type == 1) {
  2169. //正确
  2170. if (item.ques == item.ans) {
  2171. item.scoreResult = item.score;
  2172. score += item.score;
  2173. number++;
  2174. rightQuestionIds.push(item.questionId);
  2175. } else {
  2176. //错误
  2177. item.scoreResult = 0;
  2178. if (item.ques) {
  2179. doWrongQuestionIds.push(item.questionId);
  2180. }
  2181. }
  2182. allScore += item.score;
  2183. if (item.ques) {
  2184. doQuestionNum++;
  2185. doQuestionIds.push(item.questionId);
  2186. }
  2187. } else if (item.type == 2) {
  2188. let isRight =
  2189. item.ans &&
  2190. item.ans.every((quesItem, quesIndex) => {
  2191. if (item.ques) {
  2192. return item.ques[quesIndex] == item.ans[quesIndex];
  2193. } else {
  2194. return false;
  2195. }
  2196. });
  2197. if (isRight) {
  2198. score += item.score;
  2199. number++;
  2200. item.scoreResult = item.score;
  2201. rightQuestionIds.push(item.questionId);
  2202. } else {
  2203. let hasPart = false;
  2204. let checkboxScore = 1; //获取单题总分数
  2205. item.ques &&
  2206. item.ques.forEach((ques, quesIndex) => {
  2207. //选错一个全扣
  2208. if (item.ques) {
  2209. if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
  2210. checkboxScore = 0;
  2211. }
  2212. } else {
  2213. checkboxScore = 0;
  2214. }
  2215. });
  2216. console.log(checkboxScore);
  2217. //没选错
  2218. if (checkboxScore) {
  2219. checkboxScore = 0;
  2220. item.ans.forEach((ans, quesIndex) => {
  2221. //漏选扣一部分,对n题给n X partScore 分
  2222. if (item.ques) {
  2223. if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
  2224. checkboxScore += item.partScore;
  2225. hasPart = true;
  2226. }
  2227. } else {
  2228. checkboxScore = 0;
  2229. }
  2230. });
  2231. }
  2232. if (!hasPart) {
  2233. //0分
  2234. item.scoreResult = 0;
  2235. if (item.ques) {
  2236. doWrongQuestionIds.push(item.questionId);
  2237. }
  2238. } else {
  2239. //部分分
  2240. // number++;
  2241. // doWrongQuestionIds.push(item.questionId);
  2242. lessQuestionNum++
  2243. item.scoreResult = checkboxScore;
  2244. score += checkboxScore;
  2245. // rightQuestionIds.push(item.questionId)
  2246. }
  2247. }
  2248. allScore += item.score;
  2249. if (item.ques && item.ques.length) {
  2250. doQuestionNum++;
  2251. doQuestionIds.push(item.questionId);
  2252. }
  2253. } else if (item.type == 3) {
  2254. if (item.ques == item.ans) {
  2255. item.scoreResult = item.score;
  2256. score += item.score;
  2257. number++;
  2258. rightQuestionIds.push(item.questionId);
  2259. } else {
  2260. item.scoreResult = 0;
  2261. if (item.ques) {
  2262. doWrongQuestionIds.push(item.questionId);
  2263. }
  2264. }
  2265. allScore += item.score;
  2266. if (item.ques) {
  2267. doQuestionNum++;
  2268. doQuestionIds.push(item.questionId);
  2269. }
  2270. } else if (item.type == 4) {
  2271. allScore += item.score;
  2272. if (item.ques && item.ques.length) {
  2273. doQuestionNum++;
  2274. doQuestionIds.push(item.questionId);
  2275. }
  2276. } else if (item.type == 5) {
  2277. allScore += item.score;
  2278. if (item.ques && (item.ques.imageList || item.ques.text)) {
  2279. doQuestionNum++;
  2280. doQuestionIds.push(item.questionId);
  2281. }
  2282. }
  2283. });
  2284. //大于分及格
  2285. if (score >= passScore) {
  2286. reportStatus = 1;
  2287. } else {
  2288. reportStatus = 0;
  2289. }
  2290. clearInterval(this.timer);
  2291. //交卷
  2292. this.$api
  2293. .bankRecordEdit({
  2294. moduleId: this.moduleId || 0,
  2295. chapterId: this.chapterId || 0,
  2296. sectionId: this.sectionId || 0,
  2297. gradeId: this.gradeId,
  2298. examId: this.id,
  2299. goodsId: this.goodsId,
  2300. orderGoodsId: this.orderGoodsId,
  2301. reportStatus: reportStatus,
  2302. recordId: this.recordId,
  2303. courseId: this.courseId,
  2304. rightQuestionNum: number,
  2305. lessQuestionNum: lessQuestionNum,
  2306. status: 1,
  2307. doQuestionIds: doQuestionIds.join(","),
  2308. rightQuestionIds: rightQuestionIds.join(','),
  2309. doQuestionNum: doQuestionNum,
  2310. performance: score,
  2311. totalScore: allScore,
  2312. type: this.examType,
  2313. examTime: parseInt(this.allTimes),
  2314. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2315. historyExamJson: JSON.stringify(this.questionList)
  2316. })
  2317. .then((res) => {
  2318. this.isSubmit = true;
  2319. if (res.data.code == 200) {
  2320. uni.showToast({
  2321. title: "交卷成功",
  2322. duration: 1000,
  2323. mask: true,
  2324. icon: "none",
  2325. });
  2326. if (!typesubmit) {
  2327. console.log('跳转----')
  2328. setTimeout(() => {
  2329. uni.redirectTo({
  2330. url:
  2331. "/pages2/class/question_report?rightQuestionNum=" +
  2332. number +
  2333. "&doWrongQuestionNum=" +
  2334. doWrongQuestionIds.length +
  2335. "&score=" +
  2336. score +
  2337. "&totalScore=" +
  2338. allScore +
  2339. "&reportStatus=" +
  2340. reportStatus +
  2341. "&lessQuestionNum=" +
  2342. lessQuestionNum +
  2343. "&examId=" + this.id + '&recordId=' + this.recordId + '&type=' + this.examType + '&orderGoodsId='+ this.orderGoodsId,
  2344. });
  2345. }, 1000);
  2346. }
  2347. }
  2348. });
  2349. //错题集id提交(客观题)
  2350. this.$api
  2351. .examWrongRecord({
  2352. moduleId: this.moduleId || 0,
  2353. chapterId: this.chapterId || 0,
  2354. sectionId: this.sectionId || 0,
  2355. gradeId: this.gradeId,
  2356. courseId: this.courseId,
  2357. examId: this.id,
  2358. goodsId: this.goodsId,
  2359. orderGoodsId: this.orderGoodsId,
  2360. questionIds: doWrongQuestionIds,
  2361. recordId: this.recordId,
  2362. type: 2, // 视频课程的传2
  2363. })
  2364. .then((res) => {})
  2365. .catch((err) => {})
  2366. },
  2367. /**
  2368. * @param {Object} imgIndex
  2369. * @param {Object} bankIndex
  2370. * 删除简答图片
  2371. */
  2372. deleteImg(imgIndex, bankIndex) {
  2373. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2374. },
  2375. /**
  2376. * @param {Object} imgIndex
  2377. * @param {Object} bankIndex
  2378. * @param {Object} ansIndex
  2379. * 删除案例题简答图片
  2380. */
  2381. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2382. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2383. imgIndex,
  2384. 1
  2385. );
  2386. },
  2387. /**
  2388. * @param {Object} bankindex
  2389. * 选择上传图片
  2390. */
  2391. chooseImg(bankindex) {
  2392. if (
  2393. this.questionList[bankindex] &&
  2394. this.questionList[bankindex].ansText &&
  2395. this.questionList[bankindex].ansText.imageList.length >= 4
  2396. ) {
  2397. uni.showToast({
  2398. icon: "none",
  2399. title: "最多选择4张",
  2400. });
  2401. return;
  2402. }
  2403. uni.chooseImage({
  2404. count: 1, //默认9
  2405. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2406. sourceType: ["album", "camera"], //从相册选择
  2407. success: (res) => {
  2408. let self = this;
  2409. // console.log(JSON.stringify(res.tempFilePaths));
  2410. let img = res.tempFilePaths[0];
  2411. uni.getImageInfo({
  2412. src: img,
  2413. success: async (res) => {
  2414. let canvasWidth = res.width; //图片原始长宽
  2415. let canvasHeight = res.height;
  2416. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2417. uni.compressImage({
  2418. src: img,
  2419. quality: 75,
  2420. width: "50%",
  2421. height: "50%",
  2422. success: async (rest) => {
  2423. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2424. this.questionList[bankindex].ansText.imageList.push(dir);
  2425. },
  2426. });
  2427. } else {
  2428. const dir = await self.uploadFile(img, 0);
  2429. this.questionList[bankindex].ansText.imageList.push(dir);
  2430. }
  2431. },
  2432. });
  2433. },
  2434. });
  2435. },
  2436. /**
  2437. * @param {Object} bankindex
  2438. * @param {Object} ansindex
  2439. * 案例题选择上传图片
  2440. */
  2441. chooseImgChild(bankindex, ansindex) {
  2442. uni.chooseImage({
  2443. count: 1, //默认9
  2444. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2445. sourceType: ["album", "camera"], //从相册选择
  2446. success: (res) => {
  2447. let self = this;
  2448. // console.log(JSON.stringify(res.tempFilePaths));
  2449. let img = res.tempFilePaths[0];
  2450. uni.getImageInfo({
  2451. src: img,
  2452. success: async (res) => {
  2453. let canvasWidth = res.width; //图片原始长宽
  2454. let canvasHeight = res.height;
  2455. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2456. uni.compressImage({
  2457. src: img,
  2458. quality: 75,
  2459. width: "50%",
  2460. height: "50%",
  2461. success: async (rest) => {
  2462. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2463. this.questionList[bankindex].jsonStr[
  2464. ansindex
  2465. ].ansText.imageList.push(dir);
  2466. },
  2467. });
  2468. } else {
  2469. const dir = await self.uploadFile(img, 0);
  2470. this.questionList[bankindex].jsonStr[
  2471. ansindex
  2472. ].ansText.imageList.push(dir);
  2473. }
  2474. },
  2475. });
  2476. },
  2477. });
  2478. },
  2479. /**
  2480. * @param {Object} type
  2481. * @param {Object} bankindex
  2482. * 简答题答案确认
  2483. */
  2484. submitAns(bankindex) {
  2485. console.log(this.questionList[bankindex]);
  2486. if (
  2487. !this.questionList[bankindex].ansText.text &&
  2488. !this.questionList[bankindex].ansText.imageList.length
  2489. ) {
  2490. uni.showToast({
  2491. title: "请输入内容或上传图片",
  2492. duration: 2000,
  2493. icon: "none",
  2494. });
  2495. return;
  2496. }
  2497. this.$set(this.questionList[bankindex], "ques", {
  2498. imageList: this.questionList[bankindex].ansText.imageList,
  2499. text: this.questionList[bankindex].ansText.text,
  2500. });
  2501. this.isDoOver();
  2502. },
  2503. /**
  2504. * @param {Object} bankindex
  2505. * @param {Object} ansindex
  2506. * 案例题简答答案确认
  2507. */
  2508. submitAnsChild(bankindex, ansindex) {
  2509. if (
  2510. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2511. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2512. ) {
  2513. uni.showToast({
  2514. title: "请输入内容或上传图片",
  2515. duration: 2000,
  2516. icon: "none",
  2517. });
  2518. return;
  2519. }
  2520. this.$set(this.questionList[bankindex].ques, ansindex, {
  2521. imageList:
  2522. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  2523. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  2524. });
  2525. this.isDoOver();
  2526. },
  2527. isCheck(item, index) {
  2528. if (this.questionList[index].ques) {
  2529. return true
  2530. }
  2531. },
  2532. isRight(item, index) {
  2533. //单选
  2534. if (this.questionList[index].ques) {
  2535. if (item.type == 1) {
  2536. return this.questionList[index].ques == this.questionList[index].ans;
  2537. //多选
  2538. } else if (item.type == 2) {
  2539. //每一项都相等
  2540. return this.questionList[index].ans.every((item, i) => {
  2541. return item == this.questionList[index].ques[i];
  2542. });
  2543. //判断
  2544. } else if (item.type == 3) {
  2545. return this.questionList[index].ques == this.questionList[index].ans;
  2546. // } else if (item.type == 5) {
  2547. // if(this.questionList[index].ques.text){
  2548. // return true
  2549. // }else{
  2550. // return false
  2551. // }
  2552. } else {
  2553. return false;
  2554. }
  2555. } else {
  2556. return false;
  2557. }
  2558. },
  2559. right(bankIndex, ansIndex, option) {
  2560. if (
  2561. this.questionList[bankIndex].ques[ansIndex] &&
  2562. this.questionList[bankIndex].ans[ansIndex]
  2563. ) {
  2564. if (
  2565. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2566. option.optionsId
  2567. ) != -1 ||
  2568. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2569. option.optionsId
  2570. ) != -1
  2571. ) {
  2572. return true;
  2573. } else {
  2574. return false;
  2575. }
  2576. } else {
  2577. return false;
  2578. }
  2579. },
  2580. wrong(bankIndex, ansIndex, option) {
  2581. if (
  2582. this.questionList[bankIndex].ques[ansIndex] &&
  2583. this.questionList[bankIndex].ans[ansIndex]
  2584. ) {
  2585. if (
  2586. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2587. option.optionsId
  2588. ) != -1 &&
  2589. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2590. option.optionsId
  2591. ) == -1
  2592. ) {
  2593. return true;
  2594. } else {
  2595. return false;
  2596. }
  2597. } else {
  2598. return false;
  2599. }
  2600. },
  2601. isWrong(item, index) {
  2602. if (this.questionList[index].ques) {
  2603. //单选
  2604. if (item.type == 1) {
  2605. return this.questionList[index].ques != this.questionList[index].ans;
  2606. //多选
  2607. } else if (item.type == 2) {
  2608. //每一项都相等
  2609. return this.questionList[index].ques.some((item, i) => {
  2610. return this.questionList[index].ans.indexOf(item) == -1;
  2611. });
  2612. //判断
  2613. } else if (item.type == 3) {
  2614. return this.questionList[index].ques != this.questionList[index].ans;
  2615. } else {
  2616. return false;
  2617. }
  2618. } else {
  2619. return false;
  2620. }
  2621. },
  2622. isPart(item, index) {
  2623. if (this.questionList[index].ques) {
  2624. if (item.type == 2) {
  2625. let isWrong = this.questionList[index].ques.some((item, i) => {
  2626. return this.questionList[index].ans.indexOf(item) == -1;
  2627. });
  2628. let isRight = this.questionList[index].ans.every((item, i) => {
  2629. return item == this.questionList[index].ques[i];
  2630. });
  2631. if (!isRight && !isWrong) {
  2632. return true;
  2633. }
  2634. }
  2635. } else {
  2636. return false;
  2637. }
  2638. },
  2639. isOver(item, index) {
  2640. if (this.questionList[index].ques) {
  2641. if (item.type == 4) {
  2642. //案例题
  2643. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2644. if (
  2645. jsonItem.type == 1 ||
  2646. jsonItem.type == 2 ||
  2647. jsonItem.type == 3
  2648. ) {
  2649. if (item.ques[indexs]) {
  2650. return true;
  2651. } else {
  2652. return false;
  2653. }
  2654. } else if (jsonItem.type == 5) {
  2655. if (
  2656. item.ques[indexs] &&
  2657. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2658. ) {
  2659. console.log("chil");
  2660. return true;
  2661. } else {
  2662. return false;
  2663. }
  2664. }
  2665. });
  2666. if (isOver) {
  2667. return true;
  2668. } else {
  2669. return false;
  2670. }
  2671. } else if (item.type == 5) {
  2672. //简答题
  2673. //每一项都相等
  2674. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2675. return true;
  2676. }
  2677. //判断
  2678. } else {
  2679. return false;
  2680. }
  2681. } else {
  2682. return false;
  2683. }
  2684. },
  2685. tabSelect(index, bankindex) {
  2686. this.$set(this.questionList[bankindex], "current", index);
  2687. },
  2688. },
  2689. };
  2690. </script>
  2691. <style lang="scss" scoped>
  2692. .photoBox {
  2693. width: 100%;
  2694. // background-color: #ffffff;
  2695. // border-radius: 24px 24px 0px 0px;
  2696. .photoTop {
  2697. width: 100%;
  2698. height: 74rpx;
  2699. border-radius: 20px 20px 0px 0px;
  2700. background-color: #ffffff;
  2701. display: flex;
  2702. align-items: center;
  2703. justify-content: center;
  2704. padding: 0rpx 38rpx;
  2705. .sqzz {
  2706. width: 28rpx;
  2707. height: 28rpx;
  2708. display: flex;
  2709. align-items: center;
  2710. justify-content: center;
  2711. }
  2712. .centersq {
  2713. color: #333;
  2714. font-size: 30rpx;
  2715. font-weight: 500;
  2716. }
  2717. }
  2718. .photoCenter {
  2719. width: 750rpx;
  2720. height: 75vh;
  2721. position: relative;
  2722. .center_camera {
  2723. width: 100%;
  2724. height: 75vh;
  2725. // position: fixed;
  2726. .head_take {
  2727. width: 100%;
  2728. height: 75vh;
  2729. display: flex;
  2730. flex-direction: column;
  2731. }
  2732. .headTake_up {
  2733. width: 100%;
  2734. height: 100rpx;
  2735. }
  2736. .headTake_minddle {
  2737. display: flex;
  2738. .min_img {
  2739. width: 500rpx;
  2740. height: 550rpx;
  2741. }
  2742. .min_left, .min_right {
  2743. flex: 1;
  2744. height: 550rpx;
  2745. }
  2746. }
  2747. .headTake_down {
  2748. width: 100%;
  2749. flex: 1;
  2750. }
  2751. .color {
  2752. background-color: #333;
  2753. opacity: 0.5;
  2754. }
  2755. }
  2756. .custom {
  2757. width: 750rpx;
  2758. height: 75vh;
  2759. position: absolute;
  2760. z-index: 1000;
  2761. top: 0;
  2762. left: 0;
  2763. image {
  2764. width: 100%;
  2765. height: 100%;
  2766. }
  2767. }
  2768. }
  2769. .photoBoxbtns {
  2770. display: flex;
  2771. .btnResult {
  2772. height: 100rpx;
  2773. width: 100%;
  2774. background-color: #07c160;
  2775. text-align: center;
  2776. line-height: 100rpx;
  2777. color: #fff;
  2778. font-size: 32rpx;
  2779. font-weight: bold;
  2780. }
  2781. }
  2782. }
  2783. .navbar {
  2784. position: relative;
  2785. z-index: 20000;
  2786. }
  2787. .questionBank {
  2788. width: 100%;
  2789. height: 100vh;
  2790. display: flex;
  2791. flex-direction: column;
  2792. }
  2793. .swiper {
  2794. width: 100%;
  2795. flex: 1;
  2796. }
  2797. .lisSty {
  2798. margin-bottom: 16rpx;
  2799. display: flex;
  2800. .flex_auto {
  2801. flex: 1;
  2802. }
  2803. }
  2804. .activeTI {
  2805. vertical-align: middle;
  2806. display: inline-block;
  2807. border: 1rpx solid #eee;
  2808. border-radius: 50rpx;
  2809. height: 48rpx;
  2810. line-height: 46rpx;
  2811. text-align: center;
  2812. width: 48rpx;
  2813. margin-right: 15rpx;
  2814. color: #666;
  2815. font-size: 30rpx;
  2816. &.right {
  2817. color: #fff;
  2818. background: #36c75a;
  2819. }
  2820. &.wrong {
  2821. color: #fff;
  2822. background: #ff3b30;
  2823. }
  2824. &.checked, &.user_choose {
  2825. color: #fff;
  2826. background: #007aff;
  2827. }
  2828. }
  2829. .submit_checkbox {
  2830. position: fixed;
  2831. left: 0;
  2832. right: 0;
  2833. bottom: 120rpx;
  2834. margin: 20rpx auto;
  2835. width: 526rpx;
  2836. height: 80rpx;
  2837. background: rgba(0, 122, 255, 1);
  2838. color: #fff;
  2839. text-align: center;
  2840. line-height: 80rpx;
  2841. font-size: 30rpx;
  2842. border-radius: 40rpx;
  2843. &.disabled {
  2844. opacity: 0.6;
  2845. }
  2846. }
  2847. .titles {
  2848. overflow: hidden;
  2849. margin-bottom: 24rpx;
  2850. }
  2851. .titBox {
  2852. padding: 41rpx 25rpx 24rpx 25rpx;
  2853. }
  2854. .titBox_title {
  2855. padding: 21rpx;
  2856. }
  2857. .tabs {
  2858. margin: 10rpx;
  2859. display: flex;
  2860. .tab {
  2861. margin: 0 4rpx;
  2862. padding: 10rpx 13rpx;
  2863. text-align: center;
  2864. color: #007aff;
  2865. font-size: 28rpx;
  2866. border-radius: 16rpx;
  2867. background: #fff;
  2868. &.current {
  2869. color: #fff;
  2870. background: #007aff;
  2871. }
  2872. }
  2873. }
  2874. .ans {
  2875. margin: 8rpx 8rpx 8rpx;
  2876. .ans_input {
  2877. border-radius: 16rpx;
  2878. background: #fff;
  2879. .top {
  2880. border-bottom: 1rpx solid #eeeeee;
  2881. padding: 16rpx;
  2882. display: flex;
  2883. align-items: center;
  2884. .icon {
  2885. margin-right: 20rpx;
  2886. width: 40rpx;
  2887. height: 38rpx;
  2888. }
  2889. .progress {
  2890. flex: 1;
  2891. }
  2892. .submit {
  2893. width: 168rpx;
  2894. height: 48rpx;
  2895. line-height: 48rpx;
  2896. text-align: center;
  2897. color: #fff;
  2898. font-size: 30rpx;
  2899. background: #007aff;
  2900. border-radius: 24rpx;
  2901. &.disabled {
  2902. opacity: 0.6;
  2903. }
  2904. }
  2905. }
  2906. .textarea {
  2907. textarea {
  2908. width: 100%;
  2909. height: 287rpx;
  2910. padding: 10rpx;
  2911. }
  2912. }
  2913. .imgs {
  2914. overflow: hidden;
  2915. display: flex;
  2916. width: 100%;
  2917. .img {
  2918. width: 104rpx;
  2919. height: 104rpx;
  2920. border-radius: 8rpx;
  2921. position: relative;
  2922. margin: 20rpx;
  2923. text {
  2924. position: absolute;
  2925. right: -15rpx;
  2926. top: -15rpx;
  2927. width: 30rpx;
  2928. height: 30rpx;
  2929. text-align: center;
  2930. line-height: 30rpx;
  2931. color: #fff;
  2932. background: #ff3b30;
  2933. border-radius: 50%;
  2934. }
  2935. image {
  2936. width: 100%;
  2937. height: 100%;
  2938. }
  2939. }
  2940. }
  2941. }
  2942. .ans_submit {
  2943. padding: 16rpx;
  2944. border-radius: 16rpx;
  2945. background: #fff;
  2946. .imgs {
  2947. overflow: hidden;
  2948. display: flex;
  2949. width: 100%;
  2950. .img {
  2951. width: 104rpx;
  2952. height: 104rpx;
  2953. border-radius: 8rpx;
  2954. position: relative;
  2955. margin: 20rpx;
  2956. image {
  2957. width: 100%;
  2958. height: 100%;
  2959. }
  2960. }
  2961. }
  2962. }
  2963. }
  2964. .leftLetters {
  2965. display: flex;
  2966. align-items: center;
  2967. width: 220rpx;
  2968. .btnType {
  2969. padding: 5rpx 10rpx;
  2970. border: 1rpx solid #007aff;
  2971. border-radius: 10rpx;
  2972. background-color: rgba(0, 122, 255, 0.1);
  2973. font-size: 28rpx;
  2974. color: #007aff;
  2975. margin-right: 15rpx;
  2976. }
  2977. }
  2978. .firstLetter {
  2979. display: flex;
  2980. justify-content: space-between;
  2981. align-items: center;
  2982. margin-bottom: 30rpx;
  2983. }
  2984. .popupView {
  2985. height: 100%;
  2986. padding-bottom: 100rpx;
  2987. .popupTops {
  2988. height: 77rpx;
  2989. border-bottom: 1rpx solid #eee;
  2990. text-align: center;
  2991. line-height: 77rpx;
  2992. font-size: 24rpx;
  2993. color: #999;
  2994. position: relative;
  2995. .topIcon {
  2996. position: absolute;
  2997. top: 10rpx;
  2998. left: 50%;
  2999. transform: translateX(-50%);
  3000. width: 80rpx;
  3001. height: 8rpx;
  3002. background-color: #999;
  3003. border-radius: 4rpx;
  3004. }
  3005. }
  3006. .popupContent {
  3007. }
  3008. }
  3009. .pageContent {
  3010. position: relative;
  3011. background-color: #eaeef1;
  3012. height: 100%;
  3013. padding-top: 8rpx;
  3014. padding-bottom: 100rpx;
  3015. overflow-y: scroll;
  3016. }
  3017. .pad_8 {
  3018. background-color: #fff;
  3019. margin: 0rpx 8rpx 8rpx;
  3020. border-radius: 16rpx;
  3021. &.no-margin {
  3022. margin-top: -16rpx;
  3023. border-radius: 0 0 16rpx 16rpx;
  3024. }
  3025. }
  3026. .answer {
  3027. height: 80rpx;
  3028. line-height: 80rpx;
  3029. padding: 0rpx 24rpx;
  3030. display: flex;
  3031. align-items: center;
  3032. justify-content: space-between;
  3033. color: #666;
  3034. font-size: 30rpx;
  3035. }
  3036. .footer_btn {
  3037. background-color: #fff;
  3038. z-index: 10078;
  3039. position: fixed;
  3040. bottom: 0rpx;
  3041. display: flex;
  3042. align-items: center;
  3043. justify-content: space-between;
  3044. width: 100%;
  3045. height: 98rpx;
  3046. padding: 0rpx 38rpx;
  3047. border-top: 1rpx solid #eee;
  3048. .flex_center {
  3049. flex: 1;
  3050. display: flex;
  3051. justify-content: center;
  3052. align-items: center;
  3053. flex-direction: column;
  3054. margin: 0 200rpx;
  3055. font-size: 24rpx;
  3056. color: #999999;
  3057. .up-icon {
  3058. margin-bottom: 18rpx;
  3059. width: 100%;
  3060. display: flex;
  3061. justify-content: center;
  3062. image {
  3063. width: 58rpx;
  3064. height: 21rpx;
  3065. }
  3066. }
  3067. }
  3068. .collect {
  3069. visibility: hidden;
  3070. width: 100rpx;
  3071. &.show {
  3072. visibility: visible;
  3073. }
  3074. > view {
  3075. display: flex;
  3076. flex-direction: column;
  3077. align-items: center;
  3078. justify-content: center;
  3079. image {
  3080. width: 32rpx;
  3081. height: 32rpx;
  3082. margin-bottom: 6rpx;
  3083. }
  3084. view {
  3085. font-size: 24rpx;
  3086. color: #999999;
  3087. }
  3088. }
  3089. }
  3090. }
  3091. .boxSty {
  3092. padding: 44rpx 41rpx 0rpx;
  3093. }
  3094. .liListSty {
  3095. border: 1rpx solid #eeeeee;
  3096. width: 88rpx;
  3097. height: 88rpx;
  3098. border-radius: 32rpx;
  3099. text-align: center;
  3100. line-height: 88rpx;
  3101. color: #333;
  3102. font-size: 32rpx;
  3103. float: left;
  3104. margin: 20rpx 23rpx;
  3105. &.isRight {
  3106. border: 1rpx solid #eeeeee;
  3107. color: #fff;
  3108. background: #36c75a;
  3109. }
  3110. &.isWrong {
  3111. border: 1rpx solid #eeeeee;
  3112. color: #fff;
  3113. background: #ff3b30;
  3114. }
  3115. &.isPart {
  3116. border: 1rpx solid #eeeeee;
  3117. color: #fff;
  3118. background: #FFC53D;
  3119. }
  3120. &.isOver {
  3121. border: 1rpx solid #eeeeee;
  3122. color: #fff;
  3123. background: blue;
  3124. }
  3125. &.check_ans {
  3126. border: 1rpx solid #eeeeee;
  3127. color: #fff;
  3128. background: #007aff;
  3129. }
  3130. }
  3131. .answerInfos {
  3132. padding: 25rpx 25rpx 25rpx 23rpx;
  3133. }
  3134. .answerTitle {
  3135. margin-bottom: 28rpx;
  3136. color: #666;
  3137. font-size: 30rpx;
  3138. }
  3139. .answerContent {
  3140. font-size: 30rpx;
  3141. color: #666;
  3142. }
  3143. .textChild {
  3144. display: inline-block;
  3145. vertical-align: middle;
  3146. }
  3147. .dialog {
  3148. position: fixed;
  3149. left: 0;
  3150. top: 0;
  3151. width: 100%;
  3152. height: 100%;
  3153. background-color: rgba(0, 0, 0, 0.8);
  3154. display: flex;
  3155. flex-direction: column;
  3156. align-items: center;
  3157. justify-content: center;
  3158. z-index: 20000;
  3159. .text {
  3160. font-size: 32rpx;
  3161. color: #ffffff;
  3162. text-align: center;
  3163. }
  3164. .btn {
  3165. width: 242rpx;
  3166. height: 82rpx;
  3167. border: 2rpx solid #ffffff;
  3168. border-radius: 16rpx;
  3169. text-align: center;
  3170. line-height: 82rpx;
  3171. margin: 41rpx auto;
  3172. color: #fff;
  3173. font-size: 32rpx;
  3174. }
  3175. }
  3176. .dialog-arrow {
  3177. padding-top: 124rpx;
  3178. position: fixed;
  3179. left: 0;
  3180. top: 0;
  3181. width: 100%;
  3182. height: 100%;
  3183. background-color: rgba(0, 0, 0, 0.8);
  3184. z-index: 20000;
  3185. .pointer {
  3186. margin-left: 87rpx;
  3187. display: block;
  3188. width: 95rpx;
  3189. height: 98rpx;
  3190. }
  3191. .text {
  3192. padding-left: 177rpx;
  3193. font-size: 32rpx;
  3194. color: #ffffff;
  3195. }
  3196. .btn {
  3197. width: 242rpx;
  3198. height: 82rpx;
  3199. border: 2rpx solid #ffffff;
  3200. border-radius: 16rpx;
  3201. text-align: center;
  3202. line-height: 82rpx;
  3203. margin: 500rpx auto 0;
  3204. color: #fff;
  3205. font-size: 32rpx;
  3206. }
  3207. }
  3208. .dialog_wrap {
  3209. position: fixed;
  3210. left: 0;
  3211. top: 0;
  3212. width: 100%;
  3213. height: 100%;
  3214. z-index: 9999999999;
  3215. .bg {
  3216. background: rgba(0, 0, 0, 0.3);
  3217. position: absolute;
  3218. left: 0;
  3219. top: 0;
  3220. width: 100%;
  3221. height: 100%;
  3222. }
  3223. .dialog {
  3224. position: absolute;
  3225. left: 50%;
  3226. top: 50%;
  3227. transform: translate3D(-50%, -50%, 0);
  3228. width: 640rpx;
  3229. height: 439rpx;
  3230. background: #ffffff;
  3231. border-radius: 24rpx;
  3232. .title {
  3233. font-size: 30rpx;
  3234. font-weight: bold;
  3235. color: #333333;
  3236. line-height: 48rpx;
  3237. text-align: center;
  3238. margin-top: 40rpx;
  3239. }
  3240. .content {
  3241. margin: 35rpx 35rpx 0;
  3242. font-size: 30rpx;
  3243. color: #666666;
  3244. line-height: 48rpx;
  3245. }
  3246. .btns {
  3247. margin-top: 35rpx;
  3248. display: flex;
  3249. align-items: center;
  3250. justify-content: center;
  3251. .btn {
  3252. width: 200rpx;
  3253. height: 80rpx;
  3254. line-height: 80rpx;
  3255. text-align: center;
  3256. background: #f5f5f5;
  3257. border-radius: 40rpx;
  3258. font-size: 30rpx;
  3259. color: rgba(0, 122, 255, 1);
  3260. background: #f5f5f5;
  3261. margin: 0 20rpx;
  3262. &.active {
  3263. color: #f5f5f5;
  3264. background: rgba(0, 122, 255, 1);
  3265. }
  3266. }
  3267. }
  3268. }
  3269. }
  3270. .popboxs {
  3271. width: 100%;
  3272. height: 100%;
  3273. display: flex;
  3274. flex-direction: column;
  3275. align-items: center;
  3276. }
  3277. .classTops {
  3278. flex-shrink: 0;
  3279. padding: 39rpx 0rpx 4rpx;
  3280. font-weight: bold;
  3281. color: #333;
  3282. font-size: 30rpx;
  3283. }
  3284. .textStys {
  3285. width: 100%;
  3286. flex: 1;
  3287. padding: 36rpx;
  3288. }
  3289. .classFootsty {
  3290. flex-shrink: 0;
  3291. display: flex;
  3292. align-items: center;
  3293. justify-content: center;
  3294. padding: 10rpx 0rpx 40rpx;
  3295. .btnsty {
  3296. width: 200rpx;
  3297. height: 80rpx;
  3298. border-radius: 40rpx;
  3299. font-weight: bold;
  3300. font-size: 30rpx;
  3301. text-align: center;
  3302. line-height: 80rpx;
  3303. }
  3304. .btns1 {
  3305. background-color: #f5f5f5;
  3306. color: #007aff;
  3307. }
  3308. .btns2 {
  3309. margin-left: 40rpx;
  3310. background-color: #007aff;
  3311. color: #ffffff;
  3312. }
  3313. }
  3314. </style>