questionBankExplain.vue 51 KB

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