questionBank.vue 66 KB

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