questionBankContinue.vue 63 KB

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