questionBankExplainDetail.vue 62 KB

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