questionBank.vue 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820
  1. <template>
  2. <view id="questionBank">
  3. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" :statusBar="true" title="试卷"></uni-nav-bar>
  4. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  5. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  6. <view class="pageContent">
  7. <view class="pad_8 titBox">
  8. <view class="firstLetter">
  9. <view class="leftLetters">
  10. <view class="btnType">
  11. <text v-if="bank.type == 1">单选</text>
  12. <text v-if="bank.type == 2">多选</text>
  13. <text v-if="bank.type == 3">判断</text>
  14. <text v-if="bank.type == 4">案例题</text>
  15. <text v-if="bank.type == 5">简答题</text>
  16. </view>
  17. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  18. </view>
  19. <view style="color: #666;font-size: 28rpx;">{{ countdown(lastTime) }}</view>
  20. <view class="leftLetters"></view>
  21. </view>
  22. <view class="titles"><rich-text :nodes="bank.content"></rich-text></view>
  23. </view>
  24. <view class="pad_8 titBox">
  25. <template v-if="bank.type == 1">
  26. <view v-if="!bank.ques">
  27. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId, bankIndex)">
  28. <view class="activeTI">{{ ast[index] }}</view>
  29. <view class="flex_auto">{{ item.content }}</view>
  30. </view>
  31. </view>
  32. <view v-if="bank.ques">
  33. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  34. <text
  35. :class="{ right: item.optionsId == bank.ques || item.optionsId == bank.ans, wrong: item.optionsId == bank.ques && bank.ques != bank.ans }"
  36. class="activeTI"
  37. >
  38. {{ ast[index] }}
  39. </text>
  40. <view class="flex_auto">{{ item.content }}</view>
  41. </view>
  42. </view>
  43. <view 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 v-if="!bank.ques">
  56. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId, bankIndex, index)">
  57. <view :class="{ checked: item.checked }" class="activeTI">{{ ast[index] }}</view>
  58. <view class="flex_auto">{{ item.content }}</view>
  59. </view>
  60. </view>
  61. <view v-if="!bank.ques" class="submit_checkbox" @click="checkboxSubmit(bankIndex)">确认答案</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">
  77. <view class="pad_8 answer">
  78. <view>
  79. 正确答案:
  80. <text v-for="ansItem in bank.ans">{{ ast[ansItem - 1] }}</text>
  81. </view>
  82. <view>
  83. 我的答案:
  84. <text v-for="quesItem in bank.ques">{{ ast[quesItem - 1] }}</text>
  85. </view>
  86. </view>
  87. <view class="pad_8 answerInfos">
  88. <view class="answerTitle">答案解析</view>
  89. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  90. </view>
  91. </view>
  92. </template>
  93. <template v-if="bank.type == 3">
  94. <view v-if="!bank.ques">
  95. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index, bankIndex)">
  96. <view class="activeTI">{{ ast[index] }}</view>
  97. {{ item }}
  98. </view>
  99. </view>
  100. <view v-if="bank.ques">
  101. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  102. <text :class="{ right: index == bank.ques || index == bank.ans, wrong: index == bank.ques && bank.ques != bank.ans }" class="activeTI">
  103. {{ ast[index] }}
  104. </text>
  105. {{ item }}
  106. </view>
  107. </view>
  108. <view v-if="bank.ques">
  109. <view class="pad_8 answer">
  110. <view>正确答案:{{ ast[bank.ans] }}</view>
  111. <view>我的答案:{{ ast[bank.ques] }}</view>
  112. </view>
  113. <view class="pad_8 answerInfos">
  114. <view class="answerTitle">答案解析</view>
  115. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  116. </view>
  117. </view>
  118. </template>
  119. <!-- 简答题 -->
  120. <template v-if="bank.type == 5">
  121. <view class="ans">
  122. <view class="ans_input" v-if="!bank.ques">
  123. <view class="top flex">
  124. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/08-10_032.jpg" mode=""></image>
  125. <view class="progress">0/4</view>
  126. <view class="submit" @click="submitAns(bankIndex)">确认答案</view>
  127. </view>
  128. <view class="textarea"><textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea></view>
  129. <view class="imgs">
  130. <view class="img" v-for="(img, imgIndex) in bank.ansText.imageList">
  131. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  132. <image :src="$method.splitImgHost(img, true)"></image>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="ans_submit answerInfos" v-if="bank.ques">
  137. <view class="answerTitle">答案我的</view>
  138. {{ bank.ques.text }}
  139. <view class="imgs"><image class="img" v-for="ques in bank.ques.imageList" :src="$method.splitImgHost(ques, true)"></image></view>
  140. </view>
  141. </view>
  142. <view v-if="bank.ques">
  143. <view class="pad_8 answerInfos">
  144. <view class="answerTitle">答案解析</view>
  145. <view class="answerContent"><rich-text :nodes="bank.analysisContent"></rich-text></view>
  146. </view>
  147. </view>
  148. </template>
  149. <!-- 案例题 -->
  150. <template v-if="bank.type == 4">
  151. <view class="tabs">
  152. <view
  153. class="tab"
  154. :class="{ current: tabIndex == bank.current }"
  155. :key="tabIndex"
  156. v-for="(tab, tabIndex) in bank.jsonStr"
  157. @click="tabSelect(tabIndex, bankIndex)"
  158. >
  159. 问题{{ tabIndex }}
  160. </view>
  161. </view>
  162. <view v-for="(ansItem, ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  163. <view class="titles"><rich-text :nodes="ansItem.content"></rich-text></view>
  164. <template v-if="ansItem.type == 1">
  165. <view v-if="!bank.ques[ansIndex]">
  166. <view
  167. v-for="(option, childIndex) in ansItem.optionsList"
  168. :key="childIndex"
  169. class="lisSty"
  170. @click="radioSelectChild(option.optionsId, ansIndex, bankIndex)"
  171. >
  172. <view class="activeTI">{{ ast[childIndex] }}</view>
  173. <rich-text class="textChild" :nodes="option.content"></rich-text>
  174. </view>
  175. </view>
  176. <view v-if="bank.ques[ansIndex]">
  177. <view v-for="(option, childIndex) in ansItem.optionsList" :key="index" class="lisSty">
  178. <text
  179. :class="{
  180. right: option.optionsId == bank.ques[ansIndex] || option.optionsId == bank.ans[ansIndex],
  181. wrong: option.optionsId == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  182. }"
  183. class="activeTI"
  184. >
  185. {{ ast[childIndex] }}
  186. </text>
  187. <rich-text :nodes="option.content"></rich-text>
  188. </view>
  189. </view>
  190. <view v-if="bank.ques[ansIndex]">
  191. <view class="pad_8 answer">
  192. <view>正确答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  193. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  194. </view>
  195. <view class="pad_8 answerInfos">
  196. <view class="answerTitle">答案解析</view>
  197. <view class="answerContent"><rich-text :nodes="option.analysisContent"></rich-text></view>
  198. </view>
  199. </view>
  200. </template>
  201. <template v-if="ansItem.type == 2">
  202. <view v-if="!bank.ques[ansIndex]">
  203. <view
  204. v-for="(option, childindex) in ansItem.optionsList"
  205. :key="childindex"
  206. class="lisSty"
  207. @click="checkboxSelectChild(bankIndex, ansIndex, childindex)"
  208. >
  209. <view :class="{ checked: option.checked }" class="activeTI">{{ ast[childindex] }}</view>
  210. <rich-text :nodes="option.content"></rich-text>
  211. </view>
  212. </view>
  213. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" @click="checkboxSubmitChild(bankIndex, ansIndex)">确认答案</view>
  214. <view v-if="bank.ques && bank.ques[ansIndex]">
  215. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  216. <text :class="{ right: right(bankIndex, ansIndex, option), wrong: wrong(bankIndex, ansIndex, option) }" class="activeTI">
  217. {{ ast[childindex] }}
  218. </text>
  219. <rich-text :nodes="option.content"></rich-text>
  220. </view>
  221. </view>
  222. <view v-if="bank.ques[ansIndex]">
  223. <view class="pad_8 answer">
  224. <view>
  225. 正确答案:
  226. <text v-for="ansItem1 in bank.ans[ansIndex]">{{ ast[ansItem1 - 1] }}</text>
  227. </view>
  228. <view>
  229. 我的答案:
  230. <text v-for="quesItem in bank.ques[ansIndex]">{{ ast[quesItem - 1] }}</text>
  231. </view>
  232. </view>
  233. <view class="pad_8 answerInfos">
  234. <view class="answerTitle">答案解析</view>
  235. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  236. </view>
  237. </view>
  238. </template>
  239. <template v-if="ansItem.type == 3">
  240. <view v-if="!bank.ques[ansIndex]">
  241. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex, childindex, bankIndex)">
  242. <view class="activeTI">{{ ast[childindex] }}</view>
  243. {{ option }}
  244. </view>
  245. </view>
  246. <view v-if="bank.ques[ansIndex]">
  247. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  248. <text
  249. :class="{
  250. right: childindex == bank.ques[ansIndex] || childindex == bank.ans[ansIndex],
  251. wrong: childindex == bank.ques[ansIndex] && bank.ques[ansIndex] != bank.ans[ansIndex]
  252. }"
  253. class="activeTI"
  254. >
  255. {{ ast[childindex] }}
  256. </text>
  257. {{ option }}
  258. </view>
  259. </view>
  260. <view v-if="bank.ques[ansIndex]">
  261. <view class="pad_8 answer">
  262. <view>正确答案:{{ ast[bank.ans[ansIndex]] }}</view>
  263. <view>我的答案:{{ ast[bank.ques[ansIndex]] }}</view>
  264. </view>
  265. <view class="pad_8 answerInfos">
  266. <view class="answerTitle">答案解析</view>
  267. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  268. </view>
  269. </view>
  270. </template>
  271. <!-- 简答题 -->
  272. <template v-if="ansItem.type == 5">
  273. <view class="ans">
  274. <view class="ans_input" v-if="!bank.ques[ansIndex]">
  275. <view class="top flex">
  276. <image class="icon" @click="chooseImgChild(bankIndex, ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  277. <view class="progress">0/4</view>
  278. <view class="submit" @click="submitAnsChild(bankIndex, ansIndex)">确认答案</view>
  279. </view>
  280. <view class="textarea"><textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea></view>
  281. <view class="imgs">
  282. <view class="img" v-for="(img, imgIndex) in ansItem.ansText.imageList">
  283. <text @click="deleteImgChild(imgIndex, bankIndex, ansIndex)">x</text>
  284. <image :src="$method.splitImgHost(img, true)"></image>
  285. </view>
  286. </view>
  287. </view>
  288. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex]">
  289. <view class="answerTitle">答案我的</view>
  290. {{ bank.ques[ansIndex].text }}
  291. <view class="imgs">
  292. <image class="img" v-for="ques in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques, true)"></image>
  293. </view>
  294. </view>
  295. </view>
  296. <view v-if="bank.ques[ansIndex]">
  297. <view class="pad_8 answerInfos">
  298. <view class="answerTitle">答案解析</view>
  299. <view class="answerContent"><rich-text :nodes="ansItem.analysisContent"></rich-text></view>
  300. </view>
  301. </view>
  302. </template>
  303. </view>
  304. </template>
  305. </view>
  306. <view class="footer_btn">
  307. <view class="collect" :class="{ show: goodsId ? true : false }" @click="collect(collectList[bankIndex], bankIndex)">
  308. {{ collectList[bankIndex] ? '已收藏' : '未收藏' }}
  309. </view>
  310. <view @click="openFooterTab">答题卡</view>
  311. <view @click="submit">交卷</view>
  312. </view>
  313. </view>
  314. </swiper-item>
  315. </swiper>
  316. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  317. <view class="popupView">
  318. <view class="popupTops">
  319. <view class="topIcon"></view>
  320. 点击编号即可跳转至对应题目
  321. </view>
  322. <view class="popupContent">
  323. <scroll-view scroll-y="true" style="height: 506rpx;">
  324. <view class="boxSty">
  325. <view
  326. v-for="(item, index) in questionList"
  327. :key="index"
  328. @click="changeIndex(index)"
  329. :class="{ isRight: isRight(item, index), isWrong: isWrong(item, index) }"
  330. class="liListSty"
  331. >
  332. {{ index + 1 }}
  333. </view>
  334. </view>
  335. </scroll-view>
  336. </view>
  337. </view>
  338. </u-popup>
  339. <view class="dialog" v-if="showDialog">
  340. <view class="text">左右滑动切换上下题</view>
  341. <view class="btn" @click="hideDialog">我知道了</view>
  342. </view>
  343. <view class="dialog_wrap" v-if="testOver">
  344. <view class="bg"></view>
  345. <view class="dialog">
  346. <view class="title">温馨提示</view>
  347. <view class="content">
  348. <view>您已完成所有题目,</view>
  349. <view>快去交卷吧!</view>
  350. </view>
  351. <view class="btns">
  352. <view class="btn" @click="noSubmit()">暂不交卷</view>
  353. <view class="btn active" @click="submitNow()">立即交卷</view>
  354. </view>
  355. </view>
  356. </view>
  357. <view class="dialog_wrap" v-if="isLastCount">
  358. <view class="bg"></view>
  359. <view class="dialog">
  360. <view class="title">温馨提示</view>
  361. <view class="content">
  362. <view>您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view>
  363. </view>
  364. <view class="btns">
  365. <view class="btn" @click="noLeave()">暂不离开</view>
  366. <view class="btn active" @click="leaveNow()">继续离开</view>
  367. </view>
  368. </view>
  369. </view>
  370. <u-popup v-model="showpopups" mode="center" border-radius="24" height="439rpx" width="640rpx" :mask-close-able="false">
  371. <view class="popboxs">
  372. <view class="classTops">温馨提示</view>
  373. <view class="textStys">出淤泥而不染,濯清涟而不妖</view>
  374. <view class="classFootsty">
  375. <view class="btnsty btns1" @click="showpopups=false">暂不交卷</view>
  376. <view class="btnsty btns2">立即交卷</view>
  377. </view>
  378. </view>
  379. </u-popup>
  380. </view>
  381. </template>
  382. <script>
  383. export default {
  384. data() {
  385. return {
  386. showpopups: true,
  387. id: '',
  388. current: 0,
  389. questionList: [],
  390. ast: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  391. judge: ['错误', '正确'],
  392. ans: [],
  393. ques: [],
  394. show: false,
  395. showDialog: true,
  396. bankList: [],
  397. collectList: [],
  398. goodsId: '',
  399. recordId: '',
  400. isSubmit: false,
  401. lastTime: 0,
  402. timer: null,
  403. wrongList: [],
  404. bankType: 0, //试卷类型
  405. needBack: false, //是否是考试
  406. testOver: false,
  407. isLastCount: false, //是否有未答题目
  408. lastCount: 0, //剩余没有回答的题目数
  409. chapterId: 0,
  410. moduleId: 0
  411. };
  412. },
  413. onLoad(option) {
  414. this.id = option.id;
  415. this.goodsId = option.goodsid;
  416. this.chapterId = option.chapterId;
  417. this.moduleId = option.moduleId;
  418. let isBack = option.isback;
  419. if (isBack) {
  420. console.log(getApp());
  421. let app = getApp();
  422. let globalData = app.globalData;
  423. for (var k in globalData.bankData) {
  424. this[k] = globalData.bankData[k];
  425. }
  426. } else {
  427. this.goodsQuestionList();
  428. // this.wrongRecordExamQuestionList();
  429. this.bankExam();
  430. }
  431. },
  432. onUnload() {
  433. if (this.isSubmit) {
  434. return;
  435. }
  436. //考试试卷 阻止ios手势返回,自动跳回答题页
  437. if (this.needBack) {
  438. let app = getApp();
  439. app.globalData.bankData = this.$data;
  440. uni.navigateTo({
  441. url: '/pages2/bank/questionBank?id=' + this.id + '&goodsid=' + this.goodsId + '&isback=true'
  442. });
  443. } else {
  444. //点击返回按钮确认允许退出,记录答题记录
  445. this.examRecordEdit();
  446. }
  447. },
  448. methods: {
  449. bankExam() {
  450. this.$api.bankExam(this.id).then(res => {
  451. this.bankType = res.data.data.doType;
  452. if (this.bankType == 2) {
  453. this.needBack = true;
  454. }
  455. });
  456. },
  457. /**
  458. * 获取错题集
  459. */
  460. wrongRecordExamQuestionList() {
  461. this.$api
  462. .wrongRecordExamQuestionList({
  463. examId: this.id,
  464. goodsId: this.goodsId
  465. })
  466. .then(res => {
  467. this.wrongList = res.data.rows;
  468. });
  469. },
  470. /**
  471. * 点击后退按钮
  472. */
  473. clickLeft() {
  474. if (this.bankType == 1) {
  475. this.needBack = false;
  476. uni.navigateBack({
  477. delta: 1
  478. });
  479. } else if (this.bankType == 2) {
  480. let ansCount = this.questionOverNum(); //已答题数
  481. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  482. //所有题目答完
  483. if (this.lastCount == 0) {
  484. this.testOver = true;
  485. //未答完
  486. } else {
  487. this.isLastCount = true;
  488. }
  489. }
  490. },
  491. /**
  492. * 获取已经回答的题目数
  493. */
  494. questionOverNum() {
  495. let count = 0;
  496. this.questionList.forEach(item => {
  497. if (item.type == 1 || item.type == 2 || item.type == 3) {
  498. if (item.ques) {
  499. count++;
  500. }
  501. } else if (item.type == 4) {
  502. //案例题
  503. let isOver = item.jsonStr.every(jsonItem => {
  504. if (jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
  505. if (jsonItem.ques) {
  506. return true;
  507. } else {
  508. return false;
  509. }
  510. } else if (jsonItem.type == 5) {
  511. if (jsonItem.ansText.text.length || jsonItem.ansText.imageList.length) {
  512. return true;
  513. } else {
  514. return false;
  515. }
  516. }
  517. });
  518. if (isOver) {
  519. count++;
  520. }
  521. } else if (item.type == 5) {
  522. //简答题
  523. if (item.ansText.text.length || item.ansText.imageList.length) {
  524. count++;
  525. }
  526. }
  527. });
  528. return count;
  529. },
  530. /**
  531. * 暂不交卷
  532. */
  533. noSubmit() {
  534. //设为允许退出页面
  535. this.needBack = false;
  536. uni.navigateBack({
  537. delta: 1
  538. });
  539. },
  540. /**
  541. * 不离开
  542. */
  543. noLeave() {
  544. this.isLastCount = false;
  545. },
  546. /**
  547. * 立即离开并交卷
  548. */
  549. leaveNow() {
  550. this.needBack = false;
  551. uni.navigateBack({
  552. delta: 1
  553. });
  554. let score = 0; //计算总分
  555. let reportStatus = 0;
  556. let number = 0;
  557. this.questionList.forEach((item, index) => {
  558. if (item.type == 1) {
  559. if (item.ques == item.ans) {
  560. score += item.score;
  561. number++;
  562. }
  563. } else if (item.type == 2) {
  564. let isRight =
  565. item.ques &&
  566. item.ques.every((quesItem, quesIndex) => {
  567. return item.ques[quesIndex] == item.ans[quesIndex];
  568. });
  569. if (isRight) {
  570. score += item.score;
  571. number++;
  572. }
  573. } else if (item.type == 3) {
  574. if (item.ques == item.ans) {
  575. score += item.score;
  576. number++;
  577. }
  578. }
  579. });
  580. // if(score >= 60) {
  581. // reportStatus = 1
  582. // } else {
  583. // reportStatus = 0
  584. // }
  585. this.$api
  586. .examRecordEdit({
  587. examId: this.id,
  588. goodsId: this.goodsId,
  589. // reportStatus:reportStatus,
  590. doQuestionNum: this.questionOverNum(),
  591. recordId: this.recordId,
  592. rightQuestionNum: number,
  593. status: 1,
  594. score: score,
  595. historyExamJson: JSON.stringify(this.questionList)
  596. })
  597. .then(res => {});
  598. },
  599. /**
  600. * 立即交卷
  601. */
  602. submitNow() {
  603. this.needBack = false;
  604. this.submit();
  605. },
  606. /**
  607. * 离开页面统计回答正确题数
  608. */
  609. examRecordEdit() {
  610. if (!this.isSubmit) {
  611. let number = 0;
  612. let score = 0;
  613. this.questionList.forEach((item, index) => {
  614. if (item.type == 1) {
  615. if (item.ques == item.ans) {
  616. score += item.score;
  617. number++;
  618. }
  619. } else if (item.type == 2) {
  620. let isRight =
  621. item.ques &&
  622. item.ques.every((quesItem, quesIndex) => {
  623. return item.ques[quesIndex] == item.ans[quesIndex];
  624. });
  625. if (isRight) {
  626. score += item.score;
  627. number++;
  628. }
  629. } else if (item.type == 3) {
  630. if (item.ques == item.ans) {
  631. score += item.score;
  632. number++;
  633. }
  634. }
  635. });
  636. this.$api
  637. .examRecordEdit({
  638. examId: this.id,
  639. goodsId: this.goodsId,
  640. recordId: this.recordId,
  641. rightQuestionNum: number,
  642. status: 0,
  643. historyExamJson: JSON.stringify(this.questionList)
  644. })
  645. .then(res => {});
  646. }
  647. },
  648. /**
  649. * 记录总题数
  650. */
  651. examRecord() {
  652. this.$api
  653. .examRecord({
  654. chapterExamId: this.chapterId || 0,
  655. moduleExamId: this.moduleId || 0,
  656. examId: this.id,
  657. goodsId: this.goodsId,
  658. totalQuestionNum: this.questionList.length
  659. })
  660. .then(res => {
  661. this.recordId = res.data.data;
  662. });
  663. },
  664. /**
  665. * @param {Object} second倒计时过滤器
  666. */
  667. countdown(second) {
  668. if (second) {
  669. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  670. let m = parseInt((second / 60) % 60); // 计算分数
  671. let s = parseInt(second % 60); // 计算当前秒数
  672. if (h < 10) h = '0' + h;
  673. if (m < 10) m = '0' + m;
  674. if (s < 10) s = '0' + s;
  675. return h + ':' + m + ':' + s;
  676. } else {
  677. return '';
  678. }
  679. },
  680. /**
  681. * 请求题目列表
  682. */
  683. goodsQuestionList() {
  684. this.$api
  685. .goodsQuestionList({
  686. examId: this.id
  687. })
  688. .then(res => {
  689. this.lastTime = res.data.data[0].answerTime && res.data.data[0].answerTime * 60;
  690. //考试时间到了自动交卷
  691. if (this.lastTime) {
  692. this.timer = setInterval(() => {
  693. if (this.lastTime <= 0) {
  694. clearInterval(this.timer);
  695. uni.showModal({
  696. title: '提示',
  697. content: '考试时间到,自动交卷',
  698. confirmText: '确定',
  699. showCancel: false,
  700. success: res => {
  701. this.submit();
  702. }
  703. });
  704. return;
  705. }
  706. this.lastTime--;
  707. }, 1000);
  708. } else {
  709. }
  710. res.data.data.forEach((item, index) => {
  711. if (typeof item.jsonStr == 'string') {
  712. item.jsonStr = JSON.parse(item.jsonStr);
  713. if (item.type == 2) {
  714. //多选
  715. item.jsonStr.forEach(str => {
  716. str.optionsId = '' + str.optionsId;
  717. });
  718. let arr = item.answerQuestion.split(',');
  719. arr.forEach((a, i) => {
  720. arr[i] = '' + a;
  721. });
  722. item.ans = arr;
  723. return;
  724. } else if (item.type == 5) {
  725. //简答题
  726. item.ansText = {
  727. text: '',
  728. imageList: []
  729. };
  730. } else if (item.type == 4) {
  731. //案例题
  732. console.log(item.jsonStr);
  733. item.ques = [];
  734. item.current = 0;
  735. let ansArr = [];
  736. item.jsonStr.forEach((json, index) => {
  737. if (json.type == 1) {
  738. ansArr[index] = json.answerQuestion;
  739. } else if (json.type == 2) {
  740. json.optionsList.forEach(str => {
  741. str.optionsId = '' + str.optionsId;
  742. });
  743. let arr = json.answerQuestion.split(',');
  744. arr.forEach((a, i) => {
  745. arr[i] = '' + a;
  746. });
  747. ansArr[index] = arr;
  748. } else if (json.type == 3) {
  749. ansArr[index] = json.answerQuestion;
  750. } else if (json.type == 5) {
  751. ansArr[index] = {
  752. text: '',
  753. imageList: []
  754. };
  755. json.ansText = {
  756. text: '',
  757. imageList: []
  758. };
  759. }
  760. });
  761. item.ans = ansArr;
  762. return;
  763. }
  764. item.ans = item.answerQuestion;
  765. }
  766. });
  767. this.questionList = res.data.data;
  768. this.lastCount = this.questionList.length;
  769. this.examRecord();
  770. this.getCollectInfo(this.current);
  771. });
  772. },
  773. /**
  774. * @param {Object} e单选点击
  775. */
  776. radioSelect(optionsId, bindex) {
  777. if (this.questionList[bindex].ques) return;
  778. this.$set(this.questionList[bindex], 'ques', optionsId);
  779. // 回答错误
  780. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  781. this.$api
  782. .examWrongRecord({
  783. examId: this.id,
  784. goodsId: this.goodsId,
  785. questionId: this.questionList[bindex].questionId,
  786. recordId: this.recordId
  787. })
  788. .then(res => {});
  789. } else {
  790. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  791. // if(question) {
  792. // this.$api.wrongRecordDelete({
  793. // "examId": +this.id,
  794. // "goodsId": +this.goodsId,
  795. // "questionId": this.questionList[bindex].questionId,
  796. // }).then(res => {
  797. // })
  798. // }
  799. }
  800. },
  801. /**
  802. * @param {Object} e案例单选点击
  803. */
  804. radioSelectChild(optionsId, ansIndex, bindex) {
  805. if (this.questionList[bindex].ques[ansIndex]) return;
  806. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  807. },
  808. /**
  809. * @param {Object} 多选点击
  810. */
  811. checkboxSelect(optionsId, bindex, index) {
  812. this.$set(this.questionList[bindex].jsonStr[index], 'checked', !this.questionList[bindex].jsonStr[index].checked);
  813. },
  814. /**
  815. * @param {Object} 案例多选点击
  816. */
  817. checkboxSelectChild(bindex, ansIndex, childIndex) {
  818. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex], 'checked', !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked);
  819. },
  820. /**
  821. * @param {Object} 多选确认
  822. */
  823. checkboxSubmit(bindex) {
  824. if (this.questionList[bindex].ques) return;
  825. let arr = [];
  826. this.questionList[bindex].jsonStr.forEach(item => {
  827. if (item.checked) {
  828. arr.push(item.optionsId);
  829. }
  830. });
  831. this.$set(this.questionList[bindex], 'ques', arr);
  832. let isWrong = this.questionList[bindex].ques.some((quesItem, quesIndex) => {
  833. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex];
  834. });
  835. // 回答错误
  836. if (isWrong) {
  837. this.$api
  838. .examWrongRecord({
  839. examId: this.id,
  840. goodsId: this.goodsId,
  841. questionId: this.questionList[bindex].questionId,
  842. recordId: this.recordId
  843. })
  844. .then(res => {});
  845. } else {
  846. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  847. // if(question) {
  848. // this.$api.wrongRecordDelete({
  849. // "examId": +this.id,
  850. // "goodsId": +this.goodsId,
  851. // "questionId": this.questionList[bindex].questionId,
  852. // }).then(res => {
  853. // })
  854. // }
  855. }
  856. },
  857. /**
  858. * @param {Object} 案例多选确认
  859. */
  860. checkboxSubmitChild(bindex, ansIndex) {
  861. if (this.questionList[bindex].ques[ansIndex]) return;
  862. let arr = [];
  863. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  864. if (item.checked) {
  865. arr.push(item.optionsId);
  866. }
  867. });
  868. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  869. },
  870. /**
  871. * @param {Object} index
  872. * @param {Object} bindex
  873. * 判断题
  874. */
  875. judgeSelect(index, bindex) {
  876. if (this.questionList[bindex].ques) return;
  877. this.$set(this.questionList[bindex], 'ques', index + '');
  878. // 回答错误
  879. if (this.questionList[bindex].ques != this.questionList[bindex].ans) {
  880. this.$api
  881. .examWrongRecord({
  882. examId: this.id,
  883. goodsId: this.goodsId,
  884. questionId: this.questionList[bindex].questionId,
  885. recordId: this.recordId
  886. })
  887. .then(res => {});
  888. } else {
  889. // let question = this.wrongList.find(item => item.questionId == this.questionList[bindex].questionId);
  890. // if(question) {
  891. // this.$api.wrongRecordDelete({
  892. // "examId": +this.id,
  893. // "goodsId": +this.goodsId,
  894. // "questionId": this.questionList[bindex].questionId,
  895. // }).then(res => {
  896. // })
  897. // }
  898. }
  899. },
  900. /**
  901. * @param {Object} ansindex
  902. * @param {Object} childindex
  903. * @param {Object} bindex
  904. * 案例判断题
  905. */
  906. judgeSelectChild(ansindex, childindex, bindex) {
  907. if (this.questionList[bindex].ques[ansindex]) return;
  908. this.$set(this.questionList[bindex].ques, ansindex, childindex + '');
  909. },
  910. openFooterTab() {
  911. this.show = true;
  912. },
  913. hideDialog() {
  914. this.showDialog = false;
  915. },
  916. changeIndex(index) {
  917. this.current = index;
  918. },
  919. swiperChange(e) {
  920. this.current = e.detail.current;
  921. this.getCollectInfo(this.current);
  922. },
  923. /**
  924. * @param {Object} current
  925. * 获取收藏信息
  926. */
  927. getCollectInfo(current) {
  928. this.$api
  929. .getCollectInfo({
  930. examId: this.id,
  931. questionId: this.questionList[current].questionId,
  932. goodsId: this.goodsId
  933. })
  934. .then(res => {
  935. if (res.data.code == 500) {
  936. this.$set(this.collectList, current, false);
  937. } else if (res.data.code == 200) {
  938. this.$set(this.collectList, current, res.data.data);
  939. }
  940. });
  941. },
  942. /**
  943. * 提交数据
  944. */
  945. submit() {
  946. let score = 0; //计算总分
  947. let reportStatus = 0;
  948. let number = 0;
  949. this.questionList.forEach((item, index) => {
  950. if (item.type == 1) {
  951. if (item.ques == item.ans) {
  952. score += item.score;
  953. number++;
  954. }
  955. } else if (item.type == 2) {
  956. let isRight =
  957. item.ques &&
  958. item.ques.every((quesItem, quesIndex) => {
  959. return item.ques[quesIndex] == item.ans[quesIndex];
  960. });
  961. if (isRight) {
  962. score += item.score;
  963. number++;
  964. }
  965. } else if (item.type == 3) {
  966. if (item.ques == item.ans) {
  967. score += item.score;
  968. number++;
  969. }
  970. }
  971. });
  972. // if(score >= 60) {
  973. // reportStatus = 1
  974. // } else {
  975. // reportStatus = 0
  976. // }
  977. this.$api
  978. .examRecordEdit({
  979. examId: this.id,
  980. goodsId: this.goodsId,
  981. // reportStatus:reportStatus,
  982. recordId: this.recordId,
  983. rightQuestionNum: number,
  984. status: 1,
  985. score: score,
  986. historyExamJson: JSON.stringify(this.questionList)
  987. })
  988. .then(res => {
  989. this.isSubmit = true;
  990. if (res.data.code == 200) {
  991. uni.showToast({
  992. title: '交卷成功',
  993. duration: 2000,
  994. icon: 'none'
  995. });
  996. setTimeout(() => {
  997. uni.redirectTo({
  998. url: '/pages2/bank/question_report?id=' + this.recordId
  999. });
  1000. }, 2000);
  1001. }
  1002. });
  1003. },
  1004. /**
  1005. * @param {Object} state
  1006. * @param {Object} index
  1007. * 收藏
  1008. */
  1009. collect(state, index) {
  1010. if (!state) {
  1011. this.$api
  1012. .collectQuestion({
  1013. examId: this.id,
  1014. questionId: this.questionList[index].questionId,
  1015. goodsId: this.goodsId || ''
  1016. })
  1017. .then(res => {
  1018. if (res.data.code == 200) {
  1019. this.$set(this.collectList, index, true);
  1020. uni.showToast({
  1021. title: '收藏成功',
  1022. duration: 2000,
  1023. icon: 'none'
  1024. });
  1025. }
  1026. });
  1027. } else {
  1028. this.$api.deleteCollectQuestion(this.collectList[index].collectQuestionId).then(res => {
  1029. if (res.data.code == 200) {
  1030. this.$set(this.collectList, index, false);
  1031. uni.showToast({
  1032. title: '取消收藏成功',
  1033. duration: 2000,
  1034. icon: 'none'
  1035. });
  1036. }
  1037. });
  1038. }
  1039. return;
  1040. },
  1041. /**
  1042. * @param {Object} imgIndex
  1043. * @param {Object} bankIndex
  1044. * 删除简答图片
  1045. */
  1046. deleteImg(imgIndex, bankIndex) {
  1047. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1048. },
  1049. /**
  1050. * @param {Object} imgIndex
  1051. * @param {Object} bankIndex
  1052. * @param {Object} ansIndex
  1053. * 删除案例题简答图片
  1054. */
  1055. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1056. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex, 1);
  1057. },
  1058. /**
  1059. * @param {Object} bankindex
  1060. * 选择上传图片
  1061. */
  1062. chooseImg(bankindex) {
  1063. uni.chooseImage({
  1064. count: 1, //默认9
  1065. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1066. sourceType: ['album', 'camera'], //从相册选择
  1067. success: res => {
  1068. let self = this;
  1069. // console.log(JSON.stringify(res.tempFilePaths));
  1070. let img = res.tempFilePaths[0];
  1071. uni.getImageInfo({
  1072. src: img,
  1073. success: async res => {
  1074. let canvasWidth = res.width; //图片原始长宽
  1075. let canvasHeight = res.height;
  1076. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1077. uni.compressImage({
  1078. src: img,
  1079. quality: 75,
  1080. width: '50%',
  1081. height: '50%',
  1082. success: async rest => {
  1083. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1084. this.questionList[bankindex].ansText.imageList.push(dir);
  1085. }
  1086. });
  1087. } else {
  1088. const dir = await self.uploadFile(img, 0);
  1089. this.questionList[bankindex].ansText.imageList.push(dir);
  1090. }
  1091. }
  1092. });
  1093. }
  1094. });
  1095. },
  1096. /**
  1097. * @param {Object} bankindex
  1098. * @param {Object} ansindex
  1099. * 案例题选择上传图片
  1100. */
  1101. chooseImgChild(bankindex, ansindex) {
  1102. uni.chooseImage({
  1103. count: 1, //默认9
  1104. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  1105. sourceType: ['album', 'camera'], //从相册选择
  1106. success: res => {
  1107. let self = this;
  1108. // console.log(JSON.stringify(res.tempFilePaths));
  1109. let img = res.tempFilePaths[0];
  1110. uni.getImageInfo({
  1111. src: img,
  1112. success: async res => {
  1113. let canvasWidth = res.width; //图片原始长宽
  1114. let canvasHeight = res.height;
  1115. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1116. uni.compressImage({
  1117. src: img,
  1118. quality: 75,
  1119. width: '50%',
  1120. height: '50%',
  1121. success: async rest => {
  1122. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1123. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1124. }
  1125. });
  1126. } else {
  1127. const dir = await self.uploadFile(img, 0);
  1128. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir);
  1129. }
  1130. }
  1131. });
  1132. }
  1133. });
  1134. },
  1135. uploadFile(options, int) {
  1136. var self = this;
  1137. return new Promise((resolve, reject) => {
  1138. var data = {
  1139. imageStatus: int
  1140. };
  1141. self.$api.aliyunpolicy(data).then(res => {
  1142. console.log(res.data, 6);
  1143. if (res.data.code != 200) {
  1144. self.$method.showToast('签名错误' + JSON.stringify(res.data));
  1145. return;
  1146. }
  1147. var ossToken = res.data.data.resultContent;
  1148. if (ossToken.host == null || ossToken.host == undefined) {
  1149. self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
  1150. return;
  1151. }
  1152. uni.uploadFile({
  1153. url: ossToken.host,
  1154. name: 'file',
  1155. filePath: options,
  1156. fileType: 'image',
  1157. header: {
  1158. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1159. },
  1160. formData: {
  1161. key: ossToken.dir,
  1162. OSSAccessKeyId: ossToken.accessid,
  1163. policy: ossToken.policy,
  1164. Signature: ossToken.signature,
  1165. callback: ossToken.callback,
  1166. success_action_status: 200
  1167. },
  1168. success: result => {
  1169. if (result.statusCode === 200) {
  1170. resolve(ossToken.dir);
  1171. } else {
  1172. uni.showToast({
  1173. title: '上传失败',
  1174. icon: 'none'
  1175. });
  1176. return;
  1177. }
  1178. },
  1179. fail: error => {
  1180. uni.showToast({
  1181. title: '上传接口报错' + error,
  1182. icon: 'none'
  1183. });
  1184. return;
  1185. }
  1186. });
  1187. });
  1188. });
  1189. },
  1190. /**
  1191. * @param {Object} type
  1192. * @param {Object} bankindex
  1193. * 简答题答案确认
  1194. */
  1195. submitAns(bankindex) {
  1196. console.log(this.questionList[bankindex]);
  1197. if (!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1198. uni.showToast({
  1199. title: '请输入内容或上传图片',
  1200. duration: 2000,
  1201. icon: 'none'
  1202. });
  1203. return;
  1204. }
  1205. this.$set(this.questionList[bankindex], 'ques', {
  1206. imageList: this.questionList[bankindex].ansText.imageList,
  1207. text: this.questionList[bankindex].ansText.text
  1208. });
  1209. },
  1210. /**
  1211. * @param {Object} bankindex
  1212. * @param {Object} ansindex
  1213. * 案例题简答答案确认
  1214. */
  1215. submitAnsChild(bankindex, ansindex) {
  1216. if (!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1217. uni.showToast({
  1218. title: '请输入内容或上传图片',
  1219. duration: 2000,
  1220. icon: 'none'
  1221. });
  1222. return;
  1223. }
  1224. this.$set(this.questionList[bankindex].ques, ansindex, {
  1225. imageList: this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1226. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text
  1227. });
  1228. },
  1229. isRight(item, index) {
  1230. //单选
  1231. if (this.questionList[index].ques) {
  1232. if (item.type == 1) {
  1233. return this.questionList[index].ques == this.questionList[index].ans;
  1234. //多选
  1235. } else if (item.type == 2) {
  1236. //每一项都相等
  1237. return this.questionList[index].ques.every((item, i) => {
  1238. return item == this.questionList[index].ans[i];
  1239. });
  1240. //判断
  1241. } else if (item.type == 3) {
  1242. return this.questionList[index].ques == this.questionList[index].ans;
  1243. } else {
  1244. return false;
  1245. }
  1246. } else {
  1247. return false;
  1248. }
  1249. },
  1250. right(bankIndex, ansIndex, option) {
  1251. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1252. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 || this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1) {
  1253. return true;
  1254. } else {
  1255. return false;
  1256. }
  1257. } else {
  1258. return false;
  1259. }
  1260. },
  1261. wrong(bankIndex, ansIndex, option) {
  1262. if (this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1263. if (this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 && this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1) {
  1264. return true;
  1265. } else {
  1266. return false;
  1267. }
  1268. } else {
  1269. return false;
  1270. }
  1271. },
  1272. isWrong(item, index) {
  1273. if (this.questionList[index].ques) {
  1274. //单选
  1275. if (item.type == 1) {
  1276. return this.questionList[index].ques != this.questionList[index].ans;
  1277. //多选
  1278. } else if (item.type == 2) {
  1279. //每一项都相等
  1280. return this.questionList[index].ques.some((item, index) => {
  1281. return item != this.questionList[index].ans;
  1282. });
  1283. //判断
  1284. } else if (item.type == 3) {
  1285. return this.questionList[index].ques != this.questionList[index].ans;
  1286. } else {
  1287. return false;
  1288. }
  1289. } else {
  1290. return false;
  1291. }
  1292. },
  1293. tabSelect(index, bankindex) {
  1294. this.$set(this.questionList[bankindex], 'current', index);
  1295. }
  1296. }
  1297. };
  1298. </script>
  1299. <style lang="scss" scoped>
  1300. .swiper {
  1301. width: 100%;
  1302. height: calc(100vh - 44px);
  1303. }
  1304. .lisSty {
  1305. margin-bottom: 16rpx;
  1306. display: flex;
  1307. .flex_auto {
  1308. flex: 1;
  1309. }
  1310. }
  1311. .activeTI {
  1312. vertical-align: middle;
  1313. display: inline-block;
  1314. border: 1rpx solid #eee;
  1315. border-radius: 50rpx;
  1316. height: 48rpx;
  1317. line-height: 46rpx;
  1318. text-align: center;
  1319. width: 48rpx;
  1320. margin-right: 15rpx;
  1321. color: #666;
  1322. font-size: 30rpx;
  1323. &.right {
  1324. color: #fff;
  1325. background: green;
  1326. }
  1327. &.wrong {
  1328. color: #fff;
  1329. background: red;
  1330. }
  1331. &.checked {
  1332. color: #fff;
  1333. background: blue;
  1334. }
  1335. }
  1336. .submit_checkbox {
  1337. margin: 20rpx auto;
  1338. width: 526rpx;
  1339. height: 80rpx;
  1340. background: rgba(0, 122, 255, 1);
  1341. color: #fff;
  1342. text-align: center;
  1343. line-height: 80rpx;
  1344. font-size: 30rpx;
  1345. border-radius: 40rpx;
  1346. }
  1347. .titles {
  1348. overflow: hidden;
  1349. margin-bottom: 24rpx;
  1350. }
  1351. .titBox {
  1352. padding: 41rpx 25rpx 24rpx 25rpx;
  1353. }
  1354. .tabs {
  1355. margin: 10rpx;
  1356. display: flex;
  1357. .tab {
  1358. margin: 0 10rpx;
  1359. width: 96rpx;
  1360. height: 48rpx;
  1361. line-height: 48rpx;
  1362. text-align: center;
  1363. color: #007aff;
  1364. font-size: 28rpx;
  1365. border-radius: 16rpx;
  1366. &.current {
  1367. color: #fff;
  1368. background: #007aff;
  1369. }
  1370. }
  1371. }
  1372. .ans {
  1373. margin: 8rpx 8rpx 8rpx;
  1374. .ans_input {
  1375. border-radius: 16rpx;
  1376. background: #fff;
  1377. .top {
  1378. border-bottom: 1rpx solid #eeeeee;
  1379. padding: 16rpx;
  1380. display: flex;
  1381. align-items: center;
  1382. .icon {
  1383. margin-right: 20rpx;
  1384. width: 40rpx;
  1385. height: 38rpx;
  1386. }
  1387. .progress {
  1388. flex: 1;
  1389. }
  1390. .submit {
  1391. width: 168rpx;
  1392. height: 48rpx;
  1393. line-height: 48rpx;
  1394. text-align: center;
  1395. color: #fff;
  1396. font-size: 30rpx;
  1397. background: #007aff;
  1398. border-radius: 24rpx;
  1399. }
  1400. }
  1401. .textarea {
  1402. textarea {
  1403. width: 100%;
  1404. height: 287rpx;
  1405. padding: 10rpx;
  1406. }
  1407. }
  1408. .imgs {
  1409. overflow: hidden;
  1410. display: flex;
  1411. width: 100%;
  1412. .img {
  1413. width: 104rpx;
  1414. height: 104rpx;
  1415. border-radius: 8rpx;
  1416. position: relative;
  1417. margin: 20rpx;
  1418. text {
  1419. position: absolute;
  1420. right: -15rpx;
  1421. top: -15rpx;
  1422. width: 30rpx;
  1423. height: 30rpx;
  1424. text-align: center;
  1425. line-height: 30rpx;
  1426. color: #fff;
  1427. background: red;
  1428. border-radius: 50%;
  1429. }
  1430. image {
  1431. width: 100%;
  1432. height: 100%;
  1433. }
  1434. }
  1435. }
  1436. }
  1437. .ans_submit {
  1438. padding: 16rpx;
  1439. border-radius: 16rpx;
  1440. background: #fff;
  1441. .imgs {
  1442. overflow: hidden;
  1443. display: flex;
  1444. width: 100%;
  1445. .img {
  1446. width: 104rpx;
  1447. height: 104rpx;
  1448. border-radius: 8rpx;
  1449. position: relative;
  1450. margin: 20rpx;
  1451. image {
  1452. width: 100%;
  1453. height: 100%;
  1454. }
  1455. }
  1456. }
  1457. }
  1458. }
  1459. .firstLetter {
  1460. display: flex;
  1461. justify-content: space-between;
  1462. align-items: center;
  1463. margin-bottom: 30rpx;
  1464. .leftLetters {
  1465. display: flex;
  1466. align-items: center;
  1467. width: 220rpx;
  1468. .btnType {
  1469. padding: 5rpx 10rpx;
  1470. border: 1rpx solid #007aff;
  1471. border-radius: 10rpx;
  1472. background-color: rgba(0, 122, 255, 0.1);
  1473. font-size: 28rpx;
  1474. color: #007aff;
  1475. margin-right: 15rpx;
  1476. }
  1477. }
  1478. }
  1479. .popupView {
  1480. height: 100%;
  1481. padding-bottom: 100rpx;
  1482. .popupTops {
  1483. height: 77rpx;
  1484. border-bottom: 1rpx solid #eee;
  1485. text-align: center;
  1486. line-height: 77rpx;
  1487. font-size: 24rpx;
  1488. color: #999;
  1489. position: relative;
  1490. .topIcon {
  1491. position: absolute;
  1492. top: 10rpx;
  1493. left: 50%;
  1494. transform: translateX(-50%);
  1495. width: 80rpx;
  1496. height: 8rpx;
  1497. background-color: #999;
  1498. border-radius: 4rpx;
  1499. }
  1500. }
  1501. .popupContent {
  1502. }
  1503. }
  1504. .pageContent {
  1505. position: relative;
  1506. background-color: #eaeef1;
  1507. min-height: 100vh;
  1508. padding-top: 8rpx;
  1509. padding-bottom: 100rpx;
  1510. }
  1511. .pad_8 {
  1512. background-color: #fff;
  1513. margin: 0rpx 8rpx 8rpx;
  1514. border-radius: 16rpx;
  1515. }
  1516. .answer {
  1517. height: 80rpx;
  1518. line-height: 80rpx;
  1519. padding: 0rpx 24rpx;
  1520. display: flex;
  1521. align-items: center;
  1522. justify-content: space-between;
  1523. color: #666;
  1524. font-size: 30rpx;
  1525. }
  1526. .footer_btn {
  1527. background-color: #fff;
  1528. z-index: 10078;
  1529. position: fixed;
  1530. bottom: 0rpx;
  1531. display: flex;
  1532. align-items: center;
  1533. justify-content: space-between;
  1534. width: 100%;
  1535. height: 98rpx;
  1536. padding: 0rpx 38rpx;
  1537. border-top: 1rpx solid #eee;
  1538. .collect {
  1539. visibility: hidden;
  1540. &.show {
  1541. visibility: visible;
  1542. }
  1543. }
  1544. }
  1545. .boxSty {
  1546. padding: 44rpx 41rpx 0rpx;
  1547. }
  1548. .liListSty {
  1549. border: 1rpx solid #eeeeee;
  1550. width: 88rpx;
  1551. height: 88rpx;
  1552. border-radius: 32rpx;
  1553. text-align: center;
  1554. line-height: 88rpx;
  1555. color: #333;
  1556. font-size: 32rpx;
  1557. float: left;
  1558. margin: 20rpx 23rpx;
  1559. &.isRight {
  1560. border: 1rpx solid #eeeeee;
  1561. color: #fff;
  1562. background: green;
  1563. }
  1564. &.isWrong {
  1565. border: 1rpx solid #eeeeee;
  1566. color: #fff;
  1567. background: red;
  1568. }
  1569. }
  1570. .answerInfos {
  1571. padding: 25rpx 25rpx 25rpx 23rpx;
  1572. }
  1573. .answerTitle {
  1574. margin-bottom: 28rpx;
  1575. color: #666;
  1576. font-size: 30rpx;
  1577. }
  1578. .answerContent {
  1579. font-size: 30rpx;
  1580. color: #666;
  1581. }
  1582. .textChild {
  1583. display: inline-block;
  1584. vertical-align: middle;
  1585. }
  1586. .dialog {
  1587. position: fixed;
  1588. left: 0;
  1589. top: 0;
  1590. width: 100%;
  1591. height: 100%;
  1592. background-color: rgba(0, 0, 0, 0.8);
  1593. display: flex;
  1594. flex-direction: column;
  1595. align-items: center;
  1596. justify-content: center;
  1597. z-index: 20000;
  1598. .text {
  1599. font-size: 32rpx;
  1600. color: #ffffff;
  1601. text-align: center;
  1602. }
  1603. .btn {
  1604. width: 242rpx;
  1605. height: 82rpx;
  1606. border: 2rpx solid #ffffff;
  1607. border-radius: 16rpx;
  1608. text-align: center;
  1609. line-height: 82rpx;
  1610. margin: 41rpx auto;
  1611. color: #fff;
  1612. font-size: 32rpx;
  1613. }
  1614. }
  1615. .dialog_wrap {
  1616. position: fixed;
  1617. left: 0;
  1618. top: 0;
  1619. width: 100%;
  1620. height: 100%;
  1621. z-index: 9999999999;
  1622. .bg {
  1623. background: rgba(0, 0, 0, 0.3);
  1624. position: absolute;
  1625. left: 0;
  1626. top: 0;
  1627. width: 100%;
  1628. height: 100%;
  1629. }
  1630. .dialog {
  1631. position: absolute;
  1632. left: 50%;
  1633. top: 50%;
  1634. transform: translate3D(-50%, -50%, 0);
  1635. width: 640rpx;
  1636. height: 439rpx;
  1637. background: #ffffff;
  1638. border-radius: 24rpx;
  1639. .title {
  1640. font-size: 30rpx;
  1641. font-weight: bold;
  1642. color: #333333;
  1643. line-height: 48rpx;
  1644. text-align: center;
  1645. margin-top: 40rpx;
  1646. }
  1647. .content {
  1648. margin: 35rpx 35rpx 0;
  1649. font-size: 30rpx;
  1650. color: #666666;
  1651. line-height: 48rpx;
  1652. }
  1653. .btns {
  1654. margin-top: 35rpx;
  1655. display: flex;
  1656. align-items: center;
  1657. justify-content: center;
  1658. .btn {
  1659. width: 200rpx;
  1660. height: 80rpx;
  1661. line-height: 80rpx;
  1662. text-align: center;
  1663. background: #f5f5f5;
  1664. border-radius: 40rpx;
  1665. font-size: 30rpx;
  1666. color: rgba(0, 122, 255, 1);
  1667. background: #f5f5f5;
  1668. margin: 0 20rpx;
  1669. &.active {
  1670. color: #f5f5f5;
  1671. background: rgba(0, 122, 255, 1);
  1672. }
  1673. }
  1674. }
  1675. }
  1676. }
  1677. .popboxs {
  1678. width: 100%;
  1679. height: 100%;
  1680. display: flex;
  1681. flex-direction: column;
  1682. align-items: center;
  1683. }
  1684. .classTops {
  1685. flex-shrink: 0;
  1686. padding: 39rpx 0rpx 4rpx;
  1687. font-weight: bold;
  1688. color: #333;
  1689. font-size: 30rpx;
  1690. }
  1691. .textStys{
  1692. width: 100%;
  1693. flex: 1;
  1694. padding: 36rpx;
  1695. }
  1696. .classFootsty {
  1697. flex-shrink: 0;
  1698. display: flex;
  1699. align-items: center;
  1700. justify-content: center;
  1701. padding: 10rpx 0rpx 40rpx;
  1702. .btnsty {
  1703. width: 200rpx;
  1704. height: 80rpx;
  1705. border-radius: 40rpx;
  1706. font-weight: bold;
  1707. font-size: 30rpx;
  1708. text-align: center;
  1709. line-height: 80rpx;
  1710. }
  1711. .btns1 {
  1712. background-color: #f5f5f5;
  1713. color: #007aff;
  1714. }
  1715. .btns2 {
  1716. margin-left: 40rpx;
  1717. background-color: #007aff;
  1718. color: #ffffff;
  1719. }
  1720. }
  1721. </style>