questionBankContinue.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925
  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.length || 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. this.questionList.length && this.questionList.forEach((item,index) => {
  652. if(item.type == 1) {
  653. if(item.ques == item.ans) {
  654. score += item.score;
  655. number++
  656. }
  657. if (item.ques) {
  658. doQuestionNum++;
  659. }
  660. } else if(item.type == 2) {
  661. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  662. return item.ques[quesIndex] == item.ans[quesIndex]
  663. })
  664. if(isRight) {
  665. score += item.score;
  666. number++
  667. }
  668. if (item.ques && item.ques.length) {
  669. doQuestionNum++;
  670. }
  671. } else if(item.type == 3) {
  672. if(item.ques == item.ans) {
  673. score += item.score;
  674. number++
  675. }
  676. if (item.ques) {
  677. doQuestionNum++;
  678. }
  679. } else if (item == 4) {
  680. if (item.ques.length) {
  681. doQuestionNum++;
  682. }
  683. } else if (item.type == 5) {
  684. if (item.ques) {
  685. doQuestionNum++;
  686. }
  687. }
  688. })
  689. this.$api.examRecordEdit({
  690. moduleExamId:this.moduleId || 0,
  691. chapterExamId:this.chapterId || 0,
  692. examId:this.id,
  693. goodsId:this.goodsId,
  694. recordId: this.recordId,
  695. rightQuestionNum:number,
  696. status:0,
  697. doQuestionNum: doQuestionNum,
  698. historyExamJson:JSON.stringify(this.questionList)
  699. }).then(res => {
  700. })
  701. }
  702. },
  703. /**
  704. * @param {Object} e单选点击
  705. */
  706. radioSelectChild(optionsId,ansIndex,bindex) {
  707. if(this.questionList[bindex].ques[ansIndex]) return;
  708. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  709. this.isDoOver()
  710. },
  711. /**
  712. * @param {Object} 多选点击
  713. */
  714. checkboxSelect(optionsId,bindex,index) {
  715. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  716. },
  717. /**
  718. * @param {Object} 多选点击
  719. */
  720. checkboxSelectChild(bindex,ansIndex,childIndex) {
  721. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  722. },
  723. /**
  724. * 提交数据
  725. */
  726. submit() {
  727. let score = 0; //计算总分
  728. let reportStatus = 0;
  729. let number = 0;
  730. let allScore = 0;
  731. let passScore = 0;
  732. let doQuestionNum = 0;
  733. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  734. let doQuestionIds = []; //做过的题目id
  735. let rightQuestionIds = []; //做对的题目id
  736. this.questionList.forEach((item,index) => {
  737. passScore = item.passScore
  738. if(item.type == 1) {
  739. if(item.ques == item.ans) {
  740. score += item.score;
  741. number++
  742. rightQuestionIds.push(item.questionId)
  743. } else { //错误
  744. doWrongQuestionIds.push(item.questionId)
  745. }
  746. allScore += item.score
  747. if (item.ques) {
  748. doQuestionNum++;
  749. doQuestionIds.push(item.questionId)
  750. }
  751. } else if(item.type == 2) {
  752. let isRight = item.ans && item.ans.every((quesItem,quesIndex) => {
  753. if(item.ques) {
  754. return item.ques[quesIndex] == item.ans[quesIndex]
  755. } else {
  756. return false;
  757. }
  758. })
  759. if(isRight) {
  760. score += item.score;
  761. number++
  762. rightQuestionIds.push(item.questionId)
  763. } else {
  764. let checkboxScore = item.score; //获取单题总分数
  765. item.ques && item.ques.forEach((ques,quesIndex) => {
  766. //选错一个全扣
  767. if(item.ques) {
  768. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  769. checkboxScore = 0;
  770. }
  771. } else {
  772. checkboxScore = 0;
  773. }
  774. })
  775. console.log(checkboxScore)
  776. //没选错
  777. if(checkboxScore) {
  778. item.ans.forEach((ans,quesIndex) => {
  779. //漏选扣一部分
  780. if(item.ques) {
  781. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  782. checkboxScore = item.partScore;
  783. }
  784. } else {
  785. checkboxScore = 0;
  786. }
  787. })
  788. }
  789. if(checkboxScore <= 0) { //0分
  790. item.scoreResult = 0;
  791. doWrongQuestionIds.push(item.questionId)
  792. } else { //部分分
  793. number++;
  794. item.scoreResult = checkboxScore;
  795. score += checkboxScore;
  796. rightQuestionIds.push(item.questionId)
  797. }
  798. }
  799. allScore += item.score;
  800. if (item.ques && item.ques.length) {
  801. doQuestionNum++;
  802. doQuestionIds.push(item.questionId)
  803. }
  804. } else if(item.type == 3) {
  805. if(item.ques == item.ans) {
  806. score += item.score;
  807. number++
  808. rightQuestionIds.push(item.questionId)
  809. } else {
  810. doWrongQuestionIds.push(item.questionId)
  811. }
  812. allScore += item.score;
  813. if (item.ques) {
  814. doQuestionNum++;
  815. doQuestionIds.push(item.questionId)
  816. }
  817. } else if (item.type == 4) {
  818. allScore += item.score;
  819. if (item.ques && item.ques.length) {
  820. doQuestionNum++;
  821. }
  822. } else if (item.type == 5) {
  823. allScore += item.score;
  824. if (item.ques) {
  825. doQuestionNum++;
  826. }
  827. }
  828. })
  829. //大于及格
  830. if(score >= passScore) {
  831. reportStatus = 1
  832. } else {
  833. reportStatus = 0
  834. }
  835. this.$api.examRecordEdit({
  836. examId:this.id,
  837. goodsId:this.goodsId,
  838. reportStatus:reportStatus,
  839. totalScore:allScore,
  840. recordId: this.recordId,
  841. rightQuestionNum:number,
  842. status:1,
  843. moduleExamId:this.moduleId || 0,
  844. chapterExamId:this.chapterId || 0,
  845. doQuestionIds:doQuestionIds.join(','),
  846. rightQuestionIds:rightQuestionIds.join(','),
  847. doQuestionNum: doQuestionNum,
  848. performance: score,
  849. historyExamJson:JSON.stringify(this.questionList)
  850. }).then(res => {
  851. this.isSubmit = true;
  852. if(res.data.code == 200) {
  853. uni.showToast({
  854. title: '交卷成功',
  855. duration: 2000,
  856. icon:'none'
  857. });
  858. setTimeout(() => {
  859. uni.redirectTo({
  860. url:'/pages2/bank/question_report?id='+this.recordId+'&examId='+this.id
  861. })
  862. },2000)
  863. }
  864. })
  865. //错题集id提交(客观题)
  866. this.$api.examWrongRecord({
  867. examId: this.id,
  868. goodsId: this.goodsId,
  869. questionIds: doWrongQuestionIds,
  870. recordId: this.recordId
  871. }).then(res => {
  872. });
  873. },
  874. isCheckboxChecked(arr) {
  875. return arr.some(item => {
  876. if (item.checked) {
  877. return true;
  878. }
  879. });
  880. },
  881. /**
  882. * @param {Object} 多选确认
  883. */
  884. checkboxSubmit(bindex) {
  885. if(this.questionList[bindex].ques) return;
  886. let arr = [];
  887. this.questionList[bindex].jsonStr.forEach(item => {
  888. if(item.checked) {
  889. arr.push(item.optionsId)
  890. }
  891. })
  892. if(!arr.length) {
  893. uni.showToast({
  894. title:'请选择答案',
  895. icon:'none'
  896. })
  897. return;
  898. }
  899. this.$set(this.questionList[bindex],'ques',arr)
  900. this.isDoOver()
  901. },
  902. /**
  903. * @param {Object} 多选确认
  904. */
  905. checkboxSubmitChild(bindex,ansIndex) {
  906. if(this.questionList[bindex].ques[ansIndex]) return;
  907. let arr = [];
  908. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  909. if(item.checked) {
  910. arr.push(item.optionsId)
  911. }
  912. })
  913. if(!arr.length) {
  914. uni.showToast({
  915. title:'请选择答案',
  916. icon:'none'
  917. })
  918. return;
  919. }
  920. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  921. this.isDoOver()
  922. },
  923. judgeSelect(index,bindex) {
  924. if(this.questionList[bindex].ques) return;
  925. this.$set(this.questionList[bindex],'ques',index+'')
  926. this.isDoOver()
  927. },
  928. judgeSelectChild(ansindex,childindex,bindex) {
  929. if(this.questionList[bindex].ques[ansindex]) return;
  930. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  931. this.isDoOver()
  932. },
  933. /**
  934. * 立即离开并交卷
  935. */
  936. leaveNow() {
  937. this.needBack = false;
  938. this.isSubmit = true;
  939. uni.navigateBack({
  940. delta: 1
  941. });
  942. let score = 0; //计算总分
  943. let reportStatus = 0;
  944. let number = 0; //做对的题目数量
  945. let doQuestionNum = 0; //做过的题目数量
  946. let allScore = 0; //总分
  947. let passScore = 0;
  948. let doWrongQuestionIds = []; //错题和未做题id(客观题)
  949. let doQuestionIds = []; //做过的题目id
  950. let rightQuestionIds = []; //做对的题目id
  951. this.questionList.forEach((item, index) => {
  952. // passScore = item.passScore
  953. if (item.type == 1) {
  954. //正确
  955. if (item.ques == item.ans) {
  956. item.scoreResult = item.score;
  957. score += item.score;
  958. number++;
  959. rightQuestionIds.push(item.questionId)
  960. } else { //错误
  961. item.scoreResult = 0;
  962. doWrongQuestionIds.push(item.questionId)
  963. }
  964. allScore += item.score;
  965. if (item.ques) {
  966. doQuestionNum++;
  967. doQuestionIds.push(item.questionId)
  968. }
  969. } else if (item.type == 2) {
  970. let isRight =
  971. item.ans &&
  972. item.ans.every((quesItem, quesIndex) => {
  973. if(item.ques) {
  974. return item.ques[quesIndex] == item.ans[quesIndex];
  975. } else {
  976. return false;
  977. }
  978. });
  979. if (isRight) {
  980. score += item.score;
  981. number++;
  982. item.scoreResult = item.score;
  983. rightQuestionIds.push(item.questionId)
  984. } else {
  985. let checkboxScore = item.score; //获取单题总分数
  986. item.ques && item.ques.forEach((ques,quesIndex) => {
  987. //选错一个全扣
  988. if(item.ques) {
  989. if(item.ans.indexOf(item.ques[quesIndex]) == -1) {
  990. checkboxScore = 0;
  991. }
  992. } else {
  993. checkboxScore = 0;
  994. }
  995. })
  996. console.log(checkboxScore)
  997. //没选错
  998. if(checkboxScore) {
  999. item.ans.forEach((ans,quesIndex) => {
  1000. //漏选扣一部分
  1001. if(item.ques) {
  1002. if(item.ques.indexOf(item.ans[quesIndex]) == -1) {
  1003. checkboxScore = item.partScore;
  1004. }
  1005. } else {
  1006. checkboxScore = 0;
  1007. }
  1008. })
  1009. }
  1010. if(checkboxScore <= 0) { //0分
  1011. item.scoreResult = 0;
  1012. doWrongQuestionIds.push(item.questionId)
  1013. } else { //部分分
  1014. number++;
  1015. item.scoreResult = checkboxScore;
  1016. score += checkboxScore;
  1017. rightQuestionIds.push(item.questionId)
  1018. }
  1019. }
  1020. allScore += item.score;
  1021. if (item.ques && item.ques.length) {
  1022. doQuestionNum++;
  1023. doQuestionIds.push(item.questionId)
  1024. }
  1025. } else if (item.type == 3) {
  1026. if (item.ques == item.ans) {
  1027. item.scoreResult = item.score;
  1028. score += item.score;
  1029. number++;
  1030. rightQuestionIds.push(item.questionId)
  1031. } else {
  1032. item.scoreResult = 0;
  1033. doWrongQuestionIds.push(item.questionId)
  1034. }
  1035. allScore += item.score;
  1036. if (item.ques) {
  1037. doQuestionNum++;
  1038. doQuestionIds.push(item.questionId)
  1039. }
  1040. } else if (item.type == 4) {
  1041. if (item.ques && item.ques.length) {
  1042. doQuestionNum++;
  1043. }
  1044. } else if (item.type == 5) {
  1045. if (item.ques) {
  1046. doQuestionNum++;
  1047. }
  1048. }
  1049. });
  1050. //大于60分及格
  1051. if(score >= 60) {
  1052. reportStatus = 1
  1053. } else {
  1054. reportStatus = 0
  1055. }
  1056. //交卷
  1057. this.$api
  1058. .examRecordEdit({
  1059. examId: this.id,
  1060. goodsId: this.goodsId,
  1061. reportStatus:reportStatus,
  1062. recordId: this.recordId,
  1063. rightQuestionNum: number,
  1064. status: 1,
  1065. moduleExamId:this.moduleId || 0,
  1066. chapterExamId:this.chapterId || 0,
  1067. doQuestionIds:doQuestionIds.join(','),
  1068. rightQuestionIds:rightQuestionIds.join(','),
  1069. doQuestionNum: doQuestionNum,
  1070. performance: score,
  1071. totalScore: allScore,
  1072. examTime: parseInt(this.allTimes),
  1073. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1074. historyExamJson: JSON.stringify(this.questionList)
  1075. })
  1076. .then(res => {
  1077. this.isSubmit = true;
  1078. if (res.data.code == 200) {
  1079. }
  1080. });
  1081. //错题集id提交(客观题)
  1082. this.$api.examWrongRecord({
  1083. moduleExamId:this.moduleId || 0,
  1084. chapterExamId:this.chapterId || 0,
  1085. examId: this.id,
  1086. goodsId: this.goodsId,
  1087. questionIds: doWrongQuestionIds,
  1088. recordId: this.recordId
  1089. }).then(res => {
  1090. });
  1091. },
  1092. openFooterTab() {
  1093. this.show = true;
  1094. },
  1095. hideDialog() {
  1096. this.showDialog = false
  1097. },
  1098. changeIndex(index) {
  1099. this.current = index
  1100. },
  1101. swiperChange(e) {
  1102. this.current = e.detail.current;
  1103. },
  1104. deleteImg(imgIndex,bankIndex) {
  1105. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  1106. },
  1107. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  1108. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  1109. },
  1110. chooseImg(bankindex) {
  1111. uni.chooseImage({
  1112. count: 1, //默认9
  1113. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1114. sourceType: ['album','camera'], //从相册选择
  1115. success: (res) => {
  1116. let self = this;
  1117. // console.log(JSON.stringify(res.tempFilePaths));
  1118. let img = res.tempFilePaths[0];
  1119. uni.getImageInfo({
  1120. src: img,
  1121. success: async res => {
  1122. let canvasWidth = res.width; //图片原始长宽
  1123. let canvasHeight = res.height;
  1124. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1125. uni.compressImage({
  1126. src: img,
  1127. quality: 75,
  1128. width: '50%',
  1129. height: '50%',
  1130. success: async rest => {
  1131. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1132. this.questionList[bankindex].ansText.imageList.push(dir)
  1133. }
  1134. });
  1135. } else {
  1136. const dir = await self.uploadFile(img, 0);
  1137. this.questionList[bankindex].ansText.imageList.push(dir)
  1138. }
  1139. }
  1140. });
  1141. }
  1142. })
  1143. },
  1144. chooseImgChild(bankindex,ansindex) {
  1145. uni.chooseImage({
  1146. count: 1, //默认9
  1147. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  1148. sourceType: ['album','camera'], //从相册选择
  1149. success: (res) => {
  1150. let self = this;
  1151. // console.log(JSON.stringify(res.tempFilePaths));
  1152. let img = res.tempFilePaths[0];
  1153. uni.getImageInfo({
  1154. src: img,
  1155. success: async res => {
  1156. let canvasWidth = res.width; //图片原始长宽
  1157. let canvasHeight = res.height;
  1158. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1159. uni.compressImage({
  1160. src: img,
  1161. quality: 75,
  1162. width: '50%',
  1163. height: '50%',
  1164. success: async rest => {
  1165. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1166. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1167. }
  1168. });
  1169. } else {
  1170. const dir = await self.uploadFile(img, 0);
  1171. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  1172. }
  1173. }
  1174. });
  1175. }
  1176. })
  1177. },
  1178. uploadFile(options, int) {
  1179. var self = this;
  1180. return new Promise((resolve, reject) => {
  1181. var data = {
  1182. imageStatus: int
  1183. };
  1184. self.$api.aliyunpolicy(data).then(res => {
  1185. console.log(res.data,6)
  1186. if(res.data.code!=200){
  1187. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  1188. return
  1189. }
  1190. var ossToken = res.data.data.resultContent;
  1191. if(ossToken.host==null||ossToken.host==undefined){
  1192. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  1193. return
  1194. }
  1195. uni.uploadFile({
  1196. url: ossToken.host,
  1197. name: 'file',
  1198. filePath: options,
  1199. fileType: 'image',
  1200. header: {
  1201. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  1202. },
  1203. formData: {
  1204. key: ossToken.dir,
  1205. OSSAccessKeyId: ossToken.accessid,
  1206. policy: ossToken.policy,
  1207. Signature: ossToken.signature,
  1208. callback: ossToken.callback,
  1209. success_action_status: 200
  1210. },
  1211. success: result => {
  1212. if (result.statusCode === 200) {
  1213. resolve(ossToken.dir);
  1214. } else {
  1215. uni.showToast({
  1216. title: '上传失败',
  1217. icon: 'none'
  1218. });
  1219. return;
  1220. }
  1221. },
  1222. fail: error => {
  1223. uni.showToast({
  1224. title: '上传接口报错'+error,
  1225. icon: 'none'
  1226. });
  1227. return;
  1228. }
  1229. });
  1230. });
  1231. });
  1232. },
  1233. submitAns(bankindex) {
  1234. console.log(this.questionList[bankindex])
  1235. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  1236. uni.showToast({
  1237. title: '请输入内容或上传图片',
  1238. duration: 2000,
  1239. icon:'none'
  1240. });
  1241. return
  1242. }
  1243. this.$set(this.questionList[bankindex],'ques',{
  1244. imageList:this.questionList[bankindex].ansText.imageList,
  1245. text:this.questionList[bankindex].ansText.text,
  1246. })
  1247. this.isDoOver()
  1248. },
  1249. submitAnsChild(bankindex,ansindex) {
  1250. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  1251. uni.showToast({
  1252. title: '请输入内容或上传图片',
  1253. duration: 2000,
  1254. icon:'none'
  1255. });
  1256. return
  1257. }
  1258. this.$set(this.questionList[bankindex].ques,ansindex,{
  1259. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1260. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  1261. })
  1262. this.isDoOver()
  1263. },
  1264. isRight(item,index) {
  1265. //单选
  1266. if(this.questionList[index].ques) {
  1267. if(item.type == 1) {
  1268. return this.questionList[index].ques == this.questionList[index].ans;
  1269. //多选
  1270. } else if(item.type == 2) {
  1271. //每一项都相等
  1272. return this.questionList[index].ques.every((item,i) => {
  1273. console.log(item == this.questionList[index].ans[i])
  1274. return item == this.questionList[index].ans[i];
  1275. })
  1276. //判断
  1277. } else if(item.type == 3) {
  1278. return this.questionList[index].ques == this.questionList[index].ans;
  1279. } else {
  1280. return false;
  1281. }
  1282. } else {
  1283. return false;
  1284. }
  1285. },
  1286. right(bankIndex,ansIndex,option) {
  1287. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1288. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  1289. return true
  1290. } else {
  1291. return false;
  1292. }
  1293. } else {
  1294. return false;
  1295. }
  1296. },
  1297. wrong(bankIndex,ansIndex,option) {
  1298. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  1299. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  1300. return true;
  1301. } else {
  1302. return false;
  1303. }
  1304. } else {
  1305. return false;
  1306. }
  1307. },
  1308. isWrong(item,index) {
  1309. if(this.questionList[index].ques) {
  1310. //单选
  1311. if(item.type == 1) {
  1312. return this.questionList[index].ques != this.questionList[index].ans;
  1313. //多选
  1314. } else if(item.type == 2) {
  1315. //每一项都相等
  1316. return this.questionList[index].ques.some((item,i) => {
  1317. return item != this.questionList[index].ans[i];
  1318. })
  1319. //判断
  1320. } else if(item.type == 3) {
  1321. return this.questionList[index].ques != this.questionList[index].ans;
  1322. } else {
  1323. return false;
  1324. }
  1325. } else {
  1326. return false;
  1327. }
  1328. },
  1329. tabSelect(index,bankindex) {
  1330. this.$set(this.questionList[bankindex],'current',index)
  1331. },
  1332. }
  1333. };
  1334. </script>
  1335. <style lang="scss" scoped>
  1336. .questionBank {
  1337. width:100%;
  1338. height:100vh;
  1339. display: flex;
  1340. flex-direction: column;
  1341. }
  1342. .swiper {
  1343. width:100%;
  1344. flex:1;
  1345. }
  1346. .lisSty {
  1347. margin-bottom: 16rpx;
  1348. display: flex;
  1349. align-items: center;
  1350. .flex_auto {
  1351. flex:1;
  1352. }
  1353. }
  1354. .activeTI {
  1355. vertical-align: middle;
  1356. display: inline-block;
  1357. border: 1rpx solid #eee;
  1358. border-radius: 50rpx;
  1359. height: 48rpx;
  1360. line-height: 46rpx;
  1361. text-align: center;
  1362. width: 48rpx;
  1363. margin-right: 15rpx;
  1364. color: #666;
  1365. font-size: 30rpx;
  1366. &.right {
  1367. color:#fff;
  1368. background:#36C75A;
  1369. }
  1370. &.wrong {
  1371. color:#fff;
  1372. background:#FF3B30;
  1373. }
  1374. &.checked {
  1375. color:#fff;
  1376. background:#007AFF;
  1377. }
  1378. }
  1379. .submit_checkbox {
  1380. position:fixed;
  1381. left:0;
  1382. right:0;
  1383. bottom:120rpx;
  1384. margin: 20rpx auto;
  1385. left:0;
  1386. right:0;
  1387. bottom:120rpx;
  1388. margin: 20rpx auto;
  1389. width: 526rpx;
  1390. height: 80rpx;
  1391. background: rgba(0, 122, 255, 1);
  1392. color:#fff;
  1393. text-align: center;
  1394. line-height: 80rpx;
  1395. font-size: 30rpx;
  1396. border-radius: 40rpx;
  1397. &.disabled {
  1398. opacity: 0.6;
  1399. }
  1400. }
  1401. .titles {
  1402. overflow: hidden;
  1403. margin-bottom: 24rpx;
  1404. }
  1405. .titBox {
  1406. padding: 41rpx 25rpx 24rpx 25rpx;
  1407. }
  1408. .titBox_title {
  1409. padding: 21rpx;
  1410. }
  1411. .tabs {
  1412. margin:10rpx;
  1413. display: flex;
  1414. .tab {
  1415. margin: 0 4rpx;
  1416. padding:10rpx 13rpx;
  1417. text-align: center;
  1418. color: #007aff;
  1419. font-size: 28rpx;
  1420. border-radius: 16rpx;
  1421. background:#fff;
  1422. &.current {
  1423. color:#fff;
  1424. background: #007AFF;
  1425. }
  1426. }
  1427. }
  1428. .ans {
  1429. margin:8rpx 8rpx 8rpx;
  1430. .ans_input {
  1431. border-radius: 16rpx;
  1432. background:#fff;
  1433. .top {
  1434. border-bottom:1rpx solid #EEEEEE;
  1435. padding: 16rpx;
  1436. display: flex;
  1437. align-items: center;
  1438. .icon {
  1439. margin-right:20rpx;
  1440. width: 40rpx;
  1441. height: 38rpx;
  1442. }
  1443. .progress {
  1444. flex:1;
  1445. }
  1446. .submit {
  1447. width: 168rpx;
  1448. height: 48rpx;
  1449. line-height: 48rpx;
  1450. text-align: center;
  1451. color:#fff;
  1452. font-size: 30rpx;
  1453. background: #007AFF;
  1454. border-radius: 24rpx;
  1455. &.disabled {
  1456. opacity: 0.6;
  1457. }
  1458. }
  1459. }
  1460. .textarea {
  1461. textarea {
  1462. width:100%;
  1463. height:287rpx;
  1464. padding:10rpx;
  1465. }
  1466. }
  1467. .imgs {
  1468. overflow: hidden;
  1469. display: flex;
  1470. width:100%;
  1471. .img {
  1472. width: 104rpx;
  1473. height: 104rpx;
  1474. border-radius: 8rpx;
  1475. position:relative;
  1476. margin:20rpx;
  1477. text {
  1478. position:absolute;
  1479. right:-15rpx;
  1480. top:-15rpx;
  1481. width:30rpx;
  1482. height:30rpx;
  1483. text-align: center;
  1484. line-height: 30rpx;
  1485. color:#fff;
  1486. background:#FF3B30;
  1487. border-radius:50%;
  1488. }
  1489. image {
  1490. width:100%;
  1491. height:100%;
  1492. }
  1493. }
  1494. }
  1495. }
  1496. .ans_submit {
  1497. padding:16rpx;
  1498. border-radius: 16rpx;
  1499. background:#fff;
  1500. .imgs {
  1501. overflow: hidden;
  1502. display: flex;
  1503. width:100%;
  1504. .img {
  1505. width: 104rpx;
  1506. height: 104rpx;
  1507. border-radius: 8rpx;
  1508. position:relative;
  1509. margin:20rpx;
  1510. image {
  1511. width:100%;
  1512. height:100%;
  1513. }
  1514. }
  1515. }
  1516. }
  1517. }
  1518. .leftLetters {
  1519. display: flex;
  1520. align-items: center;
  1521. width: 220rpx;
  1522. .btnType {
  1523. padding: 5rpx 10rpx;
  1524. border: 1rpx solid #007aff;
  1525. border-radius: 10rpx;
  1526. background-color: rgba(0, 122, 255, 0.1);
  1527. font-size: 28rpx;
  1528. color: #007aff;
  1529. margin-right: 15rpx;
  1530. }
  1531. }
  1532. .firstLetter {
  1533. display: flex;
  1534. justify-content: space-between;
  1535. align-items: center;
  1536. margin-bottom: 30rpx;
  1537. }
  1538. .popupView {
  1539. height: 100%;
  1540. padding-bottom: 100rpx;
  1541. .popupTops {
  1542. height: 77rpx;
  1543. border-bottom: 1rpx solid #eee;
  1544. text-align: center;
  1545. line-height: 77rpx;
  1546. font-size: 24rpx;
  1547. color: #999;
  1548. position: relative;
  1549. .topIcon {
  1550. position: absolute;
  1551. top: 10rpx;
  1552. left: 50%;
  1553. transform: translateX(-50%);
  1554. width: 80rpx;
  1555. height: 8rpx;
  1556. background-color: #999;
  1557. border-radius: 4rpx;
  1558. }
  1559. }
  1560. .popupContent {
  1561. }
  1562. }
  1563. .pageContent {
  1564. position:relative;
  1565. background-color: #eaeef1;
  1566. height: 100%;
  1567. overflow-y: scroll;
  1568. padding-top: 8rpx;
  1569. padding-bottom: 100rpx;
  1570. }
  1571. .pad_8 {
  1572. background-color: #fff;
  1573. margin: 0rpx 8rpx 8rpx;
  1574. border-radius: 16rpx;
  1575. &.no-margin {
  1576. margin-top:-16rpx;
  1577. border-radius: 0 0 16rpx 16rpx;
  1578. }
  1579. }
  1580. .answer {
  1581. height: 80rpx;
  1582. line-height: 80rpx;
  1583. padding: 0rpx 24rpx;
  1584. display: flex;
  1585. align-items: center;
  1586. justify-content: space-between;
  1587. color: #666;
  1588. font-size: 30rpx;
  1589. }
  1590. .footer_btn {
  1591. background-color: #fff;
  1592. z-index: 10078;
  1593. position: fixed;
  1594. bottom: 0rpx;
  1595. display: flex;
  1596. align-items: center;
  1597. justify-content: space-between;
  1598. width: 100%;
  1599. height: 98rpx;
  1600. padding: 0rpx 38rpx;
  1601. border-top: 1rpx solid #eee;
  1602. .flex_center {
  1603. flex:1;
  1604. display: flex;
  1605. justify-content: center;
  1606. align-items: center;
  1607. flex-direction: column;
  1608. margin:0 200rpx;
  1609. font-size: 24rpx;
  1610. color: #999999;
  1611. .up-icon {
  1612. margin-bottom:18rpx;
  1613. width:100%;
  1614. display: flex;
  1615. justify-content: center;
  1616. image {
  1617. width:58rpx;
  1618. height:21rpx;
  1619. }
  1620. }
  1621. }
  1622. .collect {
  1623. visibility: hidden;
  1624. width:100rpx;
  1625. &.show {
  1626. visibility: visible;
  1627. }
  1628. >view {
  1629. display: flex;
  1630. flex-direction: column;
  1631. align-items: center;
  1632. justify-content: center;
  1633. image {
  1634. width:32rpx;
  1635. height:32rpx;
  1636. margin-bottom:6rpx;
  1637. }
  1638. view {
  1639. font-size: 24rpx;
  1640. color: #999999;
  1641. }
  1642. }
  1643. }
  1644. }
  1645. .boxSty {
  1646. padding: 44rpx 41rpx 0rpx;
  1647. }
  1648. .liListSty {
  1649. border:1rpx solid #EEEEEE;
  1650. width: 88rpx;
  1651. height: 88rpx;
  1652. border-radius: 32rpx;
  1653. text-align: center;
  1654. line-height: 88rpx;
  1655. color: #333;
  1656. font-size: 32rpx;
  1657. float: left;
  1658. margin: 20rpx 23rpx;
  1659. &.isRight {
  1660. border:1rpx solid #EEEEEE;
  1661. color:#fff;
  1662. background: #36C75A;
  1663. }
  1664. &.isWrong {
  1665. border:1rpx solid #EEEEEE;
  1666. color:#fff;
  1667. background: #FF3B30;
  1668. }
  1669. }
  1670. .answerInfos {
  1671. padding: 25rpx 25rpx 25rpx 23rpx;
  1672. }
  1673. .answerTitle {
  1674. margin-bottom: 28rpx;
  1675. color: #666;
  1676. font-size: 30rpx;
  1677. }
  1678. .answerContent {
  1679. font-size: 30rpx;
  1680. color: #666;
  1681. }
  1682. .textChild {
  1683. display: inline-block;
  1684. vertical-align: middle;
  1685. }
  1686. .dialog {
  1687. position: fixed;
  1688. left:0;
  1689. top:0;
  1690. width:100%;
  1691. height:100%;
  1692. background-color: rgba(0,0,0,0.8);
  1693. display: flex;
  1694. flex-direction: column;
  1695. align-items: center;
  1696. justify-content: center;
  1697. z-index: 20000;
  1698. .pointer {
  1699. width:338rpx;
  1700. height:240rpx;
  1701. }
  1702. .text {
  1703. font-size: 32rpx;
  1704. color: #FFFFFF;
  1705. text-align: center;
  1706. }
  1707. .btn {
  1708. width: 242rpx;
  1709. height: 82rpx;
  1710. border: 2rpx solid #FFFFFF;
  1711. border-radius: 16rpx;
  1712. text-align: center;
  1713. line-height: 82rpx;
  1714. margin:41rpx auto;
  1715. color:#fff;
  1716. font-size: 32rpx;
  1717. }
  1718. }
  1719. .popboxs {
  1720. width: 100%;
  1721. height: 100%;
  1722. display: flex;
  1723. flex-direction: column;
  1724. align-items: center;
  1725. }
  1726. .classTops {
  1727. flex-shrink: 0;
  1728. padding: 39rpx 0rpx 4rpx;
  1729. font-weight: bold;
  1730. color: #333;
  1731. font-size: 30rpx;
  1732. }
  1733. .textStys {
  1734. width: 100%;
  1735. flex: 1;
  1736. padding: 36rpx;
  1737. }
  1738. .classFootsty {
  1739. flex-shrink: 0;
  1740. display: flex;
  1741. align-items: center;
  1742. justify-content: center;
  1743. padding: 10rpx 0rpx 40rpx;
  1744. .btnsty {
  1745. width: 200rpx;
  1746. height: 80rpx;
  1747. border-radius: 40rpx;
  1748. font-weight: bold;
  1749. font-size: 30rpx;
  1750. text-align: center;
  1751. line-height: 80rpx;
  1752. }
  1753. .btns1 {
  1754. background-color: #f5f5f5;
  1755. color: #007aff;
  1756. }
  1757. .btns2 {
  1758. margin-left: 40rpx;
  1759. background-color: #007aff;
  1760. color: #ffffff;
  1761. }
  1762. }
  1763. </style>