questionBankContinue.vue 50 KB

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