questionBank.vue 67 KB

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