index.vue 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar
  4. @clickLeft="clickLeft"
  5. left-icon="back"
  6. ref="navbar"
  7. :statusBar="true"
  8. :title="examData.examName"
  9. ></uni-nav-bar>
  10. <swiper class="swiper" :current="current" @change="swiperChange">
  11. <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
  12. <view class="pageContent">
  13. <view class="pad_8 titBox">
  14. <view class="firstLetter">
  15. <view class="leftLetters">
  16. <view class="btnType">
  17. <text v-if="bank.type == 1">单选</text>
  18. <text v-if="bank.type == 2">多选</text>
  19. <text v-if="bank.type == 3">判断</text>
  20. <text v-if="bank.type == 4">案例</text>
  21. <text v-if="bank.type == 5">简答</text>
  22. </view>
  23. <text>{{ bankIndex + 1 }}/{{ questionList.length }}</text>
  24. </view>
  25. <view style="color: #666; font-size: 28rpx">{{
  26. countdown(lastTime)
  27. }}</view>
  28. </view>
  29. <view class="titles" @click="showPhoto(bank.content)"
  30. ><rich-text :nodes="bank.content"></rich-text
  31. ></view>
  32. </view>
  33. <template v-if="bank.type == 1">
  34. <view class="pad_8 titBox no-margin">
  35. <view v-if="!bank.ques">
  36. <view
  37. v-for="(item, index) in bank.jsonStr"
  38. :key="index"
  39. class="lisSty"
  40. @click="radioSelect(item.optionsId, bankIndex)"
  41. >
  42. <view class="activeTI">{{ ast[index] }}</view>
  43. <view class="flex_auto"
  44. >{{ item.content }}
  45. <view v-if="item.imgUrl">
  46. <image
  47. style="width: 600rpx"
  48. mode="widthFix"
  49. :src="$method.splitImgHost(item.imgUrl)"
  50. ></image>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-if="bank.ques">
  56. <view
  57. v-for="(item, index) in bank.jsonStr"
  58. :key="index"
  59. class="lisSty"
  60. @click="radioSelect(item.optionsId, bankIndex)"
  61. >
  62. <text
  63. :class="{
  64. right:
  65. bankType == 1 &&
  66. (item.optionsId == bank.ques ||
  67. item.optionsId == bank.ans),
  68. wrong:
  69. bankType == 1 &&
  70. item.optionsId == bank.ques &&
  71. bank.ques != bank.ans,
  72. user_choose: bankType == 2 && item.optionsId == bank.ques,
  73. }"
  74. class="activeTI"
  75. >
  76. {{ ast[index] }}
  77. </text>
  78. <view class="flex_auto">
  79. {{ item.content }}
  80. <view v-if="item.imgUrl">
  81. <image
  82. style="width: 600rpx"
  83. mode="widthFix"
  84. :src="$method.splitImgHost(item.imgUrl)"
  85. ></image>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view v-if="bankType == 1 && bank.ques">
  92. <view class="pad_8 answer">
  93. <view>题目答案:{{ ast[bank.ans - 1] }} </view>
  94. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  95. </view>
  96. <view class="pad_8 answerInfos">
  97. <view class="answerTitle">答案解析</view>
  98. <view class="answerContent"
  99. ><rich-text :nodes="bank.analysisContent"></rich-text
  100. ></view>
  101. </view>
  102. </view>
  103. </template>
  104. <template v-if="bank.type == 2">
  105. <view class="pad_8 titBox no-margin">
  106. <view v-if="!bank.ques">
  107. <view
  108. v-for="(item, index) in bank.jsonStr"
  109. :key="index"
  110. class="lisSty"
  111. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  112. >
  113. <view :class="{ checked: item.checked }" class="activeTI">{{
  114. ast[index]
  115. }}</view>
  116. <view class="flex_auto">
  117. {{ item.content }}
  118. <view v-if="item.imgUrl">
  119. <image
  120. style="width: 600rpx"
  121. mode="widthFix"
  122. :src="$method.splitImgHost(item.imgUrl)"
  123. ></image>
  124. </view>
  125. </view>
  126. </view>
  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. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  134. >
  135. <text
  136. :class="{
  137. right:
  138. bankType == 1 &&
  139. (bank.ques.indexOf(item.optionsId) != -1 ||
  140. bank.ans.indexOf(item.optionsId) != -1),
  141. wrong:
  142. bankType == 1 &&
  143. bank.ques.indexOf(item.optionsId) != -1 &&
  144. bank.ans.indexOf(item.optionsId) == -1,
  145. user_choose: bankType == 2 && item.checked,
  146. }"
  147. class="activeTI"
  148. >
  149. {{ ast[index] }}
  150. </text>
  151. <view class="flex_auto">
  152. {{ item.content }}
  153. <view v-if="item.imgUrl">
  154. <image
  155. style="width: 600rpx"
  156. mode="widthFix"
  157. :src="$method.splitImgHost(item.imgUrl)"
  158. ></image>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. <view
  164. v-if="bankType == 2 || (bankType == 1 && !bank.ques)"
  165. class="submit_checkbox"
  166. :class="{ disabled: !isCheckboxChecked(bank.jsonStr) }"
  167. @click="checkboxSubmit(bankIndex)"
  168. >确认答案</view
  169. >
  170. </view>
  171. <view v-if="bankType == 1 && bank.ques">
  172. <view class="pad_8 answer">
  173. <view>
  174. 题目答案:
  175. <text
  176. v-for="(ansItem, ansIndex) in bank.ans"
  177. :key="ansIndex"
  178. >{{ ast[ansItem - 1] }}</text
  179. >
  180. </view>
  181. <view>
  182. 我的答案:
  183. <text
  184. v-for="(quesItem, quesIndex) in bank.ques"
  185. :key="quesIndex"
  186. >{{ ast[quesItem - 1] }}</text
  187. >
  188. </view>
  189. </view>
  190. <view class="pad_8 answerInfos">
  191. <view class="answerTitle">答案解析</view>
  192. <view class="answerContent"
  193. ><rich-text :nodes="bank.analysisContent"></rich-text
  194. ></view>
  195. </view>
  196. </view>
  197. </template>
  198. <template v-if="bank.type == 3">
  199. <view class="pad_8 titBox no-margin">
  200. <view v-if="!bank.ques">
  201. <view
  202. v-for="(item, index) in judge"
  203. :key="index"
  204. class="lisSty"
  205. @click="judgeSelect(index, bankIndex)"
  206. >
  207. <view class="activeTI">{{ ast[index] }}</view>
  208. <view class="flex_auto">
  209. {{ item }}
  210. <view v-if="item.imgUrl">
  211. <image
  212. style="width: 600rpx"
  213. mode="widthFix"
  214. :src="$method.splitImgHost(item.imgUrl)"
  215. ></image>
  216. </view>
  217. </view>
  218. </view>
  219. </view>
  220. <view v-if="bank.ques">
  221. <view
  222. v-for="(item, index) in judge"
  223. :key="index"
  224. class="lisSty"
  225. @click="judgeSelect(index, bankIndex)"
  226. >
  227. <text
  228. :class="{
  229. right:
  230. bankType == 1 &&
  231. (index == (bank.ques == 1 ? 0 : 1) ||
  232. index != bank.ans),
  233. wrong:
  234. bankType == 1 &&
  235. index == (bank.ques == 1 ? 0 : 1) &&
  236. bank.ques != bank.ans,
  237. user_choose:
  238. bankType == 2 && index == (bank.ques == 1 ? 0 : 1),
  239. }"
  240. class="activeTI"
  241. >
  242. {{ ast[index] }}
  243. </text>
  244. <view class="flex_auto">
  245. {{ item }}
  246. <view v-if="item.imgUrl">
  247. <image
  248. style="width: 600rpx"
  249. mode="widthFix"
  250. :src="$method.splitImgHost(item.imgUrl)"
  251. ></image>
  252. </view>
  253. </view>
  254. </view>
  255. </view>
  256. </view>
  257. <view v-if="bankType == 1 && bank.ques">
  258. <view class="pad_8 answer">
  259. <view>题目答案:{{ ast[bank.ans == 1 ? 0 : 1] }}</view>
  260. <view>我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view>
  261. </view>
  262. <view class="pad_8 answerInfos">
  263. <view class="answerTitle">答案解析</view>
  264. <view class="answerContent"
  265. ><rich-text :nodes="bank.analysisContent"></rich-text
  266. ></view>
  267. </view>
  268. </view>
  269. </template>
  270. <!-- 简答题 -->
  271. <template v-if="bank.type == 5">
  272. <view class="pad_8 titBox">
  273. <view class="ans">
  274. <view
  275. class="ans_input"
  276. v-if="
  277. bankType == 2 ||
  278. (bankType == 1 &&
  279. (!bank.ques ||
  280. (!bank.ques.imageList.length && !bank.ques.text)))
  281. "
  282. >
  283. <view class="top flex">
  284. <image
  285. :data-index="bankIndex"
  286. class="icon"
  287. @click="chooseImg(bankIndex)"
  288. src="/static/camera.png"
  289. mode=""
  290. ></image>
  291. <view class="progress"
  292. >{{ bank.ansText.imageList.length || "0" }}/4</view
  293. >
  294. <view
  295. class="submit"
  296. :class="{ disabled: !bank.ansText.text && hasImgs(bank) }"
  297. @click="submitAns(bankIndex)"
  298. >确认答案</view
  299. >
  300. </view>
  301. <view class="textarea">
  302. <textarea
  303. v-model="bank.ansText.text"
  304. placeholder="在此输入答案"
  305. ></textarea>
  306. </view>
  307. <view class="imgs">
  308. <view
  309. class="img"
  310. v-for="(img, imgIndex) in bank.ansText.imageList"
  311. :key="imgIndex"
  312. >
  313. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  314. <image :src="$method.splitImgHost(img, true)"></image>
  315. </view>
  316. </view>
  317. </view>
  318. <view
  319. class="ans_submit answerInfos"
  320. v-if="
  321. bankType == 1 &&
  322. bank.ques &&
  323. (bank.ques.imageList.length || bank.ques.text)
  324. "
  325. >
  326. <view class="answerTitle">我的答案:</view>
  327. {{ bank.ques.text }}
  328. <view class="imgs"
  329. ><image
  330. class="img"
  331. :key="quesIndex"
  332. v-for="(ques, quesIndex) in bank.ques.imageList"
  333. :src="$method.splitImgHost(ques, true)"
  334. ></image
  335. ></view>
  336. </view>
  337. </view>
  338. </view>
  339. <view
  340. v-if="
  341. bankType == 1 &&
  342. bank.ques &&
  343. (bank.ques.imageList.length || bank.ques.text)
  344. "
  345. >
  346. <view class="pad_8 answerInfos">
  347. <view class="answerTitle">答案解析:</view>
  348. <view class="answerContent"
  349. ><rich-text :nodes="bank.analysisContent"></rich-text
  350. ></view>
  351. </view>
  352. </view>
  353. </template>
  354. <!-- 案例题 -->
  355. <template v-if="bank.type == 4">
  356. <view class="tabs">
  357. <view
  358. class="tab"
  359. :class="{ current: tabIndex == bank.current }"
  360. :key="tabIndex"
  361. v-for="(tab, tabIndex) in bank.jsonStr"
  362. @click="tabSelect(tabIndex, bankIndex)"
  363. >
  364. 问题{{ tabIndex + 1 }}
  365. </view>
  366. </view>
  367. <view
  368. v-for="(ansItem, ansIndex) in bank.jsonStr"
  369. v-if="bank.current == ansIndex"
  370. :key="ansIndex"
  371. >
  372. <template v-if="ansItem.type == 1">
  373. <view class="pad_8 titBox">
  374. <view class="leftLetters">
  375. <view class="btnType">
  376. <text>单选</text>
  377. </view>
  378. </view>
  379. <view class="titles"
  380. ><rich-text :nodes="ansItem.content"></rich-text
  381. ></view>
  382. <view v-if="!bank.ques[ansIndex]">
  383. <view
  384. v-for="(option, childIndex) in ansItem.optionsList"
  385. :key="childIndex"
  386. class="lisSty"
  387. @click="
  388. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  389. "
  390. >
  391. <view class="activeTI">{{ ast[childIndex] }}</view>
  392. <view class="flex_auto">
  393. <rich-text
  394. class="textChild"
  395. :nodes="option.content"
  396. ></rich-text>
  397. <view v-if="option.imgUrl">
  398. <image
  399. style="width: 600rpx"
  400. mode="widthFix"
  401. :src="$method.splitImgHost(option.imgUrl)"
  402. ></image>
  403. </view>
  404. </view>
  405. </view>
  406. </view>
  407. <view v-if="bank.ques[ansIndex]">
  408. <view
  409. v-for="(option, childIndex) in ansItem.optionsList"
  410. :key="childIndex"
  411. class="lisSty"
  412. @click="
  413. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  414. "
  415. >
  416. <text
  417. :class="{
  418. right:
  419. bankType == 1 &&
  420. (option.optionsId == bank.ques[ansIndex] ||
  421. option.optionsId == bank.ans[ansIndex]),
  422. wrong:
  423. bankType == 1 &&
  424. option.optionsId == bank.ques[ansIndex] &&
  425. bank.ques[ansIndex] != bank.ans[ansIndex],
  426. user_choose:
  427. bankType == 2 &&
  428. option.optionsId == bank.ques[ansIndex],
  429. }"
  430. class="activeTI"
  431. >
  432. {{ ast[childIndex] }}
  433. </text>
  434. <view class="flex_auto">
  435. <rich-text :nodes="option.content"></rich-text>
  436. <view v-if="option.imgUrl">
  437. <image
  438. style="width: 600rpx"
  439. mode="widthFix"
  440. :src="$method.splitImgHost(option.imgUrl)"
  441. ></image>
  442. </view>
  443. </view>
  444. </view>
  445. </view>
  446. </view>
  447. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  448. <view class="pad_8 answer">
  449. <view>题目答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  450. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  451. </view>
  452. <view class="pad_8 answerInfos">
  453. <view class="answerTitle">答案解析</view>
  454. <view class="answerContent"
  455. ><rich-text :nodes="option.analysisContent"></rich-text
  456. ></view>
  457. </view>
  458. </view>
  459. </template>
  460. <template v-if="ansItem.type == 2">
  461. <view class="pad_8 titBox">
  462. <view class="leftLetters">
  463. <view class="btnType">
  464. <text>多选</text>
  465. </view>
  466. </view>
  467. <view class="titles"
  468. ><rich-text :nodes="ansItem.content"></rich-text
  469. ></view>
  470. <view v-if="!bank.ques[ansIndex]">
  471. <view
  472. v-for="(option, childindex) in ansItem.optionsList"
  473. :key="childindex"
  474. class="lisSty"
  475. @click="
  476. checkboxSelectChild(bankIndex, ansIndex, childindex)
  477. "
  478. >
  479. <view
  480. :class="{ checked: option.checked }"
  481. class="activeTI"
  482. >{{ ast[childindex] }}</view
  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. v-if="
  498. bankType == 2 || (bankType == 1 && !bank.ques[ansIndex])
  499. "
  500. class="submit_checkbox"
  501. :class="{
  502. disabled: !isCheckboxChecked(ansItem.optionsList),
  503. }"
  504. @click="checkboxSubmitChild(bankIndex, ansIndex)"
  505. >确认答案</view
  506. >
  507. <view v-if="bank.ques && bank.ques[ansIndex]">
  508. <view
  509. v-for="(option, childindex) in ansItem.optionsList"
  510. :key="childindex"
  511. class="lisSty"
  512. @click="
  513. checkboxSelectChild(bankIndex, ansIndex, childindex)
  514. "
  515. >
  516. <text
  517. :class="{
  518. right:
  519. bankType == 1 && right(bankIndex, ansIndex, option),
  520. wrong:
  521. bankType == 1 && wrong(bankIndex, ansIndex, option),
  522. user_choose: bankType == 2 && option.checked,
  523. }"
  524. class="activeTI"
  525. >
  526. {{ ast[childindex] }}
  527. </text>
  528. <view class="flex_auto">
  529. <rich-text :nodes="option.content"></rich-text>
  530. <view v-if="option.imgUrl">
  531. <image
  532. style="width: 600rpx"
  533. mode="widthFix"
  534. :src="$method.splitImgHost(option.imgUrl)"
  535. ></image>
  536. </view>
  537. </view>
  538. </view>
  539. </view>
  540. </view>
  541. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  542. <view class="pad_8 answer">
  543. <view>
  544. 题目答案:
  545. <text
  546. :key="ansItemIndex1"
  547. v-for="(ansItem1, ansItemIndex1) in bank.ans[ansIndex]"
  548. >{{ ast[ansItem1 - 1] }}</text
  549. >
  550. </view>
  551. <view>
  552. 我的答案:
  553. <text
  554. :key="quesItemIndex"
  555. v-for="(quesItem, quesItemIndex) in bank.ques[ansIndex]"
  556. >{{ ast[quesItem - 1] }}</text
  557. >
  558. </view>
  559. </view>
  560. <view class="pad_8 answerInfos">
  561. <view class="answerTitle">答案解析</view>
  562. <view class="answerContent"
  563. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  564. ></view>
  565. </view>
  566. </view>
  567. </template>
  568. <template v-if="ansItem.type == 3">
  569. <view class="pad_8 titBox">
  570. <view class="leftLetters">
  571. <view class="btnType">
  572. <text>判断</text>
  573. </view>
  574. </view>
  575. <view class="titles"
  576. ><rich-text :nodes="ansItem.content"></rich-text
  577. ></view>
  578. <view v-if="!bank.ques[ansIndex]">
  579. <view
  580. v-for="(option, childindex) in judge"
  581. :key="childindex"
  582. class="lisSty"
  583. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  584. >
  585. <view class="activeTI">{{ ast[childindex] }}</view>
  586. <view class="flex_auto">
  587. {{ option }}
  588. <view v-if="option.imgUrl">
  589. <image
  590. style="width: 600rpx"
  591. mode="widthFix"
  592. :src="$method.splitImgHost(option.imgUrl)"
  593. ></image>
  594. </view>
  595. </view>
  596. </view>
  597. </view>
  598. <view v-if="bank.ques[ansIndex]">
  599. <view
  600. v-for="(option, childindex) in judge"
  601. :key="childindex"
  602. class="lisSty"
  603. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  604. >
  605. <text
  606. :class="{
  607. right:
  608. bankType == 1 &&
  609. (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
  610. childindex != bank.ans[ansIndex]),
  611. wrong:
  612. bankType == 1 &&
  613. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
  614. bank.ques[ansIndex] != bank.ans[ansIndex],
  615. user_choose:
  616. bankType == 2 &&
  617. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1),
  618. }"
  619. class="activeTI"
  620. >
  621. {{ ast[childindex] }}
  622. </text>
  623. <view class="flex_auto">
  624. {{ option }}
  625. <view v-if="option.imgUrl">
  626. <image
  627. style="width: 600rpx"
  628. mode="widthFix"
  629. :src="$method.splitImgHost(option.imgUrl)"
  630. ></image>
  631. </view>
  632. </view>
  633. </view>
  634. </view>
  635. </view>
  636. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  637. <view class="pad_8 answer">
  638. <view
  639. >题目答案:{{
  640. ast[bank.ans[ansIndex] == 1 ? 0 : 1]
  641. }}</view
  642. >
  643. <view
  644. >我的答案:{{
  645. ast[bank.ques[ansIndex] == 1 ? 0 : 1]
  646. }}</view
  647. >
  648. </view>
  649. <view class="pad_8 answerInfos">
  650. <view class="answerTitle">答案解析</view>
  651. <view class="answerContent"
  652. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  653. ></view>
  654. </view>
  655. </view>
  656. </template>
  657. <!-- 简答题 -->
  658. <template v-if="ansItem.type == 5">
  659. <view class="pad_8 titBox_title">
  660. <view class="leftLetters">
  661. <view class="btnType">
  662. <text>简答</text>
  663. </view>
  664. </view>
  665. <view><rich-text :nodes="ansItem.content"></rich-text></view>
  666. </view>
  667. <view class="pad_8 titBox_title">
  668. <view class="ans">
  669. <view
  670. class="ans_input"
  671. v-if="
  672. bankType == 2 ||
  673. (bankType == 1 &&
  674. (!bank.ques[ansIndex] ||
  675. (!bank.ques[ansIndex].text &&
  676. !bank.ques[ansIndex].imageList.length)))
  677. "
  678. >
  679. <view class="top flex">
  680. <image
  681. class="icon"
  682. @click="chooseImgChild(bankIndex, ansIndex)"
  683. src="/static/camera.png"
  684. mode=""
  685. ></image>
  686. <view class="progress"
  687. >{{ ansItem.ansText.imageList.length || "0" }}/4</view
  688. >
  689. <view
  690. class="submit"
  691. :class="{
  692. disabled: !ansItem.ansText.text && hasImgs(ansItem),
  693. }"
  694. @click="submitAnsChild(bankIndex, ansIndex)"
  695. >确认答案</view
  696. >
  697. </view>
  698. <view class="textarea">
  699. <textarea
  700. v-model="ansItem.ansText.text"
  701. placeholder="在此输入答案"
  702. ></textarea>
  703. </view>
  704. <view class="imgs">
  705. <view
  706. class="img"
  707. v-for="(img, imgIndex) in ansItem.ansText.imageList"
  708. :key="imgIndex"
  709. >
  710. <text
  711. @click="
  712. deleteImgChild(imgIndex, bankIndex, ansIndex)
  713. "
  714. >x</text
  715. >
  716. <image :src="$method.splitImgHost(img, true)"></image>
  717. </view>
  718. </view>
  719. </view>
  720. <view
  721. class="ans_submit answerInfos"
  722. v-if="
  723. bankType == 1 &&
  724. bank.ques[ansIndex] &&
  725. (bank.ques[ansIndex].imageList.length ||
  726. bank.ques[ansIndex].text)
  727. "
  728. >
  729. <view class="answerTitle">我的答案</view>
  730. {{ bank.ques[ansIndex].text || "" }}
  731. <view class="imgs">
  732. <image
  733. class="img"
  734. v-for="(ques, quesIndex) in bank.ques[ansIndex]
  735. .imageList"
  736. :key="quesIndex"
  737. :src="$method.splitImgHost(ques, true)"
  738. ></image>
  739. </view>
  740. </view>
  741. </view>
  742. </view>
  743. <view
  744. v-if="
  745. bankType == 1 &&
  746. (bank.ques[ansIndex].imageList.length ||
  747. bank.ques[ansIndex].text)
  748. "
  749. >
  750. <view class="pad_8 answerInfos">
  751. <view class="answerTitle">答案解析</view>
  752. <view class="answerContent"
  753. ><rich-text :nodes="ansItem.analysisContent"></rich-text
  754. ></view>
  755. </view>
  756. </view>
  757. </template>
  758. </view>
  759. </template>
  760. <view class="footer_btn">
  761. <view class="collect"> </view>
  762. <view class="flex_center" @click="openFooterTab">
  763. <view class="up-icon">
  764. <image src="/static/up.png"></image>
  765. </view>
  766. 答题卡
  767. </view>
  768. <view class="collect show" @click="pdsubmit">
  769. <view>
  770. <image src="/static/jj.png" mode=""></image>
  771. <view>交卷</view>
  772. </view>
  773. </view>
  774. </view>
  775. </view>
  776. </swiper-item>
  777. </swiper>
  778. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  779. <view class="popupView">
  780. <view class="popupTops">
  781. <view class="topIcon"></view>
  782. 点击编号即可跳转至对应题目
  783. </view>
  784. <view class="popupContent">
  785. <scroll-view scroll-y="true" style="height: 506rpx">
  786. <view class="boxSty">
  787. <view
  788. v-for="(item, index) in questionList"
  789. :key="index"
  790. @click="changeIndex(index)"
  791. :class="{
  792. isRight: bankType == 1 && isRight(item, index),
  793. isWrong: bankType == 1 && isWrong(item, index),
  794. isPart: bankType == 1 && isPart(item, index),
  795. isOver: bankType == 1 && isOver(item, index),
  796. check_ans: bankType == 2 && isCheck(item, index),
  797. }"
  798. class="liListSty"
  799. >
  800. {{ index + 1 }}
  801. </view>
  802. </view>
  803. </scroll-view>
  804. </view>
  805. </view>
  806. </u-popup>
  807. <view class="dialog" v-if="showDialog">
  808. <image class="pointer" src="/static/pointer.png" mode=""></image>
  809. <view class="text">左右滑动切换上下题</view>
  810. <view class="btn" @click="showDialog = false">我知道了</view>
  811. </view>
  812. <view class="dialog-arrow" v-if="showArrow">
  813. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  814. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  815. <view class="btn" @click="showArrow = false">我知道了</view>
  816. </view>
  817. <view class="dialog_wrap" v-if="testOver">
  818. <view class="bg"></view>
  819. <view class="dialog">
  820. <view class="title">温馨提示</view>
  821. <view class="content">
  822. <view>您已完成所有题目,</view>
  823. <view>快去交卷吧!</view>
  824. </view>
  825. <view class="btns">
  826. <view class="btn" @click="noSubmit()">暂不交卷</view>
  827. <view class="btn active" @click="submitNow()">立即交卷</view>
  828. </view>
  829. </view>
  830. </view>
  831. <view class="dialog_wrap" v-if="isLastCount">
  832. <view class="bg"></view>
  833. <view class="dialog">
  834. <view class="title">温馨提示</view>
  835. <view class="content">
  836. <view
  837. >您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view
  838. >
  839. </view>
  840. <view class="btns">
  841. <view class="btn" @click="noLeave()">暂不离开</view>
  842. <view class="btn active" @click="leaveNow()">继续离开</view>
  843. </view>
  844. </view>
  845. </view>
  846. <u-popup
  847. v-model="showpopups"
  848. mode="center"
  849. border-radius="24"
  850. height="439rpx"
  851. width="640rpx"
  852. :mask-close-able="false"
  853. >
  854. <view class="popboxs">
  855. <view class="classTops">温馨提示</view>
  856. <view class="textStys">
  857. {{
  858. cgType === 7
  859. ? "您还未交卷,确定结束做题吗?"
  860. : cgType === 8
  861. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  862. : cgType === 6
  863. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  864. : cgType == 9
  865. ? `您已完成所有题目,快去交卷吧!`
  866. : ""
  867. }}
  868. </view>
  869. <view class="classFootsty" v-if="cgType === 6">
  870. <view class="btnsty btns1" @click="submit">立即交卷</view>
  871. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  872. </view>
  873. <view class="classFootsty" v-if="cgType === 7">
  874. <view class="btnsty btns1" @click="backPages">下次继续</view>
  875. <view class="btnsty btns2" @click="submit">结束做题</view>
  876. </view>
  877. <view class="classFootsty" v-if="cgType === 8">
  878. <view class="btnsty btns1" @click="backPages()">下次继续</view>
  879. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  880. </view>
  881. <view class="classFootsty" v-if="cgType === 9">
  882. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  883. <view class="btnsty btns2" @click="submit">立即交卷</view>
  884. </view>
  885. </view>
  886. </u-popup>
  887. </view>
  888. </template>
  889. <script>
  890. import { mapGetters, mapActions } from "vuex";
  891. export default {
  892. computed: {
  893. ...mapGetters(["sysTime"]),
  894. },
  895. data() {
  896. return {
  897. subscribeId: 0,
  898. showpopups: false,
  899. examId: "",
  900. current: 0,
  901. questionList: [],
  902. ast: ["A", "B", "C", "D", "E", "F", "G"],
  903. judge: ["正确", "错误"],
  904. ans: [],
  905. ques: [],
  906. show: false,
  907. showDialog: false,
  908. bankList: [],
  909. collectList: [],
  910. recordId: "",
  911. isSubmit: false,
  912. lastTime: 0, //剩余考试时长
  913. allTimes: 0, //总考试时长
  914. timer: null,
  915. wrongList: [],
  916. bankType: 2, //试卷类型
  917. needBack: false, //是否是考试
  918. testOver: false,
  919. isLastCount: false, //是否有未答题目
  920. lastCount: 0, //剩余没有回答的题目数
  921. showArrow: false, //退出提示
  922. gradeId: "",
  923. examData: {},
  924. eachExamId: 0,
  925. normal: "",
  926. isAutoSubmit: false,
  927. cgType: 0, //对应设计稿弹窗编码
  928. examStartTime: 0,
  929. examEndTime: 0,
  930. simulateExamId: undefined,
  931. goodsId: undefined,
  932. orderGoodsId: undefined,
  933. };
  934. },
  935. async onLoad(option) {
  936. console.log(option);
  937. this.examStartTime = option.examStartTime;
  938. this.examEndTime = option.examEndTime;
  939. this.subscribeId = option.subscribeId || "";
  940. this.current = +option.current || 0;
  941. this.eachExamId = option.eachExamId;
  942. this.examId = option.examId;
  943. this.allTimes = this.examEndTime - this.examStartTime || "";
  944. this.goodsId = option.goodsId;
  945. this.orderGoodsId = option.orderGoodsId;
  946. let isBack = option.isback;
  947. let showDialog = uni.getStorageSync("showDialog");
  948. if (showDialog) {
  949. this.showDialog = false;
  950. } else {
  951. this.showDialog = true;
  952. uni.setStorageSync("showDialog", "1");
  953. }
  954. //考试被迫返回
  955. if (isBack) {
  956. let app = getApp();
  957. let globalData = app.globalData;
  958. for (var k in globalData.bankData) {
  959. this[k] = globalData.bankData[k];
  960. }
  961. this.showArrow = true;
  962. this.timer = setInterval(() => {
  963. if (this.lastTime <= 0) {
  964. clearInterval(this.timer);
  965. uni.showToast({
  966. icon: "none",
  967. mask: true,
  968. title: "考试时间已到,系统将自动交卷",
  969. duration: 10000,
  970. });
  971. this.isAutoSubmit = true;
  972. this.submit();
  973. return;
  974. }
  975. this.lastTime--;
  976. }, 1000);
  977. } else {
  978. //进入页面
  979. await this.bankExam();
  980. await this.setSystemTime();
  981. this.goodsQuestionList();
  982. }
  983. },
  984. onUnload() {
  985. if (this.isSubmit) {
  986. clearInterval(this.timer);
  987. return;
  988. }
  989. //考试试卷 阻止ios手势返回,自动跳回答题页
  990. if (this.needBack) {
  991. let app = getApp();
  992. app.globalData.bankData = this.$data;
  993. clearInterval(this.timer);
  994. uni.navigateTo({
  995. url:
  996. "/pages2/bank/questionBank?examId=" +
  997. this.examId +
  998. "&eachExamId=" +
  999. this.eachExamId +
  1000. "&isback=true" +
  1001. "&subscribeId=" +
  1002. this.subscribeId +
  1003. "&examStartTime=" +
  1004. this.examStartTime +
  1005. "&examEndTime=" +
  1006. this.examEndTime,
  1007. });
  1008. } else {
  1009. //点击返回按钮确认允许退出,记录答题记录
  1010. clearInterval(this.timer);
  1011. this.mockRecordEdit();
  1012. }
  1013. },
  1014. methods: {
  1015. ...mapActions(["setSystemTime"]),
  1016. /**
  1017. * 是否有上传图片
  1018. */
  1019. hasImgs(bank) {
  1020. return bank.ansText.imageList.length == 0;
  1021. },
  1022. /**
  1023. * 获取试卷类型2考试,1练习
  1024. */
  1025. bankExam() {
  1026. return new Promise((resolve) => {
  1027. this.$api.bankExam(this.examId).then((res) => {
  1028. this.bankType = res.data.data.doType;
  1029. this.examData = res.data.data;
  1030. if (this.bankType == 2) {
  1031. this.needBack = true;
  1032. }
  1033. resolve();
  1034. });
  1035. });
  1036. },
  1037. /**
  1038. * 点击后退按钮
  1039. */
  1040. clickLeft() {
  1041. if (this.bankType == 1) {
  1042. let ansCount = this.questionOverNum(true); //已答题数
  1043. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1044. //所有题目答完
  1045. if (this.lastCount == 0) {
  1046. // this.testOver = true;
  1047. this.cgType = 7;
  1048. //未答完
  1049. } else {
  1050. this.cgType = 8;
  1051. // this.isLastCount = true;
  1052. }
  1053. this.showpopups = true;
  1054. } else if (this.bankType == 2) {
  1055. let ansCount = this.questionOverNum(true); //已答题数
  1056. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1057. //所有题目答完
  1058. if (this.lastCount == 0) {
  1059. this.testOver = true;
  1060. //未答完
  1061. } else {
  1062. this.isLastCount = true;
  1063. }
  1064. }
  1065. },
  1066. /**
  1067. * 返回上一页
  1068. */
  1069. backPages() {
  1070. this.needBack = false;
  1071. uni.navigateBack({
  1072. delta: 1,
  1073. });
  1074. },
  1075. /**
  1076. * 获取已经回答的题目数
  1077. * hasSpecail (是否包含简答和案例)
  1078. */
  1079. questionOverNum(hasSpecail) {
  1080. let count = 0;
  1081. this.questionList.forEach((item) => {
  1082. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1083. if (item.ques) {
  1084. count++;
  1085. }
  1086. } else if (item.type == 4) {
  1087. //案例题
  1088. if (hasSpecail) {
  1089. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1090. if (
  1091. jsonItem.type == 1 ||
  1092. jsonItem.type == 2 ||
  1093. jsonItem.type == 3
  1094. ) {
  1095. if (item.ques[indexs]) {
  1096. return true;
  1097. } else {
  1098. return false;
  1099. }
  1100. } else if (jsonItem.type == 5) {
  1101. if (
  1102. item.ques[indexs] &&
  1103. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  1104. ) {
  1105. console.log("chil");
  1106. return true;
  1107. } else {
  1108. return false;
  1109. }
  1110. }
  1111. });
  1112. if (isOver) {
  1113. count++;
  1114. console.log(item, 444);
  1115. }
  1116. }
  1117. } else if (item.type == 5) {
  1118. //简答题
  1119. if (hasSpecail) {
  1120. if (item.ques && (item.ques.text || item.ques.imageList.length)) {
  1121. console.log(5, item);
  1122. count++;
  1123. }
  1124. }
  1125. }
  1126. });
  1127. return count;
  1128. },
  1129. mockSubscribeEdit() {
  1130. this.$api
  1131. .mockSubscribeEdit({
  1132. subscribeId: this.subscribeId,
  1133. handStatus: this.isAutoSubmit ? 2 : 1,
  1134. })
  1135. .then((res) => {});
  1136. },
  1137. /**
  1138. * 是否做完所有题目
  1139. */
  1140. isDoOver() {
  1141. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1142. if (this.questionList.length == questionOverNum) {
  1143. //全部做完弹窗
  1144. this.cgType = 9;
  1145. this.showpopups = true;
  1146. }
  1147. },
  1148. /**
  1149. * 暂不交卷
  1150. */
  1151. noSubmit() {
  1152. //设为允许退出页面
  1153. this.needBack = false;
  1154. uni.navigateBack({
  1155. delta: 1,
  1156. });
  1157. },
  1158. /**
  1159. * 不离开
  1160. */
  1161. noLeave() {
  1162. this.isLastCount = false;
  1163. },
  1164. /**
  1165. * 立即离开并交卷
  1166. */
  1167. leaveNow() {
  1168. this.needBack = false;
  1169. this.isSubmit = true;
  1170. this.submit(false);
  1171. uni.navigateBack({
  1172. delta: 1,
  1173. });
  1174. },
  1175. /**
  1176. * 立即交卷
  1177. */
  1178. submitNow() {
  1179. console.log("sds");
  1180. this.showpopups = false;
  1181. this.needBack = false;
  1182. this.submit();
  1183. },
  1184. /**
  1185. * 离开页面统计回答正确题数
  1186. */
  1187. mockRecordEdit() {
  1188. if (!this.isSubmit) {
  1189. if (this.subscribeId) {
  1190. this.mockSubscribeEdit();
  1191. }
  1192. let {
  1193. doQuestionNum,
  1194. doQuestionIds,
  1195. rightQuestionNum,
  1196. historyExamJson,
  1197. } = this.$method.calculateScore(this.questionList);
  1198. this.$api
  1199. .mockRecordEdit({
  1200. examId: this.examId,
  1201. eachExamId: this.eachExamId,
  1202. goodsId: this.goodsId,
  1203. recordId: this.recordId,
  1204. doQuestionIds,
  1205. rightQuestionNum,
  1206. status: 1,
  1207. doQuestionNum,
  1208. historyExamJson,
  1209. })
  1210. .then((res) => {});
  1211. }
  1212. },
  1213. /**
  1214. * 记录总题数
  1215. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1216. */
  1217. mockRecord(hasSpecial) {
  1218. let questionList = 0;
  1219. // if(!hasSpecial) {
  1220. this.questionList.forEach((item, index) => {
  1221. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1222. questionList++;
  1223. }
  1224. });
  1225. // } else {
  1226. // questionList = this.questionList.length;
  1227. // }
  1228. this.$api
  1229. .mockRecord({
  1230. examId: this.examId,
  1231. eachExamId: this.eachExamId,
  1232. totalQuestionNum: questionList,
  1233. allQuestionNum: this.questionList.length,
  1234. doMode: this.doMode,
  1235. simulateExamId: this.simulateExamId,
  1236. })
  1237. .then((res) => {
  1238. this.recordId = res.data.data;
  1239. //获取recordId 初始化先提交题目 以防突然下次继续做题退出报错
  1240. });
  1241. },
  1242. /**
  1243. * @param {Object} second倒计时过滤器
  1244. */
  1245. countdown(second) {
  1246. if (second) {
  1247. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1248. let m = parseInt((second / 60) % 60); // 计算分数
  1249. let s = parseInt(second % 60); // 计算当前秒数
  1250. if (h < 10) h = "0" + h;
  1251. if (m < 10) m = "0" + m;
  1252. if (s < 10) s = "0" + s;
  1253. return h + ":" + m + ":" + s;
  1254. } else {
  1255. return "";
  1256. }
  1257. },
  1258. hideDialog() {
  1259. this.showDialog = false;
  1260. },
  1261. noListTip(content = "该试卷暂无题目") {
  1262. this.hideDialog();
  1263. uni.showModal({
  1264. showCancel: false,
  1265. content,
  1266. success: (k) => {
  1267. if (k.confirm) {
  1268. this.isSubmit = true;
  1269. uni.navigateBack();
  1270. }
  1271. },
  1272. });
  1273. },
  1274. /**
  1275. * 请求题目列表
  1276. */
  1277. goodsQuestionList() {
  1278. // app/common/bank/question/list
  1279. this.$api[
  1280. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1281. ]({
  1282. examId: this.examId,
  1283. goodsId: this.goodsId,
  1284. orderGoodsId: this.orderGoodsId,
  1285. from: 3,
  1286. }).then((res) => {
  1287. if (res.data.code == 500) {
  1288. return this.noListTip("你已完成所有题目");
  1289. }
  1290. let data = res.data.data;
  1291. if (this.doMode == 3) {
  1292. this.simulateExamId = data.simulateExamId;
  1293. data = data.questionList;
  1294. }
  1295. if (!data.length) {
  1296. return this.noListTip();
  1297. }
  1298. if (this.subscribeId) {
  1299. this.lastTime = this.examEndTime - this.sysTime;
  1300. //考试时间到了自动交卷
  1301. if (this.lastTime) {
  1302. this.timer = setInterval(() => {
  1303. if (this.lastTime <= 0) {
  1304. clearInterval(this.timer);
  1305. uni.showToast({
  1306. icon: "none",
  1307. mask: true,
  1308. title: "考试时间已到,系统将自动交卷",
  1309. duration: 5000,
  1310. });
  1311. this.isAutoSubmit = true;
  1312. this.submit();
  1313. return;
  1314. }
  1315. this.lastTime--;
  1316. }, 1000);
  1317. } else {
  1318. }
  1319. }
  1320. data.forEach((item, index) => {
  1321. // if (typeof item.jsonStr == 'string') {
  1322. item.jsonStr = JSON.parse(item.jsonStr);
  1323. if (item.type == 2) {
  1324. //多选
  1325. item.jsonStr.forEach((str) => {
  1326. str.optionsId = "" + str.optionsId;
  1327. });
  1328. let arr = item.answerQuestion.split(",");
  1329. arr.forEach((a, i) => {
  1330. arr[i] = "" + a;
  1331. });
  1332. item.ans = arr;
  1333. item.analysisContent &&
  1334. (item.analysisContent = item.analysisContent.replace(
  1335. /<img/gi,
  1336. '<img style="max-width:100%;"'
  1337. ));
  1338. item.content &&
  1339. (item.content = item.content.replace(
  1340. /<img/gi,
  1341. '<img style="max-width:100%;"'
  1342. ));
  1343. return;
  1344. } else if (item.type == 5) {
  1345. //简答题
  1346. item.ansText = {
  1347. text: "",
  1348. imageList: [],
  1349. };
  1350. item.ques = {
  1351. text: "",
  1352. imageList: [],
  1353. };
  1354. item.analysisContent &&
  1355. (item.analysisContent = item.analysisContent.replace(
  1356. /<img/gi,
  1357. '<img style="max-width:100%;"'
  1358. ));
  1359. item.content &&
  1360. (item.content = item.content.replace(
  1361. /<img/gi,
  1362. '<img style="max-width:100%;"'
  1363. ));
  1364. } else if (item.type == 4) {
  1365. //案例题
  1366. item.ques = [];
  1367. item.current = 0;
  1368. let ansArr = [];
  1369. item.jsonStr.forEach((json, index) => {
  1370. if (json.type == 1) {
  1371. ansArr[index] = json.answerQuestion;
  1372. json.content &&
  1373. (json.content = json.content.replace(
  1374. /<img/gi,
  1375. '<img style="max-width:100%;"'
  1376. ));
  1377. } else if (json.type == 2) {
  1378. json.optionsList.forEach((str) => {
  1379. str.optionsId = "" + str.optionsId;
  1380. });
  1381. let arr = json.answerQuestion.split(",");
  1382. arr.forEach((a, i) => {
  1383. arr[i] = "" + a;
  1384. });
  1385. ansArr[index] = arr;
  1386. json.content &&
  1387. (json.content = json.content.replace(
  1388. /<img/gi,
  1389. '<img style="max-width:100%;"'
  1390. ));
  1391. } else if (json.type == 3) {
  1392. ansArr[index] = json.answerQuestion;
  1393. json.content &&
  1394. (json.content = json.content.replace(
  1395. /<img/gi,
  1396. '<img style="max-width:100%;"'
  1397. ));
  1398. } else if (json.type == 5) {
  1399. ansArr[index] = {
  1400. text: json.answerQuestion,
  1401. imageList: [],
  1402. };
  1403. json.ansText = {
  1404. text: "",
  1405. imageList: [],
  1406. };
  1407. json.content &&
  1408. (json.content = json.content.replace(
  1409. /<img/gi,
  1410. '<img style="max-width:100%;"'
  1411. ));
  1412. }
  1413. });
  1414. item.analysisContent &&
  1415. (item.analysisContent = item.analysisContent.replace(
  1416. /<img/gi,
  1417. '<img style="max-width:100%;"'
  1418. ));
  1419. item.content &&
  1420. (item.content = item.content.replace(
  1421. /<img/gi,
  1422. '<img style="max-width:100%;"'
  1423. ));
  1424. item.ans = ansArr;
  1425. return;
  1426. }
  1427. item.analysisContent &&
  1428. (item.analysisContent = item.analysisContent.replace(
  1429. /<img/gi,
  1430. '<img style="max-width:100%;"'
  1431. ));
  1432. item.content &&
  1433. (item.content = item.content.replace(
  1434. /<img/gi,
  1435. '<img style="max-width:100%;"'
  1436. ));
  1437. item.ans = item.answerQuestion;
  1438. // }
  1439. });
  1440. this.questionList = data;
  1441. this.lastCount = this.questionList.length;
  1442. this.mockRecord();
  1443. });
  1444. },
  1445. /**
  1446. * @param {Object} e单选点击
  1447. */
  1448. radioSelect(optionsId, bindex) {
  1449. // if (this.questionList[bindex].ques) return;
  1450. // 类型为考试的可以重新在选择答案
  1451. if (this.questionList[bindex].ques && this.bankType == 1) {
  1452. return;
  1453. }
  1454. this.$set(this.questionList[bindex], "ques", optionsId);
  1455. // if ((bindex + 1) < this.questionList.length) {
  1456. // this.current = bindex + 1
  1457. // }
  1458. console.log("改变后:", this.questionList[bindex].ques);
  1459. this.isDoOver();
  1460. },
  1461. /**
  1462. * @param {Object} e案例单选点击
  1463. */
  1464. radioSelectChild(optionsId, ansIndex, bindex) {
  1465. // if (this.questionList[bindex].ques[ansIndex]) return;
  1466. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1467. return;
  1468. }
  1469. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1470. this.isDoOver();
  1471. },
  1472. /**
  1473. * @param {Object} 多选点击
  1474. */
  1475. checkboxSelect(optionsId, bindex, index) {
  1476. if (this.questionList[bindex].ques && this.bankType == 1) {
  1477. return;
  1478. }
  1479. this.$set(
  1480. this.questionList[bindex].jsonStr[index],
  1481. "checked",
  1482. !this.questionList[bindex].jsonStr[index].checked
  1483. );
  1484. },
  1485. /**
  1486. * @param {Object} 案例多选点击
  1487. */
  1488. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1489. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1490. return;
  1491. }
  1492. this.$set(
  1493. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1494. "checked",
  1495. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1496. .checked
  1497. );
  1498. },
  1499. isCheckboxChecked(arr) {
  1500. return arr.some((item) => {
  1501. if (item.checked) {
  1502. return true;
  1503. }
  1504. });
  1505. },
  1506. /**
  1507. * @param {Object} 多选确认
  1508. */
  1509. checkboxSubmit(bindex) {
  1510. // if (this.questionList[bindex].ques) return;
  1511. if (this.questionList[bindex].ques && this.bankType == 1) {
  1512. return;
  1513. }
  1514. let arr = [];
  1515. this.questionList[bindex].jsonStr.forEach((item) => {
  1516. if (item.checked) {
  1517. arr.push(item.optionsId);
  1518. }
  1519. });
  1520. if (!arr.length) {
  1521. delete this.questionList[bindex].ques;
  1522. uni.showToast({
  1523. title: "请选择答案",
  1524. icon: "none",
  1525. });
  1526. return;
  1527. }
  1528. this.$set(this.questionList[bindex], "ques", arr);
  1529. this.$u.toast("已确认答案");
  1530. this.isDoOver();
  1531. console.log("this.questionList[bindex]", this.questionList[bindex].ques);
  1532. // let isWrong = this.questionList[bindex].ques.some(
  1533. // (quesItem, quesIndex) => {
  1534. // return (
  1535. // this.questionList[bindex].ques[quesIndex] !=
  1536. // this.questionList[bindex].ans[quesIndex]
  1537. // );
  1538. // }
  1539. // );
  1540. },
  1541. /**
  1542. * @param {Object} 案例多选确认
  1543. */
  1544. checkboxSubmitChild(bindex, ansIndex) {
  1545. // if (this.questionList[bindex].ques[ansIndex]) return;
  1546. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1547. return;
  1548. }
  1549. let arr = [];
  1550. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  1551. (item) => {
  1552. if (item.checked) {
  1553. arr.push(item.optionsId);
  1554. }
  1555. }
  1556. );
  1557. if (!arr.length) {
  1558. delete this.questionList[bindex].ques[ansIndex];
  1559. uni.showToast({
  1560. title: "请选择答案",
  1561. icon: "none",
  1562. });
  1563. return;
  1564. }
  1565. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  1566. this.$u.toast("已确认答案");
  1567. this.isDoOver();
  1568. },
  1569. /**
  1570. * @param {Object} index
  1571. * @param {Object} bindex
  1572. * 判断题
  1573. */
  1574. judgeSelect(index, bindex) {
  1575. // if (this.questionList[bindex].ques) return;
  1576. if (this.questionList[bindex].ques && this.bankType == 1) {
  1577. return;
  1578. }
  1579. // 答案: 判断题1正确 0错误
  1580. let value = index == 0 ? "1" : "0";
  1581. // this.$set(this.questionList[bindex], "ques", index + "");
  1582. this.$set(this.questionList[bindex], "ques", value);
  1583. this.isDoOver();
  1584. },
  1585. /**
  1586. * @param {Object} ansindex
  1587. * @param {Object} childindex
  1588. * @param {Object} bindex
  1589. * 案例判断题
  1590. */
  1591. judgeSelectChild(ansindex, childindex, bindex) {
  1592. // if (this.questionList[bindex].ques[ansindex]) return;
  1593. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  1594. return;
  1595. }
  1596. this.$set(
  1597. this.questionList[bindex].ques,
  1598. ansindex,
  1599. childindex == 0 ? "1" : "0"
  1600. );
  1601. this.isDoOver();
  1602. },
  1603. openFooterTab() {
  1604. this.show = true;
  1605. },
  1606. changeIndex(index) {
  1607. this.current = index;
  1608. },
  1609. swiperChange(e) {
  1610. this.current = e.detail.current;
  1611. },
  1612. pdsubmit() {
  1613. // if (this.bankType == 1) {
  1614. let ansCount = this.questionOverNum(true); //已答题数
  1615. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1616. //没有答完
  1617. if (this.lastCount !== 0) {
  1618. this.cgType = 6;
  1619. this.showpopups = true;
  1620. return;
  1621. }
  1622. // }
  1623. if (this.bankType == 2) {
  1624. if (this.lastTime > 0) {
  1625. let lastTime = this.countdown(this.lastTime);
  1626. uni.showModal({
  1627. title: "提示",
  1628. content: `时间还剩余${lastTime},确定交卷吗?`,
  1629. confirmText: "交卷",
  1630. cancelText: "继续答题",
  1631. success: (res) => {
  1632. if (res.confirm) {
  1633. //确定
  1634. this.submit();
  1635. } else {
  1636. //取消
  1637. }
  1638. },
  1639. });
  1640. return;
  1641. }
  1642. }
  1643. this.submit();
  1644. },
  1645. /**
  1646. * 交卷
  1647. */
  1648. submit(isShowTip = true) {
  1649. let form = this.$method.calculateScore(this.questionList);
  1650. if (this.subscribeId) {
  1651. this.mockSubscribeEdit();
  1652. }
  1653. //交卷
  1654. this.$api
  1655. .mockRecordEdit({
  1656. examId: this.examId,
  1657. eachExamId: this.eachExamId,
  1658. recordId: this.recordId,
  1659. status: 1,
  1660. examTime: parseInt(this.allTimes),
  1661. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  1662. ...form,
  1663. })
  1664. .then((res) => {
  1665. this.isSubmit = true;
  1666. if (res.data.code == 200) {
  1667. if (!isShowTip) {
  1668. return;
  1669. }
  1670. uni.showToast({
  1671. title: "交卷成功",
  1672. duration: 1000,
  1673. icon: "none",
  1674. });
  1675. setTimeout(() => {
  1676. uni.redirectTo({
  1677. url:
  1678. "/pages5/examReport/index?&examId=" +
  1679. this.examId +
  1680. "&id=" +
  1681. this.recordId +
  1682. "&eachExamId=" +
  1683. this.eachExamId +
  1684. "&subscribeId=" +
  1685. this.subscribeId +
  1686. "&doMode=" +
  1687. this.doMode,
  1688. });
  1689. }, 1000);
  1690. }
  1691. });
  1692. //错题集id提交(客观题)
  1693. if (doWrongQuestionIds.length) {
  1694. this.$api
  1695. .mockWrongRecord({
  1696. eachExamId: this.eachExamId,
  1697. examId: this.examId,
  1698. questionIds: doWrongQuestionIds,
  1699. recordId: this.recordId,
  1700. doMode: this.doMode,
  1701. })
  1702. .then((res) => {});
  1703. }
  1704. },
  1705. /**
  1706. * @param {Object} imgIndex
  1707. * @param {Object} bankIndex
  1708. * 删除简答图片
  1709. */
  1710. deleteImg(imgIndex, bankIndex) {
  1711. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  1712. },
  1713. /**
  1714. * @param {Object} imgIndex
  1715. * @param {Object} bankIndex
  1716. * @param {Object} ansIndex
  1717. * 删除案例题简答图片
  1718. */
  1719. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  1720. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  1721. imgIndex,
  1722. 1
  1723. );
  1724. },
  1725. /**
  1726. * @param {Object} bankindex
  1727. * 选择上传图片
  1728. */
  1729. chooseImg(bankindex) {
  1730. if (
  1731. this.questionList[bankindex] &&
  1732. this.questionList[bankindex].ansText &&
  1733. this.questionList[bankindex].ansText.imageList.length >= 4
  1734. ) {
  1735. uni.showToast({
  1736. icon: "none",
  1737. title: "最多选择4张",
  1738. });
  1739. return;
  1740. }
  1741. uni.chooseImage({
  1742. count: 1, //默认9
  1743. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  1744. sourceType: ["album", "camera"], //从相册选择
  1745. success: (res) => {
  1746. let self = this;
  1747. // console.log(JSON.stringify(res.tempFilePaths));
  1748. let img = res.tempFilePaths[0];
  1749. uni.getImageInfo({
  1750. src: img,
  1751. success: async (res) => {
  1752. let canvasWidth = res.width; //图片原始长宽
  1753. let canvasHeight = res.height;
  1754. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1755. uni.compressImage({
  1756. src: img,
  1757. quality: 75,
  1758. width: "50%",
  1759. height: "50%",
  1760. success: async (rest) => {
  1761. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1762. this.questionList[bankindex].ansText.imageList.push(dir);
  1763. },
  1764. });
  1765. } else {
  1766. const dir = await self.uploadFile(img, 0);
  1767. this.questionList[bankindex].ansText.imageList.push(dir);
  1768. }
  1769. },
  1770. });
  1771. },
  1772. });
  1773. },
  1774. /**
  1775. * @param {Object} bankindex
  1776. * @param {Object} ansindex
  1777. * 案例题选择上传图片
  1778. */
  1779. chooseImgChild(bankindex, ansindex) {
  1780. if (
  1781. this.questionList[bankindex].jsonStr[ansindex] &&
  1782. this.questionList[bankindex].jsonStr[ansindex].ansText &&
  1783. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList
  1784. .length >= 4
  1785. ) {
  1786. uni.showToast({
  1787. icon: "none",
  1788. title: "最多选择4张",
  1789. });
  1790. return;
  1791. }
  1792. uni.chooseImage({
  1793. count: 1, //默认9
  1794. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  1795. sourceType: ["album", "camera"], //从相册选择
  1796. success: (res) => {
  1797. let self = this;
  1798. // console.log(JSON.stringify(res.tempFilePaths));
  1799. let img = res.tempFilePaths[0];
  1800. uni.getImageInfo({
  1801. src: img,
  1802. success: async (res) => {
  1803. let canvasWidth = res.width; //图片原始长宽
  1804. let canvasHeight = res.height;
  1805. if (canvasWidth > 1000 || canvasHeight > 1000) {
  1806. uni.compressImage({
  1807. src: img,
  1808. quality: 75,
  1809. width: "50%",
  1810. height: "50%",
  1811. success: async (rest) => {
  1812. const dir = await self.uploadFile(rest.tempFilePath, 0);
  1813. this.questionList[bankindex].jsonStr[
  1814. ansindex
  1815. ].ansText.imageList.push(dir);
  1816. },
  1817. });
  1818. } else {
  1819. const dir = await self.uploadFile(img, 0);
  1820. this.questionList[bankindex].jsonStr[
  1821. ansindex
  1822. ].ansText.imageList.push(dir);
  1823. }
  1824. },
  1825. });
  1826. },
  1827. });
  1828. },
  1829. uploadFile(options, int) {
  1830. var self = this;
  1831. return new Promise((resolve, reject) => {
  1832. var data = {
  1833. orderGoodsId: this.orderGoodsId,
  1834. imageStatus: int,
  1835. };
  1836. self.$api.aliyunpolicy(data).then((res) => {
  1837. console.log(res.data, 6);
  1838. if (res.data.code != 200) {
  1839. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  1840. return;
  1841. }
  1842. var ossToken = res.data.data.resultContent;
  1843. if (ossToken.host == null || ossToken.host == undefined) {
  1844. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  1845. return;
  1846. }
  1847. uni.uploadFile({
  1848. url: ossToken.host,
  1849. name: "file",
  1850. filePath: options,
  1851. fileType: "image",
  1852. header: {
  1853. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1854. },
  1855. formData: {
  1856. key: ossToken.dir,
  1857. OSSAccessKeyId: ossToken.accessid,
  1858. policy: ossToken.policy,
  1859. Signature: ossToken.signature,
  1860. callback: ossToken.callback,
  1861. success_action_status: 200,
  1862. },
  1863. success: (result) => {
  1864. // if (result.statusCode === 200) {
  1865. resolve(ossToken.dir);
  1866. // } else {
  1867. // uni.showToast({
  1868. // title: "上传失败",
  1869. // icon: "none",
  1870. // });
  1871. // return;
  1872. // }
  1873. },
  1874. fail: (error) => {
  1875. uni.showToast({
  1876. title: "上传接口报错" + error,
  1877. icon: "none",
  1878. });
  1879. return;
  1880. },
  1881. });
  1882. });
  1883. });
  1884. },
  1885. /**
  1886. * @param {Object} type
  1887. * @param {Object} bankindex
  1888. * 简答题答案确认
  1889. */
  1890. submitAns(bankindex) {
  1891. console.log(this.questionList[bankindex]);
  1892. if (
  1893. !this.questionList[bankindex].ansText.text &&
  1894. !this.questionList[bankindex].ansText.imageList.length
  1895. ) {
  1896. uni.showToast({
  1897. title: "请输入内容或上传图片",
  1898. duration: 2000,
  1899. icon: "none",
  1900. });
  1901. return;
  1902. }
  1903. this.$set(this.questionList[bankindex], "ques", {
  1904. imageList: this.questionList[bankindex].ansText.imageList || [],
  1905. text: this.questionList[bankindex].ansText.text || "",
  1906. });
  1907. this.$u.toast("已确认答案");
  1908. this.isDoOver();
  1909. },
  1910. /**
  1911. * @param {Object} bankindex
  1912. * @param {Object} ansindex
  1913. * 案例题简答答案确认
  1914. */
  1915. submitAnsChild(bankindex, ansindex) {
  1916. if (
  1917. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  1918. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  1919. ) {
  1920. uni.showToast({
  1921. title: "请输入内容或上传图片",
  1922. duration: 2000,
  1923. icon: "none",
  1924. });
  1925. return;
  1926. }
  1927. this.$set(this.questionList[bankindex].ques, ansindex, {
  1928. imageList:
  1929. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList ||
  1930. [],
  1931. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text || "",
  1932. });
  1933. this.$u.toast("已确认答案");
  1934. this.isDoOver();
  1935. },
  1936. isCheck(item, index) {
  1937. if (this.questionList[index].ques) {
  1938. return true;
  1939. }
  1940. },
  1941. isRight(item, index) {
  1942. //单选
  1943. if (this.questionList[index].ques) {
  1944. if (item.type == 1) {
  1945. return this.questionList[index].ques == this.questionList[index].ans;
  1946. //多选
  1947. } else if (item.type == 2) {
  1948. //每一项都相等
  1949. return this.questionList[index].ans.every((item, i) => {
  1950. return item == this.questionList[index].ques[i];
  1951. });
  1952. //判断
  1953. } else if (item.type == 3) {
  1954. return this.questionList[index].ques == this.questionList[index].ans;
  1955. // } else if (item.type == 5) {
  1956. // if(this.questionList[index].ques.text){
  1957. // return true
  1958. // }else{
  1959. // return false
  1960. // }
  1961. } else {
  1962. return false;
  1963. }
  1964. } else {
  1965. return false;
  1966. }
  1967. },
  1968. right(bankIndex, ansIndex, option) {
  1969. if (
  1970. this.questionList[bankIndex].ques[ansIndex] &&
  1971. this.questionList[bankIndex].ans[ansIndex]
  1972. ) {
  1973. if (
  1974. this.questionList[bankIndex].ques[ansIndex].indexOf(
  1975. option.optionsId
  1976. ) != -1 ||
  1977. this.questionList[bankIndex].ans[ansIndex].indexOf(
  1978. option.optionsId
  1979. ) != -1
  1980. ) {
  1981. return true;
  1982. } else {
  1983. return false;
  1984. }
  1985. } else {
  1986. return false;
  1987. }
  1988. },
  1989. wrong(bankIndex, ansIndex, option) {
  1990. if (
  1991. this.questionList[bankIndex].ques[ansIndex] &&
  1992. this.questionList[bankIndex].ans[ansIndex]
  1993. ) {
  1994. if (
  1995. this.questionList[bankIndex].ques[ansIndex].indexOf(
  1996. option.optionsId
  1997. ) != -1 &&
  1998. this.questionList[bankIndex].ans[ansIndex].indexOf(
  1999. option.optionsId
  2000. ) == -1
  2001. ) {
  2002. return true;
  2003. } else {
  2004. return false;
  2005. }
  2006. } else {
  2007. return false;
  2008. }
  2009. },
  2010. isWrong(item, index) {
  2011. if (this.questionList[index].ques) {
  2012. //单选
  2013. if (item.type == 1) {
  2014. return this.questionList[index].ques != this.questionList[index].ans;
  2015. //多选
  2016. } else if (item.type == 2) {
  2017. //每一项都相等
  2018. return this.questionList[index].ques.some((item, i) => {
  2019. return this.questionList[index].ans.indexOf(item) == -1;
  2020. });
  2021. //判断
  2022. } else if (item.type == 3) {
  2023. return this.questionList[index].ques != this.questionList[index].ans;
  2024. } else {
  2025. return false;
  2026. }
  2027. } else {
  2028. return false;
  2029. }
  2030. },
  2031. isPart(item, index) {
  2032. if (this.questionList[index].ques) {
  2033. if (item.type == 2) {
  2034. let isWrong = this.questionList[index].ques.some((item, i) => {
  2035. return this.questionList[index].ans.indexOf(item) == -1;
  2036. });
  2037. let isRight = this.questionList[index].ans.every((item, i) => {
  2038. return item == this.questionList[index].ques[i];
  2039. });
  2040. if (!isRight && !isWrong) {
  2041. return true;
  2042. }
  2043. }
  2044. } else {
  2045. return false;
  2046. }
  2047. },
  2048. isOver(item, index) {
  2049. if (this.questionList[index].ques) {
  2050. if (item.type == 4) {
  2051. //案例题
  2052. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2053. if (
  2054. jsonItem.type == 1 ||
  2055. jsonItem.type == 2 ||
  2056. jsonItem.type == 3
  2057. ) {
  2058. if (item.ques[indexs]) {
  2059. return true;
  2060. } else {
  2061. return false;
  2062. }
  2063. } else if (jsonItem.type == 5) {
  2064. if (
  2065. item.ques[indexs] &&
  2066. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2067. ) {
  2068. console.log("chil");
  2069. return true;
  2070. } else {
  2071. return false;
  2072. }
  2073. }
  2074. });
  2075. if (isOver) {
  2076. return true;
  2077. } else {
  2078. return false;
  2079. }
  2080. } else if (item.type == 5) {
  2081. //简答题
  2082. //每一项都相等
  2083. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2084. return true;
  2085. }
  2086. //判断
  2087. } else {
  2088. return false;
  2089. }
  2090. } else {
  2091. return false;
  2092. }
  2093. },
  2094. tabSelect(index, bankindex) {
  2095. this.$set(this.questionList[bankindex], "current", index);
  2096. },
  2097. showPhoto(contentStr) {
  2098. if (contentStr && typeof contentStr == "string") {
  2099. let reg = /<img[^>]*src[=\'\"\s]+([^\'\"]*)[\'\"]?[^>]*>/gi;
  2100. let strArr = contentStr.match(reg);
  2101. strArr.forEach((str, index) => {
  2102. strArr[index] = str.replace(reg, "$1");
  2103. });
  2104. // 预览图片
  2105. uni.previewImage({
  2106. urls: strArr,
  2107. longPressActions: {
  2108. itemList: ["发送给朋友", "保存图片", "收藏"],
  2109. success: function (data) {
  2110. console.log(
  2111. "选中了第" +
  2112. (data.tapIndex + 1) +
  2113. "个按钮,第" +
  2114. (data.index + 1) +
  2115. "张图片"
  2116. );
  2117. },
  2118. fail: function (err) {
  2119. console.log(err.errMsg);
  2120. },
  2121. },
  2122. });
  2123. }
  2124. },
  2125. },
  2126. computed: {
  2127. doMode() {
  2128. // 做题模式 1章卷 2随机练习 3模拟组卷
  2129. return this.examData.simulateStatus ? 3 : undefined;
  2130. },
  2131. },
  2132. };
  2133. </script>
  2134. <style lang="scss" scoped>
  2135. .questionBank {
  2136. width: 100%;
  2137. height: 100vh;
  2138. display: flex;
  2139. flex-direction: column;
  2140. }
  2141. .swiper {
  2142. width: 100%;
  2143. flex: 1;
  2144. }
  2145. .lisSty {
  2146. margin-bottom: 16rpx;
  2147. display: flex;
  2148. align-items: center;
  2149. .flex_auto {
  2150. flex: 1;
  2151. word-break: break-all;
  2152. }
  2153. }
  2154. .activeTI {
  2155. vertical-align: middle;
  2156. display: inline-block;
  2157. border: 1rpx solid #eee;
  2158. border-radius: 50rpx;
  2159. height: 48rpx;
  2160. line-height: 46rpx;
  2161. text-align: center;
  2162. width: 48rpx;
  2163. margin-right: 15rpx;
  2164. color: #666;
  2165. font-size: 30rpx;
  2166. &.right {
  2167. color: #fff;
  2168. background: #36c75a;
  2169. }
  2170. &.wrong {
  2171. color: #fff;
  2172. background: #ff3b30;
  2173. }
  2174. &.checked,
  2175. &.user_choose {
  2176. color: #fff;
  2177. background: #007aff;
  2178. }
  2179. }
  2180. .submit_checkbox {
  2181. position: fixed;
  2182. left: 0;
  2183. right: 0;
  2184. bottom: 120rpx;
  2185. margin: 20rpx auto;
  2186. width: 526rpx;
  2187. height: 80rpx;
  2188. background: rgba(0, 122, 255, 1);
  2189. color: #fff;
  2190. text-align: center;
  2191. line-height: 80rpx;
  2192. font-size: 30rpx;
  2193. border-radius: 40rpx;
  2194. &.disabled {
  2195. opacity: 0.6;
  2196. }
  2197. }
  2198. .titles {
  2199. overflow: hidden;
  2200. margin-bottom: 24rpx;
  2201. }
  2202. .titBox {
  2203. padding: 41rpx 25rpx 24rpx 25rpx;
  2204. }
  2205. .titBox_title {
  2206. padding: 21rpx;
  2207. }
  2208. .tabs {
  2209. margin: 10rpx;
  2210. display: flex;
  2211. .tab {
  2212. margin: 0 4rpx;
  2213. padding: 10rpx 13rpx;
  2214. text-align: center;
  2215. color: #007aff;
  2216. font-size: 28rpx;
  2217. border-radius: 16rpx;
  2218. background: #fff;
  2219. &.current {
  2220. color: #fff;
  2221. background: #007aff;
  2222. }
  2223. }
  2224. }
  2225. .ans {
  2226. margin: 8rpx 8rpx 8rpx;
  2227. .ans_input {
  2228. border-radius: 16rpx;
  2229. background: #fff;
  2230. .top {
  2231. border-bottom: 1rpx solid #eeeeee;
  2232. padding: 16rpx;
  2233. display: flex;
  2234. align-items: center;
  2235. .icon {
  2236. margin-right: 20rpx;
  2237. width: 40rpx;
  2238. height: 38rpx;
  2239. }
  2240. .progress {
  2241. flex: 1;
  2242. }
  2243. .submit {
  2244. width: 168rpx;
  2245. height: 48rpx;
  2246. line-height: 48rpx;
  2247. text-align: center;
  2248. color: #fff;
  2249. font-size: 30rpx;
  2250. background: #007aff;
  2251. border-radius: 24rpx;
  2252. &.disabled {
  2253. opacity: 0.6;
  2254. }
  2255. }
  2256. }
  2257. .textarea {
  2258. textarea {
  2259. width: 100%;
  2260. height: 287rpx;
  2261. padding: 10rpx;
  2262. }
  2263. }
  2264. .imgs {
  2265. overflow: hidden;
  2266. display: flex;
  2267. width: 100%;
  2268. .img {
  2269. width: 104rpx;
  2270. height: 104rpx;
  2271. border-radius: 8rpx;
  2272. position: relative;
  2273. margin: 20rpx;
  2274. text {
  2275. position: absolute;
  2276. right: -15rpx;
  2277. top: -15rpx;
  2278. width: 30rpx;
  2279. height: 30rpx;
  2280. text-align: center;
  2281. line-height: 30rpx;
  2282. color: #fff;
  2283. background: #ff3b30;
  2284. border-radius: 50%;
  2285. }
  2286. image {
  2287. width: 100%;
  2288. height: 100%;
  2289. }
  2290. }
  2291. }
  2292. }
  2293. .ans_submit {
  2294. padding: 16rpx;
  2295. border-radius: 16rpx;
  2296. background: #fff;
  2297. .imgs {
  2298. overflow: hidden;
  2299. display: flex;
  2300. width: 100%;
  2301. .img {
  2302. width: 104rpx;
  2303. height: 104rpx;
  2304. border-radius: 8rpx;
  2305. position: relative;
  2306. margin: 20rpx;
  2307. image {
  2308. width: 100%;
  2309. height: 100%;
  2310. }
  2311. }
  2312. }
  2313. }
  2314. }
  2315. .leftLetters {
  2316. display: flex;
  2317. align-items: center;
  2318. width: 220rpx;
  2319. .btnType {
  2320. padding: 5rpx 10rpx;
  2321. border: 1rpx solid #007aff;
  2322. border-radius: 10rpx;
  2323. background-color: rgba(0, 122, 255, 0.1);
  2324. font-size: 28rpx;
  2325. color: #007aff;
  2326. margin-right: 15rpx;
  2327. }
  2328. }
  2329. .firstLetter {
  2330. display: flex;
  2331. justify-content: space-between;
  2332. align-items: center;
  2333. margin-bottom: 30rpx;
  2334. }
  2335. .popupView {
  2336. height: 100%;
  2337. padding-bottom: 100rpx;
  2338. .popupTops {
  2339. height: 77rpx;
  2340. border-bottom: 1rpx solid #eee;
  2341. text-align: center;
  2342. line-height: 77rpx;
  2343. font-size: 24rpx;
  2344. color: #999;
  2345. position: relative;
  2346. .topIcon {
  2347. position: absolute;
  2348. top: 10rpx;
  2349. left: 50%;
  2350. transform: translateX(-50%);
  2351. width: 80rpx;
  2352. height: 8rpx;
  2353. background-color: #999;
  2354. border-radius: 4rpx;
  2355. }
  2356. }
  2357. }
  2358. .pageContent {
  2359. position: relative;
  2360. background-color: #eaeef1;
  2361. height: 100%;
  2362. padding-top: 8rpx;
  2363. padding-bottom: 100rpx;
  2364. overflow-y: scroll;
  2365. }
  2366. .pad_8 {
  2367. background-color: #fff;
  2368. margin: 0rpx 8rpx 8rpx;
  2369. border-radius: 16rpx;
  2370. &.no-margin {
  2371. margin-top: -16rpx;
  2372. border-radius: 0 0 16rpx 16rpx;
  2373. }
  2374. }
  2375. .answer {
  2376. height: 80rpx;
  2377. line-height: 80rpx;
  2378. padding: 0rpx 24rpx;
  2379. display: flex;
  2380. align-items: center;
  2381. justify-content: space-between;
  2382. color: #666;
  2383. font-size: 30rpx;
  2384. }
  2385. .footer_btn {
  2386. background-color: #fff;
  2387. z-index: 10078;
  2388. position: fixed;
  2389. bottom: 0rpx;
  2390. display: flex;
  2391. align-items: center;
  2392. justify-content: space-between;
  2393. width: 100%;
  2394. height: 98rpx;
  2395. padding: 0rpx 38rpx;
  2396. border-top: 1rpx solid #eee;
  2397. .flex_center {
  2398. flex: 1;
  2399. display: flex;
  2400. justify-content: center;
  2401. align-items: center;
  2402. flex-direction: column;
  2403. margin: 0 200rpx;
  2404. font-size: 24rpx;
  2405. color: #999999;
  2406. .up-icon {
  2407. margin-bottom: 18rpx;
  2408. width: 100%;
  2409. display: flex;
  2410. justify-content: center;
  2411. image {
  2412. width: 58rpx;
  2413. height: 21rpx;
  2414. }
  2415. }
  2416. }
  2417. .collect {
  2418. visibility: hidden;
  2419. width: 100rpx;
  2420. &.show {
  2421. visibility: visible;
  2422. }
  2423. > view {
  2424. display: flex;
  2425. flex-direction: column;
  2426. align-items: center;
  2427. justify-content: center;
  2428. image {
  2429. width: 32rpx;
  2430. height: 32rpx;
  2431. margin-bottom: 6rpx;
  2432. }
  2433. view {
  2434. font-size: 24rpx;
  2435. color: #999999;
  2436. }
  2437. }
  2438. }
  2439. }
  2440. .boxSty {
  2441. padding: 44rpx 41rpx 0rpx;
  2442. }
  2443. .liListSty {
  2444. border: 1rpx solid #eeeeee;
  2445. width: 88rpx;
  2446. height: 88rpx;
  2447. border-radius: 32rpx;
  2448. text-align: center;
  2449. line-height: 88rpx;
  2450. color: #333;
  2451. font-size: 32rpx;
  2452. float: left;
  2453. margin: 20rpx 23rpx;
  2454. &.isRight {
  2455. border: 1rpx solid #eeeeee;
  2456. color: #fff;
  2457. background: #36c75a;
  2458. }
  2459. &.isWrong {
  2460. border: 1rpx solid #eeeeee;
  2461. color: #fff;
  2462. background: #ff3b30;
  2463. }
  2464. &.isPart {
  2465. border: 1rpx solid #eeeeee;
  2466. color: #fff;
  2467. background: #ffc53d;
  2468. }
  2469. &.isOver {
  2470. border: 1rpx solid #eeeeee;
  2471. color: #fff;
  2472. background: blue;
  2473. }
  2474. &.check_ans {
  2475. border: 1rpx solid #eeeeee;
  2476. color: #fff;
  2477. background: #007aff;
  2478. }
  2479. }
  2480. .answerInfos {
  2481. padding: 25rpx 25rpx 25rpx 23rpx;
  2482. }
  2483. .answerTitle {
  2484. margin-bottom: 28rpx;
  2485. color: #666;
  2486. font-size: 30rpx;
  2487. }
  2488. .answerContent {
  2489. font-size: 30rpx;
  2490. color: #666;
  2491. }
  2492. .textChild {
  2493. display: inline-block;
  2494. vertical-align: middle;
  2495. }
  2496. .dialog {
  2497. position: fixed;
  2498. left: 0;
  2499. top: 0;
  2500. width: 100%;
  2501. height: 100%;
  2502. background-color: rgba(0, 0, 0, 0.8);
  2503. display: flex;
  2504. flex-direction: column;
  2505. align-items: center;
  2506. justify-content: center;
  2507. z-index: 20000;
  2508. .pointer {
  2509. width: 338rpx;
  2510. height: 240rpx;
  2511. }
  2512. .text {
  2513. font-size: 32rpx;
  2514. color: #ffffff;
  2515. text-align: center;
  2516. }
  2517. .btn {
  2518. width: 242rpx;
  2519. height: 82rpx;
  2520. border: 2rpx solid #ffffff;
  2521. border-radius: 16rpx;
  2522. text-align: center;
  2523. line-height: 82rpx;
  2524. margin: 41rpx auto;
  2525. color: #fff;
  2526. font-size: 32rpx;
  2527. }
  2528. }
  2529. .dialog-arrow {
  2530. padding-top: 124rpx;
  2531. position: fixed;
  2532. left: 0;
  2533. top: 0;
  2534. width: 100%;
  2535. height: 100%;
  2536. background-color: rgba(0, 0, 0, 0.8);
  2537. z-index: 20000;
  2538. .pointer {
  2539. margin-left: 87rpx;
  2540. display: block;
  2541. width: 95rpx;
  2542. height: 98rpx;
  2543. }
  2544. .text {
  2545. padding-left: 177rpx;
  2546. font-size: 32rpx;
  2547. color: #ffffff;
  2548. }
  2549. .btn {
  2550. width: 242rpx;
  2551. height: 82rpx;
  2552. border: 2rpx solid #ffffff;
  2553. border-radius: 16rpx;
  2554. text-align: center;
  2555. line-height: 82rpx;
  2556. margin: 500rpx auto 0;
  2557. color: #fff;
  2558. font-size: 32rpx;
  2559. }
  2560. }
  2561. .dialog_wrap {
  2562. position: fixed;
  2563. left: 0;
  2564. top: 0;
  2565. width: 100%;
  2566. height: 100%;
  2567. z-index: 9999999999;
  2568. .bg {
  2569. background: rgba(0, 0, 0, 0.3);
  2570. position: absolute;
  2571. left: 0;
  2572. top: 0;
  2573. width: 100%;
  2574. height: 100%;
  2575. }
  2576. .dialog {
  2577. position: absolute;
  2578. left: 50%;
  2579. top: 50%;
  2580. transform: translate3D(-50%, -50%, 0);
  2581. width: 640rpx;
  2582. height: 439rpx;
  2583. background: #ffffff;
  2584. border-radius: 24rpx;
  2585. .title {
  2586. font-size: 30rpx;
  2587. font-weight: bold;
  2588. color: #333333;
  2589. line-height: 48rpx;
  2590. text-align: center;
  2591. margin-top: 40rpx;
  2592. }
  2593. .content {
  2594. margin: 35rpx 35rpx 0;
  2595. font-size: 30rpx;
  2596. color: #666666;
  2597. line-height: 48rpx;
  2598. }
  2599. .btns {
  2600. margin-top: 35rpx;
  2601. display: flex;
  2602. align-items: center;
  2603. justify-content: center;
  2604. .btn {
  2605. width: 200rpx;
  2606. height: 80rpx;
  2607. line-height: 80rpx;
  2608. text-align: center;
  2609. background: #f5f5f5;
  2610. border-radius: 40rpx;
  2611. font-size: 30rpx;
  2612. color: rgba(0, 122, 255, 1);
  2613. background: #f5f5f5;
  2614. margin: 0 20rpx;
  2615. &.active {
  2616. color: #f5f5f5;
  2617. background: rgba(0, 122, 255, 1);
  2618. }
  2619. }
  2620. }
  2621. }
  2622. }
  2623. .popboxs {
  2624. width: 100%;
  2625. height: 100%;
  2626. display: flex;
  2627. flex-direction: column;
  2628. align-items: center;
  2629. }
  2630. .classTops {
  2631. flex-shrink: 0;
  2632. padding: 39rpx 0rpx 4rpx;
  2633. font-weight: bold;
  2634. color: #333;
  2635. font-size: 30rpx;
  2636. }
  2637. .textStys {
  2638. width: 100%;
  2639. flex: 1;
  2640. padding: 36rpx;
  2641. }
  2642. .classFootsty {
  2643. flex-shrink: 0;
  2644. display: flex;
  2645. align-items: center;
  2646. justify-content: center;
  2647. padding: 10rpx 0rpx 40rpx;
  2648. .btnsty {
  2649. width: 200rpx;
  2650. height: 80rpx;
  2651. border-radius: 40rpx;
  2652. font-weight: bold;
  2653. font-size: 30rpx;
  2654. text-align: center;
  2655. line-height: 80rpx;
  2656. }
  2657. .btns1 {
  2658. background-color: #f5f5f5;
  2659. color: #007aff;
  2660. }
  2661. .btns2 {
  2662. margin-left: 40rpx;
  2663. background-color: #007aff;
  2664. color: #ffffff;
  2665. }
  2666. }
  2667. </style>