questionBank.vue 52 KB

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