questionBank.vue 98 KB

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