questionBankContinue.vue 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148
  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. /**
  1194. * @param {Object} 多选确认
  1195. */
  1196. checkboxSubmitChild(bindex, ansIndex) {
  1197. if (this.questionList[bindex].ques[ansIndex]) return;
  1198. let arr = [];
  1199. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  1200. (item) => {
  1201. if (item.checked) {
  1202. arr.push(item.optionsId);
  1203. }
  1204. }
  1205. );
  1206. if (!arr.length) {
  1207. uni.showToast({
  1208. title: "请选择答案",
  1209. icon: "none",
  1210. });
  1211. return;
  1212. }
  1213. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1214. this.isDoOver();
  1215. },
  1216. judgeSelect(index, bindex) {
  1217. if (this.questionList[bindex].ques) return;
  1218. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  1219. console.log(
  1220. "this.questionList[bindex]",
  1221. this.questionList[bindex].ques,
  1222. this.questionList[bindex]
  1223. );
  1224. this.isDoOver();
  1225. },
  1226. judgeSelectChild(ansindex, childindex, bindex) {
  1227. if (this.questionList[bindex].ques[ansindex]) return;
  1228. this.$set(
  1229. this.questionList[bindex].ques,
  1230. ansindex,
  1231. childindex == 0 ? "1" : "0"
  1232. );
  1233. this.isDoOver();
  1234. },
  1235. /**
  1236. * 立即离开并交卷
  1237. */
  1238. leaveNow() {
  1239. this.needBack = false;
  1240. this.isSubmit = true;
  1241. this.submit(false)
  1242. uni.navigateBack({
  1243. delta: 1,
  1244. });
  1245. },
  1246. openFooterTab() {
  1247. this.show = true;
  1248. },
  1249. hideDialog() {
  1250. this.showDialog = false;
  1251. },
  1252. changeIndex(index) {
  1253. this.current = index;
  1254. },
  1255. swiperChange(e) {
  1256. this.current = e.detail.current;
  1257. this.getCollectInfo(this.current);
  1258. },
  1259. deleteImg(imgIndex, bankIndex) {
  1260. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1261. },
  1262. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1263. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  1264. imgIndex,
  1265. 1
  1266. );
  1267. },
  1268. chooseImg(bankindex) {
  1269. uni.chooseImage({
  1270. count: 1, //默认9
  1271. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  1272. sourceType: ["album", "camera"], //从相册选择
  1273. success: (res) => {
  1274. let self = this;
  1275. // console.log(JSON.stringify(res.tempFilePaths));
  1276. let img = res.tempFilePaths[0];
  1277. uni.getImageInfo({
  1278. src: img,
  1279. success: async (res) => {
  1280. let canvasWidth = res.width; //图片原始长宽
  1281. let canvasHeight = res.height;
  1282. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1283. uni.compressImage({
  1284. src: img,
  1285. quality: 75,
  1286. width: "50%",
  1287. height: "50%",
  1288. success: async (rest) => {
  1289. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1290. this.questionList[bankindex].ansText.imageList.push(dir);
  1291. },
  1292. });
  1293. } else {
  1294. const dir = await self.uploadFile(img, 0);
  1295. this.questionList[bankindex].ansText.imageList.push(dir);
  1296. }
  1297. },
  1298. });
  1299. },
  1300. });
  1301. },
  1302. chooseImgChild(bankindex, ansindex) {
  1303. uni.chooseImage({
  1304. count: 1, //默认9
  1305. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  1306. sourceType: ["album", "camera"], //从相册选择
  1307. success: (res) => {
  1308. let self = this;
  1309. // console.log(JSON.stringify(res.tempFilePaths));
  1310. let img = res.tempFilePaths[0];
  1311. uni.getImageInfo({
  1312. src: img,
  1313. success: async (res) => {
  1314. let canvasWidth = res.width; //图片原始长宽
  1315. let canvasHeight = res.height;
  1316. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1317. uni.compressImage({
  1318. src: img,
  1319. quality: 75,
  1320. width: "50%",
  1321. height: "50%",
  1322. success: async (rest) => {
  1323. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1324. this.questionList[bankindex].jsonStr[
  1325. ansindex
  1326. ].ansText.imageList.push(dir);
  1327. },
  1328. });
  1329. } else {
  1330. const dir = await self.uploadFile(img, 0);
  1331. this.questionList[bankindex].jsonStr[
  1332. ansindex
  1333. ].ansText.imageList.push(dir);
  1334. }
  1335. },
  1336. });
  1337. },
  1338. });
  1339. },
  1340. uploadFile(options, int) {
  1341. var self = this;
  1342. return new Promise((resolve, reject) => {
  1343. var data = {
  1344. orderGoodsId: this.orderGoodsId,
  1345. imageStatus: int,
  1346. };
  1347. self.$api.aliyunpolicy(data).then((res) => {
  1348. console.log(res.data, 6);
  1349. if (res.data.code != 200) {
  1350. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  1351. return;
  1352. }
  1353. var ossToken = res.data.data.resultContent;
  1354. if (ossToken.host == null || ossToken.host == undefined) {
  1355. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  1356. return;
  1357. }
  1358. uni.uploadFile({
  1359. url: ossToken.host,
  1360. name: "file",
  1361. filePath: options,
  1362. fileType: "image",
  1363. header: {
  1364. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1365. },
  1366. formData: {
  1367. key: ossToken.dir,
  1368. OSSAccessKeyId: ossToken.accessid,
  1369. policy: ossToken.policy,
  1370. Signature: ossToken.signature,
  1371. callback: ossToken.callback,
  1372. success_action_status: 200,
  1373. },
  1374. success: (result) => {
  1375. // if (result.statusCode === 200) {
  1376. resolve(ossToken.dir);
  1377. // } else {
  1378. // uni.showToast({
  1379. // title: "上传失败",
  1380. // icon: "none",
  1381. // });
  1382. // return;
  1383. // }
  1384. },
  1385. fail: (error) => {
  1386. uni.showToast({
  1387. title: "上传接口报错" + error,
  1388. icon: "none",
  1389. });
  1390. return;
  1391. },
  1392. });
  1393. });
  1394. });
  1395. },
  1396. submitAns(bankindex) {
  1397. console.log(this.questionList[bankindex]);
  1398. if (
  1399. !this.questionList[bankindex].ansText.text &&
  1400. !this.questionList[bankindex].ansText.imageList.length
  1401. ) {
  1402. uni.showToast({
  1403. title: "请输入内容或上传图片",
  1404. duration: 2000,
  1405. icon: "none",
  1406. });
  1407. return;
  1408. }
  1409. this.$set(this.questionList[bankindex], "ques", {
  1410. imageList: this.questionList[bankindex].ansText.imageList,
  1411. text: this.questionList[bankindex].ansText.text,
  1412. });
  1413. this.isDoOver();
  1414. },
  1415. submitAnsChild(bankindex, ansindex) {
  1416. if (
  1417. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  1418. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  1419. ) {
  1420. uni.showToast({
  1421. title: "请输入内容或上传图片",
  1422. duration: 2000,
  1423. icon: "none",
  1424. });
  1425. return;
  1426. }
  1427. this.$set(this.questionList[bankindex].ques, ansindex, {
  1428. imageList:
  1429. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  1430. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  1431. });
  1432. this.isDoOver();
  1433. },
  1434. isRight(item, index) {
  1435. //单选
  1436. if (this.questionList[index].ques) {
  1437. if (item.type == 1) {
  1438. return this.questionList[index].ques == this.questionList[index].ans;
  1439. //多选
  1440. } else if (item.type == 2) {
  1441. //每一项都相等
  1442. return this.questionList[index].ans.every((item, i) => {
  1443. return item == this.questionList[index].ques[i];
  1444. });
  1445. //判断
  1446. } else if (item.type == 3) {
  1447. return this.questionList[index].ques == this.questionList[index].ans;
  1448. } else {
  1449. return false;
  1450. }
  1451. } else {
  1452. return false;
  1453. }
  1454. },
  1455. right(bankIndex, ansIndex, option) {
  1456. if (
  1457. this.questionList[bankIndex].ques[ansIndex] &&
  1458. this.questionList[bankIndex].ans[ansIndex]
  1459. ) {
  1460. if (
  1461. this.questionList[bankIndex].ques[ansIndex].indexOf(
  1462. option.optionsId
  1463. ) != -1 ||
  1464. this.questionList[bankIndex].ans[ansIndex].indexOf(
  1465. option.optionsId
  1466. ) != -1
  1467. ) {
  1468. return true;
  1469. } else {
  1470. return false;
  1471. }
  1472. } else {
  1473. return false;
  1474. }
  1475. },
  1476. wrong(bankIndex, ansIndex, option) {
  1477. if (
  1478. this.questionList[bankIndex].ques[ansIndex] &&
  1479. this.questionList[bankIndex].ans[ansIndex]
  1480. ) {
  1481. if (
  1482. this.questionList[bankIndex].ques[ansIndex].indexOf(
  1483. option.optionsId
  1484. ) != -1 &&
  1485. this.questionList[bankIndex].ans[ansIndex].indexOf(
  1486. option.optionsId
  1487. ) == -1
  1488. ) {
  1489. return true;
  1490. } else {
  1491. return false;
  1492. }
  1493. } else {
  1494. return false;
  1495. }
  1496. },
  1497. isWrong(item, index) {
  1498. if (this.questionList[index].ques) {
  1499. //单选
  1500. if (item.type == 1) {
  1501. return this.questionList[index].ques != this.questionList[index].ans;
  1502. //多选
  1503. } else if (item.type == 2) {
  1504. //每一项都相等
  1505. return this.questionList[index].ques.some((item, i) => {
  1506. return this.questionList[index].ans.indexOf(item) == -1;
  1507. });
  1508. //判断
  1509. } else if (item.type == 3) {
  1510. return this.questionList[index].ques != this.questionList[index].ans;
  1511. } else {
  1512. return false;
  1513. }
  1514. } else {
  1515. return false;
  1516. }
  1517. },
  1518. isPart(item, index) {
  1519. if (this.questionList[index].ques) {
  1520. if (item.type == 2) {
  1521. let isWrong = this.questionList[index].ques.some((item, i) => {
  1522. return this.questionList[index].ans.indexOf(item) == -1;
  1523. });
  1524. let isRight = this.questionList[index].ans.every((item, i) => {
  1525. return item == this.questionList[index].ques[i];
  1526. });
  1527. if (!isRight && !isWrong) {
  1528. return true;
  1529. }
  1530. }
  1531. } else {
  1532. return false;
  1533. }
  1534. },
  1535. isOver(item, index) {
  1536. if (this.questionList[index].ques) {
  1537. if (item.type == 4) {
  1538. //案例题
  1539. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1540. if (
  1541. jsonItem.type == 1 ||
  1542. jsonItem.type == 2 ||
  1543. jsonItem.type == 3
  1544. ) {
  1545. if (item.ques[indexs]) {
  1546. return true;
  1547. } else {
  1548. return false;
  1549. }
  1550. } else if (jsonItem.type == 5) {
  1551. if (
  1552. item.ques[indexs] &&
  1553. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  1554. ) {
  1555. console.log("chil");
  1556. return true;
  1557. } else {
  1558. return false;
  1559. }
  1560. }
  1561. });
  1562. if (isOver) {
  1563. return true;
  1564. } else {
  1565. return false;
  1566. }
  1567. } else if (item.type == 5) {
  1568. //简答题
  1569. //每一项都相等
  1570. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  1571. return true;
  1572. }
  1573. //判断
  1574. } else {
  1575. return false;
  1576. }
  1577. } else {
  1578. return false;
  1579. }
  1580. },
  1581. tabSelect(index, bankindex) {
  1582. this.$set(this.questionList[bankindex], "current", index);
  1583. },
  1584. showPhoto(contentStr) {
  1585. if (contentStr && typeof contentStr == "string") {
  1586. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  1587. let strArr = contentStr.match(reg);
  1588. strArr.forEach((str, index) => {
  1589. strArr[index] = str.replace(reg, "$1");
  1590. });
  1591. // 预览图片
  1592. uni.previewImage({
  1593. urls: strArr,
  1594. longPressActions: {
  1595. itemList: ["发送给朋友", "保存图片", "收藏"],
  1596. success: function (data) {
  1597. console.log(
  1598. "选中了第" +
  1599. (data.tapIndex + 1) +
  1600. "个按钮,第" +
  1601. (data.index + 1) +
  1602. "张图片"
  1603. );
  1604. },
  1605. fail: function (err) {
  1606. console.log(err.errMsg);
  1607. },
  1608. },
  1609. });
  1610. }
  1611. },
  1612. },
  1613. };
  1614. </script>
  1615. <style lang="scss" scoped>
  1616. .questionBank {
  1617. width: 100%;
  1618. height: 100vh;
  1619. display: flex;
  1620. flex-direction: column;
  1621. }
  1622. .swiper {
  1623. width: 100%;
  1624. flex: 1;
  1625. }
  1626. .lisSty {
  1627. margin-bottom: 16rpx;
  1628. display: flex;
  1629. align-items: center;
  1630. .flex_auto {
  1631. word-break: break-all;
  1632. flex: 1;
  1633. }
  1634. }
  1635. .activeTI {
  1636. vertical-align: middle;
  1637. display: inline-block;
  1638. border: 1rpx solid #eee;
  1639. border-radius: 50rpx;
  1640. height: 48rpx;
  1641. line-height: 46rpx;
  1642. text-align: center;
  1643. width: 48rpx;
  1644. margin-right: 15rpx;
  1645. color: #666;
  1646. font-size: 30rpx;
  1647. &.right {
  1648. color: #fff;
  1649. background: #36c75a;
  1650. }
  1651. &.wrong {
  1652. color: #fff;
  1653. background: #ff3b30;
  1654. }
  1655. &.checked {
  1656. color: #fff;
  1657. background: #007aff;
  1658. }
  1659. }
  1660. .submit_checkbox {
  1661. position: fixed;
  1662. left: 0;
  1663. right: 0;
  1664. bottom: 120rpx;
  1665. margin: 20rpx auto;
  1666. left: 0;
  1667. right: 0;
  1668. bottom: 120rpx;
  1669. margin: 20rpx auto;
  1670. width: 526rpx;
  1671. height: 80rpx;
  1672. background: rgba(0, 122, 255, 1);
  1673. color: #fff;
  1674. text-align: center;
  1675. line-height: 80rpx;
  1676. font-size: 30rpx;
  1677. border-radius: 40rpx;
  1678. &.disabled {
  1679. opacity: 0.6;
  1680. }
  1681. }
  1682. .titles {
  1683. overflow: hidden;
  1684. margin-bottom: 24rpx;
  1685. }
  1686. .titBox {
  1687. padding: 41rpx 25rpx 24rpx 25rpx;
  1688. }
  1689. .titBox_title {
  1690. padding: 21rpx;
  1691. }
  1692. .tabs {
  1693. margin: 10rpx;
  1694. display: flex;
  1695. .tab {
  1696. margin: 0 4rpx;
  1697. padding: 10rpx 13rpx;
  1698. text-align: center;
  1699. color: #007aff;
  1700. font-size: 28rpx;
  1701. border-radius: 16rpx;
  1702. background: #fff;
  1703. &.current {
  1704. color: #fff;
  1705. background: #007aff;
  1706. }
  1707. }
  1708. }
  1709. .ans {
  1710. margin: 8rpx 8rpx 8rpx;
  1711. .ans_input {
  1712. border-radius: 16rpx;
  1713. background: #fff;
  1714. .top {
  1715. border-bottom: 1rpx solid #eeeeee;
  1716. padding: 16rpx;
  1717. display: flex;
  1718. align-items: center;
  1719. .icon {
  1720. margin-right: 20rpx;
  1721. width: 40rpx;
  1722. height: 38rpx;
  1723. }
  1724. .progress {
  1725. flex: 1;
  1726. }
  1727. .submit {
  1728. width: 168rpx;
  1729. height: 48rpx;
  1730. line-height: 48rpx;
  1731. text-align: center;
  1732. color: #fff;
  1733. font-size: 30rpx;
  1734. background: #007aff;
  1735. border-radius: 24rpx;
  1736. &.disabled {
  1737. opacity: 0.6;
  1738. }
  1739. }
  1740. }
  1741. .textarea {
  1742. textarea {
  1743. width: 100%;
  1744. height: 287rpx;
  1745. padding: 10rpx;
  1746. }
  1747. }
  1748. .imgs {
  1749. overflow: hidden;
  1750. display: flex;
  1751. width: 100%;
  1752. .img {
  1753. width: 104rpx;
  1754. height: 104rpx;
  1755. border-radius: 8rpx;
  1756. position: relative;
  1757. margin: 20rpx;
  1758. text {
  1759. position: absolute;
  1760. right: -15rpx;
  1761. top: -15rpx;
  1762. width: 30rpx;
  1763. height: 30rpx;
  1764. text-align: center;
  1765. line-height: 30rpx;
  1766. color: #fff;
  1767. background: #ff3b30;
  1768. border-radius: 50%;
  1769. }
  1770. image {
  1771. width: 100%;
  1772. height: 100%;
  1773. }
  1774. }
  1775. }
  1776. }
  1777. .ans_submit {
  1778. padding: 16rpx;
  1779. border-radius: 16rpx;
  1780. background: #fff;
  1781. .imgs {
  1782. overflow: hidden;
  1783. display: flex;
  1784. width: 100%;
  1785. .img {
  1786. width: 104rpx;
  1787. height: 104rpx;
  1788. border-radius: 8rpx;
  1789. position: relative;
  1790. margin: 20rpx;
  1791. image {
  1792. width: 100%;
  1793. height: 100%;
  1794. }
  1795. }
  1796. }
  1797. }
  1798. }
  1799. .leftLetters {
  1800. display: flex;
  1801. align-items: center;
  1802. width: 220rpx;
  1803. .btnType {
  1804. padding: 5rpx 10rpx;
  1805. border: 1rpx solid #007aff;
  1806. border-radius: 10rpx;
  1807. background-color: rgba(0, 122, 255, 0.1);
  1808. font-size: 28rpx;
  1809. color: #007aff;
  1810. margin-right: 15rpx;
  1811. }
  1812. }
  1813. .firstLetter {
  1814. display: flex;
  1815. justify-content: space-between;
  1816. align-items: center;
  1817. margin-bottom: 30rpx;
  1818. }
  1819. .popupView {
  1820. height: 100%;
  1821. padding-bottom: 100rpx;
  1822. .popupTops {
  1823. height: 77rpx;
  1824. border-bottom: 1rpx solid #eee;
  1825. text-align: center;
  1826. line-height: 77rpx;
  1827. font-size: 24rpx;
  1828. color: #999;
  1829. position: relative;
  1830. .topIcon {
  1831. position: absolute;
  1832. top: 10rpx;
  1833. left: 50%;
  1834. transform: translateX(-50%);
  1835. width: 80rpx;
  1836. height: 8rpx;
  1837. background-color: #999;
  1838. border-radius: 4rpx;
  1839. }
  1840. }
  1841. .popupContent {
  1842. }
  1843. }
  1844. .pageContent {
  1845. position: relative;
  1846. background-color: #eaeef1;
  1847. height: 100%;
  1848. overflow-y: scroll;
  1849. padding-top: 8rpx;
  1850. padding-bottom: 100rpx;
  1851. }
  1852. .pad_8 {
  1853. background-color: #fff;
  1854. margin: 0rpx 8rpx 8rpx;
  1855. border-radius: 16rpx;
  1856. &.no-margin {
  1857. margin-top: -16rpx;
  1858. border-radius: 0 0 16rpx 16rpx;
  1859. }
  1860. }
  1861. .answer {
  1862. height: 80rpx;
  1863. line-height: 80rpx;
  1864. padding: 0rpx 24rpx;
  1865. display: flex;
  1866. align-items: center;
  1867. justify-content: space-between;
  1868. color: #666;
  1869. font-size: 30rpx;
  1870. }
  1871. .footer_btn {
  1872. background-color: #fff;
  1873. z-index: 10078;
  1874. position: fixed;
  1875. bottom: 0rpx;
  1876. display: flex;
  1877. align-items: center;
  1878. justify-content: space-between;
  1879. width: 100%;
  1880. height: 98rpx;
  1881. padding: 0rpx 38rpx;
  1882. border-top: 1rpx solid #eee;
  1883. .flex_center {
  1884. flex: 1;
  1885. display: flex;
  1886. justify-content: center;
  1887. align-items: center;
  1888. flex-direction: column;
  1889. margin: 0 200rpx;
  1890. font-size: 24rpx;
  1891. color: #999999;
  1892. .up-icon {
  1893. margin-bottom: 18rpx;
  1894. width: 100%;
  1895. display: flex;
  1896. justify-content: center;
  1897. image {
  1898. width: 58rpx;
  1899. height: 21rpx;
  1900. }
  1901. }
  1902. }
  1903. .collect {
  1904. visibility: hidden;
  1905. width: 100rpx;
  1906. &.show {
  1907. visibility: visible;
  1908. }
  1909. > view {
  1910. display: flex;
  1911. flex-direction: column;
  1912. align-items: center;
  1913. justify-content: center;
  1914. image {
  1915. width: 32rpx;
  1916. height: 32rpx;
  1917. margin-bottom: 6rpx;
  1918. }
  1919. view {
  1920. font-size: 24rpx;
  1921. color: #999999;
  1922. }
  1923. }
  1924. }
  1925. }
  1926. .boxSty {
  1927. padding: 44rpx 41rpx 0rpx;
  1928. }
  1929. .liListSty {
  1930. border: 1rpx solid #eeeeee;
  1931. width: 88rpx;
  1932. height: 88rpx;
  1933. border-radius: 32rpx;
  1934. text-align: center;
  1935. line-height: 88rpx;
  1936. color: #333;
  1937. font-size: 32rpx;
  1938. float: left;
  1939. margin: 20rpx 23rpx;
  1940. &.isRight {
  1941. border: 1rpx solid #eeeeee;
  1942. color: #fff;
  1943. background: #36c75a;
  1944. }
  1945. &.isPart {
  1946. border: 1rpx solid #eeeeee;
  1947. color: #fff;
  1948. background: #ffc53d;
  1949. }
  1950. &.isWrong {
  1951. border: 1rpx solid #eeeeee;
  1952. color: #fff;
  1953. background: #ff3b30;
  1954. }
  1955. &.isOver {
  1956. border: 1rpx solid #eeeeee;
  1957. color: #fff;
  1958. background: blue;
  1959. }
  1960. }
  1961. .answerInfos {
  1962. padding: 25rpx 25rpx 25rpx 23rpx;
  1963. }
  1964. .answerTitle {
  1965. margin-bottom: 28rpx;
  1966. color: #666;
  1967. font-size: 30rpx;
  1968. }
  1969. .answerContent {
  1970. font-size: 30rpx;
  1971. color: #666;
  1972. }
  1973. .textChild {
  1974. display: inline-block;
  1975. vertical-align: middle;
  1976. }
  1977. .dialog {
  1978. position: fixed;
  1979. left: 0;
  1980. top: 0;
  1981. width: 100%;
  1982. height: 100%;
  1983. background-color: rgba(0, 0, 0, 0.8);
  1984. display: flex;
  1985. flex-direction: column;
  1986. align-items: center;
  1987. justify-content: center;
  1988. z-index: 20000;
  1989. .pointer {
  1990. width: 338rpx;
  1991. height: 240rpx;
  1992. }
  1993. .text {
  1994. font-size: 32rpx;
  1995. color: #ffffff;
  1996. text-align: center;
  1997. }
  1998. .btn {
  1999. width: 242rpx;
  2000. height: 82rpx;
  2001. border: 2rpx solid #ffffff;
  2002. border-radius: 16rpx;
  2003. text-align: center;
  2004. line-height: 82rpx;
  2005. margin: 41rpx auto;
  2006. color: #fff;
  2007. font-size: 32rpx;
  2008. }
  2009. }
  2010. .popboxs {
  2011. width: 100%;
  2012. height: 100%;
  2013. display: flex;
  2014. flex-direction: column;
  2015. align-items: center;
  2016. }
  2017. .classTops {
  2018. flex-shrink: 0;
  2019. padding: 39rpx 0rpx 4rpx;
  2020. font-weight: bold;
  2021. color: #333;
  2022. font-size: 30rpx;
  2023. }
  2024. .textStys {
  2025. width: 100%;
  2026. flex: 1;
  2027. padding: 36rpx;
  2028. }
  2029. .classFootsty {
  2030. flex-shrink: 0;
  2031. display: flex;
  2032. align-items: center;
  2033. justify-content: center;
  2034. padding: 10rpx 0rpx 40rpx;
  2035. .btnsty {
  2036. width: 200rpx;
  2037. height: 80rpx;
  2038. border-radius: 40rpx;
  2039. font-weight: bold;
  2040. font-size: 30rpx;
  2041. text-align: center;
  2042. line-height: 80rpx;
  2043. }
  2044. .btns1 {
  2045. background-color: #f5f5f5;
  2046. color: #007aff;
  2047. }
  2048. .btns2 {
  2049. margin-left: 40rpx;
  2050. background-color: #007aff;
  2051. color: #ffffff;
  2052. }
  2053. }
  2054. </style>