questionBankContinue.vue 63 KB

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