questionBank.vue 102 KB

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