questionBank.vue 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561
  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"><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. })
  1016. .then(res => {
  1017. this.recordId = res.data.data;
  1018. //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
  1019. if(this.bankType == 1) {
  1020. this.examRecordEdit();
  1021. }
  1022. });
  1023. },
  1024. /**
  1025. * @param {Object} second倒计时过滤器
  1026. */
  1027. countdown(second) {
  1028. if (second) {
  1029. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1030. let m = parseInt((second / 60) % 60); // 计算分数
  1031. let s = parseInt(second % 60); // 计算当前秒数
  1032. if (h < 10) h = '0' + h;
  1033. if (m < 10) m = '0' + m;
  1034. if (s < 10) s = '0' + s;
  1035. return h + ':' + m + ':' + s;
  1036. } else {
  1037. return '';
  1038. }
  1039. },
  1040. /**
  1041. * 请求题目列表
  1042. */
  1043. goodsQuestionList() {
  1044. this.$api
  1045. .goodsQuestionList({
  1046. examId: this.id
  1047. })
  1048. .then(res => {
  1049. if (!res.data.data.length) {
  1050. this.hideDialog();
  1051. uni.showModal({
  1052. showCancel: false,
  1053. content: '该试卷暂无题目',
  1054. success: function(k) {
  1055. if (k.confirm) {
  1056. uni.navigateBack();
  1057. }
  1058. }
  1059. });
  1060. return;
  1061. }
  1062. this.allTimes = res.data.data[0].answerTime * 60;
  1063. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  1064. //考试时间到了自动交卷
  1065. if (this.lastTime) {
  1066. this.timer = setInterval(() => {
  1067. if (this.lastTime <= 0) {
  1068. clearInterval(this.timer);
  1069. uni.showToast({
  1070. icon:'none',
  1071. mask:true,
  1072. title:'考试时间已到,系统将自动交卷',
  1073. duration:10000
  1074. })
  1075. this.submit();
  1076. return;
  1077. }
  1078. this.lastTime--;
  1079. }, 1000);
  1080. } else {
  1081. }
  1082. res.data.data.forEach((item, index) => {
  1083. if (typeof item.jsonStr == 'string') {
  1084. item.jsonStr = JSON.parse(item.jsonStr);
  1085. console.log(index)
  1086. if (item.type == 2) {
  1087. //多选
  1088. item.jsonStr.forEach(str => {
  1089. str.optionsId = '' + str.optionsId;
  1090. });
  1091. let arr = item.answerQuestion.split(',');
  1092. arr.forEach((a, i) => {
  1093. arr[i] = '' + a;
  1094. });
  1095. item.ans = arr;
  1096. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1097. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1098. return;
  1099. } else if (item.type == 5) {
  1100. //简答题
  1101. item.ansText = {
  1102. text: '',
  1103. imageList: []
  1104. };
  1105. item.ques = {
  1106. text: '',
  1107. imageList: []
  1108. }
  1109. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1110. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1111. } else if (item.type == 4) {
  1112. //案例题
  1113. console.log(item.jsonStr);
  1114. item.ques = [];
  1115. item.current = 0;
  1116. let ansArr = [];
  1117. item.jsonStr.forEach((json, index) => {
  1118. if (json.type == 1) {
  1119. ansArr[index] = json.answerQuestion;
  1120. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1121. } else if (json.type == 2) {
  1122. json.optionsList.forEach(str => {
  1123. str.optionsId = '' + str.optionsId;
  1124. });
  1125. let arr = json.answerQuestion.split(',');
  1126. arr.forEach((a, i) => {
  1127. arr[i] = '' + a;
  1128. });
  1129. ansArr[index] = arr;
  1130. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1131. } else if (json.type == 3) {
  1132. ansArr[index] = json.answerQuestion;
  1133. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1134. } else if (json.type == 5) {
  1135. ansArr[index] = {
  1136. text: json.answerQuestion,
  1137. imageList: []
  1138. };
  1139. json.ansText = {
  1140. text: '',
  1141. imageList: []
  1142. };
  1143. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1144. }
  1145. });
  1146. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1147. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1148. item.ans = ansArr;
  1149. return;
  1150. }
  1151. console.log(item.analysisContent)
  1152. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  1153. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  1154. item.ans = item.answerQuestion;
  1155. }
  1156. });
  1157. this.questionList = res.data.data;
  1158. console.log(this.questionList)
  1159. this.lastCount = this.questionList.length;
  1160. this.examRecord();
  1161. this.getCollectInfo(this.current);
  1162. });
  1163. },
  1164. /**
  1165. * @param {Object} e单选点击
  1166. */
  1167. radioSelect(optionsId, bindex) {
  1168. if (this.questionList[bindex].ques) return;
  1169. this.$set(this.questionList[bindex], 'ques', optionsId);
  1170. this.isDoOver();
  1171. // 回答错误
  1172. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1173. this.$api
  1174. .examWrongRecord({
  1175. examId: this.id,
  1176. goodsId: this.goodsId,
  1177. moduleExamId:this.moduleId || 0,
  1178. chapterExamId:this.chapterId || 0,
  1179. questionIds: [this.questionList[bindex].questionId],
  1180. recordId: this.recordId
  1181. })
  1182. .then(res => {});
  1183. } else {
  1184. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1185. // if(question) {
  1186. // this.$api.wrongRecordDelete({
  1187. // "examId": +this.id,
  1188. // "goodsId": +this.goodsId,
  1189. // "questionId": this.questionList[bindex].questionId,
  1190. // }).then(res => {
  1191. // })
  1192. // }
  1193. }
  1194. },
  1195. /**
  1196. * @param {Object} e案例单选点击
  1197. */
  1198. radioSelectChild(optionsId, ansIndex, bindex) {
  1199. if (this.questionList[bindex].ques[ansIndex]) return;
  1200. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1201. this.isDoOver();
  1202. },
  1203. /**
  1204. * @param {Object} 多选点击
  1205. */
  1206. checkboxSelect(optionsId, bindex, index) {
  1207. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  1208. },
  1209. /**
  1210. * @param {Object} 案例多选点击
  1211. */
  1212. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1213. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  1214. },
  1215. isCheckboxChecked(arr) {
  1216. return arr.some(item => {
  1217. if (item.checked) {
  1218. return true;
  1219. }
  1220. });
  1221. },
  1222. /**
  1223. * @param {Object} 多选确认
  1224. */
  1225. checkboxSubmit(bindex) {
  1226. if (this.questionList[bindex].ques) return;
  1227. let arr = [];
  1228. this.questionList[bindex].jsonStr.forEach(item => {
  1229. if (item.checked) {
  1230. arr.push(item.optionsId);
  1231. }
  1232. });
  1233. if(!arr.length) {
  1234. uni.showToast({
  1235. title:'请选择答案',
  1236. icon:'none'
  1237. })
  1238. return;
  1239. }
  1240. this.$set(this.questionList[bindex], 'ques', arr);
  1241. this.isDoOver();
  1242. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  1243. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  1244. });
  1245. // 回答错误
  1246. if (isWrong) {
  1247. this.$api
  1248. .examWrongRecord({
  1249. examId: this.id,
  1250. goodsId: this.goodsId,
  1251. moduleExamId:this.moduleId || 0,
  1252. chapterExamId:this.chapterId || 0,
  1253. questionIds: [this.questionList[bindex].questionId],
  1254. recordId: this.recordId
  1255. })
  1256. .then(res => {});
  1257. } else {
  1258. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1259. // if(question) {
  1260. // this.$api.wrongRecordDelete({
  1261. // "examId": +this.id,
  1262. // "goodsId": +this.goodsId,
  1263. // "questionId": this.questionList[bindex].questionId,
  1264. // }).then(res => {
  1265. // })
  1266. // }
  1267. }
  1268. },
  1269. /**
  1270. * @param {Object} 案例多选确认
  1271. */
  1272. checkboxSubmitChild(bindex, ansIndex) {
  1273. if (this.questionList[bindex].ques[ansIndex]) return;
  1274. let arr = [];
  1275. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  1276. if (item.checked) {
  1277. arr.push(item.optionsId);
  1278. }
  1279. });
  1280. if(!arr.length) {
  1281. uni.showToast({
  1282. title:'请选择答案',
  1283. icon:'none'
  1284. })
  1285. return;
  1286. }
  1287. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1288. this.isDoOver();
  1289. },
  1290. /**
  1291. * @param {Object} index
  1292. * @param {Object} bindex
  1293. * 判断题
  1294. */
  1295. judgeSelect(index, bindex) {
  1296. if (this.questionList[bindex].ques) return;
  1297. this.$set(this.questionList[bindex], 'ques', index + '');
  1298. this.isDoOver();
  1299. // 回答错误
  1300. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  1301. this.$api
  1302. .examWrongRecord({
  1303. examId: this.id,
  1304. goodsId: this.goodsId,
  1305. moduleExamId:this.moduleId || 0,
  1306. chapterExamId:this.chapterId || 0,
  1307. questionIds:[this.questionList[bindex].questionId],
  1308. recordId: this.recordId
  1309. })
  1310. .then(res => {});
  1311. } else {
  1312. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  1313. // if(question) {
  1314. // this.$api.wrongRecordDelete({
  1315. // "examId": +this.id,
  1316. // "goodsId": +this.goodsId,
  1317. // "questionId": this.questionList[bindex].questionId,
  1318. // }).then(res => {
  1319. // })
  1320. // }
  1321. }
  1322. },
  1323. /**
  1324. * @param {Object} ansindex
  1325. * @param {Object} childindex
  1326. * @param {Object} bindex
  1327. * 案例判断题
  1328. */
  1329. judgeSelectChild(ansindex, childindex, bindex) {
  1330. if (this.questionList[bindex].ques[ansindex]) return;
  1331. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  1332. this.isDoOver();
  1333. },
  1334. openFooterTab() {
  1335. this.show = true;
  1336. },
  1337. changeIndex(index) {
  1338. this.current = index;
  1339. },
  1340. swiperChange(e) {
  1341. this.current = e.detail.current;
  1342. this.getCollectInfo(this.current);
  1343. },
  1344. /**
  1345. * @param {Object} current
  1346. * 获取收藏信息
  1347. */
  1348. getCollectInfo(current) {
  1349. this.$api
  1350. .getCollectInfo({
  1351. examId: this.id,
  1352. questionId: this.questionList[current].questionId,
  1353. goodsId: this.goodsId
  1354. })
  1355. .then(res => {
  1356. if (res.data.code == 500) {
  1357. this.$set(this.collectList, current, false);
  1358. } else if (res.data.code == 200) {
  1359. this.$set(this.collectList, current, res.data.data);
  1360. }
  1361. });
  1362. },
  1363. pdsubmit() {
  1364. // if (this.bankType == 1) {
  1365. let ansCount = this.questionOverNum(true); //已答题数
  1366. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1367. //没有答完
  1368. if (this.lastCount !== 0) {
  1369. this.cgType = 6;
  1370. this.showpopups = true;
  1371. return;
  1372. }
  1373. // }
  1374. if(this.bankType == 2) {
  1375. if(this.lastTime > 0) {
  1376. let lastTime = this.countdown(this.lastTime)
  1377. uni.showModal({
  1378. title:'提示',
  1379. content:`时间还剩余${lastTime},确定交卷吗?`,
  1380. confirmText:'交卷',
  1381. cancelText:'继续答题',
  1382. success:(res) => {
  1383. if(res.confirm) { //确定
  1384. this.submit();
  1385. } else { //取消
  1386. }
  1387. }
  1388. })
  1389. return;
  1390. }
  1391. }
  1392. this.submit();
  1393. },
  1394. /**
  1395. * 交卷
  1396. */
  1397. submit() {
  1398. let score = 0; //计算总分
  1399. let reportStatus = 0;
  1400. let number = 0; //做对的题目数量
  1401. let doQuestionNum = 0; //做过的题目数量
  1402. let allScore = 0; //总分
  1403. let passScore = 0;
  1404. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  1405. let doQuestionIds = []; //做过的题目id
  1406. let rightQuestionIds = []; //做对的题目id
  1407. this.questionList.forEach((item, index) => {
  1408. passScore = item.passScore
  1409. if (item.type == 1) {
  1410. //正确
  1411. if (item.ques == item.ans) {
  1412. item.scoreResult = item.score;
  1413. score += item.score;
  1414. number++;
  1415. rightQuestionIds.push(item.questionId)
  1416. } else { //错误
  1417. item.scoreResult = 0;
  1418. doWrongQuestionIds.push(item.questionId)
  1419. }
  1420. allScore += item.score;
  1421. if (item.ques) {
  1422. doQuestionNum++;
  1423. doQuestionIds.push(item.questionId)
  1424. }
  1425. } else if (item.type == 2) {
  1426. let isRight =
  1427. item.ans &&
  1428. item.ans.every((quesItem, quesIndex) => {
  1429. if(item.ques) {
  1430. return item.ques[quesIndex] == item.ans[quesIndex];
  1431. } else {
  1432. return false;
  1433. }
  1434. });
  1435. if (isRight) {
  1436. score += item.score;
  1437. number++;
  1438. item.scoreResult = item.score;
  1439. rightQuestionIds.push(item.questionId)
  1440. } else {
  1441. let checkboxScore = item.score; //获取单题总分数
  1442. item.ques && item.ques.forEach((ques,quesIndex) => {
  1443. //选错一个全扣
  1444. if(item.ques) {
  1445. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  1446. checkboxScore = 0;
  1447. }
  1448. } else {
  1449. checkboxScore = 0;
  1450. }
  1451. })
  1452. console.log(checkboxScore)
  1453. //没选错
  1454. if(checkboxScore) {
  1455. item.ans.forEach((ans,quesIndex) => {
  1456. //漏选扣一部分
  1457. if(item.ques) {
  1458. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1459. checkboxScore = item.partScore;
  1460. }
  1461. } else {
  1462. checkboxScore = 0;
  1463. }
  1464. })
  1465. }
  1466. if(checkboxScore <= 0) { //0分
  1467. item.scoreResult = 0;
  1468. doWrongQuestionIds.push(item.questionId)
  1469. } else { //部分分
  1470. // number++;
  1471. doWrongQuestionIds.push(item.questionId)
  1472. item.scoreResult = checkboxScore;
  1473. score += checkboxScore;
  1474. // rightQuestionIds.push(item.questionId)
  1475. }
  1476. }
  1477. allScore += item.score;
  1478. if (item.ques && item.ques.length) {
  1479. doQuestionNum++;
  1480. doQuestionIds.push(item.questionId)
  1481. }
  1482. } else if (item.type == 3) {
  1483. if (item.ques == item.ans) {
  1484. item.scoreResult = item.score;
  1485. score += item.score;
  1486. number++;
  1487. rightQuestionIds.push(item.questionId)
  1488. } else {
  1489. item.scoreResult = 0;
  1490. doWrongQuestionIds.push(item.questionId)
  1491. }
  1492. allScore += item.score;
  1493. if (item.ques) {
  1494. doQuestionNum++;
  1495. doQuestionIds.push(item.questionId)
  1496. }
  1497. } else if (item.type == 4) {
  1498. allScore += item.score;
  1499. if (item.ques && item.ques.length) {
  1500. doQuestionNum++;
  1501. doQuestionIds.push(item.questionId)
  1502. }
  1503. } else if (item.type == 5) {
  1504. allScore += item.score;
  1505. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1506. doQuestionNum++;
  1507. doQuestionIds.push(item.questionId)
  1508. }
  1509. }
  1510. });
  1511. //大于及格
  1512. if(score >= passScore) {
  1513. reportStatus = 1
  1514. } else {
  1515. reportStatus = 0
  1516. }
  1517. //交卷
  1518. this.$api
  1519. .examRecordEdit({
  1520. examId: this.id,
  1521. goodsId: this.goodsId,
  1522. reportStatus:reportStatus,
  1523. recordId: this.recordId,
  1524. rightQuestionNum: number,
  1525. status: 1,
  1526. moduleExamId:this.moduleId || 0,
  1527. chapterExamId:this.chapterId || 0,
  1528. doQuestionIds:doQuestionIds.join(','),
  1529. rightQuestionIds:rightQuestionIds.join(','),
  1530. doQuestionNum: doQuestionNum,
  1531. performance: score,
  1532. totalScore: allScore,
  1533. examTime: parseInt(this.allTimes),
  1534. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1535. historyExamJson: JSON.stringify(this.questionList)
  1536. })
  1537. .then(res => {
  1538. this.isSubmit = true;
  1539. if (res.data.code == 200) {
  1540. uni.showToast({
  1541. title: '交卷成功',
  1542. duration: 1000,
  1543. icon: 'none'
  1544. });
  1545. setTimeout(() => {
  1546. uni.redirectTo({
  1547. url: '/pages2/bank/question_report?goodsId='+this.goodsId+'&chapterId='+this.chapterId+'&moduleId='+this.moduleId+'&examId='+this.id+'&id=' + this.recordId
  1548. });
  1549. }, 1000);
  1550. }
  1551. });
  1552. //错题集id提交(客观题)
  1553. this.$api.examWrongRecord({
  1554. examId: this.id,
  1555. goodsId: this.goodsId,
  1556. questionIds: doWrongQuestionIds,
  1557. recordId: this.recordId
  1558. }).then(res => {
  1559. });
  1560. },
  1561. /**
  1562. * @param {Object} state
  1563. * @param {Object} index
  1564. * 收藏
  1565. */
  1566. collect(state, index) {
  1567. if (!state) {
  1568. this.$api
  1569. .collectQuestion({
  1570. examId: this.id,
  1571. questionId: this.questionList[index].questionId,
  1572. goodsId: this.goodsId || ''
  1573. })
  1574. .then(res => {
  1575. if (res.data.code == 200) {
  1576. this.$set(this.collectList, index, true);
  1577. uni.showToast({
  1578. title: '收藏成功',
  1579. duration: 2000,
  1580. icon: 'none'
  1581. });
  1582. this.getCollectInfo(index)
  1583. }
  1584. });
  1585. } else {
  1586. this.$api.deleteCollectQuestion(this.collectList[index].collectQuestionId).then(res => {
  1587. if (res.data.code == 200) {
  1588. this.$set(this.collectList, index, false);
  1589. uni.showToast({
  1590. title: '取消收藏成功',
  1591. duration: 2000,
  1592. icon: 'none'
  1593. });
  1594. }
  1595. });
  1596. }
  1597. return;
  1598. },
  1599. /**
  1600. * @param {Object} imgIndex
  1601. * @param {Object} bankIndex
  1602. * 删除简答图片
  1603. */
  1604. deleteImg(imgIndex, bankIndex) {
  1605. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1606. },
  1607. /**
  1608. * @param {Object} imgIndex
  1609. * @param {Object} bankIndex
  1610. * @param {Object} ansIndex
  1611. * 删除案例题简答图片
  1612. */
  1613. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1614. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1615. },
  1616. /**
  1617. * @param {Object} bankindex
  1618. * 选择上传图片
  1619. */
  1620. chooseImg(bankindex) {
  1621. if(this.questionList[bankindex] && this.questionList[bankindex].ansText && this.questionList[bankindex].ansText.imageList.length >= 4) {
  1622. uni.showToast({
  1623. icon:'none',
  1624. title:'最多选择4张'
  1625. })
  1626. return;
  1627. }
  1628. uni.chooseImage({
  1629. count: 1, //默认9
  1630. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1631. sourceType: ['album', 'camera'], //从相册选择
  1632. success: res => {
  1633. let self = this;
  1634. // console.log(JSON.stringify(res.tempFilePaths));
  1635. let img = res.tempFilePaths[0];
  1636. uni.getImageInfo({
  1637. src: img,
  1638. success: async res => {
  1639. let canvasWidth = res.width; //图片原始长宽
  1640. let canvasHeight = res.height;
  1641. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1642. uni.compressImage({
  1643. src: img,
  1644. quality: 75,
  1645. width: '50%',
  1646. height: '50%',
  1647. success: async rest => {
  1648. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1649. this.questionList[bankindex].ansText.imageList.push(dir);
  1650. }
  1651. });
  1652. } else {
  1653. const dir = await self.uploadFile(img, 0);
  1654. this.questionList[bankindex].ansText.imageList.push(dir);
  1655. }
  1656. }
  1657. });
  1658. }
  1659. });
  1660. },
  1661. /**
  1662. * @param {Object} bankindex
  1663. * @param {Object} ansindex
  1664. * 案例题选择上传图片
  1665. */
  1666. chooseImgChild(bankindex, ansindex) {
  1667. if(this.questionList[bankindex].jsonStr[ansindex] && this.questionList[bankindex].jsonStr[ansindex].ansText && this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length >= 4) {
  1668. uni.showToast({
  1669. icon:'none',
  1670. title:'最多选择4张'
  1671. })
  1672. return;
  1673. }
  1674. uni.chooseImage({
  1675. count: 1, //默认9
  1676. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1677. sourceType: ['album', 'camera'], //从相册选择
  1678. success: res => {
  1679. let self = this;
  1680. // console.log(JSON.stringify(res.tempFilePaths));
  1681. let img = res.tempFilePaths[0];
  1682. uni.getImageInfo({
  1683. src: img,
  1684. success: async res => {
  1685. let canvasWidth = res.width; //图片原始长宽
  1686. let canvasHeight = res.height;
  1687. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1688. uni.compressImage({
  1689. src: img,
  1690. quality: 75,
  1691. width: '50%',
  1692. height: '50%',
  1693. success: async rest => {
  1694. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1695. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1696. }
  1697. });
  1698. } else {
  1699. const dir = await self.uploadFile(img, 0);
  1700. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1701. }
  1702. }
  1703. });
  1704. }
  1705. });
  1706. },
  1707. uploadFile(options, int) {
  1708. var self = this;
  1709. return new Promise((resolve, reject) => {
  1710. var data = {
  1711. imageStatus: int
  1712. };
  1713. self.$api.aliyunpolicy(data).then(res => {
  1714. console.log(res.data, 6);
  1715. if (res.data.code != 200) {
  1716. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1717. return;
  1718. }
  1719. var ossToken = res.data.data.resultContent;
  1720. if (ossToken.host == null || ossToken.host == undefined) {
  1721. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1722. return;
  1723. }
  1724. uni.uploadFile({
  1725. url: ossToken.host,
  1726. name: 'file',
  1727. filePath: options,
  1728. fileType: 'image',
  1729. header: {
  1730. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1731. },
  1732. formData: {
  1733. key: ossToken.dir,
  1734. OSSAccessKeyId: ossToken.accessid,
  1735. policy: ossToken.policy,
  1736. Signature: ossToken.signature,
  1737. callback: ossToken.callback,
  1738. success_action_status: 200
  1739. },
  1740. success: result => {
  1741. if (result.statusCode === 200) {
  1742. resolve(ossToken.dir);
  1743. } else {
  1744. uni.showToast({
  1745. title: '上传失败',
  1746. icon: 'none'
  1747. });
  1748. return;
  1749. }
  1750. },
  1751. fail: error => {
  1752. uni.showToast({
  1753. title: '上传接口报错' + error,
  1754. icon: 'none'
  1755. });
  1756. return;
  1757. }
  1758. });
  1759. });
  1760. });
  1761. },
  1762. /**
  1763. * @param {Object} type
  1764. * @param {Object} bankindex
  1765. * 简答题答案确认
  1766. */
  1767. submitAns(bankindex) {
  1768. console.log(this.questionList[bankindex]);
  1769. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1770. uni.showToast({
  1771. title: '请输入内容或上传图片',
  1772. duration: 2000,
  1773. icon: 'none'
  1774. });
  1775. return;
  1776. }
  1777. this.$set(this.questionList[bankindex], 'ques', {
  1778. imageList: this.questionList[bankindex].ansText.imageList || [],
  1779. text: this.questionList[bankindex].ansText.text || ''
  1780. });
  1781. this.isDoOver()
  1782. },
  1783. /**
  1784. * @param {Object} bankindex
  1785. * @param {Object} ansindex
  1786. * 案例题简答答案确认
  1787. */
  1788. submitAnsChild(bankindex, ansindex) {
  1789. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1790. uni.showToast({
  1791. title: '请输入内容或上传图片',
  1792. duration: 2000,
  1793. icon: 'none'
  1794. });
  1795. return;
  1796. }
  1797. this.$set(this.questionList[bankindex].ques, ansindex, {
  1798. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList || [],
  1799. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || ''
  1800. });
  1801. this.isDoOver()
  1802. },
  1803. isRight(item, index) {
  1804. //单选
  1805. if (this.questionList[index].ques) {
  1806. if (item.type == 1) {
  1807. return this.questionList[index].ques == this.questionList[index].ans;
  1808. //多选
  1809. } else if (item.type == 2) {
  1810. //每一项都相等
  1811. return this.questionList[index].ans.every((item, i) => {
  1812. return item == this.questionList[index].ques[i];
  1813. });
  1814. //判断
  1815. } else if (item.type == 3) {
  1816. return this.questionList[index].ques == this.questionList[index].ans;
  1817. // } else if (item.type == 5) {
  1818. // if(this.questionList[index].ques.text){
  1819. // return true
  1820. // }else{
  1821. // return false
  1822. // }
  1823. } else {
  1824. return false;
  1825. }
  1826. } else {
  1827. return false;
  1828. }
  1829. },
  1830. right(bankIndex, ansIndex, option) {
  1831. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1832. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1833. return true;
  1834. } else {
  1835. return false;
  1836. }
  1837. } else {
  1838. return false;
  1839. }
  1840. },
  1841. wrong(bankIndex, ansIndex, option) {
  1842. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1843. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1844. return true;
  1845. } else {
  1846. return false;
  1847. }
  1848. } else {
  1849. return false;
  1850. }
  1851. },
  1852. isWrong(item, index) {
  1853. if (this.questionList[index].ques) {
  1854. //单选
  1855. if (item.type == 1) {
  1856. return this.questionList[index].ques != this.questionList[index].ans;
  1857. //多选
  1858. } else if (item.type == 2) {
  1859. //每一项都相等
  1860. return this.questionList[index].ans.some((item, i) => {
  1861. return item != this.questionList[index].ques[i];
  1862. });
  1863. //判断
  1864. } else if (item.type == 3) {
  1865. return this.questionList[index].ques != this.questionList[index].ans;
  1866. } else {
  1867. return false;
  1868. }
  1869. } else {
  1870. return false;
  1871. }
  1872. },
  1873. tabSelect(index, bankindex) {
  1874. this.$set(this.questionList[bankindex], 'current', index);
  1875. }
  1876. }
  1877. };
  1878. </script>
  1879. <style lang="scss" scoped>
  1880. .questionBank {
  1881. width:100%;
  1882. height:100vh;
  1883. display: flex;
  1884. flex-direction: column;
  1885. }
  1886. .swiper {
  1887. width: 100%;
  1888. flex:1;
  1889. }
  1890. .lisSty {
  1891. margin-bottom: 16rpx;
  1892. display: flex;
  1893. align-items: center;
  1894. .flex_auto {
  1895. flex: 1;
  1896. }
  1897. }
  1898. .activeTI {
  1899. vertical-align: middle;
  1900. display: inline-block;
  1901. border: 1rpx solid #eee;
  1902. border-radius: 50rpx;
  1903. height: 48rpx;
  1904. line-height: 46rpx;
  1905. text-align: center;
  1906. width: 48rpx;
  1907. margin-right: 15rpx;
  1908. color: #666;
  1909. font-size: 30rpx;
  1910. &.right {
  1911. color: #fff;
  1912. background: #36C75A;
  1913. }
  1914. &.wrong {
  1915. color: #fff;
  1916. background: #FF3B30;
  1917. }
  1918. &.checked {
  1919. color: #fff;
  1920. background: #007AFF;
  1921. }
  1922. }
  1923. .submit_checkbox {
  1924. position:fixed;
  1925. left:0;
  1926. right:0;
  1927. bottom:120rpx;
  1928. margin: 20rpx auto;
  1929. width: 526rpx;
  1930. height: 80rpx;
  1931. background: rgba(0, 122, 255, 1);
  1932. color: #fff;
  1933. text-align: center;
  1934. line-height: 80rpx;
  1935. font-size: 30rpx;
  1936. border-radius: 40rpx;
  1937. &.disabled {
  1938. opacity: 0.6;
  1939. }
  1940. }
  1941. .titles {
  1942. overflow: hidden;
  1943. margin-bottom: 24rpx;
  1944. }
  1945. .titBox {
  1946. padding: 41rpx 25rpx 24rpx 25rpx;
  1947. }
  1948. .titBox_title {
  1949. padding: 21rpx;
  1950. }
  1951. .tabs {
  1952. margin: 10rpx;
  1953. display: flex;
  1954. .tab {
  1955. margin: 0 4rpx;
  1956. padding:10rpx 13rpx;
  1957. text-align: center;
  1958. color: #007aff;
  1959. font-size: 28rpx;
  1960. border-radius: 16rpx;
  1961. background:#fff;
  1962. &.current {
  1963. color: #fff;
  1964. background: #007aff;
  1965. }
  1966. }
  1967. }
  1968. .ans {
  1969. margin: 8rpx 8rpx 8rpx;
  1970. .ans_input {
  1971. border-radius: 16rpx;
  1972. background: #fff;
  1973. .top {
  1974. border-bottom: 1rpx solid #eeeeee;
  1975. padding: 16rpx;
  1976. display: flex;
  1977. align-items: center;
  1978. .icon {
  1979. margin-right: 20rpx;
  1980. width: 40rpx;
  1981. height: 38rpx;
  1982. }
  1983. .progress {
  1984. flex: 1;
  1985. }
  1986. .submit {
  1987. width: 168rpx;
  1988. height: 48rpx;
  1989. line-height: 48rpx;
  1990. text-align: center;
  1991. color: #fff;
  1992. font-size: 30rpx;
  1993. background: #007aff;
  1994. border-radius: 24rpx;
  1995. &.disabled {
  1996. opacity: 0.6;
  1997. }
  1998. }
  1999. }
  2000. .textarea {
  2001. textarea {
  2002. width: 100%;
  2003. height: 287rpx;
  2004. padding: 10rpx;
  2005. }
  2006. }
  2007. .imgs {
  2008. overflow: hidden;
  2009. display: flex;
  2010. width: 100%;
  2011. .img {
  2012. width: 104rpx;
  2013. height: 104rpx;
  2014. border-radius: 8rpx;
  2015. position: relative;
  2016. margin: 20rpx;
  2017. text {
  2018. position: absolute;
  2019. right: -15rpx;
  2020. top: -15rpx;
  2021. width: 30rpx;
  2022. height: 30rpx;
  2023. text-align: center;
  2024. line-height: 30rpx;
  2025. color: #fff;
  2026. background: #FF3B30;
  2027. border-radius: 50%;
  2028. }
  2029. image {
  2030. width: 100%;
  2031. height: 100%;
  2032. }
  2033. }
  2034. }
  2035. }
  2036. .ans_submit {
  2037. padding: 16rpx;
  2038. border-radius: 16rpx;
  2039. background: #fff;
  2040. .imgs {
  2041. overflow: hidden;
  2042. display: flex;
  2043. width: 100%;
  2044. .img {
  2045. width: 104rpx;
  2046. height: 104rpx;
  2047. border-radius: 8rpx;
  2048. position: relative;
  2049. margin: 20rpx;
  2050. image {
  2051. width: 100%;
  2052. height: 100%;
  2053. }
  2054. }
  2055. }
  2056. }
  2057. }
  2058. .leftLetters {
  2059. display: flex;
  2060. align-items: center;
  2061. width: 220rpx;
  2062. .btnType {
  2063. padding: 5rpx 10rpx;
  2064. border: 1rpx solid #007aff;
  2065. border-radius: 10rpx;
  2066. background-color: rgba(0, 122, 255, 0.1);
  2067. font-size: 28rpx;
  2068. color: #007aff;
  2069. margin-right: 15rpx;
  2070. }
  2071. }
  2072. .firstLetter {
  2073. display: flex;
  2074. justify-content: space-between;
  2075. align-items: center;
  2076. margin-bottom: 30rpx;
  2077. }
  2078. .popupView {
  2079. height: 100%;
  2080. padding-bottom: 100rpx;
  2081. .popupTops {
  2082. height: 77rpx;
  2083. border-bottom: 1rpx solid #eee;
  2084. text-align: center;
  2085. line-height: 77rpx;
  2086. font-size: 24rpx;
  2087. color: #999;
  2088. position: relative;
  2089. .topIcon {
  2090. position: absolute;
  2091. top: 10rpx;
  2092. left: 50%;
  2093. transform: translateX(-50%);
  2094. width: 80rpx;
  2095. height: 8rpx;
  2096. background-color: #999;
  2097. border-radius: 4rpx;
  2098. }
  2099. }
  2100. .popupContent {
  2101. }
  2102. }
  2103. .pageContent {
  2104. position: relative;
  2105. background-color: #eaeef1;
  2106. height: 100%;
  2107. padding-top: 8rpx;
  2108. padding-bottom: 100rpx;
  2109. overflow-y: scroll;
  2110. }
  2111. .pad_8 {
  2112. background-color: #fff;
  2113. margin: 0rpx 8rpx 8rpx;
  2114. border-radius: 16rpx;
  2115. &.no-margin {
  2116. margin-top:-16rpx;
  2117. border-radius: 0 0 16rpx 16rpx;
  2118. }
  2119. }
  2120. .answer {
  2121. height: 80rpx;
  2122. line-height: 80rpx;
  2123. padding: 0rpx 24rpx;
  2124. display: flex;
  2125. align-items: center;
  2126. justify-content: space-between;
  2127. color: #666;
  2128. font-size: 30rpx;
  2129. }
  2130. .footer_btn {
  2131. background-color: #fff;
  2132. z-index: 10078;
  2133. position: fixed;
  2134. bottom: 0rpx;
  2135. display: flex;
  2136. align-items: center;
  2137. justify-content: space-between;
  2138. width: 100%;
  2139. height: 98rpx;
  2140. padding: 0rpx 38rpx;
  2141. border-top: 1rpx solid #eee;
  2142. .flex_center {
  2143. flex:1;
  2144. display: flex;
  2145. justify-content: center;
  2146. align-items: center;
  2147. flex-direction: column;
  2148. margin:0 200rpx;
  2149. font-size: 24rpx;
  2150. color: #999999;
  2151. .up-icon {
  2152. margin-bottom:18rpx;
  2153. width:100%;
  2154. display: flex;
  2155. justify-content: center;
  2156. image {
  2157. width:58rpx;
  2158. height:21rpx;
  2159. }
  2160. }
  2161. }
  2162. .collect {
  2163. visibility: hidden;
  2164. width:100rpx;
  2165. &.show {
  2166. visibility: visible;
  2167. }
  2168. >view {
  2169. display: flex;
  2170. flex-direction: column;
  2171. align-items: center;
  2172. justify-content: center;
  2173. image {
  2174. width:32rpx;
  2175. height:32rpx;
  2176. margin-bottom:6rpx;
  2177. }
  2178. view {
  2179. font-size: 24rpx;
  2180. color: #999999;
  2181. }
  2182. }
  2183. }
  2184. }
  2185. .boxSty {
  2186. padding: 44rpx 41rpx 0rpx;
  2187. }
  2188. .liListSty {
  2189. border: 1rpx solid #eeeeee;
  2190. width: 88rpx;
  2191. height: 88rpx;
  2192. border-radius: 32rpx;
  2193. text-align: center;
  2194. line-height: 88rpx;
  2195. color: #333;
  2196. font-size: 32rpx;
  2197. float: left;
  2198. margin: 20rpx 23rpx;
  2199. &.isRight {
  2200. border: 1rpx solid #eeeeee;
  2201. color: #fff;
  2202. background: #36C75A;
  2203. }
  2204. &.isWrong {
  2205. border: 1rpx solid #eeeeee;
  2206. color: #fff;
  2207. background: #FF3B30;
  2208. }
  2209. }
  2210. .answerInfos {
  2211. padding: 25rpx 25rpx 25rpx 23rpx;
  2212. }
  2213. .answerTitle {
  2214. margin-bottom: 28rpx;
  2215. color: #666;
  2216. font-size: 30rpx;
  2217. }
  2218. .answerContent {
  2219. font-size: 30rpx;
  2220. color: #666;
  2221. }
  2222. .textChild {
  2223. display: inline-block;
  2224. vertical-align: middle;
  2225. }
  2226. .dialog {
  2227. position: fixed;
  2228. left: 0;
  2229. top: 0;
  2230. width: 100%;
  2231. height: 100%;
  2232. background-color: rgba(0, 0, 0, 0.8);
  2233. display: flex;
  2234. flex-direction: column;
  2235. align-items: center;
  2236. justify-content: center;
  2237. z-index: 20000;
  2238. .pointer {
  2239. width:338rpx;
  2240. height:240rpx;
  2241. }
  2242. .text {
  2243. font-size: 32rpx;
  2244. color: #ffffff;
  2245. text-align: center;
  2246. }
  2247. .btn {
  2248. width: 242rpx;
  2249. height: 82rpx;
  2250. border: 2rpx solid #ffffff;
  2251. border-radius: 16rpx;
  2252. text-align: center;
  2253. line-height: 82rpx;
  2254. margin: 41rpx auto;
  2255. color: #fff;
  2256. font-size: 32rpx;
  2257. }
  2258. }
  2259. .dialog-arrow {
  2260. padding-top:124rpx;
  2261. position: fixed;
  2262. left: 0;
  2263. top: 0;
  2264. width: 100%;
  2265. height: 100%;
  2266. background-color: rgba(0, 0, 0, 0.8);
  2267. z-index: 20000;
  2268. .pointer {
  2269. margin-left:87rpx;
  2270. display: block;
  2271. width:95rpx;
  2272. height:98rpx;
  2273. }
  2274. .text {
  2275. padding-left:177rpx;
  2276. font-size: 32rpx;
  2277. color: #ffffff;
  2278. }
  2279. .btn {
  2280. width: 242rpx;
  2281. height: 82rpx;
  2282. border: 2rpx solid #ffffff;
  2283. border-radius: 16rpx;
  2284. text-align: center;
  2285. line-height: 82rpx;
  2286. margin: 500rpx auto 0;
  2287. color: #fff;
  2288. font-size: 32rpx;
  2289. }
  2290. }
  2291. .dialog_wrap {
  2292. position: fixed;
  2293. left: 0;
  2294. top: 0;
  2295. width: 100%;
  2296. height: 100%;
  2297. z-index: 9999999999;
  2298. .bg {
  2299. background: rgba(0, 0, 0, 0.3);
  2300. position: absolute;
  2301. left: 0;
  2302. top: 0;
  2303. width: 100%;
  2304. height: 100%;
  2305. }
  2306. .dialog {
  2307. position: absolute;
  2308. left: 50%;
  2309. top: 50%;
  2310. transform: translate3D(-50%, -50%, 0);
  2311. width: 640rpx;
  2312. height: 439rpx;
  2313. background: #ffffff;
  2314. border-radius: 24rpx;
  2315. .title {
  2316. font-size: 30rpx;
  2317. font-weight: bold;
  2318. color: #333333;
  2319. line-height: 48rpx;
  2320. text-align: center;
  2321. margin-top: 40rpx;
  2322. }
  2323. .content {
  2324. margin: 35rpx 35rpx 0;
  2325. font-size: 30rpx;
  2326. color: #666666;
  2327. line-height: 48rpx;
  2328. }
  2329. .btns {
  2330. margin-top: 35rpx;
  2331. display: flex;
  2332. align-items: center;
  2333. justify-content: center;
  2334. .btn {
  2335. width: 200rpx;
  2336. height: 80rpx;
  2337. line-height: 80rpx;
  2338. text-align: center;
  2339. background: #f5f5f5;
  2340. border-radius: 40rpx;
  2341. font-size: 30rpx;
  2342. color: rgba(0, 122, 255, 1);
  2343. background: #f5f5f5;
  2344. margin: 0 20rpx;
  2345. &.active {
  2346. color: #f5f5f5;
  2347. background: rgba(0, 122, 255, 1);
  2348. }
  2349. }
  2350. }
  2351. }
  2352. }
  2353. .popboxs {
  2354. width: 100%;
  2355. height: 100%;
  2356. display: flex;
  2357. flex-direction: column;
  2358. align-items: center;
  2359. }
  2360. .classTops {
  2361. flex-shrink: 0;
  2362. padding: 39rpx 0rpx 4rpx;
  2363. font-weight: bold;
  2364. color: #333;
  2365. font-size: 30rpx;
  2366. }
  2367. .textStys {
  2368. width: 100%;
  2369. flex: 1;
  2370. padding: 36rpx;
  2371. }
  2372. .classFootsty {
  2373. flex-shrink: 0;
  2374. display: flex;
  2375. align-items: center;
  2376. justify-content: center;
  2377. padding: 10rpx 0rpx 40rpx;
  2378. .btnsty {
  2379. width: 200rpx;
  2380. height: 80rpx;
  2381. border-radius: 40rpx;
  2382. font-weight: bold;
  2383. font-size: 30rpx;
  2384. text-align: center;
  2385. line-height: 80rpx;
  2386. }
  2387. .btns1 {
  2388. background-color: #f5f5f5;
  2389. color: #007aff;
  2390. }
  2391. .btns2 {
  2392. margin-left: 40rpx;
  2393. background-color: #007aff;
  2394. color: #ffffff;
  2395. }
  2396. }
  2397. </style>