questionBank.vue 69 KB

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