questionBank.vue 99 KB

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