questionBank.vue 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar class="navbar" @clickLeft="clickLeft" left-icon="back" :statusBar="true" title="试卷"></uni-nav-bar>
  4. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  5. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  6. <view class="pageContent">
  7. <view class="pad_8 titBox">
  8. <view class="firstLetter">
  9. <view class="leftLetters">
  10. <view class="btnType">
  11. <text v-if="bank.type == 1">单选</text>
  12. <text v-if="bank.type == 2">多选</text>
  13. <text v-if="bank.type == 3">判断</text>
  14. <text v-if="bank.type == 4">案例</text>
  15. <text v-if="bank.type == 5">简答</text>
  16. </view>
  17. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  18. </view>
  19. <view style="color: #666;font-size: 28rpx;">{{ countdown(lastTime) }}</view>
  20. <view class="leftLetters"></view>
  21. </view>
  22. <view class="titles"><rich-text :nodes="bank.content"></rich-text></view>
  23. </view>
  24. <template v-if="bank.type == 1">
  25. <view class="pad_8 titBox no-margin">
  26. <view v-if="!bank.ques">
  27. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId, bankIndex)">
  28. <view class="activeTI">{{ ast[index] }}</view>
  29. <view class="flex_auto">{{ item.content }}</view>
  30. </view>
  31. </view>
  32. <view v-if="bank.ques">
  33. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  34. <text
  35. :class="{ right: item.optionsId == bank.ques || item.optionsId == bank.ans, wrong: item.optionsId == bank.ques && bank.ques != bank.ans }"
  36. class="activeTI"
  37. >
  38. {{ ast[index] }}
  39. </text>
  40. <view class="flex_auto">{{ item.content }}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view v-if="bank.ques">
  45. <view class="pad_8 answer">
  46. <view>正确答案:{{ ast[bank.ans - 1] }}</view>
  47. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  48. </view>
  49. <view class="pad_8 answerInfos">
  50. <view class="answerTitle">答案解析</view>
  51. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  52. </view>
  53. </view>
  54. </template>
  55. <template v-if="bank.type == 2">
  56. <view class="pad_8 titBox no-margin">
  57. <view v-if="!bank.ques">
  58. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId, bankIndex, index)">
  59. <view :class="{ checked: item.checked }" class="activeTI">{{ ast[index] }}</view>
  60. <view class="flex_auto">{{ item.content }}</view>
  61. </view>
  62. </view>
  63. <view v-if="!bank.ques" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(bank.jsonStr)}" @click="checkboxSubmit(bankIndex)">确认答案</view>
  64. <view v-if="bank.ques">
  65. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  66. <text
  67. :class="{
  68. right: bank.ques.indexOf(item.optionsId) != -1 || bank.ans.indexOf(item.optionsId) != -1,
  69. wrong: bank.ques.indexOf(item.optionsId) != -1 && bank.ans.indexOf(item.optionsId) == -1
  70. }"
  71. class="activeTI"
  72. >
  73. {{ ast[index] }}
  74. </text>
  75. <view class="flex_auto">{{ item.content }}</view>
  76. </view>
  77. </view>
  78. </view>
  79. <view v-if="bank.ques">
  80. <view class="pad_8 answer">
  81. <view>
  82. 正确答案:
  83. <text v-for="(ansItem,ansItemIndex) in bank.ans" :key="ansItemIndex">{{ ast[ansItem - 1] }}</text>
  84. </view>
  85. <view>
  86. 我的答案:
  87. <text v-for="(quesItem,quesItemIndex) in bank.ques" :key="quesItemIndex">{{ ast[quesItem - 1] }}</text>
  88. </view>
  89. </view>
  90. <view class="pad_8 answerInfos">
  91. <view class="answerTitle">答案解析</view>
  92. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  93. </view>
  94. </view>
  95. </template>
  96. <template v-if="bank.type == 3">
  97. <view class="pad_8 titBox no-margin">
  98. <view v-if="!bank.ques">
  99. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index, bankIndex)">
  100. <view class="activeTI">{{ ast[index] }}</view>
  101. <view class="flex_auto">
  102. {{ item }}
  103. </view>
  104. </view>
  105. </view>
  106. <view v-if="bank.ques">
  107. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  108. <text :class="{ right: index == bank.ques || index == bank.ans, wrong: index == bank.ques && bank.ques != bank.ans }" class="activeTI">
  109. {{ ast[index] }}
  110. </text>
  111. <view class="flex_auto">
  112. {{ item }}
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <view v-if="bank.ques">
  118. <view class="pad_8 answer">
  119. <view>正确答案:{{ ast[bank.ans] }}</view>
  120. <view>我的答案:{{ ast[bank.ques] }}</view>
  121. </view>
  122. <view class="pad_8 answerInfos">
  123. <view class="answerTitle">答案解析</view>
  124. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  125. </view>
  126. </view>
  127. </template>
  128. <!-- 简答题 -->
  129. <template v-if="bank.type == 5">
  130. <view class="pad_8 titBox">
  131. <view class="ans">
  132. <view class="ans_input" v-if="!bank.ques || (!bank.ques.text && !bank.ques.imageList.length)">
  133. <view class="top flex">
  134. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/camera.png" mode=""></image>
  135. <view class="progress">{{bank.ansText.imageList.length || '0'}}/4</view>
  136. <view class="submit" :class="{disabled:!bank.ansText.text && hasImgs(bank)}" @click="submitAns(bankIndex)">确认答案</view>
  137. </view>
  138. <view class="textarea"><textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea></view>
  139. <view class="imgs">
  140. <view class="img" v-for="(img, imgIndex) in bank.ansText.imageList" :key="imgIndex">
  141. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  142. <image :src="$method.splitImgHost(img, true)"></image>
  143. </view>
  144. </view>
  145. </view>
  146. <view class="ans_submit answerInfos" v-if="bank.ques">
  147. <view class="answerTitle">我的答案:</view>
  148. {{ bank.ques.text }}
  149. <view class="imgs"><image class="img" v-for="(ques,quesIndex) in bank.ques.imageList" :key="quesIndex" :src="$method.splitImgHost(ques, true)"></image></view>
  150. </view>
  151. </view>
  152. </view>
  153. <view v-if="bank.ques && (bank.ques.text || bank.ques.imageList.length)">
  154. <view class="pad_8 answerInfos">
  155. <view class="answerTitle">答案解析:</view>
  156. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  157. </view>
  158. </view>
  159. </template>
  160. <!-- 案例题 -->
  161. <template v-if="bank.type == 4">
  162. <view class="tabs">
  163. <view
  164. class="tab"
  165. :class="{ current: tabIndex == bank.current }"
  166. :key="tabIndex"
  167. v-for="(tab, tabIndex) in bank.jsonStr"
  168. @click="tabSelect(tabIndex, bankIndex)"
  169. >
  170. 问题{{ tabIndex+1 }}
  171. </view>
  172. </view>
  173. <view v-for="(ansItem, ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  174. <template v-if="ansItem.type == 1">
  175. <view class="pad_8 titBox">
  176. <view class="leftLetters">
  177. <view class="btnType">
  178. <text>单选</text>
  179. </view>
  180. </view>
  181. <view class="titles">
  182. <rich-text :nodes="ansItem.content"></rich-text>
  183. </view>
  184. <view v-if="!bank.ques[ansIndex]">
  185. <view
  186. v-for="(option, childIndex) in ansItem.optionsList"
  187. :key="childIndex"
  188. class="lisSty"
  189. @click="radioSelectChild(option.optionsId, ansIndex, bankIndex)"
  190. >
  191. <view class="activeTI">{{ ast[childIndex] }}</view>
  192. <view class="flex_auto">
  193. <rich-text class="textChild" :nodes="option.content"></rich-text>
  194. </view>
  195. </view>
  196. </view>
  197. <view v-if="bank.ques[ansIndex]">
  198. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty">
  199. <text
  200. :class="{
  201. right: option.optionsId == bank.ques[ansIndex] || option.optionsId == bank.ans[ansIndex],
  202. wrong: option.optionsId == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  203. }"
  204. class="activeTI"
  205. >
  206. {{ ast[childIndex] }}
  207. </text>
  208. <view class="flex_auto">
  209. <rich-text :nodes="option.content"></rich-text>
  210. </view>
  211. </view>
  212. </view>
  213. </view>
  214. <view v-if="bank.ques[ansIndex]">
  215. <view class="pad_8 answer">
  216. <view>正确答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  217. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  218. </view>
  219. <view class="pad_8 answerInfos">
  220. <view class="answerTitle">答案解析</view>
  221. <view class="answerContent"><rich-text :nodes="option.analysisContent"></rich-text></view>
  222. </view>
  223. </view>
  224. </template>
  225. <template v-if="ansItem.type == 2">
  226. <view class="pad_8 titBox">
  227. <view class="leftLetters">
  228. <view class="btnType">
  229. <text>多选</text>
  230. </view>
  231. </view>
  232. <view class="titles">
  233. <rich-text :nodes="ansItem.content"></rich-text>
  234. </view>
  235. <view v-if="!bank.ques[ansIndex]">
  236. <view
  237. v-for="(option, childindex) in ansItem.optionsList"
  238. :key="childindex"
  239. class="lisSty"
  240. @click="checkboxSelectChild(bankIndex, ansIndex, childindex)"
  241. >
  242. <view :class="{ checked: option.checked }" class="activeTI">{{ ast[childindex] }}</view>
  243. <view class="flex_auto">
  244. <rich-text :nodes="option.content"></rich-text>
  245. </view>
  246. </view>
  247. </view>
  248. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" :class="{disabled:!isCheckboxChecked(ansItem.optionsList)}" @click="checkboxSubmitChild(bankIndex, ansIndex)">确认答案</view>
  249. <view v-if="bank.ques && bank.ques[ansIndex]">
  250. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  251. <text :class="{ right: right(bankIndex, ansIndex, option), wrong: wrong(bankIndex, ansIndex, option) }" class="activeTI">
  252. {{ ast[childindex] }}
  253. </text>
  254. <view class="flex_auto">
  255. <rich-text :nodes="option.content"></rich-text>
  256. </view>
  257. </view>
  258. </view>
  259. </view>
  260. <view v-if="bank.ques[ansIndex]">
  261. <view class="pad_8 answer">
  262. <view>
  263. 正确答案:
  264. <text :key="ansItemIndex1" v-for="(ansItem1,ansItemIndex1) in bank.ans[ansIndex]">{{ ast[ansItem1 - 1] }}</text>
  265. </view>
  266. <view>
  267. 我的答案:
  268. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) in bank.ques[ansIndex]">{{ ast[quesItem - 1] }}</text>
  269. </view>
  270. </view>
  271. <view class="pad_8 answerInfos">
  272. <view class="answerTitle">答案解析</view>
  273. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  274. </view>
  275. </view>
  276. </template>
  277. <template v-if="ansItem.type == 3">
  278. <view class="pad_8 titBox">
  279. <view class="leftLetters">
  280. <view class="btnType">
  281. <text>判断</text>
  282. </view>
  283. </view>
  284. <view class="titles">
  285. <rich-text :nodes="ansItem.content"></rich-text>
  286. </view>
  287. <view v-if="!bank.ques[ansIndex]">
  288. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex, childindex, bankIndex)">
  289. <view class="activeTI">{{ ast[childindex] }}</view>
  290. <view class="flex_auto">
  291. {{ option }}
  292. </view>
  293. </view>
  294. </view>
  295. <view v-if="bank.ques[ansIndex]">
  296. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  297. <text
  298. :class="{
  299. right: childindex == bank.ques[ansIndex] || childindex == bank.ans[ansIndex],
  300. wrong: childindex == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  301. }"
  302. class="activeTI"
  303. >
  304. {{ ast[childindex] }}
  305. </text>
  306. <view class="flex_auto">
  307. {{ option }}
  308. </view>
  309. </view>
  310. </view>
  311. </view>
  312. <view v-if="bank.ques[ansIndex]">
  313. <view class="pad_8 answer">
  314. <view>正确答案:{{ ast[bank.ans[ansIndex]] }}</view>
  315. <view>我的答案:{{ ast[bank.ques[ansIndex]] }}</view>
  316. </view>
  317. <view class="pad_8 answerInfos">
  318. <view class="answerTitle">答案解析</view>
  319. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  320. </view>
  321. </view>
  322. </template>
  323. <!-- 简答题 -->
  324. <template v-if="ansItem.type == 5">
  325. <view class="pad_8 titBox_title">
  326. <view class="leftLetters">
  327. <view class="btnType">
  328. <text>简答</text>
  329. </view>
  330. </view>
  331. <view class="titles">
  332. <rich-text :nodes="ansItem.content"></rich-text>
  333. </view>
  334. </view>
  335. <view class="pad_8 titBox_title">
  336. <view class="ans">
  337. <view class="ans_input" v-if="!bank.ques[ansIndex] || (!bank.ques[ansIndex].text && !bank.ques[ansIndex].imageList.length)">
  338. <view class="top flex">
  339. <image class="icon" @click="chooseImgChild(bankIndex, ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  340. <view class="progress">{{ansItem.ansText.imageList.length || '0'}}/4</view>
  341. <view class="submit" @click="submitAnsChild(bankIndex, ansIndex)">确认答案</view>
  342. </view>
  343. <view class="textarea"><textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea></view>
  344. <view class="imgs">
  345. <view class="img" :key="imgIndex" v-for="(img, imgIndex) in ansItem.ansText.imageList">
  346. <text @click="deleteImgChild(imgIndex, bankIndex, ansIndex)">x</text>
  347. <image :src="$method.splitImgHost(img, true)"></image>
  348. </view>
  349. </view>
  350. </view>
  351. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex]">
  352. <view class="answerTitle">我的答案</view>
  353. {{ bank.ques[ansIndex].text }}
  354. <view class="imgs">
  355. <image class="img" :key="quesIndex" v-for="(ques,quesIndex) in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques, true)"></image>
  356. </view>
  357. </view>
  358. </view>
  359. </view>
  360. <view v-if="bank.ques[ansIndex]">
  361. <view class="pad_8 answerInfos">
  362. <view class="answerTitle">答案解析</view>
  363. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  364. </view>
  365. </view>
  366. </template>
  367. </view>
  368. </template>
  369. <view class="footer_btn">
  370. <view class="collect">
  371. <view v-if="collectList[bankIndex]">
  372. <image src="/static/icon/collected.png" mode=""></image>
  373. <view>取消收藏</view>
  374. </view>
  375. </view>
  376. <view class="flex_center" @click="openFooterTab">
  377. <view class="up-icon">
  378. <image src="/static/up.png"></image>
  379. </view>
  380. 答题卡
  381. </view>
  382. <view class="collect show" @click="pdsubmit">
  383. <view>
  384. <image src="/static/jj.png" mode=""></image>
  385. <view>交卷</view>
  386. </view>
  387. </view>
  388. </view>
  389. </view>
  390. </swiper-item>
  391. </swiper>
  392. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  393. <view class="popupView">
  394. <view class="popupTops">
  395. <view class="topIcon"></view>
  396. 点击编号即可跳转至对应题目
  397. </view>
  398. <view class="popupContent">
  399. <scroll-view scroll-y="true" style="height: 506rpx;">
  400. <view class="boxSty">
  401. <view
  402. v-for="(item, index) in questionList"
  403. :key="index"
  404. @click="changeIndex(index)"
  405. :class="{ isRight: isRight(item, index), isWrong: isWrong(item, index) }"
  406. class="liListSty"
  407. >
  408. {{ index + 1 }}
  409. </view>
  410. </view>
  411. </scroll-view>
  412. </view>
  413. </view>
  414. </u-popup>
  415. <view class="dialog" v-if="showDialog">
  416. <view class="text">左右滑动切换上下题</view>
  417. <view class="btn" @click="hideDialog">我知道了</view>
  418. </view>
  419. <view class="dialog-arrow" v-if="showArrow">
  420. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  421. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  422. <view class="btn" @click="showArrow = false">我知道了</view>
  423. </view>
  424. <view class="dialog_wrap" v-if="testOver">
  425. <view class="bg"></view>
  426. <view class="dialog">
  427. <view class="title">温馨提示</view>
  428. <view class="content">
  429. <view>您已完成所有题目,</view>
  430. <view>快去交卷吧!</view>
  431. </view>
  432. <view class="btns">
  433. <view class="btn" @click="noSubmit()">暂不交卷</view>
  434. <view class="btn active" @click="submitNow()">立即交卷</view>
  435. </view>
  436. </view>
  437. </view>
  438. <view class="dialog_wrap" v-if="isLastCount">
  439. <view class="bg"></view>
  440. <view class="dialog">
  441. <view class="title">温馨提示</view>
  442. <view class="content">
  443. <view>您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view>
  444. </view>
  445. <view class="btns">
  446. <view class="btn" @click="noLeave()">暂不离开</view>
  447. <view class="btn active" @click="leaveNow()">继续离开</view>
  448. </view>
  449. </view>
  450. </view>
  451. <u-popup v-model="showpopups" mode="center" border-radius="24" height="439rpx" width="640rpx" :mask-close-able="false">
  452. <view class="popboxs">
  453. <view class="classTops">温馨提示</view>
  454. <view class="textStys">
  455. {{
  456. cgType === 7
  457. ? '您还未交卷,确定结束做题吗?'
  458. : cgType === 8
  459. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  460. : cgType === 6
  461. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  462. : cgType == 9
  463. ? `您已完成所有题目,快去交卷吧!`
  464. : ''
  465. }}
  466. </view>
  467. <view class="classFootsty" v-if="cgType === 6">
  468. <view class="btnsty btns1" @click="submit">立即交卷</view>
  469. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  470. </view>
  471. <view class="classFootsty" v-if="cgType === 7">
  472. <view class="btnsty btns1" @click="showpopups = false">下次继续</view>
  473. <view class="btnsty btns2" @click="backPages">结束做题</view>
  474. </view>
  475. <view class="classFootsty" v-if="cgType === 8">
  476. <view class="btnsty btns1" @click="leaveNow()">下次继续</view>
  477. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  478. </view>
  479. <view class="classFootsty" v-if="cgType === 9">
  480. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  481. <view class="btnsty btns2" @click="submit">立即交卷</view>
  482. </view>
  483. </view>
  484. </u-popup>
  485. <u-mask :show="photoPopup" >
  486. <!-- 播放前拍照start -->
  487. <view v-if="photoPopup" :mask-close-able="false" style="bottom: 0;position: fixed;width: 100%;z-index: 999;">
  488. <view class="photoBox">
  489. <view class="photoTop">
  490. <view class="sqzz" v-if="false"><u-icon name="close" color="#333333" size="30" @click="closePhoto"></u-icon></view>
  491. <view class="centersq">请正视手机屏幕</view>
  492. <view class="sqzz"></view>
  493. </view>
  494. <view class="photoCenter">
  495. <view style="width: 100%; height: 979rpx;position: fixed;" v-if="photoPopup">
  496. <camera device-position="front" flash="off" @error="error" style="width: 100%; height: 100%;" ></camera>
  497. </view>
  498. <view class="custom"><image src="/static/zhezhao.png" mode=""></image></view>
  499. </view>
  500. <view class="btnResult" @click="takePhoto">拍照</view>
  501. </view>
  502. </view>
  503. </u-mask>
  504. </view>
  505. </template>
  506. <script>
  507. export default {
  508. data() {
  509. return {
  510. photoPopup:false,
  511. showpopups: false,
  512. id: '',
  513. current: 0,
  514. questionList: [],
  515. ast: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  516. judge: ['错误', '正确'],
  517. ans: [],
  518. ques: [],
  519. show: false,
  520. showDialog: false,
  521. bankList: [],
  522. collectList: [],
  523. goodsId: '',
  524. recordId: '',
  525. isSubmit: false,
  526. lastTime: 0, //剩余考试时长
  527. allTimes: 0, //总考试时长
  528. timer: null,
  529. wrongList: [],
  530. bankType: 0, //试卷类型
  531. needBack: false, //是否是考试
  532. testOver: false,
  533. isLastCount: false, //是否有未答题目
  534. lastCount: 0, //剩余没有回答的题目数
  535. chapterId: 0,
  536. moduleId: 0,
  537. showArrow:false, //退出提示
  538. isFromVideo:'',
  539. gradeId:'',
  540. courseId:0,
  541. cgType: 0 ,//对应设计稿弹窗编码,
  542. avatarUrl:'',
  543. ossAvatarUrl: '',
  544. goodsDetail:{},
  545. isTakePhoto:false,
  546. needPhoto:false //是否需要拍照
  547. };
  548. },
  549. async onLoad(option) {
  550. this.id = option.id;
  551. this.goodsId = option.goodsid;
  552. this.chapterId = option.chapterId;
  553. this.courseId = option.courseId;
  554. this.moduleId = option.moduleId;
  555. this.isFromVideo = option.isFromVideo||'';
  556. this.gradeId = option.gradeId || '';
  557. let isBack = option.isback;
  558. let showDialog = uni.getStorageSync('showDialog');
  559. if(showDialog) {
  560. this.showDialog = false;
  561. } else {
  562. this.showDialog = true;
  563. uni.setStorageSync('showDialog','1');
  564. }
  565. //考试时候用手势或者返回键 被迫返回做题
  566. if (isBack) {
  567. console.log(getApp());
  568. let app = getApp();
  569. let globalData = app.globalData;
  570. for (var k in globalData.bankData) {
  571. this[k] = globalData.bankData[k];
  572. }
  573. this.showArrow = true;
  574. //需要拍没拍过直接弹出摄像头
  575. if(this.needPhoto && !this.isTakePhoto) {
  576. this.photoPopup = true;
  577. } else { //不需要拍照
  578. if(this.lastTime) {
  579. this.timer = setInterval(() => {
  580. if (this.lastTime <= 0) {
  581. clearInterval(this.timer);
  582. uni.showToast({
  583. icon:'none',
  584. mask:true,
  585. title:'考试时间已到,系统将自动交卷',
  586. duration:10000
  587. })
  588. this.submit();
  589. return;
  590. }
  591. this.lastTime--;
  592. }, 1000);
  593. }
  594. }
  595. } else {
  596. await this.getGoodsDetail()
  597. this.goodsQuestionList();
  598. this.bankExam();
  599. }
  600. },
  601. onUnload() {
  602. if (this.isSubmit) {
  603. clearInterval(this.timer)
  604. return;
  605. }
  606. if(this.needPhoto && !this.isTakePhoto) {
  607. return;
  608. }
  609. //考试试卷 阻止ios手势返回,自动跳回答题页
  610. if (this.needBack) {
  611. let app = getApp();
  612. app.globalData.bankData = this.$data;
  613. clearInterval(this.timer);
  614. uni.navigateTo({
  615. url: '/pages2/class/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
  616. });
  617. } else {
  618. //点击返回按钮确认允许退出,交卷
  619. clearInterval(this.timer)
  620. this.examRecordEdit();
  621. }
  622. },
  623. methods: {
  624. getGoodsDetail() {
  625. return new Promise((resolve) => {
  626. let self = this
  627. this.$api.goodsDetail(this.goodsId).then(res => {
  628. self.goodsDetail = res.data.data;
  629. if (self.goodsDetail.goodsPhotoExamConfig) {
  630. let goodsPhotoExamConfig = JSON.parse(self.goodsDetail.goodsPhotoExamConfig);
  631. if (goodsPhotoExamConfig.photograph > 0) {
  632. self.needPhoto = true;
  633. }
  634. }
  635. resolve()
  636. });
  637. })
  638. },
  639. postStudyRecord() {
  640. let self = this
  641. let data = {
  642. photo: self.ossAvatarUrl,
  643. recordId: self.recordId
  644. };
  645. console.log(data,"拍照提交")
  646. this.$api.studyExamPhotoRecord(data).then(res => {
  647. console.log(res,"拍照提交结果")
  648. if(res.data.code!=200){
  649. uni.showToast({
  650. icon:'none',
  651. mask:true,
  652. title:res.data.msg,
  653. duration:10000
  654. })
  655. return
  656. }
  657. self.ossAvatarUrl = ''
  658. self.isTakePhoto = true;
  659. //拍照
  660. if(this.lastTime) {
  661. this.timer = setInterval(() => {
  662. if (this.lastTime <= 0) {
  663. clearInterval(this.timer);
  664. uni.showToast({
  665. icon:'none',
  666. mask:true,
  667. title:'考试时间已到,系统将自动交卷',
  668. duration:10000
  669. })
  670. this.submit();
  671. return;
  672. }
  673. this.lastTime--;
  674. }, 1000);
  675. }
  676. });
  677. },
  678. uploadFile(options, int) {
  679. var self = this;
  680. return new Promise((resolve, reject) => {
  681. var data = {
  682. imageStatus: int
  683. };
  684. self.$api.aliyunpolicy(data).then(res => {
  685. if (res.data.code != 200) {
  686. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  687. return;
  688. }
  689. var ossToken = res.data.data.resultContent;
  690. if (ossToken.host == null || ossToken.host == undefined) {
  691. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  692. return;
  693. }
  694. uni.uploadFile({
  695. url: ossToken.host,
  696. name: 'file',
  697. filePath: options,
  698. fileType: 'image',
  699. header: {
  700. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  701. },
  702. formData: {
  703. key: ossToken.dir,
  704. OSSAccessKeyId: ossToken.accessid,
  705. policy: ossToken.policy,
  706. Signature: ossToken.signature,
  707. callback: ossToken.callback,
  708. success_action_status: 200
  709. },
  710. success: result => {
  711. if (result.statusCode === 200) {
  712. self.ossAvatarUrl = ossToken.dir;
  713. resolve();
  714. } else {
  715. uni.showToast({
  716. title: '上传失败',
  717. icon: 'none'
  718. });
  719. return;
  720. }
  721. },
  722. fail: error => {
  723. uni.showToast({
  724. title: '上传接口报错' + error,
  725. icon: 'none'
  726. });
  727. return;
  728. }
  729. });
  730. });
  731. });
  732. },
  733. imageInfos() {
  734. var self = this;
  735. return new Promise((resolve, reject) => {
  736. uni.getImageInfo({
  737. src: self.avatarUrl,
  738. success: async res => {
  739. let canvasWidth = res.width; //图片原始长宽
  740. let canvasHeight = res.height;
  741. if (canvasWidth > 1000 || canvasHeight > 1000) {
  742. uni.compressImage({
  743. src: self.avatarUrl,
  744. quality: 75,
  745. width: '50%',
  746. height: '50%',
  747. success: async rest => {
  748. const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
  749. resolve();
  750. }
  751. });
  752. } else {
  753. console.log('无需压缩');
  754. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  755. resolve();
  756. }
  757. }
  758. });
  759. });
  760. },
  761. async submitPhoto() {
  762. const waitYS = await this.imageInfos();
  763. this.postStudyRecord(); //提交记录
  764. },
  765. //确认拍照
  766. takePhoto() {
  767. var self = this;
  768. const ctx = uni.createCameraContext();
  769. ctx.takePhoto({
  770. quality: 'high',
  771. success: res => {
  772. console.log(res.tempImagePath);
  773. self.avatarUrl = res.tempImagePath;
  774. self.submitPhoto();
  775. self.photoPopup = false;
  776. },
  777. fail: err => {
  778. console.log(err);
  779. }
  780. });
  781. },
  782. /**
  783. * 是否有上传图片
  784. */
  785. hasImgs(bank) {
  786. return bank.ansText.imageList.length == 0;
  787. },
  788. /**
  789. * 获取试卷类型2考试,1练习
  790. */
  791. bankExam() {
  792. this.$api.bankExam(this.id).then(res => {
  793. this.bankType = res.data.data.doType;
  794. if (this.bankType == 2) {
  795. this.needBack = true;
  796. }
  797. });
  798. },
  799. /**
  800. * 点击后退按钮
  801. */
  802. clickLeft() {
  803. //需要拍照没有拍直接返回
  804. if(this.needPhoto && !this.isTakePhoto) {
  805. this.isSubmit = true;
  806. uni.navigateBack({
  807. delta:1
  808. })
  809. return;
  810. }
  811. if (this.bankType == 1) {
  812. let ansCount = this.questionOverNum(); //已答题数
  813. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  814. //所有题目答完
  815. if (this.lastCount == 0) {
  816. // this.testOver = true;
  817. this.cgType = 7;
  818. //未答完
  819. } else {
  820. this.cgType = 8;
  821. // this.isLastCount = true;
  822. }
  823. this.showpopups = true;
  824. } else if (this.bankType == 2) {
  825. let ansCount = this.questionOverNum(); //已答题数
  826. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  827. //所有题目答完
  828. if (this.lastCount == 0) {
  829. this.testOver = true;
  830. //未答完
  831. } else {
  832. this.isLastCount = true;
  833. }
  834. }
  835. },
  836. /**
  837. * 返回上一页
  838. */
  839. backPages() {
  840. this.needBack = false;
  841. uni.navigateBack({
  842. delta: 1
  843. });
  844. },
  845. /**
  846. * 获取已经回答的题目数
  847. * hasSpecail (是否包含简答和案例)
  848. */
  849. questionOverNum(hasSpecail) {
  850. let count = 0;
  851. this.questionList.forEach(item => {
  852. if (item.type == 1 || item.type == 2 || item.type == 3) {
  853. if (item.ques) {
  854. count++;
  855. }
  856. } else if (item.type == 4) {
  857. //案例题
  858. if(hasSpecail) {
  859. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  860. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  861. if (item.ques[indexs]) {
  862. return true;
  863. } else {
  864. return false;
  865. }
  866. } else if (jsonItem.type == 5) {
  867. console.log(jsonItem, 111);
  868. if (item.ques[indexs] && (item.ques[indexs].text.length || item.ques[indexs].imageList.length)) {
  869. return true;
  870. } else {
  871. return false;
  872. }
  873. }
  874. });
  875. if (isOver) {
  876. count++;
  877. console.log(item, 444);
  878. }
  879. }
  880. } else if (item.type == 5) {
  881. //简答题
  882. if(hasSpecail) {
  883. if (item.ques && (item.ques.text.length || item.ques.imageList.length)) {
  884. count++;
  885. }
  886. }
  887. }
  888. });
  889. return count;
  890. },
  891. /**
  892. * 是否做完所有题目
  893. */
  894. isDoOver() {
  895. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  896. if(this.questionList.length == questionOverNum) { //全部做完弹窗
  897. this.cgType = 9;
  898. this.showpopups = true;
  899. }
  900. },
  901. /**
  902. * 暂不交卷
  903. */
  904. noSubmit() {
  905. //设为允许退出页面
  906. this.needBack = false;
  907. uni.navigateBack({
  908. delta: 1
  909. });
  910. },
  911. /**
  912. * 不离开
  913. */
  914. noLeave() {
  915. this.isLastCount = false;
  916. },
  917. /**
  918. * 立即离开并交卷
  919. */
  920. leaveNow() {
  921. this.isSubmit = true;
  922. uni.navigateBack({
  923. delta: 1
  924. });
  925. //需要拍照没有拍,返回不扣次数
  926. if(this.needPhoto && !this.isTakePhoto) {
  927. return;
  928. }
  929. let score = 0; //计算总分
  930. let reportStatus = 0;
  931. let number = 0;
  932. let doQuestionIds = []; //做过的题目id
  933. let doQuestionNum = 0; //做过的题目数量
  934. let passScore = 0;
  935. let allScore = 0; //总分
  936. this.questionList.forEach((item, index) => {
  937. passScore = item.passScore
  938. if (item.type == 1) {
  939. if (item.ques == item.ans) {
  940. item.scoreResult = item.score;
  941. score += item.score;
  942. number++;
  943. } else {
  944. item.scoreResult = 0;
  945. }
  946. if (item.ques) {
  947. doQuestionNum++;
  948. doQuestionIds.push(item.questionId)
  949. }
  950. allScore += item.score;
  951. } else if (item.type == 2) {
  952. let isRight =
  953. item.ques &&
  954. item.ques.every((quesItem, quesIndex) => {
  955. return item.ques[quesIndex] == item.ans[quesIndex];
  956. });
  957. if (isRight) { //全对
  958. item.scoreResult = item.score;
  959. score += item.score;
  960. number++;
  961. } else {
  962. let checkboxScore = item.score; //获取单题总分数
  963. item.ques && item.ques.forEach((ques,quesIndex) => {
  964. //选错一个全扣
  965. if(item.ques) {
  966. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  967. checkboxScore = 0;
  968. }
  969. } else {
  970. checkboxScore = 0;
  971. }
  972. })
  973. //没选错
  974. if(checkboxScore) {
  975. item.ans.forEach((ans,quesIndex) => {
  976. //漏选扣一部分
  977. if(item.ques) {
  978. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  979. checkboxScore = item.partScore;
  980. }
  981. } else {
  982. checkboxScore = 0;
  983. }
  984. })
  985. }
  986. if(checkboxScore <= 0) {
  987. item.scoreResult = 0;
  988. } else {
  989. item.scoreResult = checkboxScore;
  990. }
  991. score += checkboxScore;
  992. }
  993. if (item.ques && item.ques.length) {
  994. doQuestionNum++;
  995. doQuestionIds.push(item.questionId)
  996. }
  997. allScore += item.score;
  998. } else if (item.type == 3) {
  999. if (item.ques == item.ans) {
  1000. item.scoreResult = item.score;
  1001. score += item.score;
  1002. number++;
  1003. } else {
  1004. item.scoreResult = 0;
  1005. }
  1006. if (item.ques) {
  1007. doQuestionNum++;
  1008. doQuestionIds.push(item.questionId)
  1009. }
  1010. allScore += item.score;
  1011. } else {
  1012. allScore += item.score;
  1013. }
  1014. });
  1015. if(score >= passScore) {
  1016. reportStatus = 1
  1017. } else {
  1018. reportStatus = 0
  1019. }
  1020. this.$api
  1021. .bankRecordEdit({
  1022. chapterId:this.chapterId || 0,
  1023. moduleId:this.moduleId || 0,
  1024. examId: this.id,
  1025. goodsId: this.goodsId,
  1026. recordId:this.recordId,
  1027. courseId:this.courseId,
  1028. reportStatus:reportStatus,
  1029. rightQuestionNum: number,
  1030. doQuestionNum:doQuestionNum,
  1031. status: 1,
  1032. doQuestionIds:doQuestionIds.join(','),
  1033. gradeId:this.gradeId,
  1034. performance: score,
  1035. totalScore: allScore,
  1036. // examTime: parseInt(this.allTimes),
  1037. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1038. // historyExamJson: JSON.stringify(this.questionList)
  1039. })
  1040. .then(res => {});
  1041. },
  1042. /**
  1043. * 立即交卷
  1044. */
  1045. submitNow() {
  1046. this.showpopups = false;
  1047. this.needBack = false;
  1048. this.submit();
  1049. },
  1050. /**
  1051. * 离开页面统计回答正确题数
  1052. */
  1053. examRecordEdit() {
  1054. if (!this.isSubmit) {
  1055. let number = 0;
  1056. let score = 0;
  1057. let doQuestionNum = 0;
  1058. let reportStatus = 0;
  1059. this.questionList.forEach((item, index) => {
  1060. if (item.type == 1) {
  1061. if (item.ques == item.ans) {
  1062. score += item.score;
  1063. number++;
  1064. }
  1065. if (item.ques) {
  1066. doQuestionNum++;
  1067. }
  1068. } else if (item.type == 2) {
  1069. let isRight =
  1070. item.ques &&
  1071. item.ques.every((quesItem, quesIndex) => {
  1072. return item.ques[quesIndex] == item.ans[quesIndex];
  1073. });
  1074. if (isRight) {
  1075. score += item.score;
  1076. number++;
  1077. } else {
  1078. let checkboxScore = item.score; //获取单题总分数
  1079. item.ques.forEach((ques,quesIndex) => {
  1080. //选错一个全扣
  1081. if(item.ques) {
  1082. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1083. checkboxScore = 0;
  1084. }
  1085. } else {
  1086. checkboxScore = 0;
  1087. }
  1088. })
  1089. //没选错
  1090. if(checkboxScore) {
  1091. item.ans.forEach((ans,quesIndex) => {
  1092. //漏选扣一部分
  1093. if(item.ques) {
  1094. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1095. checkboxScore = item.partScore;
  1096. }
  1097. } else {
  1098. checkboxScore = 0;
  1099. }
  1100. })
  1101. }
  1102. if(checkboxScore <= 0) {
  1103. item.scoreResult = 0;
  1104. } else {
  1105. item.scoreResult = checkboxScore;
  1106. score += checkboxScore;
  1107. number++;
  1108. }
  1109. }
  1110. if (item.ques && item.ques.length) {
  1111. doQuestionNum++;
  1112. }
  1113. } else if (item.type == 3) {
  1114. if (item.ques == item.ans) {
  1115. score += item.score;
  1116. number++;
  1117. }
  1118. if (item.ques) {
  1119. doQuestionNum++;
  1120. }
  1121. } else if (item == 4) {
  1122. if (item.ques.length) {
  1123. doQuestionNum++;
  1124. }
  1125. } else if (item.type == 5) {
  1126. if (item.ques) {
  1127. doQuestionNum++;
  1128. }
  1129. }
  1130. });
  1131. if(score >= 60) {
  1132. reportStatus = 1
  1133. }
  1134. this.$api
  1135. .bankRecordEdit({
  1136. chapterId:this.chapterId || 0,
  1137. moduleId:this.moduleId || 0,
  1138. gradeId:this.gradeId,
  1139. examId: this.id,
  1140. courseId:this.courseId,
  1141. goodsId: this.goodsId,
  1142. recordId:this.recordId,
  1143. performance:score,
  1144. reportStatus:reportStatus,
  1145. status: 1,
  1146. // historyExamJson: JSON.stringify(this.questionList)
  1147. })
  1148. .then(res => {});
  1149. }
  1150. },
  1151. /**
  1152. * @param {Object} second倒计时过滤器
  1153. */
  1154. countdown(second) {
  1155. if (second) {
  1156. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1157. let m = parseInt((second / 60) % 60); // 计算分数
  1158. let s = parseInt(second % 60); // 计算当前秒数
  1159. if (h < 10) h = '0' + h;
  1160. if (m < 10) m = '0' + m;
  1161. if (s < 10) s = '0' + s;
  1162. return h + ':' + m + ':' + s;
  1163. } else {
  1164. return '';
  1165. }
  1166. },
  1167. /**
  1168. * 请求题目列表
  1169. */
  1170. goodsQuestionList() {
  1171. this.$api
  1172. .goodsQuestionList({
  1173. examId: this.id
  1174. })
  1175. .then(async res => {
  1176. if (!res.data.data.length) {
  1177. this.hideDialog();
  1178. uni.showModal({
  1179. showCancel: false,
  1180. content: '该试卷暂无题目',
  1181. success: function(k) {
  1182. if (k.confirm) {
  1183. uni.navigateBack();
  1184. }
  1185. }
  1186. });
  1187. return;
  1188. }
  1189. this.allTimes = res.data.data[0].answerTime * 60;
  1190. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  1191. res.data.data.forEach((item, index) => {
  1192. if (typeof item.jsonStr == 'string') {
  1193. item.jsonStr = JSON.parse(item.jsonStr);
  1194. if (item.type == 2) {
  1195. //多选
  1196. item.jsonStr.forEach(str => {
  1197. str.optionsId = '' + str.optionsId;
  1198. });
  1199. let arr = item.answerQuestion.split(',');
  1200. arr.forEach((a, i) => {
  1201. arr[i] = '' + a;
  1202. });
  1203. item.ans = arr;
  1204. return;
  1205. } else if (item.type == 5) {
  1206. //简答题
  1207. item.ansText = {
  1208. text: '',
  1209. imageList: []
  1210. };
  1211. item.ques = {
  1212. text: '',
  1213. imageList: []
  1214. }
  1215. } else if (item.type == 4) {
  1216. //案例题
  1217. console.log(item.jsonStr);
  1218. item.ques = [];
  1219. item.current = 0;
  1220. let ansArr = [];
  1221. item.jsonStr.forEach((json, index) => {
  1222. if (json.type == 1) {
  1223. ansArr[index] = json.answerQuestion;
  1224. } else if (json.type == 2) {
  1225. json.optionsList.forEach(str => {
  1226. str.optionsId = '' + str.optionsId;
  1227. });
  1228. let arr = json.answerQuestion.split(',');
  1229. arr.forEach((a, i) => {
  1230. arr[i] = '' + a;
  1231. });
  1232. ansArr[index] = arr;
  1233. } else if (json.type == 3) {
  1234. ansArr[index] = json.answerQuestion;
  1235. } else if (json.type == 5) {
  1236. ansArr[index] = {
  1237. text: '',
  1238. imageList: []
  1239. };
  1240. json.ansText = {
  1241. text: '',
  1242. imageList: []
  1243. };
  1244. }
  1245. });
  1246. item.ans = ansArr;
  1247. return;
  1248. }
  1249. item.ans = item.answerQuestion;
  1250. }
  1251. });
  1252. this.questionList = res.data.data;
  1253. this.lastCount = this.questionList.length;
  1254. await this.examRecord();
  1255. });
  1256. },
  1257. /**
  1258. * 记录总题数,获取recordId
  1259. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1260. */
  1261. examRecord(hasSpecial) {
  1262. return new Promise(resolve => {
  1263. let self = this
  1264. let questionList = 0;
  1265. if(!hasSpecial) {
  1266. this.questionList.forEach((item, index) => {
  1267. if(item.type == 1 || item.type == 2 || item.type == 3) {
  1268. questionList++;
  1269. }
  1270. })
  1271. } else {
  1272. questionList = this.questionList.length;
  1273. }
  1274. this.$api
  1275. .bankRecord({
  1276. chapterExamId: this.chapterId || 0,
  1277. moduleExamId: this.moduleId || 0,
  1278. examId: this.id,
  1279. goodsId: this.goodsId,
  1280. gradeId:this.gradeId,
  1281. totalQuestionNum: questionList
  1282. })
  1283. .then(res => {
  1284. this.recordId = res.data.data;
  1285. if(self.needPhoto){
  1286. self.photoPopup = true; //拍照
  1287. } else {
  1288. if(this.lastTime) {
  1289. this.timer = setInterval(() => {
  1290. if (this.lastTime <= 0) {
  1291. clearInterval(this.timer);
  1292. uni.showToast({
  1293. icon:'none',
  1294. mask:true,
  1295. title:'考试时间已到,系统将自动交卷',
  1296. duration:10000
  1297. })
  1298. this.submit();
  1299. return;
  1300. }
  1301. this.lastTime--;
  1302. }, 1000);
  1303. }
  1304. resolve()
  1305. }
  1306. });
  1307. })
  1308. },
  1309. /**
  1310. * @param {Object} e单选点击
  1311. */
  1312. radioSelect(optionsId, bindex) {
  1313. if (this.questionList[bindex].ques) return;
  1314. this.$set(this.questionList[bindex], 'ques', optionsId);
  1315. this.isDoOver()
  1316. },
  1317. /**
  1318. * @param {Object} e案例单选点击
  1319. */
  1320. radioSelectChild(optionsId, ansIndex, bindex) {
  1321. if (this.questionList[bindex].ques[ansIndex]) return;
  1322. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1323. this.isDoOver()
  1324. },
  1325. /**
  1326. * @param {Object} 多选点击
  1327. */
  1328. checkboxSelect(optionsId, bindex, index) {
  1329. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  1330. },
  1331. /**
  1332. * @param {Object} 案例多选点击
  1333. */
  1334. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1335. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  1336. },
  1337. isCheckboxChecked(arr) {
  1338. return arr.some(item => {
  1339. if (item.checked) {
  1340. return true;
  1341. }
  1342. });
  1343. },
  1344. /**
  1345. * @param {Object} 多选确认
  1346. */
  1347. checkboxSubmit(bindex) {
  1348. if (this.questionList[bindex].ques) return;
  1349. let arr = [];
  1350. this.questionList[bindex].jsonStr.forEach(item => {
  1351. if (item.checked) {
  1352. arr.push(item.optionsId);
  1353. }
  1354. });
  1355. if(!arr.length) {
  1356. uni.showToast({
  1357. title:'请选择答案',
  1358. icon:'none'
  1359. })
  1360. return;
  1361. }
  1362. this.$set(this.questionList[bindex], 'ques', arr);
  1363. this.isDoOver()
  1364. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  1365. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  1366. });
  1367. },
  1368. /**
  1369. * @param {Object} 案例多选确认
  1370. */
  1371. checkboxSubmitChild(bindex, ansIndex) {
  1372. if (this.questionList[bindex].ques[ansIndex]) return;
  1373. let arr = [];
  1374. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  1375. if (item.checked) {
  1376. arr.push(item.optionsId);
  1377. }
  1378. });
  1379. if(!arr.length) {
  1380. uni.showToast({
  1381. title:'请选择答案',
  1382. icon:'none'
  1383. })
  1384. return;
  1385. }
  1386. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1387. this.isDoOver()
  1388. },
  1389. /**
  1390. * @param {Object} index
  1391. * @param {Object} bindex
  1392. * 判断题
  1393. */
  1394. judgeSelect(index, bindex) {
  1395. if (this.questionList[bindex].ques) return;
  1396. this.$set(this.questionList[bindex], 'ques', index + '');
  1397. this.isDoOver()
  1398. },
  1399. /**
  1400. * @param {Object} ansindex
  1401. * @param {Object} childindex
  1402. * @param {Object} bindex
  1403. * 案例判断题
  1404. */
  1405. judgeSelectChild(ansindex, childindex, bindex) {
  1406. if (this.questionList[bindex].ques[ansindex]) return;
  1407. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  1408. this.isDoOver()
  1409. },
  1410. openFooterTab() {
  1411. this.show = true;
  1412. },
  1413. hideDialog() {
  1414. this.showDialog = false;
  1415. },
  1416. changeIndex(index) {
  1417. this.current = index;
  1418. },
  1419. swiperChange(e) {
  1420. this.current = e.detail.current;
  1421. },
  1422. pdsubmit() {
  1423. let ansCount = this.questionOverNum(true); //已答题数
  1424. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1425. //没有答完
  1426. if (this.lastCount !== 0) {
  1427. this.cgType = 6;
  1428. this.showpopups = true;
  1429. return;
  1430. }
  1431. if(this.bankType == 2) {
  1432. if(this.lastTime > 0) {
  1433. let lastTime = this.countdown(this.lastTime)
  1434. uni.showModal({
  1435. title:'提示',
  1436. content:`时间还剩余${lastTime},确定交卷吗?`,
  1437. confirmText:'交卷',
  1438. cancelText:'继续答题',
  1439. success:(res) => {
  1440. if(res.confirm) { //确定
  1441. this.submit();
  1442. } else { //取消
  1443. }
  1444. }
  1445. })
  1446. return;
  1447. }
  1448. }
  1449. this.submit();
  1450. },
  1451. /**
  1452. * 交卷
  1453. */
  1454. submit() {
  1455. let score = 0; //计算总分
  1456. let reportStatus = 0;
  1457. let number = 0; //做对的题目数量
  1458. let doQuestionNum = 0; //做过的题目数量
  1459. let allScore = 0; //总分
  1460. let passScore = 0;
  1461. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1462. let doQuestionIds = []; //做过的题目id
  1463. let rightQuestionIds = []; //做对的题目id
  1464. this.questionList.forEach((item, index) => {
  1465. passScore = item.passScore
  1466. if (item.type == 1) {
  1467. //正确
  1468. if (item.ques == item.ans) {
  1469. item.scoreResult = item.score;
  1470. score += item.score;
  1471. number++;
  1472. rightQuestionIds.push(item.questionId)
  1473. } else { //错误
  1474. item.scoreResult = 0;
  1475. doWrongQuestionIds.push(item.questionId)
  1476. }
  1477. allScore += item.score;
  1478. if (item.ques) {
  1479. doQuestionNum++;
  1480. doQuestionIds.push(item.questionId)
  1481. }
  1482. } else if (item.type == 2) {
  1483. let isRight =
  1484. item.ans &&
  1485. item.ans.every((quesItem, quesIndex) => {
  1486. if(item.ques) {
  1487. return item.ques[quesIndex] == item.ans[quesIndex];
  1488. } else {
  1489. return false;
  1490. }
  1491. });
  1492. if (isRight) {
  1493. score += item.score;
  1494. number++;
  1495. item.scoreResult = item.score;
  1496. rightQuestionIds.push(item.questionId)
  1497. } else {
  1498. let checkboxScore = item.score; //获取单题总分数
  1499. item.ques && item.ques.forEach((ques,quesIndex) => {
  1500. //选错一个全扣
  1501. if(item.ques) {
  1502. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1503. checkboxScore = 0;
  1504. }
  1505. } else {
  1506. checkboxScore = 0;
  1507. }
  1508. })
  1509. console.log(checkboxScore)
  1510. //没选错
  1511. if(checkboxScore) {
  1512. item.ans.forEach((ans,quesIndex) => {
  1513. //漏选扣一部分
  1514. if(item.ques) {
  1515. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1516. checkboxScore = item.partScore;
  1517. }
  1518. } else {
  1519. checkboxScore = 0;
  1520. }
  1521. })
  1522. }
  1523. if(checkboxScore <= 0) { //0分
  1524. item.scoreResult = 0;
  1525. doWrongQuestionIds.push(item.questionId)
  1526. } else { //部分分
  1527. number++;
  1528. item.scoreResult = checkboxScore;
  1529. score += checkboxScore;
  1530. rightQuestionIds.push(item.questionId)
  1531. }
  1532. }
  1533. allScore += item.score;
  1534. if (item.ques && item.ques.length) {
  1535. doQuestionNum++;
  1536. doQuestionIds.push(item.questionId)
  1537. }
  1538. } else if (item.type == 3) {
  1539. if (item.ques == item.ans) {
  1540. item.scoreResult = item.score;
  1541. score += item.score;
  1542. number++;
  1543. rightQuestionIds.push(item.questionId)
  1544. } else {
  1545. item.scoreResult = 0;
  1546. doWrongQuestionIds.push(item.questionId)
  1547. }
  1548. allScore += item.score;
  1549. if (item.ques) {
  1550. doQuestionNum++;
  1551. doQuestionIds.push(item.questionId)
  1552. }
  1553. } else if (item.type == 4) {
  1554. allScore += item.score;
  1555. if (item.ques && item.ques.length) {
  1556. doQuestionNum++;
  1557. doQuestionIds.push(item.questionId)
  1558. }
  1559. } else if (item.type == 5) {
  1560. allScore += item.score;
  1561. if (item.ques && (item.ques.imageList || item.ques.text)) {
  1562. doQuestionNum++;
  1563. doQuestionIds.push(item.questionId)
  1564. }
  1565. }
  1566. });
  1567. //大于分及格
  1568. if(score >= passScore) {
  1569. reportStatus = 1
  1570. } else {
  1571. reportStatus = 0
  1572. }
  1573. //交卷
  1574. this.$api
  1575. .bankRecordEdit({
  1576. moduleId:this.moduleId || 0,
  1577. chapterId:this.chapterId || 0,
  1578. gradeId:this.gradeId,
  1579. examId: this.id,
  1580. goodsId: this.goodsId,
  1581. reportStatus:reportStatus,
  1582. recordId: this.recordId,
  1583. courseId:this.courseId,
  1584. rightQuestionNum: number,
  1585. status: 1,
  1586. doQuestionIds:doQuestionIds.join(','),
  1587. // rightQuestionIds:rightQuestionIds.join(','),
  1588. // doQuestionNum: doQuestionNum,
  1589. performance: score,
  1590. totalScore: allScore,
  1591. // examTime: parseInt(this.allTimes),
  1592. // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1593. // historyExamJson: JSON.stringify(this.questionList)
  1594. })
  1595. .then(res => {
  1596. this.isSubmit = true;
  1597. if (res.data.code == 200) {
  1598. uni.showToast({
  1599. title: '交卷成功',
  1600. duration: 1000,
  1601. mask:true,
  1602. icon: 'none'
  1603. });
  1604. setTimeout(() => {
  1605. uni.redirectTo({
  1606. url: '/pages2/class/question_report?rightQuestionNum='+number+'&doWrongQuestionNum='+doWrongQuestionIds.length+'&score='+score+'&totalScore='+allScore+'&reportStatus='+reportStatus
  1607. });
  1608. }, 1000);
  1609. }
  1610. });
  1611. },
  1612. /**
  1613. * @param {Object} imgIndex
  1614. * @param {Object} bankIndex
  1615. * 删除简答图片
  1616. */
  1617. deleteImg(imgIndex, bankIndex) {
  1618. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1619. },
  1620. /**
  1621. * @param {Object} imgIndex
  1622. * @param {Object} bankIndex
  1623. * @param {Object} ansIndex
  1624. * 删除案例题简答图片
  1625. */
  1626. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1627. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1628. },
  1629. /**
  1630. * @param {Object} bankindex
  1631. * 选择上传图片
  1632. */
  1633. chooseImg(bankindex) {
  1634. if(this.questionList[bankindex] && this.questionList[bankindex].ansText && this.questionList[bankindex].ansText.imageList.length >= 4) {
  1635. uni.showToast({
  1636. icon:'none',
  1637. title:'最多选择4张'
  1638. })
  1639. return;
  1640. }
  1641. uni.chooseImage({
  1642. count: 1, //默认9
  1643. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1644. sourceType: ['album', 'camera'], //从相册选择
  1645. success: res => {
  1646. let self = this;
  1647. // console.log(JSON.stringify(res.tempFilePaths));
  1648. let img = res.tempFilePaths[0];
  1649. uni.getImageInfo({
  1650. src: img,
  1651. success: async res => {
  1652. let canvasWidth = res.width; //图片原始长宽
  1653. let canvasHeight = res.height;
  1654. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1655. uni.compressImage({
  1656. src: img,
  1657. quality: 75,
  1658. width: '50%',
  1659. height: '50%',
  1660. success: async rest => {
  1661. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1662. this.questionList[bankindex].ansText.imageList.push(dir);
  1663. }
  1664. });
  1665. } else {
  1666. const dir = await self.uploadFile(img, 0);
  1667. this.questionList[bankindex].ansText.imageList.push(dir);
  1668. }
  1669. }
  1670. });
  1671. }
  1672. });
  1673. },
  1674. /**
  1675. * @param {Object} bankindex
  1676. * @param {Object} ansindex
  1677. * 案例题选择上传图片
  1678. */
  1679. chooseImgChild(bankindex, ansindex) {
  1680. uni.chooseImage({
  1681. count: 1, //默认9
  1682. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1683. sourceType: ['album', 'camera'], //从相册选择
  1684. success: res => {
  1685. let self = this;
  1686. // console.log(JSON.stringify(res.tempFilePaths));
  1687. let img = res.tempFilePaths[0];
  1688. uni.getImageInfo({
  1689. src: img,
  1690. success: async res => {
  1691. let canvasWidth = res.width; //图片原始长宽
  1692. let canvasHeight = res.height;
  1693. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1694. uni.compressImage({
  1695. src: img,
  1696. quality: 75,
  1697. width: '50%',
  1698. height: '50%',
  1699. success: async rest => {
  1700. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1701. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1702. }
  1703. });
  1704. } else {
  1705. const dir = await self.uploadFile(img, 0);
  1706. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1707. }
  1708. }
  1709. });
  1710. }
  1711. });
  1712. },
  1713. uploadFile(options, int) {
  1714. var self = this;
  1715. return new Promise((resolve, reject) => {
  1716. var data = {
  1717. imageStatus: int
  1718. };
  1719. self.$api.aliyunpolicy(data).then(res => {
  1720. console.log(res.data, 6);
  1721. if (res.data.code != 200) {
  1722. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1723. return;
  1724. }
  1725. var ossToken = res.data.data.resultContent;
  1726. if (ossToken.host == null || ossToken.host == undefined) {
  1727. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1728. return;
  1729. }
  1730. uni.uploadFile({
  1731. url: ossToken.host,
  1732. name: 'file',
  1733. filePath: options,
  1734. fileType: 'image',
  1735. header: {
  1736. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1737. },
  1738. formData: {
  1739. key: ossToken.dir,
  1740. OSSAccessKeyId: ossToken.accessid,
  1741. policy: ossToken.policy,
  1742. Signature: ossToken.signature,
  1743. callback: ossToken.callback,
  1744. success_action_status: 200
  1745. },
  1746. success: result => {
  1747. if (result.statusCode === 200) {
  1748. self.ossAvatarUrl = ossToken.dir;
  1749. resolve(ossToken.dir);
  1750. } else {
  1751. uni.showToast({
  1752. title: '上传失败',
  1753. icon: 'none'
  1754. });
  1755. return;
  1756. }
  1757. },
  1758. fail: error => {
  1759. uni.showToast({
  1760. title: '上传接口报错' + error,
  1761. icon: 'none'
  1762. });
  1763. return;
  1764. }
  1765. });
  1766. });
  1767. });
  1768. },
  1769. /**
  1770. * @param {Object} type
  1771. * @param {Object} bankindex
  1772. * 简答题答案确认
  1773. */
  1774. submitAns(bankindex) {
  1775. console.log(this.questionList[bankindex]);
  1776. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1777. uni.showToast({
  1778. title: '请输入内容或上传图片',
  1779. duration: 2000,
  1780. icon: 'none'
  1781. });
  1782. return;
  1783. }
  1784. this.$set(this.questionList[bankindex], 'ques', {
  1785. imageList: this.questionList[bankindex].ansText.imageList,
  1786. text: this.questionList[bankindex].ansText.text
  1787. });
  1788. this.isDoOver()
  1789. },
  1790. /**
  1791. * @param {Object} bankindex
  1792. * @param {Object} ansindex
  1793. * 案例题简答答案确认
  1794. */
  1795. submitAnsChild(bankindex, ansindex) {
  1796. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1797. uni.showToast({
  1798. title: '请输入内容或上传图片',
  1799. duration: 2000,
  1800. icon: 'none'
  1801. });
  1802. return;
  1803. }
  1804. this.$set(this.questionList[bankindex].ques, ansindex, {
  1805. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1806. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text
  1807. });
  1808. this.isDoOver()
  1809. },
  1810. isRight(item, index) {
  1811. //单选
  1812. if (this.questionList[index].ques) {
  1813. if (item.type == 1) {
  1814. return this.questionList[index].ques == this.questionList[index].ans;
  1815. //多选
  1816. } else if (item.type == 2) {
  1817. //每一项都相等
  1818. return this.questionList[index].ques.every((item, i) => {
  1819. return item == this.questionList[index].ans[i];
  1820. });
  1821. //判断
  1822. } else if (item.type == 3) {
  1823. return this.questionList[index].ques == this.questionList[index].ans;
  1824. // } else if (item.type == 5) {
  1825. // if(this.questionList[index].ques.text){
  1826. // return true
  1827. // }else{
  1828. // return false
  1829. // }
  1830. } else {
  1831. return false;
  1832. }
  1833. } else {
  1834. return false;
  1835. }
  1836. },
  1837. right(bankIndex, ansIndex, option) {
  1838. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1839. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1840. return true;
  1841. } else {
  1842. return false;
  1843. }
  1844. } else {
  1845. return false;
  1846. }
  1847. },
  1848. wrong(bankIndex, ansIndex, option) {
  1849. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1850. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1851. return true;
  1852. } else {
  1853. return false;
  1854. }
  1855. } else {
  1856. return false;
  1857. }
  1858. },
  1859. isWrong(item, index) {
  1860. if (this.questionList[index].ques) {
  1861. //单选
  1862. if (item.type == 1) {
  1863. return this.questionList[index].ques != this.questionList[index].ans;
  1864. //多选
  1865. } else if (item.type == 2) {
  1866. //每一项都相等
  1867. return this.questionList[index].ques.some((item, index) => {
  1868. return item != this.questionList[index].ans;
  1869. });
  1870. //判断
  1871. } else if (item.type == 3) {
  1872. return this.questionList[index].ques != this.questionList[index].ans;
  1873. } else {
  1874. return false;
  1875. }
  1876. } else {
  1877. return false;
  1878. }
  1879. },
  1880. tabSelect(index, bankindex) {
  1881. this.$set(this.questionList[bankindex], 'current', index);
  1882. }
  1883. }
  1884. };
  1885. </script>
  1886. <style lang="scss" scoped>
  1887. .photoBox {
  1888. background-color: #FFFFFF;
  1889. border-radius: 32px 32px 0px 0px;
  1890. .photoTop {
  1891. height: 74upx;
  1892. display: flex;
  1893. align-items: center;
  1894. justify-content: space-between;
  1895. padding: 0upx 38upx;
  1896. .sqzz {
  1897. width: 28upx;
  1898. height: 28upx;
  1899. display: flex;
  1900. align-items: center;
  1901. justify-content: center;
  1902. }
  1903. .centersq {
  1904. color: #333;
  1905. font-size: 30upx;
  1906. font-weight: 500;
  1907. }
  1908. }
  1909. .photoCenter {
  1910. width: 750upx;
  1911. height: 979upx;
  1912. position: relative;
  1913. .custom {
  1914. width: 750upx;
  1915. height: 979upx;
  1916. position: absolute;
  1917. z-index: 1000;
  1918. top: 0;
  1919. left: 0;
  1920. image {
  1921. width: 100%;
  1922. height: 100%;
  1923. }
  1924. }
  1925. }
  1926. .btnResult {
  1927. height: 100rpx;
  1928. width: 100%;
  1929. background-color: #07c160;
  1930. text-align: center;
  1931. line-height: 100upx;
  1932. color: #fff;
  1933. font-size: 32upx;
  1934. font-weight: bold;
  1935. }
  1936. }
  1937. .navbar {
  1938. position: relative;
  1939. z-index: 20000;
  1940. }
  1941. .questionBank {
  1942. width:100%;
  1943. height:100vh;
  1944. display: flex;
  1945. flex-direction: column;
  1946. }
  1947. .swiper {
  1948. width: 100%;
  1949. flex:1;
  1950. }
  1951. .lisSty {
  1952. margin-bottom: 16rpx;
  1953. display: flex;
  1954. .flex_auto {
  1955. flex: 1;
  1956. }
  1957. }
  1958. .activeTI {
  1959. vertical-align: middle;
  1960. display: inline-block;
  1961. border: 1rpx solid #eee;
  1962. border-radius: 50rpx;
  1963. height: 48rpx;
  1964. line-height: 46rpx;
  1965. text-align: center;
  1966. width: 48rpx;
  1967. margin-right: 15rpx;
  1968. color: #666;
  1969. font-size: 30rpx;
  1970. &.right {
  1971. color: #fff;
  1972. background: #36C75A;
  1973. }
  1974. &.wrong {
  1975. color: #fff;
  1976. background: #FF3B30;
  1977. }
  1978. &.checked {
  1979. color: #fff;
  1980. background: #007AFF;
  1981. }
  1982. }
  1983. .submit_checkbox {
  1984. position:fixed;
  1985. left:0;
  1986. right:0;
  1987. bottom:120rpx;
  1988. margin: 20rpx auto;
  1989. width: 526rpx;
  1990. height: 80rpx;
  1991. background: rgba(0, 122, 255, 1);
  1992. color: #fff;
  1993. text-align: center;
  1994. line-height: 80rpx;
  1995. font-size: 30rpx;
  1996. border-radius: 40rpx;
  1997. &.disabled {
  1998. opacity: 0.6;
  1999. }
  2000. }
  2001. .titles {
  2002. overflow: hidden;
  2003. margin-bottom: 24rpx;
  2004. }
  2005. .titBox {
  2006. padding: 41rpx 25rpx 24rpx 25rpx;
  2007. }
  2008. .titBox_title {
  2009. padding: 21rpx;
  2010. }
  2011. .tabs {
  2012. margin: 10rpx;
  2013. display: flex;
  2014. .tab {
  2015. margin: 0 4rpx;
  2016. padding:10rpx 13rpx;
  2017. text-align: center;
  2018. color: #007aff;
  2019. font-size: 28rpx;
  2020. border-radius: 16rpx;
  2021. background:#fff;
  2022. &.current {
  2023. color: #fff;
  2024. background: #007aff;
  2025. }
  2026. }
  2027. }
  2028. .ans {
  2029. margin: 8rpx 8rpx 8rpx;
  2030. .ans_input {
  2031. border-radius: 16rpx;
  2032. background: #fff;
  2033. .top {
  2034. border-bottom: 1rpx solid #eeeeee;
  2035. padding: 16rpx;
  2036. display: flex;
  2037. align-items: center;
  2038. .icon {
  2039. margin-right: 20rpx;
  2040. width: 40rpx;
  2041. height: 38rpx;
  2042. }
  2043. .progress {
  2044. flex: 1;
  2045. }
  2046. .submit {
  2047. width: 168rpx;
  2048. height: 48rpx;
  2049. line-height: 48rpx;
  2050. text-align: center;
  2051. color: #fff;
  2052. font-size: 30rpx;
  2053. background: #007aff;
  2054. border-radius: 24rpx;
  2055. &.disabled {
  2056. opacity: 0.6;
  2057. }
  2058. }
  2059. }
  2060. .textarea {
  2061. textarea {
  2062. width: 100%;
  2063. height: 287rpx;
  2064. padding: 10rpx;
  2065. }
  2066. }
  2067. .imgs {
  2068. overflow: hidden;
  2069. display: flex;
  2070. width: 100%;
  2071. .img {
  2072. width: 104rpx;
  2073. height: 104rpx;
  2074. border-radius: 8rpx;
  2075. position: relative;
  2076. margin: 20rpx;
  2077. text {
  2078. position: absolute;
  2079. right: -15rpx;
  2080. top: -15rpx;
  2081. width: 30rpx;
  2082. height: 30rpx;
  2083. text-align: center;
  2084. line-height: 30rpx;
  2085. color: #fff;
  2086. background: #FF3B30;
  2087. border-radius: 50%;
  2088. }
  2089. image {
  2090. width: 100%;
  2091. height: 100%;
  2092. }
  2093. }
  2094. }
  2095. }
  2096. .ans_submit {
  2097. padding: 16rpx;
  2098. border-radius: 16rpx;
  2099. background: #fff;
  2100. .imgs {
  2101. overflow: hidden;
  2102. display: flex;
  2103. width: 100%;
  2104. .img {
  2105. width: 104rpx;
  2106. height: 104rpx;
  2107. border-radius: 8rpx;
  2108. position: relative;
  2109. margin: 20rpx;
  2110. image {
  2111. width: 100%;
  2112. height: 100%;
  2113. }
  2114. }
  2115. }
  2116. }
  2117. }
  2118. .leftLetters {
  2119. display: flex;
  2120. align-items: center;
  2121. width: 220rpx;
  2122. .btnType {
  2123. padding: 5rpx 10rpx;
  2124. border: 1rpx solid #007aff;
  2125. border-radius: 10rpx;
  2126. background-color: rgba(0, 122, 255, 0.1);
  2127. font-size: 28rpx;
  2128. color: #007aff;
  2129. margin-right: 15rpx;
  2130. }
  2131. }
  2132. .firstLetter {
  2133. display: flex;
  2134. justify-content: space-between;
  2135. align-items: center;
  2136. margin-bottom: 30rpx;
  2137. }
  2138. .popupView {
  2139. height: 100%;
  2140. padding-bottom: 100rpx;
  2141. .popupTops {
  2142. height: 77rpx;
  2143. border-bottom: 1rpx solid #eee;
  2144. text-align: center;
  2145. line-height: 77rpx;
  2146. font-size: 24rpx;
  2147. color: #999;
  2148. position: relative;
  2149. .topIcon {
  2150. position: absolute;
  2151. top: 10rpx;
  2152. left: 50%;
  2153. transform: translateX(-50%);
  2154. width: 80rpx;
  2155. height: 8rpx;
  2156. background-color: #999;
  2157. border-radius: 4rpx;
  2158. }
  2159. }
  2160. .popupContent {
  2161. }
  2162. }
  2163. .pageContent {
  2164. position: relative;
  2165. background-color: #eaeef1;
  2166. height: 100%;
  2167. padding-top: 8rpx;
  2168. padding-bottom: 100rpx;
  2169. overflow-y: scroll;
  2170. }
  2171. .pad_8 {
  2172. background-color: #fff;
  2173. margin: 0rpx 8rpx 8rpx;
  2174. border-radius: 16rpx;
  2175. &.no-margin {
  2176. margin-top:-16rpx;
  2177. border-radius: 0 0 16rpx 16rpx;
  2178. }
  2179. }
  2180. .answer {
  2181. height: 80rpx;
  2182. line-height: 80rpx;
  2183. padding: 0rpx 24rpx;
  2184. display: flex;
  2185. align-items: center;
  2186. justify-content: space-between;
  2187. color: #666;
  2188. font-size: 30rpx;
  2189. }
  2190. .footer_btn {
  2191. background-color: #fff;
  2192. z-index: 10078;
  2193. position: fixed;
  2194. bottom: 0rpx;
  2195. display: flex;
  2196. align-items: center;
  2197. justify-content: space-between;
  2198. width: 100%;
  2199. height: 98rpx;
  2200. padding: 0rpx 38rpx;
  2201. border-top: 1rpx solid #eee;
  2202. .flex_center {
  2203. flex:1;
  2204. display: flex;
  2205. justify-content: center;
  2206. align-items: center;
  2207. flex-direction: column;
  2208. margin:0 200rpx;
  2209. font-size: 24rpx;
  2210. color: #999999;
  2211. .up-icon {
  2212. margin-bottom:18rpx;
  2213. width:100%;
  2214. display: flex;
  2215. justify-content: center;
  2216. image {
  2217. width:58rpx;
  2218. height:21rpx;
  2219. }
  2220. }
  2221. }
  2222. .collect {
  2223. visibility: hidden;
  2224. width:100rpx;
  2225. &.show {
  2226. visibility: visible;
  2227. }
  2228. >view {
  2229. display: flex;
  2230. flex-direction: column;
  2231. align-items: center;
  2232. justify-content: center;
  2233. image {
  2234. width:32rpx;
  2235. height:32rpx;
  2236. margin-bottom:6rpx;
  2237. }
  2238. view {
  2239. font-size: 24rpx;
  2240. color: #999999;
  2241. }
  2242. }
  2243. }
  2244. }
  2245. .boxSty {
  2246. padding: 44rpx 41rpx 0rpx;
  2247. }
  2248. .liListSty {
  2249. border: 1rpx solid #eeeeee;
  2250. width: 88rpx;
  2251. height: 88rpx;
  2252. border-radius: 32rpx;
  2253. text-align: center;
  2254. line-height: 88rpx;
  2255. color: #333;
  2256. font-size: 32rpx;
  2257. float: left;
  2258. margin: 20rpx 23rpx;
  2259. &.isRight {
  2260. border: 1rpx solid #eeeeee;
  2261. color: #fff;
  2262. background: #36C75A;
  2263. }
  2264. &.isWrong {
  2265. border: 1rpx solid #eeeeee;
  2266. color: #fff;
  2267. background: #FF3B30;
  2268. }
  2269. }
  2270. .answerInfos {
  2271. padding: 25rpx 25rpx 25rpx 23rpx;
  2272. }
  2273. .answerTitle {
  2274. margin-bottom: 28rpx;
  2275. color: #666;
  2276. font-size: 30rpx;
  2277. }
  2278. .answerContent {
  2279. font-size: 30rpx;
  2280. color: #666;
  2281. }
  2282. .textChild {
  2283. display: inline-block;
  2284. vertical-align: middle;
  2285. }
  2286. .dialog {
  2287. position: fixed;
  2288. left: 0;
  2289. top: 0;
  2290. width: 100%;
  2291. height: 100%;
  2292. background-color: rgba(0, 0, 0, 0.8);
  2293. display: flex;
  2294. flex-direction: column;
  2295. align-items: center;
  2296. justify-content: center;
  2297. z-index: 20000;
  2298. .text {
  2299. font-size: 32rpx;
  2300. color: #ffffff;
  2301. text-align: center;
  2302. }
  2303. .btn {
  2304. width: 242rpx;
  2305. height: 82rpx;
  2306. border: 2rpx solid #ffffff;
  2307. border-radius: 16rpx;
  2308. text-align: center;
  2309. line-height: 82rpx;
  2310. margin: 41rpx auto;
  2311. color: #fff;
  2312. font-size: 32rpx;
  2313. }
  2314. }
  2315. .dialog-arrow {
  2316. padding-top:124rpx;
  2317. position: fixed;
  2318. left: 0;
  2319. top: 0;
  2320. width: 100%;
  2321. height: 100%;
  2322. background-color: rgba(0, 0, 0, 0.8);
  2323. z-index: 20000;
  2324. .pointer {
  2325. margin-left:87rpx;
  2326. display: block;
  2327. width:95rpx;
  2328. height:98rpx;
  2329. }
  2330. .text {
  2331. padding-left:177rpx;
  2332. font-size: 32rpx;
  2333. color: #ffffff;
  2334. }
  2335. .btn {
  2336. width: 242rpx;
  2337. height: 82rpx;
  2338. border: 2rpx solid #ffffff;
  2339. border-radius: 16rpx;
  2340. text-align: center;
  2341. line-height: 82rpx;
  2342. margin: 500rpx auto 0;
  2343. color: #fff;
  2344. font-size: 32rpx;
  2345. }
  2346. }
  2347. .dialog_wrap {
  2348. position: fixed;
  2349. left: 0;
  2350. top: 0;
  2351. width: 100%;
  2352. height: 100%;
  2353. z-index: 9999999999;
  2354. .bg {
  2355. background: rgba(0, 0, 0, 0.3);
  2356. position: absolute;
  2357. left: 0;
  2358. top: 0;
  2359. width: 100%;
  2360. height: 100%;
  2361. }
  2362. .dialog {
  2363. position: absolute;
  2364. left: 50%;
  2365. top: 50%;
  2366. transform: translate3D(-50%, -50%, 0);
  2367. width: 640rpx;
  2368. height: 439rpx;
  2369. background: #ffffff;
  2370. border-radius: 24rpx;
  2371. .title {
  2372. font-size: 30rpx;
  2373. font-weight: bold;
  2374. color: #333333;
  2375. line-height: 48rpx;
  2376. text-align: center;
  2377. margin-top: 40rpx;
  2378. }
  2379. .content {
  2380. margin: 35rpx 35rpx 0;
  2381. font-size: 30rpx;
  2382. color: #666666;
  2383. line-height: 48rpx;
  2384. }
  2385. .btns {
  2386. margin-top: 35rpx;
  2387. display: flex;
  2388. align-items: center;
  2389. justify-content: center;
  2390. .btn {
  2391. width: 200rpx;
  2392. height: 80rpx;
  2393. line-height: 80rpx;
  2394. text-align: center;
  2395. background: #f5f5f5;
  2396. border-radius: 40rpx;
  2397. font-size: 30rpx;
  2398. color: rgba(0, 122, 255, 1);
  2399. background: #f5f5f5;
  2400. margin: 0 20rpx;
  2401. &.active {
  2402. color: #f5f5f5;
  2403. background: rgba(0, 122, 255, 1);
  2404. }
  2405. }
  2406. }
  2407. }
  2408. }
  2409. .popboxs {
  2410. width: 100%;
  2411. height: 100%;
  2412. display: flex;
  2413. flex-direction: column;
  2414. align-items: center;
  2415. }
  2416. .classTops {
  2417. flex-shrink: 0;
  2418. padding: 39rpx 0rpx 4rpx;
  2419. font-weight: bold;
  2420. color: #333;
  2421. font-size: 30rpx;
  2422. }
  2423. .textStys {
  2424. width: 100%;
  2425. flex: 1;
  2426. padding: 36rpx;
  2427. }
  2428. .classFootsty {
  2429. flex-shrink: 0;
  2430. display: flex;
  2431. align-items: center;
  2432. justify-content: center;
  2433. padding: 10rpx 0rpx 40rpx;
  2434. .btnsty {
  2435. width: 200rpx;
  2436. height: 80rpx;
  2437. border-radius: 40rpx;
  2438. font-weight: bold;
  2439. font-size: 30rpx;
  2440. text-align: center;
  2441. line-height: 80rpx;
  2442. }
  2443. .btns1 {
  2444. background-color: #f5f5f5;
  2445. color: #007aff;
  2446. }
  2447. .btns2 {
  2448. margin-left: 40rpx;
  2449. background-color: #007aff;
  2450. color: #ffffff;
  2451. }
  2452. }
  2453. </style>