questionBankContinue.vue 47 KB

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