questionBank.vue 45 KB

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