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. if (this.bankType == 2) {
  1506. this.needBack = true;
  1507. }
  1508. return Promise.resolve();
  1509. });
  1510. },
  1511. /**
  1512. * 点击后退按钮
  1513. */
  1514. clickLeft() {
  1515. //需要拍照没有拍直接返回
  1516. if (this.needPhoto && !this.isTakePhoto) {
  1517. this.isSubmit = true;
  1518. uni.navigateBack({
  1519. delta: 1,
  1520. });
  1521. return;
  1522. }
  1523. if (this.bankType == 1) {
  1524. let ansCount = this.questionOverNum(); //已答题数
  1525. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1526. //所有题目答完
  1527. if (this.lastCount == 0) {
  1528. // this.testOver = true;
  1529. this.cgType = 7;
  1530. //未答完
  1531. } else {
  1532. this.cgType = 8;
  1533. // this.isLastCount = true;
  1534. }
  1535. this.showpopups = true;
  1536. } else if (this.bankType == 2) {
  1537. let ansCount = this.questionOverNum(); //已答题数
  1538. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1539. //所有题目答完
  1540. if (this.lastCount == 0) {
  1541. this.testOver = true;
  1542. //未答完
  1543. } else {
  1544. this.isLastCount = true;
  1545. }
  1546. }
  1547. },
  1548. /**
  1549. * 返回上一页
  1550. */
  1551. backPages() {
  1552. this.needBack = false;
  1553. uni.navigateBack({
  1554. delta: 1,
  1555. });
  1556. },
  1557. /**
  1558. * 获取已经回答的题目数
  1559. * hasSpecail (是否包含简答和案例)
  1560. */
  1561. questionOverNum(hasSpecail) {
  1562. let count = 0;
  1563. this.questionList.forEach((item) => {
  1564. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1565. if (item.ques) {
  1566. count++;
  1567. }
  1568. } else if (item.type == 4) {
  1569. //案例题
  1570. if (hasSpecail) {
  1571. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1572. if (
  1573. jsonItem.type == 1 ||
  1574. jsonItem.type == 2 ||
  1575. jsonItem.type == 3
  1576. ) {
  1577. if (item.ques[indexs]) {
  1578. return true;
  1579. } else {
  1580. return false;
  1581. }
  1582. } else if (jsonItem.type == 5) {
  1583. console.log(jsonItem, 111);
  1584. if (
  1585. item.ques[indexs] &&
  1586. (item.ques[indexs].text.length ||
  1587. item.ques[indexs].imageList.length)
  1588. ) {
  1589. return true;
  1590. } else {
  1591. return false;
  1592. }
  1593. }
  1594. });
  1595. if (isOver) {
  1596. count++;
  1597. console.log(item, 444);
  1598. }
  1599. }
  1600. } else if (item.type == 5) {
  1601. //简答题
  1602. if (hasSpecail) {
  1603. if (
  1604. item.ques &&
  1605. (item.ques.text.length || item.ques.imageList.length)
  1606. ) {
  1607. count++;
  1608. }
  1609. }
  1610. }
  1611. });
  1612. return count;
  1613. },
  1614. /**
  1615. * 是否做完所有题目
  1616. */
  1617. isDoOver() {
  1618. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1619. if (this.questionList.length == questionOverNum) {
  1620. //全部做完弹窗
  1621. this.cgType = 9;
  1622. this.showpopups = true;
  1623. }
  1624. },
  1625. /**
  1626. * 暂不交卷
  1627. */
  1628. noSubmit() {
  1629. //设为允许退出页面
  1630. this.needBack = false;
  1631. uni.navigateBack({
  1632. delta: 1,
  1633. });
  1634. },
  1635. /**
  1636. * 不离开
  1637. */
  1638. noLeave() {
  1639. this.isLastCount = false;
  1640. },
  1641. /**
  1642. * 立即离开并交卷
  1643. */
  1644. leaveNow() {
  1645. this.isSubmit = true;
  1646. uni.navigateBack({
  1647. delta: 1,
  1648. });
  1649. //需要拍照没有拍,返回不扣次数
  1650. if (this.needPhoto && !this.isTakePhoto) {
  1651. return;
  1652. }
  1653. this.submit("leaveNow");
  1654. },
  1655. /**
  1656. * 立即交卷
  1657. */
  1658. submitNow() {
  1659. this.showpopups = false;
  1660. this.needBack = false;
  1661. this.submit();
  1662. },
  1663. /**
  1664. * 离开页面统计回答正确题数
  1665. */
  1666. examRecordEdit() {
  1667. if (!this.isSubmit) {
  1668. this.submit("leave");
  1669. }
  1670. },
  1671. /**
  1672. * @param {Object} second倒计时过滤器
  1673. */
  1674. countdown(second) {
  1675. if (second) {
  1676. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1677. let m = parseInt((second / 60) % 60); // 计算分数
  1678. let s = parseInt(second % 60); // 计算当前秒数
  1679. if (h < 10) h = "0" + h;
  1680. if (m < 10) m = "0" + m;
  1681. if (s < 10) s = "0" + s;
  1682. return h + ":" + m + ":" + s;
  1683. } else {
  1684. return "";
  1685. }
  1686. },
  1687. noListTip(content = "该试卷暂无题目") {
  1688. this.hideDialog();
  1689. uni.showModal({
  1690. showCancel: false,
  1691. content,
  1692. success: (k) => {
  1693. if (k.confirm) {
  1694. this.isSubmit = true;
  1695. uni.navigateBack();
  1696. }
  1697. },
  1698. });
  1699. },
  1700. /**
  1701. * 请求题目列表
  1702. */
  1703. goodsQuestionList() {
  1704. this.$api[
  1705. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1706. ]({
  1707. examId: this.id,
  1708. goodsId: this.goodsId,
  1709. orderGoodsId: this.orderGoodsId,
  1710. from: 2,
  1711. }).then(async (res) => {
  1712. if (res.data.code == 500) {
  1713. return this.noListTip('你已完成所有题目')
  1714. }
  1715. let data = res.data.data;
  1716. if (this.doMode == 3) {
  1717. this.simulateExamId = data.simulateExamId;
  1718. data = data.questionList;
  1719. }
  1720. if (!data.length) {
  1721. return this.noListTip()
  1722. }
  1723. this.allTimes = data[0].answerTime * 60;
  1724. this.lastTime = data[0].answerTime && data[0].answerTime * 60;
  1725. data.forEach((item, index) => {
  1726. if (typeof item.jsonStr == "string") {
  1727. item.jsonStr = JSON.parse(item.jsonStr);
  1728. if (item.type == 2) {
  1729. //多选
  1730. item.jsonStr.forEach((str) => {
  1731. str.optionsId = "" + str.optionsId;
  1732. });
  1733. let arr = item.answerQuestion.split(",");
  1734. arr.forEach((a, i) => {
  1735. arr[i] = "" + a;
  1736. });
  1737. item.ans = arr;
  1738. item.analysisContent &&
  1739. (item.analysisContent = item.analysisContent.replace(
  1740. /<img/gi,
  1741. '<img style="max-width:100%;"'
  1742. ));
  1743. item.content &&
  1744. (item.content = item.content.replace(
  1745. /<img/gi,
  1746. '<img style="max-width:100%;"'
  1747. ));
  1748. return;
  1749. } else if (item.type == 5) {
  1750. //简答题
  1751. item.ansText = {
  1752. text: "",
  1753. imageList: [],
  1754. };
  1755. item.ques = {
  1756. text: "",
  1757. imageList: [],
  1758. };
  1759. item.analysisContent &&
  1760. (item.analysisContent = item.analysisContent.replace(
  1761. /<img/gi,
  1762. '<img style="max-width:100%;"'
  1763. ));
  1764. item.content &&
  1765. (item.content = item.content.replace(
  1766. /<img/gi,
  1767. '<img style="max-width:100%;"'
  1768. ));
  1769. } else if (item.type == 4) {
  1770. //案例题
  1771. console.log(item.jsonStr);
  1772. item.ques = [];
  1773. item.current = 0;
  1774. let ansArr = [];
  1775. item.jsonStr.forEach((json, index) => {
  1776. if (json.type == 1) {
  1777. ansArr[index] = json.answerQuestion;
  1778. json.content &&
  1779. (json.content = json.content.replace(
  1780. /<img/gi,
  1781. '<img style="max-width:100%;"'
  1782. ));
  1783. } else if (json.type == 2) {
  1784. json.optionsList.forEach((str) => {
  1785. str.optionsId = "" + str.optionsId;
  1786. });
  1787. let arr = json.answerQuestion.split(",");
  1788. arr.forEach((a, i) => {
  1789. arr[i] = "" + a;
  1790. });
  1791. ansArr[index] = arr;
  1792. json.content &&
  1793. (json.content = json.content.replace(
  1794. /<img/gi,
  1795. '<img style="max-width:100%;"'
  1796. ));
  1797. } else if (json.type == 3) {
  1798. ansArr[index] = json.answerQuestion;
  1799. json.content &&
  1800. (json.content = json.content.replace(
  1801. /<img/gi,
  1802. '<img style="max-width:100%;"'
  1803. ));
  1804. } else if (json.type == 5) {
  1805. ansArr[index] = {
  1806. text: "",
  1807. imageList: [],
  1808. };
  1809. json.ansText = {
  1810. text: "",
  1811. imageList: [],
  1812. };
  1813. json.content &&
  1814. (json.content = json.content.replace(
  1815. /<img/gi,
  1816. '<img style="max-width:100%;"'
  1817. ));
  1818. }
  1819. });
  1820. item.analysisContent &&
  1821. (item.analysisContent = item.analysisContent.replace(
  1822. /<img/gi,
  1823. '<img style="max-width:100%;"'
  1824. ));
  1825. item.content &&
  1826. (item.content = item.content.replace(
  1827. /<img/gi,
  1828. '<img style="max-width:100%;"'
  1829. ));
  1830. item.ans = ansArr;
  1831. return;
  1832. }
  1833. item.content &&
  1834. (item.content = item.content.replace(
  1835. /<img/gi,
  1836. '<img style="max-width:100%;"'
  1837. ));
  1838. item.ans = item.answerQuestion;
  1839. }
  1840. });
  1841. this.questionList = data;
  1842. this.lastCount = this.questionList.length;
  1843. this.getCollectInfo(this.current);
  1844. await this.examRecord();
  1845. });
  1846. },
  1847. /**
  1848. * 记录总题数,获取recordId
  1849. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1850. */
  1851. examRecord(hasSpecial) {
  1852. return new Promise((resolve) => {
  1853. let questionList = 0;
  1854. // if(!hasSpecial) {
  1855. this.questionList.forEach((item, index) => {
  1856. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1857. questionList++;
  1858. }
  1859. });
  1860. // } else {
  1861. // questionList = this.questionList.length;
  1862. // }
  1863. this.$api
  1864. .bankRecord({
  1865. courseId: this.courseId,
  1866. // chapterExamId: this.chapterId || 0,
  1867. // moduleExamId: this.moduleId || 0,
  1868. chapterId: this.chapterId || 0,
  1869. moduleId: this.moduleId || 0,
  1870. sectionId: this.sectionId || 0,
  1871. examId: this.id,
  1872. goodsId: this.goodsId,
  1873. orderGoodsId: this.orderGoodsId,
  1874. gradeId: this.gradeId,
  1875. totalQuestionNum: questionList,
  1876. allQuestionNum: this.questionList.length,
  1877. type: this.examType,
  1878. simulateExamId: this.simulateExamId,
  1879. doMode: this.doMode,
  1880. })
  1881. .then((res) => {
  1882. this.recordId = res.data.data;
  1883. if (this.needPhoto) {
  1884. if (!this.learning && this.examType != 2) {
  1885. if (uni.getStorageSync("tabkePhotoShow")) {
  1886. // #ifdef MP-WEIXIN
  1887. this.photoPopup = true; //拍照
  1888. this.isTaking = true;
  1889. // #endif
  1890. // #ifdef H5
  1891. this.isHadCamera();
  1892. // #endif
  1893. } else {
  1894. this.popupPhotoShow = true;
  1895. uni.setStorageSync("tabkePhotoShow", 1); // 本地缓存用来判断是否已经弹出过弹窗
  1896. }
  1897. }
  1898. } else {
  1899. if (this.lastTime) {
  1900. this.timer = setInterval(() => {
  1901. if (this.lastTime <= 0) {
  1902. clearInterval(this.timer);
  1903. uni.showToast({
  1904. icon: "none",
  1905. mask: true,
  1906. title: "考试时间已到,系统将自动交卷",
  1907. duration: 10000,
  1908. });
  1909. this.submit();
  1910. return;
  1911. }
  1912. this.lastTime--;
  1913. }, 1000);
  1914. }
  1915. resolve();
  1916. }
  1917. });
  1918. });
  1919. },
  1920. /**
  1921. * @param {Object} e单选点击
  1922. */
  1923. radioSelect(optionsId, bindex) {
  1924. // if (this.questionList[bindex].ques) return;
  1925. if (this.questionList[bindex].ques && this.bankType == 1) {
  1926. return;
  1927. }
  1928. this.$set(this.questionList[bindex], "ques", optionsId);
  1929. // if ((bindex + 1) < this.questionList.length) {
  1930. // this.current = bindex + 1
  1931. // }
  1932. this.isDoOver();
  1933. },
  1934. /**
  1935. * @param {Object} e案例单选点击
  1936. */
  1937. radioSelectChild(optionsId, ansIndex, bindex) {
  1938. // if (this.questionList[bindex].ques[ansIndex]) return;
  1939. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1940. return;
  1941. }
  1942. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1943. this.isDoOver();
  1944. },
  1945. /**
  1946. * @param {Object} 多选点击
  1947. */
  1948. checkboxSelect(optionsId, bindex, index) {
  1949. if (this.questionList[bindex].ques && this.bankType == 1) {
  1950. return;
  1951. }
  1952. this.$set(
  1953. this.questionList[bindex].jsonStr[index],
  1954. "checked",
  1955. !this.questionList[bindex].jsonStr[index].checked
  1956. );
  1957. },
  1958. /**
  1959. * @param {Object} 案例多选点击
  1960. */
  1961. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1962. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1963. return;
  1964. }
  1965. this.$set(
  1966. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1967. "checked",
  1968. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1969. .checked
  1970. );
  1971. },
  1972. isCheckboxChecked(arr) {
  1973. return arr.some((item) => {
  1974. if (item.checked) {
  1975. return true;
  1976. }
  1977. });
  1978. },
  1979. /**
  1980. * @param {Object} 多选确认
  1981. */
  1982. checkboxSubmit(bindex) {
  1983. // if (this.questionList[bindex].ques) return;
  1984. if (this.questionList[bindex].ques && this.bankType == 1) {
  1985. return;
  1986. }
  1987. let arr = [];
  1988. this.questionList[bindex].jsonStr.forEach((item) => {
  1989. if (item.checked) {
  1990. arr.push(item.optionsId);
  1991. }
  1992. });
  1993. if (!arr.length) {
  1994. delete this.questionList[bindex].ques;
  1995. uni.showToast({
  1996. title: "请选择答案",
  1997. icon: "none",
  1998. });
  1999. return;
  2000. }
  2001. this.$set(this.questionList[bindex], "ques", arr);
  2002. this.$u.toast("已确认答案");
  2003. this.isDoOver();
  2004. // let isWrong = this.questionList[bindex].ques.some(
  2005. // (quesItem, quesIndex) => {
  2006. // return (
  2007. // this.questionList[bindex].ques[quesIndex] !=
  2008. // this.questionList[bindex].ans[quesIndex]
  2009. // );
  2010. // }
  2011. // );
  2012. // let isWrong = this.questionList[bindex].ques.some((item, i) => {
  2013. // return this.questionList[bindex].ans.indexOf(item) == -1;
  2014. // })
  2015. },
  2016. /**
  2017. * @param {Object} 案例多选确认
  2018. */
  2019. checkboxSubmitChild(bindex, ansIndex) {
  2020. // if (this.questionList[bindex].ques[ansIndex]) return;
  2021. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  2022. return;
  2023. }
  2024. let arr = [];
  2025. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  2026. (item) => {
  2027. if (item.checked) {
  2028. arr.push(item.optionsId);
  2029. }
  2030. }
  2031. );
  2032. if (!arr.length) {
  2033. delete this.questionList[bindex].ques[ansIndex];
  2034. uni.showToast({
  2035. title: "请选择答案",
  2036. icon: "none",
  2037. });
  2038. return;
  2039. }
  2040. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  2041. this.$u.toast("已确认答案");
  2042. this.isDoOver();
  2043. },
  2044. /**
  2045. * @param {Object} index
  2046. * @param {Object} bindex
  2047. * 判断题
  2048. */
  2049. judgeSelect(index, bindex) {
  2050. // if (this.questionList[bindex].ques) return;
  2051. if (this.questionList[bindex].ques && this.bankType == 1) {
  2052. return;
  2053. }
  2054. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  2055. this.isDoOver();
  2056. },
  2057. /**
  2058. * @param {Object} ansindex
  2059. * @param {Object} childindex
  2060. * @param {Object} bindex
  2061. * 案例判断题
  2062. */
  2063. judgeSelectChild(ansindex, childindex, bindex) {
  2064. // if (this.questionList[bindex].ques[ansindex]) return;
  2065. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  2066. return;
  2067. }
  2068. this.$set(
  2069. this.questionList[bindex].ques,
  2070. ansindex,
  2071. childindex == 0 ? "1" : "0"
  2072. );
  2073. this.isDoOver();
  2074. },
  2075. openFooterTab() {
  2076. this.show = true;
  2077. },
  2078. hideDialog() {
  2079. this.showDialog = false;
  2080. },
  2081. changeIndex(index) {
  2082. this.current = index;
  2083. },
  2084. swiperChange(e) {
  2085. this.current = e.detail.current;
  2086. this.getCollectInfo(this.current);
  2087. },
  2088. /**
  2089. * @param {Object} current
  2090. * 获取收藏信息
  2091. */
  2092. getCollectInfo(current) {
  2093. this.$api
  2094. .getCollectInfo({
  2095. examId: this.id,
  2096. questionId: this.questionList[current].questionId,
  2097. goodsId: this.goodsId,
  2098. orderGoodsId: this.orderGoodsId,
  2099. })
  2100. .then((res) => {
  2101. if (res.data.code == 500) {
  2102. this.$set(this.collectList, current, false);
  2103. } else if (res.data.code == 200) {
  2104. this.$set(this.collectList, current, res.data.data);
  2105. }
  2106. });
  2107. },
  2108. /**
  2109. * @param {Object} state
  2110. * @param {Object} index
  2111. * 收藏
  2112. */
  2113. collect(state, index) {
  2114. if (!state) {
  2115. this.$api
  2116. .collectQuestion({
  2117. examId: this.id,
  2118. questionId: this.questionList[index].questionId,
  2119. goodsId: this.goodsId || "",
  2120. orderGoodsId: this.orderGoodsId,
  2121. doMode: this.doMode,
  2122. })
  2123. .then((res) => {
  2124. if (res.data.code == 200) {
  2125. this.$set(this.collectList, index, true);
  2126. uni.showToast({
  2127. title: "收藏成功",
  2128. duration: 2000,
  2129. icon: "none",
  2130. });
  2131. this.getCollectInfo(index);
  2132. }
  2133. });
  2134. } else {
  2135. this.$api
  2136. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2137. .then((res) => {
  2138. if (res.data.code == 200) {
  2139. this.$set(this.collectList, index, false);
  2140. uni.showToast({
  2141. title: "取消收藏成功",
  2142. duration: 2000,
  2143. icon: "none",
  2144. });
  2145. }
  2146. });
  2147. }
  2148. return;
  2149. },
  2150. pdsubmit() {
  2151. let ansCount = this.questionOverNum(true); //已答题数
  2152. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2153. //没有答完
  2154. if (this.lastCount !== 0) {
  2155. this.cgType = 6;
  2156. this.showpopups = true;
  2157. return;
  2158. }
  2159. if (this.bankType == 2) {
  2160. if (this.lastTime > 0) {
  2161. let lastTime = this.countdown(this.lastTime);
  2162. uni.showModal({
  2163. title: "提示",
  2164. content: `时间还剩余${lastTime},确定交卷吗?`,
  2165. confirmText: "交卷",
  2166. cancelText: "继续答题",
  2167. success: (res) => {
  2168. if (res.confirm) {
  2169. //确定
  2170. this.submit();
  2171. } else {
  2172. //取消
  2173. }
  2174. },
  2175. });
  2176. return;
  2177. }
  2178. }
  2179. this.submit();
  2180. },
  2181. /**
  2182. * 交卷
  2183. */
  2184. submit(typesubmit) {
  2185. let form = this.$method.calculateScore(this.questionList);
  2186. clearInterval(this.timer);
  2187. //交卷
  2188. this.$api
  2189. .bankRecordEdit({
  2190. moduleId: this.moduleId || 0,
  2191. chapterId: this.chapterId || 0,
  2192. sectionId: this.sectionId || 0,
  2193. gradeId: this.gradeId,
  2194. examId: this.id,
  2195. goodsId: this.goodsId,
  2196. orderGoodsId: this.orderGoodsId,
  2197. recordId: this.recordId,
  2198. courseId: this.courseId,
  2199. status: 1,
  2200. type: this.examType,
  2201. examTime: parseInt(this.allTimes),
  2202. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2203. ...form
  2204. })
  2205. .then((res) => {
  2206. this.isSubmit = true;
  2207. if (res.data.code == 200) {
  2208. uni.showToast({
  2209. title: "交卷成功",
  2210. duration: 1000,
  2211. mask: true,
  2212. icon: "none",
  2213. });
  2214. if (!typesubmit) {
  2215. console.log("跳转----");
  2216. setTimeout(() => {
  2217. uni.redirectTo({
  2218. url:
  2219. "/pages2/class/question_report?rightQuestionNum=" +
  2220. number +
  2221. "&doWrongQuestionNum=" +
  2222. doWrongQuestionIds.length +
  2223. "&score=" +
  2224. score +
  2225. "&totalScore=" +
  2226. allScore +
  2227. "&reportStatus=" +
  2228. reportStatus +
  2229. "&lessQuestionNum=" +
  2230. lessQuestionNum +
  2231. "&examId=" +
  2232. this.id +
  2233. "&recordId=" +
  2234. this.recordId +
  2235. "&type=" +
  2236. this.examType +
  2237. "&orderGoodsId=" +
  2238. this.orderGoodsId,
  2239. });
  2240. }, 1000);
  2241. }
  2242. }
  2243. });
  2244. //错题集id提交(客观题)
  2245. this.$api
  2246. .examWrongRecord({
  2247. moduleId: this.moduleId || 0,
  2248. chapterId: this.chapterId || 0,
  2249. sectionId: this.sectionId || 0,
  2250. gradeId: this.gradeId,
  2251. courseId: this.courseId,
  2252. examId: this.id,
  2253. goodsId: this.goodsId,
  2254. orderGoodsId: this.orderGoodsId,
  2255. questionIds: form.questionIds,
  2256. recordId: this.recordId,
  2257. type: 2, // 视频课程的传2
  2258. doMode: this.doMode,
  2259. })
  2260. .then((res) => {})
  2261. .catch((err) => {});
  2262. },
  2263. /**
  2264. * @param {Object} imgIndex
  2265. * @param {Object} bankIndex
  2266. * 删除简答图片
  2267. */
  2268. deleteImg(imgIndex, bankIndex) {
  2269. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2270. },
  2271. /**
  2272. * @param {Object} imgIndex
  2273. * @param {Object} bankIndex
  2274. * @param {Object} ansIndex
  2275. * 删除案例题简答图片
  2276. */
  2277. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2278. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2279. imgIndex,
  2280. 1
  2281. );
  2282. },
  2283. /**
  2284. * @param {Object} bankindex
  2285. * 选择上传图片
  2286. */
  2287. chooseImg(bankindex) {
  2288. if (
  2289. this.questionList[bankindex] &&
  2290. this.questionList[bankindex].ansText &&
  2291. this.questionList[bankindex].ansText.imageList.length >= 4
  2292. ) {
  2293. uni.showToast({
  2294. icon: "none",
  2295. title: "最多选择4张",
  2296. });
  2297. return;
  2298. }
  2299. uni.chooseImage({
  2300. count: 1, //默认9
  2301. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2302. sourceType: ["album", "camera"], //从相册选择
  2303. success: (res) => {
  2304. let self = this;
  2305. // console.log(JSON.stringify(res.tempFilePaths));
  2306. let img = res.tempFilePaths[0];
  2307. uni.getImageInfo({
  2308. src: img,
  2309. success: async (res) => {
  2310. let canvasWidth = res.width; //图片原始长宽
  2311. let canvasHeight = res.height;
  2312. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2313. uni.compressImage({
  2314. src: img,
  2315. quality: 75,
  2316. width: "50%",
  2317. height: "50%",
  2318. success: async (rest) => {
  2319. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2320. this.questionList[bankindex].ansText.imageList.push(dir);
  2321. },
  2322. });
  2323. } else {
  2324. const dir = await self.uploadFile(img, 0);
  2325. this.questionList[bankindex].ansText.imageList.push(dir);
  2326. }
  2327. },
  2328. });
  2329. },
  2330. });
  2331. },
  2332. /**
  2333. * @param {Object} bankindex
  2334. * @param {Object} ansindex
  2335. * 案例题选择上传图片
  2336. */
  2337. chooseImgChild(bankindex, ansindex) {
  2338. uni.chooseImage({
  2339. count: 1, //默认9
  2340. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2341. sourceType: ["album", "camera"], //从相册选择
  2342. success: (res) => {
  2343. let self = this;
  2344. // console.log(JSON.stringify(res.tempFilePaths));
  2345. let img = res.tempFilePaths[0];
  2346. uni.getImageInfo({
  2347. src: img,
  2348. success: async (res) => {
  2349. let canvasWidth = res.width; //图片原始长宽
  2350. let canvasHeight = res.height;
  2351. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2352. uni.compressImage({
  2353. src: img,
  2354. quality: 75,
  2355. width: "50%",
  2356. height: "50%",
  2357. success: async (rest) => {
  2358. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2359. this.questionList[bankindex].jsonStr[
  2360. ansindex
  2361. ].ansText.imageList.push(dir);
  2362. },
  2363. });
  2364. } else {
  2365. const dir = await self.uploadFile(img, 0);
  2366. this.questionList[bankindex].jsonStr[
  2367. ansindex
  2368. ].ansText.imageList.push(dir);
  2369. }
  2370. },
  2371. });
  2372. },
  2373. });
  2374. },
  2375. /**
  2376. * @param {Object} type
  2377. * @param {Object} bankindex
  2378. * 简答题答案确认
  2379. */
  2380. submitAns(bankindex) {
  2381. console.log(this.questionList[bankindex]);
  2382. if (
  2383. !this.questionList[bankindex].ansText.text &&
  2384. !this.questionList[bankindex].ansText.imageList.length
  2385. ) {
  2386. uni.showToast({
  2387. title: "请输入内容或上传图片",
  2388. duration: 2000,
  2389. icon: "none",
  2390. });
  2391. return;
  2392. }
  2393. this.$set(this.questionList[bankindex], "ques", {
  2394. imageList: this.questionList[bankindex].ansText.imageList,
  2395. text: this.questionList[bankindex].ansText.text,
  2396. });
  2397. this.$u.toast("已确认答案");
  2398. this.isDoOver();
  2399. },
  2400. /**
  2401. * @param {Object} bankindex
  2402. * @param {Object} ansindex
  2403. * 案例题简答答案确认
  2404. */
  2405. submitAnsChild(bankindex, ansindex) {
  2406. if (
  2407. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2408. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2409. ) {
  2410. uni.showToast({
  2411. title: "请输入内容或上传图片",
  2412. duration: 2000,
  2413. icon: "none",
  2414. });
  2415. return;
  2416. }
  2417. this.$set(this.questionList[bankindex].ques, ansindex, {
  2418. imageList:
  2419. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  2420. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  2421. });
  2422. this.$u.toast("已确认答案");
  2423. this.isDoOver();
  2424. },
  2425. isCheck(item, index) {
  2426. if (this.questionList[index].ques) {
  2427. return true;
  2428. }
  2429. },
  2430. isRight(item, index) {
  2431. //单选
  2432. if (this.questionList[index].ques) {
  2433. if (item.type == 1) {
  2434. return this.questionList[index].ques == this.questionList[index].ans;
  2435. //多选
  2436. } else if (item.type == 2) {
  2437. //每一项都相等
  2438. return this.questionList[index].ans.every((item, i) => {
  2439. return item == this.questionList[index].ques[i];
  2440. });
  2441. //判断
  2442. } else if (item.type == 3) {
  2443. return this.questionList[index].ques == this.questionList[index].ans;
  2444. // } else if (item.type == 5) {
  2445. // if(this.questionList[index].ques.text){
  2446. // return true
  2447. // }else{
  2448. // return false
  2449. // }
  2450. } else {
  2451. return false;
  2452. }
  2453. } else {
  2454. return false;
  2455. }
  2456. },
  2457. right(bankIndex, ansIndex, option) {
  2458. if (
  2459. this.questionList[bankIndex].ques[ansIndex] &&
  2460. this.questionList[bankIndex].ans[ansIndex]
  2461. ) {
  2462. if (
  2463. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2464. option.optionsId
  2465. ) != -1 ||
  2466. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2467. option.optionsId
  2468. ) != -1
  2469. ) {
  2470. return true;
  2471. } else {
  2472. return false;
  2473. }
  2474. } else {
  2475. return false;
  2476. }
  2477. },
  2478. wrong(bankIndex, ansIndex, option) {
  2479. if (
  2480. this.questionList[bankIndex].ques[ansIndex] &&
  2481. this.questionList[bankIndex].ans[ansIndex]
  2482. ) {
  2483. if (
  2484. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2485. option.optionsId
  2486. ) != -1 &&
  2487. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2488. option.optionsId
  2489. ) == -1
  2490. ) {
  2491. return true;
  2492. } else {
  2493. return false;
  2494. }
  2495. } else {
  2496. return false;
  2497. }
  2498. },
  2499. isWrong(item, index) {
  2500. if (this.questionList[index].ques) {
  2501. //单选
  2502. if (item.type == 1) {
  2503. return this.questionList[index].ques != this.questionList[index].ans;
  2504. //多选
  2505. } else if (item.type == 2) {
  2506. //每一项都相等
  2507. return this.questionList[index].ques.some((item, i) => {
  2508. return this.questionList[index].ans.indexOf(item) == -1;
  2509. });
  2510. //判断
  2511. } else if (item.type == 3) {
  2512. return this.questionList[index].ques != this.questionList[index].ans;
  2513. } else {
  2514. return false;
  2515. }
  2516. } else {
  2517. return false;
  2518. }
  2519. },
  2520. isPart(item, index) {
  2521. if (this.questionList[index].ques) {
  2522. if (item.type == 2) {
  2523. let isWrong = this.questionList[index].ques.some((item, i) => {
  2524. return this.questionList[index].ans.indexOf(item) == -1;
  2525. });
  2526. let isRight = this.questionList[index].ans.every((item, i) => {
  2527. return item == this.questionList[index].ques[i];
  2528. });
  2529. if (!isRight && !isWrong) {
  2530. return true;
  2531. }
  2532. }
  2533. } else {
  2534. return false;
  2535. }
  2536. },
  2537. isOver(item, index) {
  2538. if (this.questionList[index].ques) {
  2539. if (item.type == 4) {
  2540. //案例题
  2541. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2542. if (
  2543. jsonItem.type == 1 ||
  2544. jsonItem.type == 2 ||
  2545. jsonItem.type == 3
  2546. ) {
  2547. if (item.ques[indexs]) {
  2548. return true;
  2549. } else {
  2550. return false;
  2551. }
  2552. } else if (jsonItem.type == 5) {
  2553. if (
  2554. item.ques[indexs] &&
  2555. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2556. ) {
  2557. console.log("chil");
  2558. return true;
  2559. } else {
  2560. return false;
  2561. }
  2562. }
  2563. });
  2564. if (isOver) {
  2565. return true;
  2566. } else {
  2567. return false;
  2568. }
  2569. } else if (item.type == 5) {
  2570. //简答题
  2571. //每一项都相等
  2572. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2573. return true;
  2574. }
  2575. //判断
  2576. } else {
  2577. return false;
  2578. }
  2579. } else {
  2580. return false;
  2581. }
  2582. },
  2583. tabSelect(index, bankindex) {
  2584. this.$set(this.questionList[bankindex], "current", index);
  2585. },
  2586. /**
  2587. * 退出全屏
  2588. */
  2589. exitFullscreen() {
  2590. try {
  2591. var de = document;
  2592. // console.log(de);
  2593. if (de.exitFullscreen) {
  2594. de.exitFullscreen();
  2595. } else if (de.mozCancelFullScreen) {
  2596. de.mozCancelFullScreen();
  2597. } else if (de.webkitCancelFullScreen) {
  2598. de.webkitCancelFullScreen();
  2599. }
  2600. } catch (err) {}
  2601. },
  2602. fullele() {
  2603. return (
  2604. document.fullscreenElement ||
  2605. document.webkitFullscreenElement ||
  2606. document.msFullscreenElement ||
  2607. document.mozFullScreenElement ||
  2608. null
  2609. );
  2610. },
  2611. //判断是否全屏
  2612. isFullScreen() {
  2613. return !!(document.webkitIsFullScreen || this.fullele());
  2614. },
  2615. getUserMedia(constraints, success, error) {
  2616. console.log("getUserMedia===", constraints, "success:", success);
  2617. if (window.navigator.mediaDevices.getUserMedia) {
  2618. // 最新的标准API
  2619. window.navigator.mediaDevices
  2620. .getUserMedia(constraints)
  2621. .then(success)
  2622. .catch(error);
  2623. } else if (window.navigator.webkitGetUserMedia) {
  2624. // webkit核心浏览器
  2625. window.navigator.webkitGetUserMedia(constraints, success, error);
  2626. } else if (window.navigator.mozGetUserMedia) {
  2627. // firfox浏览器
  2628. window.navigator.mozGetUserMedia(constraints, success, error);
  2629. } else if (window.navigator.getUserMedia) {
  2630. // 旧版API
  2631. window.navigator.getUserMedia(constraints, success, error);
  2632. }
  2633. },
  2634. photographSuccess(stream) {
  2635. console.log("有摄像头---", stream);
  2636. this.photoPopup = true;
  2637. this.isTaking = true;
  2638. this.$nextTick(() => {
  2639. const video = document.querySelector("video");
  2640. console.log("video:", video);
  2641. video.srcObject = stream;
  2642. video.play();
  2643. });
  2644. },
  2645. photographError(err) {
  2646. console.log("没有摄像头:", err);
  2647. uni.showModal({
  2648. title: "提示",
  2649. content:
  2650. "课程学习需要开启摄像头进行拍照,经检测您的设备无摄像头可使用,请检测环境是否支持。",
  2651. cancelText: "取消",
  2652. confirmText: "确定",
  2653. success: (res) => {
  2654. if (res.confirm) {
  2655. uni.navigateBack();
  2656. } else if (res.cancel) {
  2657. }
  2658. },
  2659. });
  2660. },
  2661. },
  2662. };
  2663. </script>
  2664. <style lang="scss" scoped>
  2665. .photoBox {
  2666. width: 100%;
  2667. // background-color: #ffffff;
  2668. // border-radius: 24px 24px 0px 0px;
  2669. .photoTop {
  2670. width: 100%;
  2671. height: 74rpx;
  2672. border-radius: 20px 20px 0px 0px;
  2673. background-color: #ffffff;
  2674. display: flex;
  2675. align-items: center;
  2676. justify-content: center;
  2677. padding: 0rpx 38rpx;
  2678. .sqzz {
  2679. width: 28rpx;
  2680. height: 28rpx;
  2681. display: flex;
  2682. align-items: center;
  2683. justify-content: center;
  2684. }
  2685. .centersq {
  2686. color: #333;
  2687. font-size: 30rpx;
  2688. font-weight: 500;
  2689. }
  2690. }
  2691. .photoCenter {
  2692. width: 750rpx;
  2693. height: 75vh;
  2694. position: relative;
  2695. .center_camera {
  2696. width: 100%;
  2697. height: 75vh;
  2698. position: fixed;
  2699. .head_take {
  2700. width: 100%;
  2701. height: 75vh;
  2702. display: flex;
  2703. flex-direction: column;
  2704. }
  2705. .headTake_up {
  2706. width: 100%;
  2707. height: 100rpx;
  2708. }
  2709. .headTake_minddle {
  2710. display: flex;
  2711. .min_img {
  2712. width: 500rpx;
  2713. height: 550rpx;
  2714. }
  2715. .min_left,
  2716. .min_right {
  2717. flex: 1;
  2718. height: 550rpx;
  2719. }
  2720. }
  2721. .headTake_down {
  2722. width: 100%;
  2723. flex: 1;
  2724. }
  2725. .color {
  2726. background-color: #333;
  2727. opacity: 0.5;
  2728. }
  2729. .photo_v {
  2730. width: 100%;
  2731. height: 100%;
  2732. }
  2733. .mask {
  2734. width: 500rpx;
  2735. height: 550rpx;
  2736. position: absolute;
  2737. top: 100rpx;
  2738. left: 0;
  2739. right: 0;
  2740. bottom: 0;
  2741. margin: 0 auto;
  2742. box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.4);
  2743. }
  2744. }
  2745. .custom {
  2746. width: 750rpx;
  2747. height: 75vh;
  2748. position: absolute;
  2749. z-index: 1000;
  2750. top: 0;
  2751. left: 0;
  2752. image {
  2753. width: 100%;
  2754. height: 100%;
  2755. }
  2756. }
  2757. }
  2758. .photoBoxbtns {
  2759. display: flex;
  2760. .takePhoto_btn {
  2761. width: 100%;
  2762. display: flex;
  2763. align-items: center;
  2764. justify-content: space-between;
  2765. background: #a9a7a9;
  2766. padding: 40rpx 26rpx;
  2767. .middle_btn {
  2768. width: 120rpx;
  2769. height: 120rpx;
  2770. border-radius: 40rpx;
  2771. border: 4rpx solid #ffffff;
  2772. display: flex;
  2773. align-items: center;
  2774. justify-content: center;
  2775. }
  2776. .square {
  2777. width: 96rpx;
  2778. height: 96rpx;
  2779. background: #ffffff;
  2780. border-radius: 28rpx;
  2781. }
  2782. .rights {
  2783. font-size: 32rpx;
  2784. font-weight: 500;
  2785. color: #ffffff;
  2786. }
  2787. }
  2788. .btnResult {
  2789. height: 100rpx;
  2790. width: 100%;
  2791. background-color: #07c160;
  2792. text-align: center;
  2793. line-height: 100rpx;
  2794. color: #fff;
  2795. font-size: 32rpx;
  2796. font-weight: bold;
  2797. }
  2798. }
  2799. }
  2800. .navbar {
  2801. position: relative;
  2802. z-index: 20000;
  2803. }
  2804. .questionBank {
  2805. width: 100%;
  2806. height: 100vh;
  2807. display: flex;
  2808. flex-direction: column;
  2809. }
  2810. .swiper {
  2811. width: 100%;
  2812. flex: 1;
  2813. }
  2814. .lisSty {
  2815. margin-bottom: 16rpx;
  2816. display: flex;
  2817. .flex_auto {
  2818. flex: 1;
  2819. word-break: break-all;
  2820. }
  2821. }
  2822. .activeTI {
  2823. vertical-align: middle;
  2824. display: inline-block;
  2825. border: 1rpx solid #eee;
  2826. border-radius: 50rpx;
  2827. height: 48rpx;
  2828. line-height: 46rpx;
  2829. text-align: center;
  2830. width: 48rpx;
  2831. margin-right: 15rpx;
  2832. color: #666;
  2833. font-size: 30rpx;
  2834. &.right {
  2835. color: #fff;
  2836. background: #36c75a;
  2837. }
  2838. &.wrong {
  2839. color: #fff;
  2840. background: #ff3b30;
  2841. }
  2842. &.checked,
  2843. &.user_choose {
  2844. color: #fff;
  2845. background: #007aff;
  2846. }
  2847. }
  2848. .submit_checkbox {
  2849. position: fixed;
  2850. left: 0;
  2851. right: 0;
  2852. bottom: 120rpx;
  2853. margin: 20rpx auto;
  2854. width: 526rpx;
  2855. height: 80rpx;
  2856. background: rgba(0, 122, 255, 1);
  2857. color: #fff;
  2858. text-align: center;
  2859. line-height: 80rpx;
  2860. font-size: 30rpx;
  2861. border-radius: 40rpx;
  2862. &.disabled {
  2863. opacity: 0.6;
  2864. }
  2865. }
  2866. .titles {
  2867. overflow: hidden;
  2868. margin-bottom: 24rpx;
  2869. }
  2870. .titBox {
  2871. padding: 41rpx 25rpx 24rpx 25rpx;
  2872. }
  2873. .titBox_title {
  2874. padding: 21rpx;
  2875. }
  2876. .tabs {
  2877. margin: 10rpx;
  2878. display: flex;
  2879. .tab {
  2880. margin: 0 4rpx;
  2881. padding: 10rpx 13rpx;
  2882. text-align: center;
  2883. color: #007aff;
  2884. font-size: 28rpx;
  2885. border-radius: 16rpx;
  2886. background: #fff;
  2887. &.current {
  2888. color: #fff;
  2889. background: #007aff;
  2890. }
  2891. }
  2892. }
  2893. .ans {
  2894. margin: 8rpx 8rpx 8rpx;
  2895. .ans_input {
  2896. border-radius: 16rpx;
  2897. background: #fff;
  2898. .top {
  2899. border-bottom: 1rpx solid #eeeeee;
  2900. padding: 16rpx;
  2901. display: flex;
  2902. align-items: center;
  2903. .icon {
  2904. margin-right: 20rpx;
  2905. width: 40rpx;
  2906. height: 38rpx;
  2907. }
  2908. .progress {
  2909. flex: 1;
  2910. }
  2911. .submit {
  2912. width: 168rpx;
  2913. height: 48rpx;
  2914. line-height: 48rpx;
  2915. text-align: center;
  2916. color: #fff;
  2917. font-size: 30rpx;
  2918. background: #007aff;
  2919. border-radius: 24rpx;
  2920. &.disabled {
  2921. opacity: 0.6;
  2922. }
  2923. }
  2924. }
  2925. .textarea {
  2926. textarea {
  2927. width: 100%;
  2928. height: 287rpx;
  2929. padding: 10rpx;
  2930. }
  2931. }
  2932. .imgs {
  2933. overflow: hidden;
  2934. display: flex;
  2935. width: 100%;
  2936. .img {
  2937. width: 104rpx;
  2938. height: 104rpx;
  2939. border-radius: 8rpx;
  2940. position: relative;
  2941. margin: 20rpx;
  2942. text {
  2943. position: absolute;
  2944. right: -15rpx;
  2945. top: -15rpx;
  2946. width: 30rpx;
  2947. height: 30rpx;
  2948. text-align: center;
  2949. line-height: 30rpx;
  2950. color: #fff;
  2951. background: #ff3b30;
  2952. border-radius: 50%;
  2953. }
  2954. image {
  2955. width: 100%;
  2956. height: 100%;
  2957. }
  2958. }
  2959. }
  2960. }
  2961. .ans_submit {
  2962. padding: 16rpx;
  2963. border-radius: 16rpx;
  2964. background: #fff;
  2965. .imgs {
  2966. overflow: hidden;
  2967. display: flex;
  2968. width: 100%;
  2969. .img {
  2970. width: 104rpx;
  2971. height: 104rpx;
  2972. border-radius: 8rpx;
  2973. position: relative;
  2974. margin: 20rpx;
  2975. image {
  2976. width: 100%;
  2977. height: 100%;
  2978. }
  2979. }
  2980. }
  2981. }
  2982. }
  2983. .leftLetters {
  2984. display: flex;
  2985. align-items: center;
  2986. width: 220rpx;
  2987. .btnType {
  2988. padding: 5rpx 10rpx;
  2989. border: 1rpx solid #007aff;
  2990. border-radius: 10rpx;
  2991. background-color: rgba(0, 122, 255, 0.1);
  2992. font-size: 28rpx;
  2993. color: #007aff;
  2994. margin-right: 15rpx;
  2995. }
  2996. }
  2997. .firstLetter {
  2998. display: flex;
  2999. justify-content: space-between;
  3000. align-items: center;
  3001. margin-bottom: 30rpx;
  3002. }
  3003. .popupView {
  3004. height: 100%;
  3005. padding-bottom: 100rpx;
  3006. .popupTops {
  3007. height: 77rpx;
  3008. border-bottom: 1rpx solid #eee;
  3009. text-align: center;
  3010. line-height: 77rpx;
  3011. font-size: 24rpx;
  3012. color: #999;
  3013. position: relative;
  3014. .topIcon {
  3015. position: absolute;
  3016. top: 10rpx;
  3017. left: 50%;
  3018. transform: translateX(-50%);
  3019. width: 80rpx;
  3020. height: 8rpx;
  3021. background-color: #999;
  3022. border-radius: 4rpx;
  3023. }
  3024. }
  3025. .popupContent {
  3026. }
  3027. }
  3028. .pageContent {
  3029. position: relative;
  3030. background-color: #eaeef1;
  3031. height: 100%;
  3032. padding-top: 8rpx;
  3033. padding-bottom: 100rpx;
  3034. overflow-y: scroll;
  3035. }
  3036. .pad_8 {
  3037. background-color: #fff;
  3038. margin: 0rpx 8rpx 8rpx;
  3039. border-radius: 16rpx;
  3040. &.no-margin {
  3041. margin-top: -16rpx;
  3042. border-radius: 0 0 16rpx 16rpx;
  3043. }
  3044. }
  3045. .answer {
  3046. height: 80rpx;
  3047. line-height: 80rpx;
  3048. padding: 0rpx 24rpx;
  3049. display: flex;
  3050. align-items: center;
  3051. justify-content: space-between;
  3052. color: #666;
  3053. font-size: 30rpx;
  3054. }
  3055. .footer_btn {
  3056. background-color: #fff;
  3057. z-index: 10078;
  3058. position: fixed;
  3059. bottom: 0rpx;
  3060. display: flex;
  3061. align-items: center;
  3062. justify-content: space-between;
  3063. width: 100%;
  3064. height: 98rpx;
  3065. padding: 0rpx 38rpx;
  3066. border-top: 1rpx solid #eee;
  3067. .flex_center {
  3068. flex: 1;
  3069. display: flex;
  3070. justify-content: center;
  3071. align-items: center;
  3072. flex-direction: column;
  3073. margin: 0 200rpx;
  3074. font-size: 24rpx;
  3075. color: #999999;
  3076. .up-icon {
  3077. margin-bottom: 18rpx;
  3078. width: 100%;
  3079. display: flex;
  3080. justify-content: center;
  3081. image {
  3082. width: 58rpx;
  3083. height: 21rpx;
  3084. }
  3085. }
  3086. }
  3087. .collect {
  3088. visibility: hidden;
  3089. width: 100rpx;
  3090. &.show {
  3091. visibility: visible;
  3092. }
  3093. > view {
  3094. display: flex;
  3095. flex-direction: column;
  3096. align-items: center;
  3097. justify-content: center;
  3098. image {
  3099. width: 32rpx;
  3100. height: 32rpx;
  3101. margin-bottom: 6rpx;
  3102. }
  3103. view {
  3104. font-size: 24rpx;
  3105. color: #999999;
  3106. }
  3107. }
  3108. }
  3109. }
  3110. .boxSty {
  3111. padding: 44rpx 41rpx 0rpx;
  3112. }
  3113. .liListSty {
  3114. border: 1rpx solid #eeeeee;
  3115. width: 88rpx;
  3116. height: 88rpx;
  3117. border-radius: 32rpx;
  3118. text-align: center;
  3119. line-height: 88rpx;
  3120. color: #333;
  3121. font-size: 32rpx;
  3122. float: left;
  3123. margin: 20rpx 23rpx;
  3124. &.isRight {
  3125. border: 1rpx solid #eeeeee;
  3126. color: #fff;
  3127. background: #36c75a;
  3128. }
  3129. &.isWrong {
  3130. border: 1rpx solid #eeeeee;
  3131. color: #fff;
  3132. background: #ff3b30;
  3133. }
  3134. &.isPart {
  3135. border: 1rpx solid #eeeeee;
  3136. color: #fff;
  3137. background: #ffc53d;
  3138. }
  3139. &.isOver {
  3140. border: 1rpx solid #eeeeee;
  3141. color: #fff;
  3142. background: blue;
  3143. }
  3144. &.check_ans {
  3145. border: 1rpx solid #eeeeee;
  3146. color: #fff;
  3147. background: #007aff;
  3148. }
  3149. }
  3150. .answerInfos {
  3151. padding: 25rpx 25rpx 25rpx 23rpx;
  3152. }
  3153. .answerTitle {
  3154. margin-bottom: 28rpx;
  3155. color: #666;
  3156. font-size: 30rpx;
  3157. }
  3158. .answerContent {
  3159. font-size: 30rpx;
  3160. color: #666;
  3161. }
  3162. .textChild {
  3163. display: inline-block;
  3164. vertical-align: middle;
  3165. }
  3166. .dialog {
  3167. position: fixed;
  3168. left: 0;
  3169. top: 0;
  3170. width: 100%;
  3171. height: 100%;
  3172. background-color: rgba(0, 0, 0, 0.8);
  3173. display: flex;
  3174. flex-direction: column;
  3175. align-items: center;
  3176. justify-content: center;
  3177. z-index: 20000;
  3178. .text {
  3179. font-size: 32rpx;
  3180. color: #ffffff;
  3181. text-align: center;
  3182. }
  3183. .btn {
  3184. width: 242rpx;
  3185. height: 82rpx;
  3186. border: 2rpx solid #ffffff;
  3187. border-radius: 16rpx;
  3188. text-align: center;
  3189. line-height: 82rpx;
  3190. margin: 41rpx auto;
  3191. color: #fff;
  3192. font-size: 32rpx;
  3193. }
  3194. }
  3195. .dialog-arrow {
  3196. padding-top: 124rpx;
  3197. position: fixed;
  3198. left: 0;
  3199. top: 0;
  3200. width: 100%;
  3201. height: 100%;
  3202. background-color: rgba(0, 0, 0, 0.8);
  3203. z-index: 20000;
  3204. .pointer {
  3205. margin-left: 87rpx;
  3206. display: block;
  3207. width: 95rpx;
  3208. height: 98rpx;
  3209. }
  3210. .text {
  3211. padding-left: 177rpx;
  3212. font-size: 32rpx;
  3213. color: #ffffff;
  3214. }
  3215. .btn {
  3216. width: 242rpx;
  3217. height: 82rpx;
  3218. border: 2rpx solid #ffffff;
  3219. border-radius: 16rpx;
  3220. text-align: center;
  3221. line-height: 82rpx;
  3222. margin: 500rpx auto 0;
  3223. color: #fff;
  3224. font-size: 32rpx;
  3225. }
  3226. }
  3227. .dialog_wrap {
  3228. position: fixed;
  3229. left: 0;
  3230. top: 0;
  3231. width: 100%;
  3232. height: 100%;
  3233. z-index: 9999999999;
  3234. .bg {
  3235. background: rgba(0, 0, 0, 0.3);
  3236. position: absolute;
  3237. left: 0;
  3238. top: 0;
  3239. width: 100%;
  3240. height: 100%;
  3241. }
  3242. .dialog {
  3243. position: absolute;
  3244. left: 50%;
  3245. top: 50%;
  3246. transform: translate3D(-50%, -50%, 0);
  3247. width: 640rpx;
  3248. height: 439rpx;
  3249. background: #ffffff;
  3250. border-radius: 24rpx;
  3251. .title {
  3252. font-size: 30rpx;
  3253. font-weight: bold;
  3254. color: #333333;
  3255. line-height: 48rpx;
  3256. text-align: center;
  3257. margin-top: 40rpx;
  3258. }
  3259. .content {
  3260. margin: 35rpx 35rpx 0;
  3261. font-size: 30rpx;
  3262. color: #666666;
  3263. line-height: 48rpx;
  3264. }
  3265. .btns {
  3266. margin-top: 35rpx;
  3267. display: flex;
  3268. align-items: center;
  3269. justify-content: center;
  3270. .btn {
  3271. width: 200rpx;
  3272. height: 80rpx;
  3273. line-height: 80rpx;
  3274. text-align: center;
  3275. background: #f5f5f5;
  3276. border-radius: 40rpx;
  3277. font-size: 30rpx;
  3278. color: rgba(0, 122, 255, 1);
  3279. background: #f5f5f5;
  3280. margin: 0 20rpx;
  3281. &.active {
  3282. color: #f5f5f5;
  3283. background: rgba(0, 122, 255, 1);
  3284. }
  3285. }
  3286. }
  3287. }
  3288. }
  3289. .popboxs {
  3290. width: 100%;
  3291. height: 100%;
  3292. display: flex;
  3293. flex-direction: column;
  3294. align-items: center;
  3295. }
  3296. .classTops {
  3297. flex-shrink: 0;
  3298. padding: 39rpx 0rpx 4rpx;
  3299. font-weight: bold;
  3300. color: #333;
  3301. font-size: 30rpx;
  3302. }
  3303. .textStys {
  3304. width: 100%;
  3305. flex: 1;
  3306. padding: 36rpx;
  3307. }
  3308. .classFootsty {
  3309. flex-shrink: 0;
  3310. display: flex;
  3311. align-items: center;
  3312. justify-content: center;
  3313. padding: 10rpx 0rpx 40rpx;
  3314. .btnsty {
  3315. width: 200rpx;
  3316. height: 80rpx;
  3317. border-radius: 40rpx;
  3318. font-weight: bold;
  3319. font-size: 30rpx;
  3320. text-align: center;
  3321. line-height: 80rpx;
  3322. }
  3323. .btns1 {
  3324. background-color: #f5f5f5;
  3325. color: #007aff;
  3326. }
  3327. .btns2 {
  3328. margin-left: 40rpx;
  3329. background-color: #007aff;
  3330. color: #ffffff;
  3331. }
  3332. }
  3333. </style>