questionBank.vue 98 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502
  1. <template>
  2. <view class="questionBank">
  3. <uni-nav-bar
  4. class="navbar"
  5. @clickLeft="clickLeft"
  6. left-icon="back"
  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. class="leftLetters"
  30. @click="collect(collectList[bankIndex], bankIndex)"
  31. style="justify-content: flex-end"
  32. >
  33. <image
  34. v-if="collectList[bankIndex]"
  35. src="/static/icon_star_sel.png"
  36. ></image>
  37. <image v-else src="/static/icon_star.png"></image>
  38. </view>
  39. </view>
  40. <view class="titles">
  41. <rich-text :nodes="bank.content"></rich-text>
  42. </view>
  43. </view>
  44. <template v-if="bank.type == 1">
  45. <view class="pad_8 titBox no-margin">
  46. <view v-if="!bank.ques">
  47. <view
  48. v-for="(item, index) in bank.jsonStr"
  49. :key="index"
  50. class="lisSty"
  51. @click="radioSelect(item.optionsId, bankIndex)"
  52. >
  53. <view class="activeTI">{{ ast[index] }}</view>
  54. <view class="flex_auto">{{ item.content }}</view>
  55. </view>
  56. </view>
  57. <view v-if="bank.ques">
  58. <view
  59. v-for="(item, index) in bank.jsonStr"
  60. :key="index"
  61. class="lisSty"
  62. @click="radioSelect(item.optionsId, bankIndex)"
  63. >
  64. <text
  65. :class="{
  66. right:
  67. bankType == 1 &&
  68. (item.optionsId == bank.ques ||
  69. item.optionsId == bank.ans),
  70. wrong:
  71. bankType == 1 &&
  72. item.optionsId == bank.ques &&
  73. bank.ques != bank.ans,
  74. user_choose: bankType == 2 && item.optionsId == bank.ques,
  75. }"
  76. class="activeTI"
  77. >
  78. {{ ast[index] }}
  79. </text>
  80. <view class="flex_auto">{{ item.content }}</view>
  81. </view>
  82. </view>
  83. </view>
  84. <view v-if="bankType == 1 && bank.ques">
  85. <view class="pad_8 answer">
  86. <view>题目答案:{{ ast[bank.ans - 1] }}</view>
  87. <view>我的答案:{{ ast[bank.ques - 1] }}</view>
  88. </view>
  89. <view class="pad_8 answerInfos">
  90. <view class="answerTitle">答案解析</view>
  91. <view class="answerContent">
  92. <rich-text :nodes="bank.analysisContent"></rich-text>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <template v-if="bank.type == 2">
  98. <view class="pad_8 titBox no-margin">
  99. <view v-if="!bank.ques">
  100. <view
  101. v-for="(item, index) in bank.jsonStr"
  102. :key="index"
  103. class="lisSty"
  104. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  105. >
  106. <view :class="{ checked: item.checked }" class="activeTI">{{
  107. ast[index]
  108. }}</view>
  109. <view class="flex_auto">{{ item.content }}</view>
  110. </view>
  111. </view>
  112. <view
  113. v-if="bankType == 2 || (bankType == 1 && !bank.ques)"
  114. class="submit_checkbox"
  115. :class="{ disabled: !isCheckboxChecked(bank.jsonStr) }"
  116. @click="checkboxSubmit(bankIndex)"
  117. >确认答案</view
  118. >
  119. <view v-if="bank.ques">
  120. <view
  121. v-for="(item, index) in bank.jsonStr"
  122. :key="index"
  123. class="lisSty"
  124. @click="checkboxSelect(item.optionsId, bankIndex, index)"
  125. >
  126. <text
  127. :class="{
  128. right:
  129. bankType == 1 &&
  130. (bank.ques.indexOf(item.optionsId) != -1 ||
  131. bank.ans.indexOf(item.optionsId) != -1),
  132. wrong:
  133. bankType == 1 &&
  134. bank.ques.indexOf(item.optionsId) != -1 &&
  135. bank.ans.indexOf(item.optionsId) == -1,
  136. user_choose: bankType == 2 && item.checked,
  137. }"
  138. class="activeTI"
  139. >
  140. {{ ast[index] }}
  141. </text>
  142. <view class="flex_auto">{{ item.content }}</view>
  143. </view>
  144. </view>
  145. </view>
  146. <view v-if="bankType == 1 && bank.ques">
  147. <view class="pad_8 answer">
  148. <view>
  149. 题目答案:
  150. <text
  151. v-for="(ansItem, ansItemIndex) in bank.ans"
  152. :key="ansItemIndex"
  153. >{{ ast[ansItem - 1] }}</text
  154. >
  155. </view>
  156. <view>
  157. 我的答案:
  158. <text
  159. v-for="(quesItem, quesItemIndex) in bank.ques"
  160. :key="quesItemIndex"
  161. >{{ ast[quesItem - 1] }}</text
  162. >
  163. </view>
  164. </view>
  165. <view class="pad_8 answerInfos">
  166. <view class="answerTitle">答案解析</view>
  167. <view class="answerContent">
  168. <rich-text :nodes="bank.analysisContent"></rich-text>
  169. </view>
  170. </view>
  171. </view>
  172. </template>
  173. <template v-if="bank.type == 3">
  174. <view class="pad_8 titBox no-margin">
  175. <view v-if="!bank.ques">
  176. <view
  177. v-for="(item, index) in judge"
  178. :key="index"
  179. class="lisSty"
  180. @click="judgeSelect(index, bankIndex)"
  181. >
  182. <view class="activeTI">{{ ast[index] }}</view>
  183. <view class="flex_auto">
  184. {{ item }}
  185. </view>
  186. </view>
  187. </view>
  188. <view v-if="bank.ques">
  189. <view
  190. v-for="(item, index) in judge"
  191. :key="index"
  192. class="lisSty"
  193. @click="judgeSelect(index, bankIndex)"
  194. >
  195. <text
  196. :class="{
  197. right:
  198. bankType == 1 &&
  199. (index == (bank.ques == 1 ? 0 : 1) ||
  200. index != bank.ans),
  201. wrong:
  202. bankType == 1 &&
  203. index == (bank.ques == 1 ? 0 : 1) &&
  204. bank.ques != bank.ans,
  205. user_choose:
  206. bankType == 2 && index == (bank.ques == 1 ? 0 : 1),
  207. }"
  208. class="activeTI"
  209. >
  210. {{ ast[index] }}
  211. </text>
  212. <view class="flex_auto">
  213. {{ item }}
  214. </view>
  215. </view>
  216. </view>
  217. </view>
  218. <view v-if="bankType == 1 && bank.ques">
  219. <view class="pad_8 answer">
  220. <view>题目答案:{{ ast[bank.ans == 1 ? 0 : 1] }}</view>
  221. <view>我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view>
  222. </view>
  223. <view class="pad_8 answerInfos">
  224. <view class="answerTitle">答案解析</view>
  225. <view class="answerContent">
  226. <rich-text :nodes="bank.analysisContent"></rich-text>
  227. </view>
  228. </view>
  229. </view>
  230. </template>
  231. <!-- 简答题 -->
  232. <template v-if="bank.type == 5">
  233. <view class="pad_8 titBox">
  234. <view class="ans">
  235. <view
  236. class="ans_input"
  237. v-if="
  238. bankType == 2 ||
  239. (bankType == 1 &&
  240. (!bank.ques ||
  241. (!bank.ques.imageList.length && !bank.ques.text)))
  242. "
  243. >
  244. <view class="top flex">
  245. <image
  246. :data-index="bankIndex"
  247. class="icon"
  248. @click="chooseImg(bankIndex)"
  249. src="/static/camera.png"
  250. mode=""
  251. ></image>
  252. <view class="progress"
  253. >{{ bank.ansText.imageList.length || "0" }}/4</view
  254. >
  255. <view
  256. class="submit"
  257. :class="{ disabled: !bank.ansText.text && hasImgs(bank) }"
  258. @click="submitAns(bankIndex)"
  259. >确认答案</view
  260. >
  261. </view>
  262. <view class="textarea">
  263. <textarea
  264. v-model="bank.ansText.text"
  265. placeholder="在此输入答案"
  266. ></textarea>
  267. </view>
  268. <view class="imgs">
  269. <view
  270. class="img"
  271. v-for="(img, imgIndex) in bank.ansText.imageList"
  272. :key="imgIndex"
  273. >
  274. <text @click="deleteImg(imgIndex, bankIndex)">x</text>
  275. <image :src="$method.splitImgHost(img, true)"></image>
  276. </view>
  277. </view>
  278. </view>
  279. <view
  280. class="ans_submit answerInfos"
  281. v-if="
  282. bankType == 1 &&
  283. (bank.ques.text || bank.ques.imageList.length)
  284. "
  285. >
  286. <view class="answerTitle">我的答案:</view>
  287. {{ bank.ques.text }}
  288. <view class="imgs">
  289. <image
  290. class="img"
  291. v-for="(ques, quesIndex) in bank.ques.imageList"
  292. :key="quesIndex"
  293. :src="$method.splitImgHost(ques, true)"
  294. ></image>
  295. </view>
  296. </view>
  297. </view>
  298. </view>
  299. <view
  300. v-if="
  301. bankType == 1 &&
  302. bank.ques &&
  303. (bank.ques.text || bank.ques.imageList.length)
  304. "
  305. >
  306. <view class="pad_8 answerInfos">
  307. <view class="answerTitle">答案解析:</view>
  308. <view class="answerContent">
  309. <rich-text :nodes="bank.analysisContent"></rich-text>
  310. </view>
  311. </view>
  312. </view>
  313. </template>
  314. <!-- 案例题 -->
  315. <template v-if="bank.type == 4">
  316. <view class="tabs">
  317. <view
  318. class="tab"
  319. :class="{ current: tabIndex == bank.current }"
  320. :key="tabIndex"
  321. v-for="(tab, tabIndex) in bank.jsonStr"
  322. @click="tabSelect(tabIndex, bankIndex)"
  323. >
  324. 问题{{ tabIndex + 1 }}
  325. </view>
  326. </view>
  327. <view
  328. v-for="(ansItem, ansIndex) in bank.jsonStr"
  329. v-if="bank.current == ansIndex"
  330. :key="ansIndex"
  331. >
  332. <template v-if="ansItem.type == 1">
  333. <view class="pad_8 titBox">
  334. <view class="leftLetters">
  335. <view class="btnType">
  336. <text>单选</text>
  337. </view>
  338. </view>
  339. <view class="titles">
  340. <rich-text :nodes="ansItem.content"></rich-text>
  341. </view>
  342. <view v-if="!bank.ques[ansIndex]">
  343. <view
  344. v-for="(option, childIndex) in ansItem.optionsList"
  345. :key="childIndex"
  346. class="lisSty"
  347. @click="
  348. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  349. "
  350. >
  351. <view class="activeTI">{{ ast[childIndex] }}</view>
  352. <view class="flex_auto">
  353. <rich-text
  354. class="textChild"
  355. :nodes="option.content"
  356. ></rich-text>
  357. </view>
  358. </view>
  359. </view>
  360. <view v-if="bank.ques[ansIndex]">
  361. <view
  362. v-for="(option, childIndex) in ansItem.optionsList"
  363. :key="childIndex"
  364. class="lisSty"
  365. @click="
  366. radioSelectChild(option.optionsId, ansIndex, bankIndex)
  367. "
  368. >
  369. <text
  370. :class="{
  371. right:
  372. bankType == 1 &&
  373. (option.optionsId == bank.ques[ansIndex] ||
  374. option.optionsId == bank.ans[ansIndex]),
  375. wrong:
  376. bankType == 1 &&
  377. option.optionsId == bank.ques[ansIndex] &&
  378. bank.ques[ansIndex] != bank.ans[ansIndex],
  379. user_choose:
  380. bankType == 2 &&
  381. option.optionsId == bank.ques[ansIndex],
  382. }"
  383. class="activeTI"
  384. >
  385. {{ ast[childIndex] }}
  386. </text>
  387. <view class="flex_auto">
  388. <rich-text :nodes="option.content"></rich-text>
  389. </view>
  390. </view>
  391. </view>
  392. </view>
  393. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  394. <view class="pad_8 answer">
  395. <view>题目答案:{{ ast[bank.ans[ansIndex] - 1] }}</view>
  396. <view>我的答案:{{ ast[bank.ques[ansIndex] - 1] }}</view>
  397. </view>
  398. <view class="pad_8 answerInfos">
  399. <view class="answerTitle">答案解析</view>
  400. <view class="answerContent">
  401. <rich-text :nodes="option.analysisContent"></rich-text>
  402. </view>
  403. </view>
  404. </view>
  405. </template>
  406. <template v-if="ansItem.type == 2">
  407. <view class="pad_8 titBox">
  408. <view class="leftLetters">
  409. <view class="btnType">
  410. <text>多选</text>
  411. </view>
  412. </view>
  413. <view class="titles">
  414. <rich-text :nodes="ansItem.content"></rich-text>
  415. </view>
  416. <view v-if="!bank.ques[ansIndex]">
  417. <view
  418. v-for="(option, childindex) in ansItem.optionsList"
  419. :key="childindex"
  420. class="lisSty"
  421. @click="
  422. checkboxSelectChild(bankIndex, ansIndex, childindex)
  423. "
  424. >
  425. <view
  426. :class="{ checked: option.checked }"
  427. class="activeTI"
  428. >
  429. {{ ast[childindex] }}
  430. </view>
  431. <view class="flex_auto">
  432. <rich-text :nodes="option.content"></rich-text>
  433. </view>
  434. </view>
  435. </view>
  436. <view
  437. v-if="
  438. bankType == 2 || (bankType == 1 && !bank.ques[ansIndex])
  439. "
  440. class="submit_checkbox"
  441. :class="{
  442. disabled: !isCheckboxChecked(ansItem.optionsList),
  443. }"
  444. @click="checkboxSubmitChild(bankIndex, ansIndex)"
  445. >确认答案</view
  446. >
  447. <view v-if="bank.ques && bank.ques[ansIndex]">
  448. <view
  449. v-for="(option, childindex) in ansItem.optionsList"
  450. :key="childindex"
  451. class="lisSty"
  452. @click="
  453. checkboxSelectChild(bankIndex, ansIndex, childindex)
  454. "
  455. >
  456. <text
  457. :class="{
  458. right:
  459. bankType == 1 && right(bankIndex, ansIndex, option),
  460. wrong:
  461. bankType == 1 && wrong(bankIndex, ansIndex, option),
  462. user_choose: bankType == 2 && option.checked,
  463. }"
  464. class="activeTI"
  465. >
  466. {{ ast[childindex] }}
  467. </text>
  468. <view class="flex_auto">
  469. <rich-text :nodes="option.content"></rich-text>
  470. </view>
  471. </view>
  472. </view>
  473. </view>
  474. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  475. <view class="pad_8 answer">
  476. <view>
  477. 题目答案:
  478. <text
  479. :key="ansItemIndex1"
  480. v-for="(ansItem1, ansItemIndex1) in bank.ans[ansIndex]"
  481. >{{ ast[ansItem1 - 1] }}</text
  482. >
  483. </view>
  484. <view>
  485. 我的答案:
  486. <text
  487. :key="quesItemIndex"
  488. v-for="(quesItem, quesItemIndex) in bank.ques[ansIndex]"
  489. >{{ ast[quesItem - 1] }}</text
  490. >
  491. </view>
  492. </view>
  493. <view class="pad_8 answerInfos">
  494. <view class="answerTitle">答案解析</view>
  495. <view class="answerContent">
  496. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  497. </view>
  498. </view>
  499. </view>
  500. </template>
  501. <template v-if="ansItem.type == 3">
  502. <view class="pad_8 titBox">
  503. <view class="leftLetters">
  504. <view class="btnType">
  505. <text>判断</text>
  506. </view>
  507. </view>
  508. <view class="titles">
  509. <rich-text :nodes="ansItem.content"></rich-text>
  510. </view>
  511. <view v-if="!bank.ques[ansIndex]">
  512. <view
  513. v-for="(option, childindex) in judge"
  514. :key="childindex"
  515. class="lisSty"
  516. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  517. >
  518. <view class="activeTI">{{ ast[childindex] }}</view>
  519. <view class="flex_auto">
  520. {{ option }}
  521. </view>
  522. </view>
  523. </view>
  524. <view v-if="bank.ques[ansIndex]">
  525. <view
  526. v-for="(option, childindex) in judge"
  527. :key="childindex"
  528. class="lisSty"
  529. @click="judgeSelectChild(ansIndex, childindex, bankIndex)"
  530. >
  531. <text
  532. :class="{
  533. right:
  534. bankType == 1 &&
  535. (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
  536. childindex != bank.ans[ansIndex]),
  537. wrong:
  538. bankType == 1 &&
  539. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
  540. bank.ques[ansIndex] != bank.ans[ansIndex],
  541. user_choose:
  542. bankType == 2 &&
  543. childindex == (bank.ques[ansIndex] == 1 ? 0 : 1),
  544. }"
  545. class="activeTI"
  546. >
  547. {{ ast[childindex] }}
  548. </text>
  549. <view class="flex_auto">
  550. {{ option }}
  551. </view>
  552. </view>
  553. </view>
  554. </view>
  555. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  556. <view class="pad_8 answer">
  557. <view
  558. >题目答案:{{
  559. ast[bank.ans[ansIndex] == 1 ? 0 : 1]
  560. }}</view
  561. >
  562. <view
  563. >我的答案:{{
  564. ast[bank.ques[ansIndex] == 1 ? 0 : 1]
  565. }}</view
  566. >
  567. </view>
  568. <view class="pad_8 answerInfos">
  569. <view class="answerTitle">答案解析</view>
  570. <view class="answerContent">
  571. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  572. </view>
  573. </view>
  574. </view>
  575. </template>
  576. <!-- 简答题 -->
  577. <template v-if="ansItem.type == 5">
  578. <view class="pad_8 titBox_title">
  579. <view class="leftLetters">
  580. <view class="btnType">
  581. <text>简答</text>
  582. </view>
  583. </view>
  584. <view class="titles">
  585. <rich-text :nodes="ansItem.content"></rich-text>
  586. </view>
  587. </view>
  588. <view class="pad_8 titBox_title">
  589. <view class="ans">
  590. <view
  591. class="ans_input"
  592. v-if="
  593. bankType == 2 ||
  594. (bankType == 1 &&
  595. (!bank.ques[ansIndex] ||
  596. (!bank.ques[ansIndex].text &&
  597. !bank.ques[ansIndex].imageList.length)))
  598. "
  599. >
  600. <view class="top flex">
  601. <image
  602. class="icon"
  603. @click="chooseImgChild(bankIndex, ansIndex)"
  604. src="/static/08-10_032.jpg"
  605. mode=""
  606. ></image>
  607. <view class="progress"
  608. >{{ ansItem.ansText.imageList.length || "0" }}/4
  609. </view>
  610. <view
  611. class="submit"
  612. @click="submitAnsChild(bankIndex, ansIndex)"
  613. >确认答案
  614. </view>
  615. </view>
  616. <view class="textarea">
  617. <textarea
  618. v-model="ansItem.ansText.text"
  619. placeholder="在此输入答案"
  620. ></textarea>
  621. </view>
  622. <view class="imgs">
  623. <view
  624. class="img"
  625. :key="imgIndex"
  626. v-for="(img, imgIndex) in ansItem.ansText.imageList"
  627. >
  628. <text
  629. @click="
  630. deleteImgChild(imgIndex, bankIndex, ansIndex)
  631. "
  632. >x</text
  633. >
  634. <image :src="$method.splitImgHost(img, true)"></image>
  635. </view>
  636. </view>
  637. </view>
  638. <view
  639. class="ans_submit answerInfos"
  640. v-if="bankType == 1 && bank.ques[ansIndex]"
  641. >
  642. <view class="answerTitle">我的答案</view>
  643. {{ bank.ques[ansIndex].text }}
  644. <view class="imgs">
  645. <image
  646. class="img"
  647. :key="quesIndex"
  648. v-for="(ques, quesIndex) in bank.ques[ansIndex]
  649. .imageList"
  650. :src="$method.splitImgHost(ques, true)"
  651. ></image>
  652. </view>
  653. </view>
  654. </view>
  655. </view>
  656. <view v-if="bankType == 1 && bank.ques[ansIndex]">
  657. <view class="pad_8 answerInfos">
  658. <view class="answerTitle">答案解析</view>
  659. <view class="answerContent">
  660. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  661. </view>
  662. </view>
  663. </view>
  664. </template>
  665. </view>
  666. </template>
  667. </view>
  668. </swiper-item>
  669. </swiper>
  670. <bank-bom
  671. v-if="questionList.length"
  672. :questionList="questionList"
  673. :bankType="bankType"
  674. :current.sync="current"
  675. @submit="pdsubmit"
  676. ></bank-bom>
  677. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  678. <view class="popupView">
  679. <view class="popupTops">
  680. <view class="topIcon"></view>
  681. 点击编号即可跳转至对应题目
  682. </view>
  683. <view class="popupContent">
  684. <scroll-view scroll-y="true" style="height: 506rpx">
  685. <view class="boxSty">
  686. <view
  687. v-for="(item, index) in questionList"
  688. :key="index"
  689. @click="changeIndex(index)"
  690. :class="{
  691. isRight: bankType == 1 && isRight(item, index),
  692. isWrong: bankType == 1 && isWrong(item, index),
  693. isPart: bankType == 1 && isPart(item, index),
  694. isOver: bankType == 1 && isOver(item, index),
  695. check_ans: bankType == 2 && isCheck(item, index),
  696. }"
  697. class="liListSty"
  698. >
  699. {{ index + 1 }}
  700. </view>
  701. </view>
  702. </scroll-view>
  703. </view>
  704. </view>
  705. </u-popup>
  706. <view class="dialog" v-if="showDialog">
  707. <view class="text">左右滑动切换上下题</view>
  708. <view class="btn" @click="hideDialog">我知道了</view>
  709. </view>
  710. <view class="dialog-arrow" v-if="showArrow">
  711. <image class="pointer" src="/static/arrow-left.png" mode=""></image>
  712. <view class="text">您当前正在测试, 若想退出请点击左上角返回按钮。</view>
  713. <view class="btn" @click="showArrow = false">我知道了</view>
  714. </view>
  715. <view class="dialog_wrap" v-if="testOver">
  716. <view class="bg"></view>
  717. <view class="dialog">
  718. <view class="title">温馨提示</view>
  719. <view class="content">
  720. <view>您已完成所有题目,</view>
  721. <view>快去交卷吧!</view>
  722. </view>
  723. <view class="btns">
  724. <view class="btn" @click="noSubmit()">暂不交卷</view>
  725. <view class="btn active" @click="submitNow()">立即交卷</view>
  726. </view>
  727. </view>
  728. </view>
  729. <view class="dialog_wrap" v-if="isLastCount">
  730. <view class="bg"></view>
  731. <view class="dialog">
  732. <view class="title">温馨提示</view>
  733. <view class="content">
  734. <view
  735. >您当前正在测试,还剩{{ lastCount }}道题未完成,离开视为交卷</view
  736. >
  737. </view>
  738. <view class="btns">
  739. <view class="btn" @click="noLeave()">暂不离开</view>
  740. <view class="btn active" @click="leaveNow()">继续离开</view>
  741. </view>
  742. </view>
  743. </view>
  744. <u-popup
  745. v-model="showpopups"
  746. mode="center"
  747. border-radius="24"
  748. height="439rpx"
  749. width="640rpx"
  750. :mask-close-able="false"
  751. >
  752. <view class="popboxs">
  753. <view class="classTops">温馨提示</view>
  754. <view class="textStys">
  755. {{
  756. cgType === 7
  757. ? "您还未交卷,确定结束做题吗?"
  758. : cgType === 8
  759. ? `您还有${lastCount}道题未作答, 现在继续作答,还是下次继续?`
  760. : cgType === 6
  761. ? `您还有${lastCount}道题未作答, 您确定要交卷吗?`
  762. : cgType == 9
  763. ? `您已完成所有题目,快去交卷吧!`
  764. : ""
  765. }}
  766. </view>
  767. <view class="classFootsty" v-if="cgType === 6">
  768. <view class="btnsty btns1" @click="submit()">立即交卷</view>
  769. <view class="btnsty btns2" @click="showpopups = false">继续做题</view>
  770. </view>
  771. <view class="classFootsty" v-if="cgType === 7">
  772. <view class="btnsty btns1" @click="showpopups = false">下次继续</view>
  773. <view class="btnsty btns2" @click="backPages">结束做题</view>
  774. </view>
  775. <view class="classFootsty" v-if="cgType === 8">
  776. <view class="btnsty btns1" @click="leaveNow()">下次继续</view>
  777. <view class="btnsty btns2" @click="showpopups = false">继续作答</view>
  778. </view>
  779. <view class="classFootsty" v-if="cgType === 9">
  780. <view class="btnsty btns1" @click="showpopups = false">暂不交卷</view>
  781. <view class="btnsty btns2" @click="submit()">立即交卷</view>
  782. </view>
  783. </view>
  784. </u-popup>
  785. <!-- 节卷不需要拍照 -->
  786. <!-- :show="examType != 2 && photoPopup" -->
  787. <u-popup
  788. v-model="photoPopup"
  789. mode="bottom"
  790. border-radius="40"
  791. :mask-close-able="false"
  792. >
  793. <!-- 播放前拍照start -->
  794. <!-- :mask-close-able="false" -->
  795. <!-- style="bottom: 0; position: fixed; width: 100%; z-index: 999" -->
  796. <view v-if="examType != 2 && photoPopup">
  797. <view class="photoBox">
  798. <view class="photoTop">
  799. <view class="sqzz" v-if="false">
  800. <u-icon
  801. name="close"
  802. color="#333333"
  803. size="30"
  804. @click="closePhoto"
  805. ></u-icon>
  806. </view>
  807. <view class="centersq">请正视手机屏幕</view>
  808. <view class="sqzz"></view>
  809. </view>
  810. <view class="photoCenter">
  811. <view class="center_camera" v-if="photoPopup && isTaking">
  812. <!-- #ifdef MP-WEIXIN -->
  813. <camera
  814. device-position="front"
  815. flash="off"
  816. @error="error"
  817. style="width: 100%; height: 100%"
  818. >
  819. <!-- 加人脸框 -->
  820. <cover-view class="head_take">
  821. <cover-view class="headTake_up color"></cover-view>
  822. <cover-view class="headTake_minddle">
  823. <cover-view class="min_left color"></cover-view>
  824. <cover-view class="min_img"></cover-view>
  825. <cover-view class="min_right color"></cover-view>
  826. </cover-view>
  827. <cover-view class="headTake_down color"></cover-view>
  828. </cover-view>
  829. </camera>
  830. <!-- #endif -->
  831. <!-- #ifdef H5 -->
  832. <video
  833. :controls="false"
  834. id="video"
  835. width="400"
  836. height="300"
  837. class="photo_v"
  838. ></video>
  839. <view class="mask"></view>
  840. <!-- #endif -->
  841. </view>
  842. <view class="custom" v-if="!isTaking">
  843. <!-- #ifdef MP-WEIXIN -->
  844. <image :src="avatarUrl" mode=""></image>
  845. <!-- #endif -->
  846. <!-- #ifdef H5 -->
  847. <image :src="faceUrl" mode=""></image>
  848. <!-- #endif -->
  849. </view>
  850. </view>
  851. <view class="photoBoxbtns">
  852. <!-- <view class="btnResult" v-if="isTaking" @click="takePhoto"
  853. >拍照</view
  854. > -->
  855. <view v-if="isTaking" class="takePhoto_btn">
  856. <view style="width: 100rpx; height: 2rpx"></view>
  857. <view class="middle_btn" @click="takePhoto">
  858. <view class="square"></view>
  859. </view>
  860. <view class="rights" @click="takePhTips()">
  861. <text>拍照提示</text>
  862. <u-icon name="arrow-right" color="#FFFFFF" size="30"></u-icon>
  863. </view>
  864. </view>
  865. <view class="btnResult" v-if="!isTaking" @click="reTake">重拍</view>
  866. <view class="btnResult" v-if="!isTaking" @click="submitPhoto"
  867. >确认</view
  868. >
  869. </view>
  870. </view>
  871. </view>
  872. </u-popup>
  873. <!-- 拍照提示 -->
  874. <popup-photo
  875. :popupPhotoShow.sync="popupPhotoShow"
  876. @takePhoto="toTakePhoto()"
  877. ></popup-photo>
  878. </view>
  879. </template>
  880. <script>
  881. import PopupPhoto from "@/components/popup/index.vue";
  882. import BankBom from "../../components/common/BankBom.vue";
  883. export default {
  884. components: {
  885. PopupPhoto,
  886. BankBom,
  887. },
  888. data() {
  889. return {
  890. photoPopup: false,
  891. showpopups: false,
  892. id: "",
  893. current: 0,
  894. questionList: [],
  895. ast: ["A", "B", "C", "D", "E", "F", "G"],
  896. judge: ["正确", "错误"],
  897. ans: [],
  898. ques: [],
  899. show: false,
  900. showDialog: false,
  901. bankList: [],
  902. collectList: [],
  903. goodsId: "",
  904. recordId: "",
  905. isSubmit: false,
  906. lastTime: 0, //剩余考试时长
  907. allTimes: 0, //总考试时长
  908. timer: null,
  909. wrongList: [],
  910. bankType: 0, //试卷类型
  911. needBack: false, //是否是考试
  912. testOver: false,
  913. isLastCount: false, //是否有未答题目
  914. lastCount: 0, //剩余没有回答的题目数
  915. chapterId: 0,
  916. moduleId: 0,
  917. sectionId: 0,
  918. showArrow: false, //退出提示
  919. isFromVideo: "",
  920. gradeId: "",
  921. courseId: 0,
  922. cgType: 0, //对应设计稿弹窗编码,
  923. avatarUrl: "",
  924. ossAvatarUrl: "",
  925. goodsDetail: {},
  926. isTakePhoto: false,
  927. orderGoodsId: 0,
  928. isTaking: true, //是否正在拍照
  929. needPhoto: false, //是否需要拍照
  930. examType: 0, // 3-模块,1-章,2-节
  931. compareFaceData: 0, // 拍照匹配相似度
  932. learning: false, // 1合格,0不合格
  933. originShowDialog: false,
  934. uploadLock: false, //上传图片
  935. examData: {},
  936. popupPhotoShow: false,
  937. // h5
  938. faceUrl: "",
  939. simulateExamId: undefined,
  940. isBackVideo: "",
  941. isReach: false, //599重拍
  942. };
  943. },
  944. watch: {
  945. photoPopup(n) {
  946. // 拍照弹窗和showDialog同时出现时,先展示拍照弹窗再展示showDialog弹窗
  947. if (n) {
  948. this.showDialog && (this.showDialog = false);
  949. } else {
  950. this.originShowDialog && (this.showDialog = true);
  951. }
  952. },
  953. },
  954. async onLoad(option) {
  955. this.examType = option.type;
  956. this.id = option.id;
  957. this.goodsId = option.goodsid || "";
  958. this.chapterId = option.chapterId;
  959. this.courseId = option.courseId;
  960. this.sectionId = option.sectionId;
  961. this.moduleId = option.moduleId;
  962. this.isFromVideo = option.isFromVideo || "";
  963. this.gradeId = option.gradeId || "";
  964. this.orderGoodsId = Number(option.orderGoodsId);
  965. let isBack = option.isback;
  966. this.isBackVideo = option.isBackVideo;
  967. let showDialog = uni.getStorageSync("showDialog");
  968. if (showDialog) {
  969. this.showDialog = false;
  970. } else {
  971. this.showDialog = true;
  972. this.originShowDialog = true;
  973. uni.setStorageSync("showDialog", "1");
  974. }
  975. //考试时候用手势或者返回键 被迫返回做题
  976. if (isBack) {
  977. let app = getApp();
  978. let globalData = app.globalData;
  979. for (var k in globalData.bankData) {
  980. this[k] = globalData.bankData[k];
  981. }
  982. this.showArrow = true;
  983. //需要拍没拍过直接弹出摄像头
  984. if (this.needPhoto && !this.isTakePhoto) {
  985. if (!this.learning && this.examType != 2) {
  986. if (uni.getStorageSync("tabkePhotoShow")) {
  987. // #ifdef MP-WEIXIN
  988. this.photoPopup = true;
  989. this.isTaking = true;
  990. // #endif
  991. this.avatarUrl = "";
  992. // #ifdef H5
  993. this.isHadCamera();
  994. // #endif
  995. } else {
  996. this.popupPhotoShow = true;
  997. uni.setStorageSync("tabkePhotoShow", 1); // 本地缓存用来判断是否已经弹出过弹窗
  998. }
  999. }
  1000. } else {
  1001. //不需要拍照
  1002. if (this.lastTime) {
  1003. this.timer = setInterval(() => {
  1004. if (this.lastTime <= 0) {
  1005. clearInterval(this.timer);
  1006. uni.showToast({
  1007. icon: "none",
  1008. mask: true,
  1009. title: "考试时间已到,系统将自动交卷",
  1010. duration: 10000,
  1011. });
  1012. this.submit();
  1013. return;
  1014. }
  1015. this.lastTime--;
  1016. }, 1000);
  1017. }
  1018. }
  1019. } else {
  1020. await this.getGoodsDetail();
  1021. this.needPhoto && (await this.getExamLearnStatus());
  1022. // 请求题目列表
  1023. await this.bankExam();
  1024. this.goodsQuestionList();
  1025. }
  1026. },
  1027. mounted() {},
  1028. onUnload() {
  1029. if (this.isSubmit) {
  1030. clearInterval(this.timer);
  1031. return;
  1032. }
  1033. if (this.needPhoto && !this.isTakePhoto) {
  1034. return;
  1035. }
  1036. //考试试卷 阻止ios手势返回,自动跳回答题页
  1037. if (this.needBack) {
  1038. let app = getApp();
  1039. app.globalData.bankData = this.$data;
  1040. clearInterval(this.timer);
  1041. uni.navigateTo({
  1042. url:
  1043. "/pages2/class/questionBank?id=" +
  1044. this.id +
  1045. "&goodsid=" +
  1046. this.goodsId +
  1047. "&isback=true&orderGoodsId=" +
  1048. this.orderGoodsId,
  1049. });
  1050. } else {
  1051. //点击返回按钮确认允许退出,交卷
  1052. clearInterval(this.timer);
  1053. this.examRecordEdit();
  1054. }
  1055. },
  1056. computed: {
  1057. doMode() {
  1058. // 做题模式 1章卷 2随机练习 3模拟组卷
  1059. return this.examData.simulateStatus ? 3 : undefined;
  1060. },
  1061. },
  1062. methods: {
  1063. getExamLearnStatus() {
  1064. return this.$api
  1065. .getExamLearnStatus({
  1066. goodsId: this.goodsId,
  1067. gradeId: this.gradeId,
  1068. chapterId: this.chapterId,
  1069. courseId: this.courseId,
  1070. moduleId: this.moduleId,
  1071. type: this.examType,
  1072. examId: this.id,
  1073. })
  1074. .then((res) => {
  1075. this.learning = res.data.data;
  1076. return Promise.resolve();
  1077. });
  1078. },
  1079. getGoodsDetail() {
  1080. return new Promise((resolve) => {
  1081. let self = this;
  1082. this.$api.goodsDetail(this.goodsId).then((res) => {
  1083. self.goodsDetail = res.data.data;
  1084. if (self.goodsDetail.goodsPhotoExamConfig) {
  1085. let goodsPhotoExamConfig = JSON.parse(
  1086. self.goodsDetail.goodsPhotoExamConfig
  1087. );
  1088. if (goodsPhotoExamConfig.photograph > 0) {
  1089. self.needPhoto = true;
  1090. }
  1091. }
  1092. resolve();
  1093. });
  1094. });
  1095. },
  1096. reTake() {
  1097. this.isTaking = true;
  1098. // #ifdef H5
  1099. this.faceUrl = "";
  1100. this.getUserMedia({
  1101. video: {
  1102. width: 400,
  1103. height: 300,
  1104. },
  1105. });
  1106. // #endif
  1107. },
  1108. postStudyRecord() {
  1109. let self = this;
  1110. let data = {
  1111. photo: self.ossAvatarUrl,
  1112. recordId: self.recordId,
  1113. };
  1114. if (this.ossAvatarUrl) {
  1115. data.similarity = this.compareFaceData; // 相似度
  1116. }
  1117. // console.log(data, "拍照提交");
  1118. this.$api.studyExamPhotoRecord(data).then((res) => {
  1119. // console.log(res, "拍照提交结果");
  1120. if (res.data.code != 200) {
  1121. uni.showToast({
  1122. icon: "none",
  1123. mask: true,
  1124. title: res.data.msg,
  1125. duration: 10000,
  1126. });
  1127. return;
  1128. }
  1129. self.ossAvatarUrl = "";
  1130. self.isTakePhoto = true;
  1131. if(this.isReach){
  1132. return this.submit();
  1133. }
  1134. //拍照
  1135. if (this.lastTime) {
  1136. this.timer = setInterval(() => {
  1137. if (this.lastTime <= 0) {
  1138. clearInterval(this.timer);
  1139. uni.showToast({
  1140. icon: "none",
  1141. mask: true,
  1142. title: "考试时间已到,系统将自动交卷",
  1143. duration: 10000,
  1144. });
  1145. this.submit();
  1146. return;
  1147. }
  1148. this.lastTime--;
  1149. }, 1000);
  1150. }
  1151. });
  1152. },
  1153. uploadFile(options, int) {
  1154. var self = this;
  1155. return new Promise((resolve, reject) => {
  1156. var data = {
  1157. imageStatus: int,
  1158. gradeId: this.gradeId,
  1159. };
  1160. self.$api.aliyunpolicy(data).then((res) => {
  1161. if (res.data.code != 200) {
  1162. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  1163. return;
  1164. }
  1165. var ossToken = res.data.data.resultContent;
  1166. if (ossToken.host == null || ossToken.host == undefined) {
  1167. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  1168. return;
  1169. }
  1170. let filePath = "";
  1171. // #ifdef H5
  1172. var localData = options; //dataUrl为base64位
  1173. let base = atob(localData.substring(localData.indexOf(",") + 1)); // base是将base64编码解码,去掉data:image/png;base64部分
  1174. let length = base.length;
  1175. let url = new Uint8Array(length);
  1176. while (length--) {
  1177. url[length] = base.charCodeAt(length);
  1178. }
  1179. filePath = new File([url], "a.jpg", {
  1180. type: "image/jpg",
  1181. });
  1182. console.log("filePath:", filePath);
  1183. uni.uploadFile({
  1184. url: ossToken.host,
  1185. name: "file",
  1186. file: filePath,
  1187. fileType: "image",
  1188. header: {
  1189. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1190. },
  1191. formData: {
  1192. key: ossToken.dir,
  1193. OSSAccessKeyId: ossToken.accessid,
  1194. policy: ossToken.policy,
  1195. Signature: ossToken.signature,
  1196. callback: ossToken.callback,
  1197. success_action_status: 200,
  1198. },
  1199. success: (result) => {
  1200. this.$u.toast("上传成功");
  1201. this.ossAvatarUrl = ossToken.dir;
  1202. console.log("h5上传成功--:", this.ossAvatarUrl);
  1203. resolve();
  1204. },
  1205. fail: (error) => {
  1206. console.log("h5上传失败:", error);
  1207. uni.showToast({
  1208. title: "上传接口报错,请重新拍照上传" + error,
  1209. icon: "none",
  1210. });
  1211. this.openPhoto();
  1212. return;
  1213. },
  1214. });
  1215. // #endif
  1216. // #ifdef MP-WEIXIN
  1217. uni.uploadFile({
  1218. url: ossToken.host,
  1219. name: "file",
  1220. filePath: options,
  1221. fileType: "image",
  1222. header: {
  1223. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1224. },
  1225. formData: {
  1226. key: ossToken.dir,
  1227. OSSAccessKeyId: ossToken.accessid,
  1228. policy: ossToken.policy,
  1229. Signature: ossToken.signature,
  1230. callback: ossToken.callback,
  1231. success_action_status: 200,
  1232. },
  1233. success: (result) => {
  1234. // if (result.statusCode === 200) {
  1235. self.ossAvatarUrl = ossToken.dir;
  1236. resolve(ossToken.dir);
  1237. // } else {
  1238. // uni.showToast({
  1239. // title: "上传失败",
  1240. // icon: "none",
  1241. // });
  1242. // return;
  1243. // }
  1244. },
  1245. fail: (error) => {
  1246. uni.showToast({
  1247. title: "上传接口报错" + error,
  1248. icon: "none",
  1249. });
  1250. this.uploadLock = false;
  1251. this.openPhoto();
  1252. return;
  1253. },
  1254. });
  1255. // #endif
  1256. });
  1257. });
  1258. },
  1259. imageInfos() {
  1260. var self = this;
  1261. return new Promise(async (resolve, reject) => {
  1262. // #ifdef MP-WEIXIN
  1263. uni.getImageInfo({
  1264. src: self.avatarUrl,
  1265. success: async (res) => {
  1266. let canvasWidth = res.width; //图片原始长宽
  1267. let canvasHeight = res.height;
  1268. if (canvasWidth > 2000 || canvasHeight > 2000) {
  1269. uni.compressImage({
  1270. src: self.avatarUrl,
  1271. quality: 75,
  1272. width: "35%",
  1273. height: "35%",
  1274. success: async (rest) => {
  1275. const waitUpload = await self.uploadFile(
  1276. rest.tempFilePath,
  1277. 0
  1278. );
  1279. resolve(waitUpload);
  1280. },
  1281. });
  1282. } else if (canvasWidth > 1000 || canvasHeight > 1000) {
  1283. uni.compressImage({
  1284. src: self.avatarUrl,
  1285. quality: 75,
  1286. width: "50%",
  1287. height: "50%",
  1288. success: async (rest) => {
  1289. const waitUpload = await self.uploadFile(
  1290. rest.tempFilePath,
  1291. 0
  1292. );
  1293. resolve(waitUpload);
  1294. },
  1295. });
  1296. } else {
  1297. console.log("无需压缩");
  1298. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  1299. resolve(waitUpload);
  1300. }
  1301. },
  1302. });
  1303. // #endif
  1304. // #ifdef H5
  1305. const waitUpload = await this.uploadFile(this.faceUrl, 0);
  1306. resolve(waitUpload);
  1307. // #endif
  1308. });
  1309. },
  1310. /**
  1311. * 人脸匹配
  1312. */
  1313. faceRecognition() {
  1314. return new Promise((resolve) => {
  1315. // #ifdef MP-WEIXIN
  1316. let fileSystem = uni.getFileSystemManager();
  1317. fileSystem.readFile({
  1318. filePath: `${this.avatarUrl}`,
  1319. encoding: "base64",
  1320. position: 0,
  1321. success: (res) => {
  1322. let base64 = "data:image/jpg;base64," + res.data;
  1323. console.log("试卷-base64Data人脸识别参数:", {
  1324. imageA: base64,
  1325. orderGoodsId: this.orderGoodsId,
  1326. gradeId: this.gradeId,
  1327. });
  1328. this.CompareFace(base64, resolve);
  1329. },
  1330. fail(err) {
  1331. console.error(err, "err");
  1332. },
  1333. });
  1334. // #endif
  1335. // #ifdef H5
  1336. this.CompareFace(this.faceUrl, resolve);
  1337. // #endif
  1338. });
  1339. },
  1340. CompareFace(url, resolve) {
  1341. let timer = setTimeout(() => {
  1342. uni.showToast({
  1343. icon: "none",
  1344. title: "拍照超时,请重新拍照",
  1345. duration: 2000,
  1346. success: () => {
  1347. setTimeout(() => {
  1348. uni.navigateBack();
  1349. }, 1000);
  1350. },
  1351. });
  1352. }, 10 * 1000);
  1353. this.$api
  1354. .faceCertificationCompareFace({
  1355. imageA: url,
  1356. orderGoodsId: this.orderGoodsId,
  1357. gradeId: this.gradeId,
  1358. })
  1359. .then((res) => {
  1360. clearTimeout(timer);
  1361. console.log(res, "人脸识别成功res");
  1362. resolve(res.data.data);
  1363. })
  1364. .catch((err) => {
  1365. clearTimeout(timer);
  1366. // 当前网络延迟,
  1367. console.log("人脸识别错误:", err);
  1368. uni.showModal({
  1369. content: "当前网络延迟",
  1370. showCancel: false,
  1371. success: (resultst) => {
  1372. if (resultst.confirm) {
  1373. uni.navigateBack();
  1374. }
  1375. },
  1376. });
  1377. });
  1378. },
  1379. toTakePhoto() {
  1380. this.popupPhotoShow = false;
  1381. this.openPhoto();
  1382. },
  1383. takePhTips() {
  1384. this.popupPhotoShow = true;
  1385. this.isTaking = false;
  1386. this.photoPopup = false;
  1387. },
  1388. // 确认拍照
  1389. async submitPhoto() {
  1390. if (this.uploadLock) {
  1391. return;
  1392. }
  1393. this.uploadLock = true;
  1394. let compareFaceData = await this.faceRecognition();
  1395. this.compareFaceData = compareFaceData;
  1396. if (compareFaceData >= 80) {
  1397. const waitYS = await this.imageInfos();
  1398. this.postStudyRecord(); //提交记录
  1399. this.photoPopup = false;
  1400. } else {
  1401. uni.showToast({
  1402. title: "人脸匹配不通过,请重新拍照上传",
  1403. icon: "none",
  1404. duration: 2000,
  1405. });
  1406. setTimeout(() => {
  1407. this.uploadLock = false;
  1408. this.openPhoto();
  1409. }, 2000);
  1410. }
  1411. },
  1412. //拍照
  1413. openPhoto() {
  1414. console.log("开始拍照");
  1415. // this.enableAutoRotation = false;
  1416. // #ifdef MP-WEIXIN
  1417. this.photoPopup = true;
  1418. this.isTaking = true;
  1419. uni.setKeepScreenOn({
  1420. keepScreenOn: true,
  1421. });
  1422. uni.authorize({
  1423. scope: "scope.camera",
  1424. success() {},
  1425. });
  1426. // #endif
  1427. // #ifdef H5
  1428. this.isHadCamera();
  1429. // #endif
  1430. },
  1431. isHadCamera() {
  1432. if (
  1433. (window.navigator.mediaDevices &&
  1434. window.navigator.mediaDevices.getUserMedia) ||
  1435. window.navigator.getUserMedia ||
  1436. window.navigator.webkitGetUserMedia ||
  1437. window.navigator.mozGetUserMedia
  1438. ) {
  1439. console.log("getUserMedia----");
  1440. // 调用用户媒体设备, 访问摄像头
  1441. this.getUserMedia(
  1442. {
  1443. video: {
  1444. width: 400,
  1445. height: 300,
  1446. },
  1447. },
  1448. this.photographSuccess,
  1449. this.photographError
  1450. );
  1451. } else {
  1452. console.log("1111没有摄像");
  1453. this.photographError();
  1454. }
  1455. },
  1456. //确认拍照
  1457. takePhoto() {
  1458. // #ifdef MP-WEIXIN
  1459. const ctx = uni.createCameraContext();
  1460. ctx.takePhoto({
  1461. quality: "high",
  1462. success: (res) => {
  1463. console.log(res.tempImagePath);
  1464. this.avatarUrl = res.tempImagePath;
  1465. // self.submitPhoto();
  1466. this.isTaking = false;
  1467. },
  1468. fail: (err) => {
  1469. console.log(err);
  1470. },
  1471. });
  1472. // #endif
  1473. // #ifdef H5
  1474. const canvas = document.createElement("canvas");
  1475. canvas.width = 400;
  1476. canvas.height = 400;
  1477. const context = canvas.getContext("2d");
  1478. const video = document.querySelector("video");
  1479. context.drawImage(video, 0, 0, 400, 400);
  1480. this.faceUrl = canvas.toDataURL("image/png");
  1481. this.isTaking = false;
  1482. // #endif
  1483. },
  1484. /**
  1485. * 是否有上传图片
  1486. */
  1487. hasImgs(bank) {
  1488. return bank.ansText.imageList.length == 0;
  1489. },
  1490. /**
  1491. * 获取试卷类型2考试,1练习
  1492. */
  1493. bankExam() {
  1494. return this.$api.bankExam(this.id).then((res) => {
  1495. const { examLimitClient, doType } = res.data.data;
  1496. if (!this.$method.examClientCanLearn(examLimitClient)) {
  1497. return;
  1498. }
  1499. this.bankType = doType;
  1500. this.examData = res.data.data;
  1501. this.allTimes = this.examData.answerTime * 60;
  1502. this.lastTime =
  1503. this.examData.answerTime && this.examData.answerTime * 60;
  1504. if (this.bankType == 2) {
  1505. this.needBack = true;
  1506. }
  1507. return Promise.resolve();
  1508. });
  1509. },
  1510. /**
  1511. * 点击后退按钮
  1512. */
  1513. clickLeft() {
  1514. //需要拍照没有拍直接返回
  1515. if (this.needPhoto && !this.isTakePhoto) {
  1516. this.isSubmit = true;
  1517. uni.navigateBack({
  1518. delta: 1,
  1519. });
  1520. return;
  1521. }
  1522. if (this.bankType == 1) {
  1523. let ansCount = this.questionOverNum(); //已答题数
  1524. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1525. //所有题目答完
  1526. if (this.lastCount == 0) {
  1527. // this.testOver = true;
  1528. this.cgType = 7;
  1529. //未答完
  1530. } else {
  1531. this.cgType = 8;
  1532. // this.isLastCount = true;
  1533. }
  1534. this.showpopups = true;
  1535. } else if (this.bankType == 2) {
  1536. let ansCount = this.questionOverNum(); //已答题数
  1537. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1538. //所有题目答完
  1539. if (this.lastCount == 0) {
  1540. this.testOver = true;
  1541. //未答完
  1542. } else {
  1543. this.isLastCount = true;
  1544. }
  1545. }
  1546. },
  1547. /**
  1548. * 返回上一页
  1549. */
  1550. backPages() {
  1551. this.needBack = false;
  1552. uni.navigateBack({
  1553. delta: 1,
  1554. });
  1555. },
  1556. /**
  1557. * 获取已经回答的题目数
  1558. * hasSpecail (是否包含简答和案例)
  1559. */
  1560. questionOverNum(hasSpecail) {
  1561. let count = 0;
  1562. this.questionList.forEach((item) => {
  1563. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1564. if (item.ques) {
  1565. count++;
  1566. }
  1567. } else if (item.type == 4) {
  1568. //案例题
  1569. if (hasSpecail) {
  1570. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1571. if (
  1572. jsonItem.type == 1 ||
  1573. jsonItem.type == 2 ||
  1574. jsonItem.type == 3
  1575. ) {
  1576. if (item.ques[indexs]) {
  1577. return true;
  1578. } else {
  1579. return false;
  1580. }
  1581. } else if (jsonItem.type == 5) {
  1582. console.log(jsonItem, 111);
  1583. if (
  1584. item.ques[indexs] &&
  1585. (item.ques[indexs].text.length ||
  1586. item.ques[indexs].imageList.length)
  1587. ) {
  1588. return true;
  1589. } else {
  1590. return false;
  1591. }
  1592. }
  1593. });
  1594. if (isOver) {
  1595. count++;
  1596. console.log(item, 444);
  1597. }
  1598. }
  1599. } else if (item.type == 5) {
  1600. //简答题
  1601. if (hasSpecail) {
  1602. if (
  1603. item.ques &&
  1604. (item.ques.text.length || item.ques.imageList.length)
  1605. ) {
  1606. count++;
  1607. }
  1608. }
  1609. }
  1610. });
  1611. return count;
  1612. },
  1613. /**
  1614. * 是否做完所有题目
  1615. */
  1616. isDoOver() {
  1617. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1618. if (this.questionList.length == questionOverNum) {
  1619. //全部做完弹窗
  1620. this.cgType = 9;
  1621. this.showpopups = true;
  1622. }
  1623. },
  1624. /**
  1625. * 暂不交卷
  1626. */
  1627. noSubmit() {
  1628. //设为允许退出页面
  1629. this.needBack = false;
  1630. uni.navigateBack({
  1631. delta: 1,
  1632. });
  1633. },
  1634. /**
  1635. * 不离开
  1636. */
  1637. noLeave() {
  1638. this.isLastCount = false;
  1639. },
  1640. /**
  1641. * 立即离开并交卷
  1642. */
  1643. leaveNow() {
  1644. this.isSubmit = true;
  1645. uni.navigateBack({
  1646. delta: 1,
  1647. });
  1648. //需要拍照没有拍,返回不扣次数
  1649. if (this.needPhoto && !this.isTakePhoto) {
  1650. return;
  1651. }
  1652. this.submit("leaveNow");
  1653. },
  1654. /**
  1655. * 立即交卷
  1656. */
  1657. submitNow() {
  1658. this.showpopups = false;
  1659. this.needBack = false;
  1660. this.submit();
  1661. },
  1662. /**
  1663. * 离开页面统计回答正确题数
  1664. */
  1665. examRecordEdit() {
  1666. if (!this.isSubmit) {
  1667. this.submit("leave");
  1668. }
  1669. },
  1670. /**
  1671. * @param {Object} second倒计时过滤器
  1672. */
  1673. countdown(second) {
  1674. if (second) {
  1675. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1676. let m = parseInt((second / 60) % 60); // 计算分数
  1677. let s = parseInt(second % 60); // 计算当前秒数
  1678. if (h < 10) h = "0" + h;
  1679. if (m < 10) m = "0" + m;
  1680. if (s < 10) s = "0" + s;
  1681. return h + ":" + m + ":" + s;
  1682. } else {
  1683. return "";
  1684. }
  1685. },
  1686. noListTip(content = "该试卷暂无题目") {
  1687. this.hideDialog();
  1688. uni.showModal({
  1689. showCancel: false,
  1690. content,
  1691. success: (k) => {
  1692. if (k.confirm) {
  1693. this.isSubmit = true;
  1694. uni.navigateBack();
  1695. }
  1696. },
  1697. });
  1698. },
  1699. /**
  1700. * 请求题目列表
  1701. */
  1702. goodsQuestionList() {
  1703. this.$api[
  1704. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1705. ]({
  1706. examId: this.id,
  1707. goodsId: this.goodsId,
  1708. orderGoodsId: this.orderGoodsId,
  1709. from: 2,
  1710. }).then(async (res) => {
  1711. if (res.data.code == 500) {
  1712. return this.noListTip("你已完成所有题目");
  1713. }
  1714. let data = res.data.data;
  1715. if (this.doMode == 3) {
  1716. this.simulateExamId = data.simulateExamId;
  1717. data = data.questionList;
  1718. }
  1719. if (!data.length) {
  1720. return this.noListTip();
  1721. }
  1722. data.forEach((item, index) => {
  1723. if (typeof item.jsonStr == "string") {
  1724. item.jsonStr = JSON.parse(item.jsonStr);
  1725. if (item.type == 2) {
  1726. //多选
  1727. item.jsonStr.forEach((str) => {
  1728. str.optionsId = "" + str.optionsId;
  1729. });
  1730. let arr = item.answerQuestion.split(",");
  1731. arr.forEach((a, i) => {
  1732. arr[i] = "" + a;
  1733. });
  1734. item.ans = arr;
  1735. item.analysisContent &&
  1736. (item.analysisContent = item.analysisContent.replace(
  1737. /<img/gi,
  1738. '<img style="max-width:100%;"'
  1739. ));
  1740. item.content &&
  1741. (item.content = item.content.replace(
  1742. /<img/gi,
  1743. '<img style="max-width:100%;"'
  1744. ));
  1745. return;
  1746. } else if (item.type == 5) {
  1747. //简答题
  1748. item.ansText = {
  1749. text: "",
  1750. imageList: [],
  1751. };
  1752. item.ques = {
  1753. text: "",
  1754. imageList: [],
  1755. };
  1756. item.analysisContent &&
  1757. (item.analysisContent = item.analysisContent.replace(
  1758. /<img/gi,
  1759. '<img style="max-width:100%;"'
  1760. ));
  1761. item.content &&
  1762. (item.content = item.content.replace(
  1763. /<img/gi,
  1764. '<img style="max-width:100%;"'
  1765. ));
  1766. } else if (item.type == 4) {
  1767. //案例题
  1768. console.log(item.jsonStr);
  1769. item.ques = [];
  1770. item.current = 0;
  1771. let ansArr = [];
  1772. item.jsonStr.forEach((json, index) => {
  1773. if (json.type == 1) {
  1774. ansArr[index] = json.answerQuestion;
  1775. json.content &&
  1776. (json.content = json.content.replace(
  1777. /<img/gi,
  1778. '<img style="max-width:100%;"'
  1779. ));
  1780. } else if (json.type == 2) {
  1781. json.optionsList.forEach((str) => {
  1782. str.optionsId = "" + str.optionsId;
  1783. });
  1784. let arr = json.answerQuestion.split(",");
  1785. arr.forEach((a, i) => {
  1786. arr[i] = "" + a;
  1787. });
  1788. ansArr[index] = arr;
  1789. json.content &&
  1790. (json.content = json.content.replace(
  1791. /<img/gi,
  1792. '<img style="max-width:100%;"'
  1793. ));
  1794. } else if (json.type == 3) {
  1795. ansArr[index] = json.answerQuestion;
  1796. json.content &&
  1797. (json.content = json.content.replace(
  1798. /<img/gi,
  1799. '<img style="max-width:100%;"'
  1800. ));
  1801. } else if (json.type == 5) {
  1802. ansArr[index] = {
  1803. text: "",
  1804. imageList: [],
  1805. };
  1806. json.ansText = {
  1807. text: "",
  1808. imageList: [],
  1809. };
  1810. json.content &&
  1811. (json.content = json.content.replace(
  1812. /<img/gi,
  1813. '<img style="max-width:100%;"'
  1814. ));
  1815. }
  1816. });
  1817. item.analysisContent &&
  1818. (item.analysisContent = item.analysisContent.replace(
  1819. /<img/gi,
  1820. '<img style="max-width:100%;"'
  1821. ));
  1822. item.content &&
  1823. (item.content = item.content.replace(
  1824. /<img/gi,
  1825. '<img style="max-width:100%;"'
  1826. ));
  1827. item.ans = ansArr;
  1828. return;
  1829. }
  1830. item.content &&
  1831. (item.content = item.content.replace(
  1832. /<img/gi,
  1833. '<img style="max-width:100%;"'
  1834. ));
  1835. item.ans = item.answerQuestion;
  1836. }
  1837. });
  1838. this.questionList = data;
  1839. this.lastCount = this.questionList.length;
  1840. this.getCollectInfo(this.current);
  1841. await this.examRecord();
  1842. });
  1843. },
  1844. /**
  1845. * 记录总题数,获取recordId
  1846. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1847. */
  1848. examRecord(hasSpecial) {
  1849. return new Promise((resolve) => {
  1850. let questionList = 0;
  1851. // if(!hasSpecial) {
  1852. this.questionList.forEach((item, index) => {
  1853. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1854. questionList++;
  1855. }
  1856. });
  1857. // } else {
  1858. // questionList = this.questionList.length;
  1859. // }
  1860. this.$api
  1861. .bankRecord({
  1862. courseId: this.courseId,
  1863. // chapterExamId: this.chapterId || 0,
  1864. // moduleExamId: this.moduleId || 0,
  1865. chapterId: this.chapterId || 0,
  1866. moduleId: this.moduleId || 0,
  1867. sectionId: this.sectionId || 0,
  1868. examId: this.id,
  1869. goodsId: this.goodsId,
  1870. orderGoodsId: this.orderGoodsId,
  1871. gradeId: this.gradeId,
  1872. totalQuestionNum: questionList,
  1873. allQuestionNum: this.questionList.length,
  1874. type: this.examType,
  1875. simulateExamId: this.simulateExamId,
  1876. doMode: this.doMode,
  1877. })
  1878. .then((res) => {
  1879. this.recordId = res.data.data;
  1880. if (this.needPhoto) {
  1881. if (!this.learning && this.examType != 2) {
  1882. if (uni.getStorageSync("tabkePhotoShow")) {
  1883. // #ifdef MP-WEIXIN
  1884. this.photoPopup = true; //拍照
  1885. this.isTaking = true;
  1886. // #endif
  1887. // #ifdef H5
  1888. this.isHadCamera();
  1889. // #endif
  1890. } else {
  1891. this.popupPhotoShow = true;
  1892. uni.setStorageSync("tabkePhotoShow", 1); // 本地缓存用来判断是否已经弹出过弹窗
  1893. }
  1894. }
  1895. } else {
  1896. if (this.lastTime) {
  1897. this.timer = setInterval(() => {
  1898. if (this.lastTime <= 0) {
  1899. clearInterval(this.timer);
  1900. uni.showToast({
  1901. icon: "none",
  1902. mask: true,
  1903. title: "考试时间已到,系统将自动交卷",
  1904. duration: 10000,
  1905. });
  1906. this.submit();
  1907. return;
  1908. }
  1909. this.lastTime--;
  1910. }, 1000);
  1911. }
  1912. resolve();
  1913. }
  1914. });
  1915. });
  1916. },
  1917. /**
  1918. * @param {Object} e单选点击
  1919. */
  1920. radioSelect(optionsId, bindex) {
  1921. // if (this.questionList[bindex].ques) return;
  1922. if (this.questionList[bindex].ques && this.bankType == 1) {
  1923. return;
  1924. }
  1925. this.$set(this.questionList[bindex], "ques", optionsId);
  1926. // if ((bindex + 1) < this.questionList.length) {
  1927. // this.current = bindex + 1
  1928. // }
  1929. this.isDoOver();
  1930. },
  1931. /**
  1932. * @param {Object} e案例单选点击
  1933. */
  1934. radioSelectChild(optionsId, ansIndex, bindex) {
  1935. // if (this.questionList[bindex].ques[ansIndex]) return;
  1936. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1937. return;
  1938. }
  1939. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1940. this.isDoOver();
  1941. },
  1942. /**
  1943. * @param {Object} 多选点击
  1944. */
  1945. checkboxSelect(optionsId, bindex, index) {
  1946. if (this.questionList[bindex].ques && this.bankType == 1) {
  1947. return;
  1948. }
  1949. this.$set(
  1950. this.questionList[bindex].jsonStr[index],
  1951. "checked",
  1952. !this.questionList[bindex].jsonStr[index].checked
  1953. );
  1954. },
  1955. /**
  1956. * @param {Object} 案例多选点击
  1957. */
  1958. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1959. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1960. return;
  1961. }
  1962. this.$set(
  1963. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1964. "checked",
  1965. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1966. .checked
  1967. );
  1968. },
  1969. isCheckboxChecked(arr) {
  1970. return arr.some((item) => {
  1971. if (item.checked) {
  1972. return true;
  1973. }
  1974. });
  1975. },
  1976. /**
  1977. * @param {Object} 多选确认
  1978. */
  1979. checkboxSubmit(bindex) {
  1980. // if (this.questionList[bindex].ques) return;
  1981. if (this.questionList[bindex].ques && this.bankType == 1) {
  1982. return;
  1983. }
  1984. let arr = [];
  1985. this.questionList[bindex].jsonStr.forEach((item) => {
  1986. if (item.checked) {
  1987. arr.push(item.optionsId);
  1988. }
  1989. });
  1990. if (!arr.length) {
  1991. delete this.questionList[bindex].ques;
  1992. uni.showToast({
  1993. title: "请选择答案",
  1994. icon: "none",
  1995. });
  1996. return;
  1997. }
  1998. this.$set(this.questionList[bindex], "ques", arr);
  1999. this.$u.toast("已确认答案");
  2000. this.isDoOver();
  2001. // 切换下一题
  2002. if (
  2003. this.bankType != 1 &&
  2004. this.cgType != 9 &&
  2005. bindex != this.questionList.length - 1
  2006. ) {
  2007. this.current = bindex + 1;
  2008. this.getCollectInfo(this.current);
  2009. }
  2010. },
  2011. /**
  2012. * @param {Object} 案例多选确认
  2013. */
  2014. checkboxSubmitChild(bindex, ansIndex) {
  2015. // if (this.questionList[bindex].ques[ansIndex]) return;
  2016. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  2017. return;
  2018. }
  2019. let arr = [];
  2020. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  2021. (item) => {
  2022. if (item.checked) {
  2023. arr.push(item.optionsId);
  2024. }
  2025. }
  2026. );
  2027. if (!arr.length) {
  2028. delete this.questionList[bindex].ques[ansIndex];
  2029. uni.showToast({
  2030. title: "请选择答案",
  2031. icon: "none",
  2032. });
  2033. return;
  2034. }
  2035. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  2036. this.$u.toast("已确认答案");
  2037. this.isDoOver();
  2038. // 切换下一题
  2039. if (
  2040. this.bankType != 1 &&
  2041. this.cgType != 9 &&
  2042. ansIndex != this.questionList[bindex].ques.length - 1
  2043. ) {
  2044. this.questionList[bindex].current += 1;
  2045. }
  2046. },
  2047. /**
  2048. * @param {Object} index
  2049. * @param {Object} bindex
  2050. * 判断题
  2051. */
  2052. judgeSelect(index, bindex) {
  2053. // if (this.questionList[bindex].ques) return;
  2054. if (this.questionList[bindex].ques && this.bankType == 1) {
  2055. return;
  2056. }
  2057. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  2058. this.isDoOver();
  2059. },
  2060. /**
  2061. * @param {Object} ansindex
  2062. * @param {Object} childindex
  2063. * @param {Object} bindex
  2064. * 案例判断题
  2065. */
  2066. judgeSelectChild(ansindex, childindex, bindex) {
  2067. // if (this.questionList[bindex].ques[ansindex]) return;
  2068. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  2069. return;
  2070. }
  2071. this.$set(
  2072. this.questionList[bindex].ques,
  2073. ansindex,
  2074. childindex == 0 ? "1" : "0"
  2075. );
  2076. this.isDoOver();
  2077. },
  2078. openFooterTab() {
  2079. this.show = true;
  2080. },
  2081. hideDialog() {
  2082. this.showDialog = false;
  2083. },
  2084. changeIndex(index) {
  2085. this.current = index;
  2086. },
  2087. swiperChange(e) {
  2088. this.current = e.detail.current;
  2089. this.getCollectInfo(this.current);
  2090. },
  2091. /**
  2092. * @param {Object} current
  2093. * 获取收藏信息
  2094. */
  2095. getCollectInfo(current) {
  2096. this.$api
  2097. .getCollectInfo({
  2098. examId: this.id,
  2099. questionId: this.questionList[current].questionId,
  2100. goodsId: this.goodsId,
  2101. orderGoodsId: this.orderGoodsId,
  2102. })
  2103. .then((res) => {
  2104. if (res.data.code == 500) {
  2105. this.$set(this.collectList, current, false);
  2106. } else if (res.data.code == 200) {
  2107. this.$set(this.collectList, current, res.data.data);
  2108. }
  2109. });
  2110. },
  2111. /**
  2112. * @param {Object} state
  2113. * @param {Object} index
  2114. * 收藏
  2115. */
  2116. collect(state, index) {
  2117. if (!state) {
  2118. this.$api
  2119. .collectQuestion({
  2120. examId: this.id,
  2121. questionId: this.questionList[index].questionId,
  2122. goodsId: this.goodsId || "",
  2123. orderGoodsId: this.orderGoodsId,
  2124. doMode: this.doMode,
  2125. })
  2126. .then((res) => {
  2127. if (res.data.code == 200) {
  2128. this.$set(this.collectList, index, true);
  2129. uni.showToast({
  2130. title: "收藏成功",
  2131. duration: 2000,
  2132. icon: "none",
  2133. });
  2134. this.getCollectInfo(index);
  2135. }
  2136. });
  2137. } else {
  2138. this.$api
  2139. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2140. .then((res) => {
  2141. if (res.data.code == 200) {
  2142. this.$set(this.collectList, index, false);
  2143. uni.showToast({
  2144. title: "取消收藏成功",
  2145. duration: 2000,
  2146. icon: "none",
  2147. });
  2148. }
  2149. });
  2150. }
  2151. return;
  2152. },
  2153. pdsubmit() {
  2154. let ansCount = this.questionOverNum(true); //已答题数
  2155. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2156. //没有答完
  2157. if (this.lastCount !== 0) {
  2158. this.cgType = 6;
  2159. this.showpopups = true;
  2160. return;
  2161. }
  2162. if (this.bankType == 2) {
  2163. if (this.lastTime > 0) {
  2164. let lastTime = this.countdown(this.lastTime);
  2165. uni.showModal({
  2166. title: "提示",
  2167. content: `时间还剩余${lastTime},确定交卷吗?`,
  2168. confirmText: "交卷",
  2169. cancelText: "继续答题",
  2170. success: (res) => {
  2171. if (res.confirm) {
  2172. //确定
  2173. this.submit();
  2174. } else {
  2175. //取消
  2176. }
  2177. },
  2178. });
  2179. return;
  2180. }
  2181. }
  2182. this.submit();
  2183. },
  2184. /**
  2185. * 交卷
  2186. */
  2187. submit(typesubmit) {
  2188. let form = this.$method.calculateScore(this.questionList);
  2189. clearInterval(this.timer);
  2190. //交卷
  2191. this.$api
  2192. .bankRecordEdit({
  2193. moduleId: this.moduleId || 0,
  2194. chapterId: this.chapterId || 0,
  2195. sectionId: this.sectionId || 0,
  2196. gradeId: this.gradeId,
  2197. examId: this.id,
  2198. goodsId: this.goodsId,
  2199. orderGoodsId: this.orderGoodsId,
  2200. recordId: this.recordId,
  2201. courseId: this.courseId,
  2202. status: 1,
  2203. type: this.examType,
  2204. examTime: parseInt(this.allTimes),
  2205. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2206. ...form,
  2207. })
  2208. .then((res) => {
  2209. this.isSubmit = true;
  2210. this.isReach = false
  2211. if (res.data.code == 200) {
  2212. uni.showToast({
  2213. title: "交卷成功",
  2214. duration: 1000,
  2215. mask: true,
  2216. icon: "none",
  2217. });
  2218. if (!typesubmit) {
  2219. console.log("跳转----");
  2220. setTimeout(() => {
  2221. uni.redirectTo({
  2222. url:
  2223. "/pages2/class/question_report?recordId=" +
  2224. this.recordId +
  2225. "&type=" +
  2226. this.examType +
  2227. "&orderGoodsId=" +
  2228. this.orderGoodsId +
  2229. "&isBackVideo=" +
  2230. this.isBackVideo +
  2231. "&bankType=" +
  2232. this.bankType,
  2233. });
  2234. }, 1000);
  2235. }
  2236. } else if (res.data.code == 559) {
  2237. this.isReach = true;
  2238. this.uploadLock = false;
  2239. this.openPhoto();
  2240. }
  2241. });
  2242. //错题集id提交(客观题)
  2243. this.$api
  2244. .examWrongRecord({
  2245. moduleId: this.moduleId || 0,
  2246. chapterId: this.chapterId || 0,
  2247. sectionId: this.sectionId || 0,
  2248. gradeId: this.gradeId,
  2249. courseId: this.courseId,
  2250. examId: this.id,
  2251. goodsId: this.goodsId,
  2252. orderGoodsId: this.orderGoodsId,
  2253. questionIds: form.questionIds,
  2254. recordId: this.recordId,
  2255. type: 2, // 视频课程的传2
  2256. doMode: this.doMode,
  2257. })
  2258. .then((res) => {})
  2259. .catch((err) => {});
  2260. },
  2261. /**
  2262. * @param {Object} imgIndex
  2263. * @param {Object} bankIndex
  2264. * 删除简答图片
  2265. */
  2266. deleteImg(imgIndex, bankIndex) {
  2267. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2268. },
  2269. /**
  2270. * @param {Object} imgIndex
  2271. * @param {Object} bankIndex
  2272. * @param {Object} ansIndex
  2273. * 删除案例题简答图片
  2274. */
  2275. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2276. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2277. imgIndex,
  2278. 1
  2279. );
  2280. },
  2281. /**
  2282. * @param {Object} bankindex
  2283. * 选择上传图片
  2284. */
  2285. chooseImg(bankindex) {
  2286. if (
  2287. this.questionList[bankindex] &&
  2288. this.questionList[bankindex].ansText &&
  2289. this.questionList[bankindex].ansText.imageList.length >= 4
  2290. ) {
  2291. uni.showToast({
  2292. icon: "none",
  2293. title: "最多选择4张",
  2294. });
  2295. return;
  2296. }
  2297. uni.chooseImage({
  2298. count: 1, //默认9
  2299. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2300. sourceType: ["album", "camera"], //从相册选择
  2301. success: (res) => {
  2302. let self = this;
  2303. // console.log(JSON.stringify(res.tempFilePaths));
  2304. let img = res.tempFilePaths[0];
  2305. uni.getImageInfo({
  2306. src: img,
  2307. success: async (res) => {
  2308. let canvasWidth = res.width; //图片原始长宽
  2309. let canvasHeight = res.height;
  2310. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2311. uni.compressImage({
  2312. src: img,
  2313. quality: 75,
  2314. width: "50%",
  2315. height: "50%",
  2316. success: async (rest) => {
  2317. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2318. this.questionList[bankindex].ansText.imageList.push(dir);
  2319. },
  2320. });
  2321. } else {
  2322. const dir = await self.uploadFile(img, 0);
  2323. this.questionList[bankindex].ansText.imageList.push(dir);
  2324. }
  2325. },
  2326. });
  2327. },
  2328. });
  2329. },
  2330. /**
  2331. * @param {Object} bankindex
  2332. * @param {Object} ansindex
  2333. * 案例题选择上传图片
  2334. */
  2335. chooseImgChild(bankindex, ansindex) {
  2336. uni.chooseImage({
  2337. count: 1, //默认9
  2338. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2339. sourceType: ["album", "camera"], //从相册选择
  2340. success: (res) => {
  2341. let self = this;
  2342. // console.log(JSON.stringify(res.tempFilePaths));
  2343. let img = res.tempFilePaths[0];
  2344. uni.getImageInfo({
  2345. src: img,
  2346. success: async (res) => {
  2347. let canvasWidth = res.width; //图片原始长宽
  2348. let canvasHeight = res.height;
  2349. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2350. uni.compressImage({
  2351. src: img,
  2352. quality: 75,
  2353. width: "50%",
  2354. height: "50%",
  2355. success: async (rest) => {
  2356. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2357. this.questionList[bankindex].jsonStr[
  2358. ansindex
  2359. ].ansText.imageList.push(dir);
  2360. },
  2361. });
  2362. } else {
  2363. const dir = await self.uploadFile(img, 0);
  2364. this.questionList[bankindex].jsonStr[
  2365. ansindex
  2366. ].ansText.imageList.push(dir);
  2367. }
  2368. },
  2369. });
  2370. },
  2371. });
  2372. },
  2373. /**
  2374. * @param {Object} type
  2375. * @param {Object} bankindex
  2376. * 简答题答案确认
  2377. */
  2378. submitAns(bankindex) {
  2379. console.log(this.questionList[bankindex]);
  2380. if (
  2381. !this.questionList[bankindex].ansText.text &&
  2382. !this.questionList[bankindex].ansText.imageList.length
  2383. ) {
  2384. uni.showToast({
  2385. title: "请输入内容或上传图片",
  2386. duration: 2000,
  2387. icon: "none",
  2388. });
  2389. return;
  2390. }
  2391. this.$set(this.questionList[bankindex], "ques", {
  2392. imageList: this.questionList[bankindex].ansText.imageList,
  2393. text: this.questionList[bankindex].ansText.text,
  2394. });
  2395. this.$u.toast("已确认答案");
  2396. this.isDoOver();
  2397. },
  2398. /**
  2399. * @param {Object} bankindex
  2400. * @param {Object} ansindex
  2401. * 案例题简答答案确认
  2402. */
  2403. submitAnsChild(bankindex, ansindex) {
  2404. if (
  2405. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2406. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2407. ) {
  2408. uni.showToast({
  2409. title: "请输入内容或上传图片",
  2410. duration: 2000,
  2411. icon: "none",
  2412. });
  2413. return;
  2414. }
  2415. this.$set(this.questionList[bankindex].ques, ansindex, {
  2416. imageList:
  2417. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  2418. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  2419. });
  2420. this.$u.toast("已确认答案");
  2421. this.isDoOver();
  2422. },
  2423. isCheck(item, index) {
  2424. // 案例题处理
  2425. let { ques, type, ans } = item;
  2426. if (type == 4) {
  2427. return ans.length == ques.length;
  2428. }
  2429. if (ques) {
  2430. return true;
  2431. }
  2432. },
  2433. isRight(item, index) {
  2434. //单选
  2435. if (this.questionList[index].ques) {
  2436. if (item.type == 1) {
  2437. return this.questionList[index].ques == this.questionList[index].ans;
  2438. //多选
  2439. } else if (item.type == 2) {
  2440. //每一项都相等
  2441. return this.questionList[index].ans.every((item, i) => {
  2442. return item == this.questionList[index].ques[i];
  2443. });
  2444. //判断
  2445. } else if (item.type == 3) {
  2446. return this.questionList[index].ques == this.questionList[index].ans;
  2447. // } else if (item.type == 5) {
  2448. // if(this.questionList[index].ques.text){
  2449. // return true
  2450. // }else{
  2451. // return false
  2452. // }
  2453. } else {
  2454. return false;
  2455. }
  2456. } else {
  2457. return false;
  2458. }
  2459. },
  2460. right(bankIndex, ansIndex, option) {
  2461. if (
  2462. this.questionList[bankIndex].ques[ansIndex] &&
  2463. this.questionList[bankIndex].ans[ansIndex]
  2464. ) {
  2465. if (
  2466. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2467. option.optionsId
  2468. ) != -1 ||
  2469. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2470. option.optionsId
  2471. ) != -1
  2472. ) {
  2473. return true;
  2474. } else {
  2475. return false;
  2476. }
  2477. } else {
  2478. return false;
  2479. }
  2480. },
  2481. wrong(bankIndex, ansIndex, option) {
  2482. if (
  2483. this.questionList[bankIndex].ques[ansIndex] &&
  2484. this.questionList[bankIndex].ans[ansIndex]
  2485. ) {
  2486. if (
  2487. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2488. option.optionsId
  2489. ) != -1 &&
  2490. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2491. option.optionsId
  2492. ) == -1
  2493. ) {
  2494. return true;
  2495. } else {
  2496. return false;
  2497. }
  2498. } else {
  2499. return false;
  2500. }
  2501. },
  2502. isWrong(item, index) {
  2503. if (this.questionList[index].ques) {
  2504. //单选
  2505. if (item.type == 1) {
  2506. return this.questionList[index].ques != this.questionList[index].ans;
  2507. //多选
  2508. } else if (item.type == 2) {
  2509. //每一项都相等
  2510. return this.questionList[index].ques.some((item, i) => {
  2511. return this.questionList[index].ans.indexOf(item) == -1;
  2512. });
  2513. //判断
  2514. } else if (item.type == 3) {
  2515. return this.questionList[index].ques != this.questionList[index].ans;
  2516. } else {
  2517. return false;
  2518. }
  2519. } else {
  2520. return false;
  2521. }
  2522. },
  2523. isPart(item, index) {
  2524. if (this.questionList[index].ques) {
  2525. if (item.type == 2) {
  2526. let isWrong = this.questionList[index].ques.some((item, i) => {
  2527. return this.questionList[index].ans.indexOf(item) == -1;
  2528. });
  2529. let isRight = this.questionList[index].ans.every((item, i) => {
  2530. return item == this.questionList[index].ques[i];
  2531. });
  2532. if (!isRight && !isWrong) {
  2533. return true;
  2534. }
  2535. }
  2536. } else {
  2537. return false;
  2538. }
  2539. },
  2540. isOver(item, index) {
  2541. if (this.questionList[index].ques) {
  2542. if (item.type == 4) {
  2543. //案例题
  2544. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2545. if (
  2546. jsonItem.type == 1 ||
  2547. jsonItem.type == 2 ||
  2548. jsonItem.type == 3
  2549. ) {
  2550. if (item.ques[indexs]) {
  2551. return true;
  2552. } else {
  2553. return false;
  2554. }
  2555. } else if (jsonItem.type == 5) {
  2556. if (
  2557. item.ques[indexs] &&
  2558. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2559. ) {
  2560. console.log("chil");
  2561. return true;
  2562. } else {
  2563. return false;
  2564. }
  2565. }
  2566. });
  2567. if (isOver) {
  2568. return true;
  2569. } else {
  2570. return false;
  2571. }
  2572. } else if (item.type == 5) {
  2573. //简答题
  2574. //每一项都相等
  2575. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2576. return true;
  2577. }
  2578. //判断
  2579. } else {
  2580. return false;
  2581. }
  2582. } else {
  2583. return false;
  2584. }
  2585. },
  2586. tabSelect(index, bankindex) {
  2587. this.$set(this.questionList[bankindex], "current", index);
  2588. },
  2589. /**
  2590. * 退出全屏
  2591. */
  2592. exitFullscreen() {
  2593. try {
  2594. var de = document;
  2595. // console.log(de);
  2596. if (de.exitFullscreen) {
  2597. de.exitFullscreen();
  2598. } else if (de.mozCancelFullScreen) {
  2599. de.mozCancelFullScreen();
  2600. } else if (de.webkitCancelFullScreen) {
  2601. de.webkitCancelFullScreen();
  2602. }
  2603. } catch (err) {}
  2604. },
  2605. fullele() {
  2606. return (
  2607. document.fullscreenElement ||
  2608. document.webkitFullscreenElement ||
  2609. document.msFullscreenElement ||
  2610. document.mozFullScreenElement ||
  2611. null
  2612. );
  2613. },
  2614. //判断是否全屏
  2615. isFullScreen() {
  2616. return !!(document.webkitIsFullScreen || this.fullele());
  2617. },
  2618. getUserMedia(constraints, success, error) {
  2619. console.log("getUserMedia===", constraints, "success:", success);
  2620. if (window.navigator.mediaDevices.getUserMedia) {
  2621. // 最新的标准API
  2622. window.navigator.mediaDevices
  2623. .getUserMedia(constraints)
  2624. .then(success)
  2625. .catch(error);
  2626. } else if (window.navigator.webkitGetUserMedia) {
  2627. // webkit核心浏览器
  2628. window.navigator.webkitGetUserMedia(constraints, success, error);
  2629. } else if (window.navigator.mozGetUserMedia) {
  2630. // firfox浏览器
  2631. window.navigator.mozGetUserMedia(constraints, success, error);
  2632. } else if (window.navigator.getUserMedia) {
  2633. // 旧版API
  2634. window.navigator.getUserMedia(constraints, success, error);
  2635. }
  2636. },
  2637. photographSuccess(stream) {
  2638. console.log("有摄像头---", stream);
  2639. this.photoPopup = true;
  2640. this.isTaking = true;
  2641. this.$nextTick(() => {
  2642. const video = document.querySelector("video");
  2643. console.log("video:", video);
  2644. video.srcObject = stream;
  2645. video.play();
  2646. });
  2647. },
  2648. photographError(err) {
  2649. console.log("没有摄像头:", err);
  2650. uni.showModal({
  2651. title: "提示",
  2652. content:
  2653. "课程学习需要开启摄像头进行拍照,经检测您的设备无摄像头可使用,请检测环境是否支持。",
  2654. cancelText: "取消",
  2655. confirmText: "确定",
  2656. success: (res) => {
  2657. if (res.confirm) {
  2658. uni.navigateBack();
  2659. } else if (res.cancel) {
  2660. }
  2661. },
  2662. });
  2663. },
  2664. },
  2665. };
  2666. </script>
  2667. <style lang="scss" scoped>
  2668. .photoBox {
  2669. width: 100%;
  2670. // background-color: #ffffff;
  2671. // border-radius: 24px 24px 0px 0px;
  2672. .photoTop {
  2673. width: 100%;
  2674. height: 74rpx;
  2675. border-radius: 20px 20px 0px 0px;
  2676. background-color: #ffffff;
  2677. display: flex;
  2678. align-items: center;
  2679. justify-content: center;
  2680. padding: 0rpx 38rpx;
  2681. .sqzz {
  2682. width: 28rpx;
  2683. height: 28rpx;
  2684. display: flex;
  2685. align-items: center;
  2686. justify-content: center;
  2687. }
  2688. .centersq {
  2689. color: #333;
  2690. font-size: 30rpx;
  2691. font-weight: 500;
  2692. }
  2693. }
  2694. .photoCenter {
  2695. width: 750rpx;
  2696. height: 75vh;
  2697. position: relative;
  2698. .center_camera {
  2699. width: 100%;
  2700. height: 75vh;
  2701. position: fixed;
  2702. .head_take {
  2703. width: 100%;
  2704. height: 75vh;
  2705. display: flex;
  2706. flex-direction: column;
  2707. }
  2708. .headTake_up {
  2709. width: 100%;
  2710. height: 100rpx;
  2711. }
  2712. .headTake_minddle {
  2713. display: flex;
  2714. .min_img {
  2715. width: 500rpx;
  2716. height: 550rpx;
  2717. }
  2718. .min_left,
  2719. .min_right {
  2720. flex: 1;
  2721. height: 550rpx;
  2722. }
  2723. }
  2724. .headTake_down {
  2725. width: 100%;
  2726. flex: 1;
  2727. }
  2728. .color {
  2729. background-color: #333;
  2730. opacity: 0.5;
  2731. }
  2732. .photo_v {
  2733. width: 100%;
  2734. height: 100%;
  2735. }
  2736. .mask {
  2737. width: 500rpx;
  2738. height: 550rpx;
  2739. position: absolute;
  2740. top: 100rpx;
  2741. left: 0;
  2742. right: 0;
  2743. bottom: 0;
  2744. margin: 0 auto;
  2745. box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.4);
  2746. }
  2747. }
  2748. .custom {
  2749. width: 750rpx;
  2750. height: 75vh;
  2751. position: absolute;
  2752. z-index: 1000;
  2753. top: 0;
  2754. left: 0;
  2755. image {
  2756. width: 100%;
  2757. height: 100%;
  2758. }
  2759. }
  2760. }
  2761. .photoBoxbtns {
  2762. display: flex;
  2763. .takePhoto_btn {
  2764. width: 100%;
  2765. display: flex;
  2766. align-items: center;
  2767. justify-content: space-between;
  2768. background: #a9a7a9;
  2769. padding: 40rpx 26rpx;
  2770. .middle_btn {
  2771. width: 120rpx;
  2772. height: 120rpx;
  2773. border-radius: 40rpx;
  2774. border: 4rpx solid #ffffff;
  2775. display: flex;
  2776. align-items: center;
  2777. justify-content: center;
  2778. }
  2779. .square {
  2780. width: 96rpx;
  2781. height: 96rpx;
  2782. background: #ffffff;
  2783. border-radius: 28rpx;
  2784. }
  2785. .rights {
  2786. font-size: 32rpx;
  2787. font-weight: 500;
  2788. color: #ffffff;
  2789. }
  2790. }
  2791. .btnResult {
  2792. height: 100rpx;
  2793. width: 100%;
  2794. background-color: #07c160;
  2795. text-align: center;
  2796. line-height: 100rpx;
  2797. color: #fff;
  2798. font-size: 32rpx;
  2799. font-weight: bold;
  2800. }
  2801. }
  2802. }
  2803. .navbar {
  2804. position: relative;
  2805. z-index: 20000;
  2806. }
  2807. .questionBank {
  2808. width: 100%;
  2809. height: 100vh;
  2810. display: flex;
  2811. flex-direction: column;
  2812. }
  2813. .swiper {
  2814. width: 100%;
  2815. flex: 1;
  2816. }
  2817. .lisSty {
  2818. margin-bottom: 16rpx;
  2819. display: flex;
  2820. .flex_auto {
  2821. flex: 1;
  2822. word-break: break-all;
  2823. }
  2824. }
  2825. .activeTI {
  2826. vertical-align: middle;
  2827. display: inline-block;
  2828. border: 1rpx solid #eee;
  2829. border-radius: 50rpx;
  2830. height: 48rpx;
  2831. line-height: 46rpx;
  2832. text-align: center;
  2833. width: 48rpx;
  2834. margin-right: 15rpx;
  2835. color: #666;
  2836. font-size: 30rpx;
  2837. &.right {
  2838. color: #fff;
  2839. background: #36c75a;
  2840. }
  2841. &.wrong {
  2842. color: #fff;
  2843. background: #ff3b30;
  2844. }
  2845. &.checked,
  2846. &.user_choose {
  2847. color: #fff;
  2848. background: #007aff;
  2849. }
  2850. }
  2851. .submit_checkbox {
  2852. position: fixed;
  2853. left: 0;
  2854. right: 0;
  2855. bottom: 120rpx;
  2856. margin: 20rpx auto;
  2857. width: 526rpx;
  2858. height: 80rpx;
  2859. background: rgba(0, 122, 255, 1);
  2860. color: #fff;
  2861. text-align: center;
  2862. line-height: 80rpx;
  2863. font-size: 30rpx;
  2864. border-radius: 40rpx;
  2865. &.disabled {
  2866. opacity: 0.6;
  2867. }
  2868. }
  2869. .titles {
  2870. overflow: hidden;
  2871. margin-bottom: 24rpx;
  2872. }
  2873. .titBox {
  2874. padding: 41rpx 25rpx 24rpx 25rpx;
  2875. }
  2876. .titBox_title {
  2877. padding: 21rpx;
  2878. }
  2879. .tabs {
  2880. margin: 10rpx;
  2881. display: flex;
  2882. .tab {
  2883. margin: 0 4rpx;
  2884. padding: 10rpx 13rpx;
  2885. text-align: center;
  2886. color: #007aff;
  2887. font-size: 28rpx;
  2888. border-radius: 16rpx;
  2889. background: #fff;
  2890. &.current {
  2891. color: #fff;
  2892. background: #007aff;
  2893. }
  2894. }
  2895. }
  2896. .ans {
  2897. margin: 8rpx 8rpx 8rpx;
  2898. .ans_input {
  2899. border-radius: 16rpx;
  2900. background: #fff;
  2901. .top {
  2902. border-bottom: 1rpx solid #eeeeee;
  2903. padding: 16rpx;
  2904. display: flex;
  2905. align-items: center;
  2906. .icon {
  2907. margin-right: 20rpx;
  2908. width: 40rpx;
  2909. height: 38rpx;
  2910. }
  2911. .progress {
  2912. flex: 1;
  2913. }
  2914. .submit {
  2915. width: 168rpx;
  2916. height: 48rpx;
  2917. line-height: 48rpx;
  2918. text-align: center;
  2919. color: #fff;
  2920. font-size: 30rpx;
  2921. background: #007aff;
  2922. border-radius: 24rpx;
  2923. &.disabled {
  2924. opacity: 0.6;
  2925. }
  2926. }
  2927. }
  2928. .textarea {
  2929. textarea {
  2930. width: 100%;
  2931. height: 287rpx;
  2932. padding: 10rpx;
  2933. }
  2934. }
  2935. .imgs {
  2936. overflow: hidden;
  2937. display: flex;
  2938. width: 100%;
  2939. .img {
  2940. width: 104rpx;
  2941. height: 104rpx;
  2942. border-radius: 8rpx;
  2943. position: relative;
  2944. margin: 20rpx;
  2945. text {
  2946. position: absolute;
  2947. right: -15rpx;
  2948. top: -15rpx;
  2949. width: 30rpx;
  2950. height: 30rpx;
  2951. text-align: center;
  2952. line-height: 30rpx;
  2953. color: #fff;
  2954. background: #ff3b30;
  2955. border-radius: 50%;
  2956. }
  2957. image {
  2958. width: 100%;
  2959. height: 100%;
  2960. }
  2961. }
  2962. }
  2963. }
  2964. .ans_submit {
  2965. padding: 16rpx;
  2966. border-radius: 16rpx;
  2967. background: #fff;
  2968. .imgs {
  2969. overflow: hidden;
  2970. display: flex;
  2971. width: 100%;
  2972. .img {
  2973. width: 104rpx;
  2974. height: 104rpx;
  2975. border-radius: 8rpx;
  2976. position: relative;
  2977. margin: 20rpx;
  2978. image {
  2979. width: 100%;
  2980. height: 100%;
  2981. }
  2982. }
  2983. }
  2984. }
  2985. }
  2986. .leftLetters {
  2987. display: flex;
  2988. align-items: center;
  2989. width: 220rpx;
  2990. .btnType {
  2991. padding: 5rpx 10rpx;
  2992. border: 1rpx solid #007aff;
  2993. border-radius: 10rpx;
  2994. background-color: rgba(0, 122, 255, 0.1);
  2995. font-size: 28rpx;
  2996. color: #007aff;
  2997. margin-right: 15rpx;
  2998. }
  2999. image {
  3000. width: 40rpx;
  3001. height: 40rpx;
  3002. padding-right: 8rpx;
  3003. }
  3004. }
  3005. .firstLetter {
  3006. display: flex;
  3007. justify-content: space-between;
  3008. align-items: center;
  3009. margin-bottom: 30rpx;
  3010. }
  3011. .popupView {
  3012. height: 100%;
  3013. padding-bottom: 100rpx;
  3014. .popupTops {
  3015. height: 77rpx;
  3016. border-bottom: 1rpx solid #eee;
  3017. text-align: center;
  3018. line-height: 77rpx;
  3019. font-size: 24rpx;
  3020. color: #999;
  3021. position: relative;
  3022. .topIcon {
  3023. position: absolute;
  3024. top: 10rpx;
  3025. left: 50%;
  3026. transform: translateX(-50%);
  3027. width: 80rpx;
  3028. height: 8rpx;
  3029. background-color: #999;
  3030. border-radius: 4rpx;
  3031. }
  3032. }
  3033. .popupContent {
  3034. }
  3035. }
  3036. .pageContent {
  3037. position: relative;
  3038. background-color: #eaeef1;
  3039. height: 100%;
  3040. padding-top: 8rpx;
  3041. padding-bottom: 100rpx;
  3042. overflow-y: scroll;
  3043. }
  3044. .pad_8 {
  3045. background-color: #fff;
  3046. margin: 0rpx 8rpx 8rpx;
  3047. border-radius: 16rpx;
  3048. &.no-margin {
  3049. margin-top: -16rpx;
  3050. border-radius: 0 0 16rpx 16rpx;
  3051. }
  3052. }
  3053. .answer {
  3054. height: 80rpx;
  3055. line-height: 80rpx;
  3056. padding: 0rpx 24rpx;
  3057. display: flex;
  3058. align-items: center;
  3059. justify-content: space-between;
  3060. color: #666;
  3061. font-size: 30rpx;
  3062. }
  3063. .footer_btn {
  3064. background-color: #fff;
  3065. z-index: 10078;
  3066. position: fixed;
  3067. bottom: 0rpx;
  3068. display: flex;
  3069. align-items: center;
  3070. justify-content: space-between;
  3071. width: 100%;
  3072. height: 98rpx;
  3073. padding: 0rpx 38rpx;
  3074. border-top: 1rpx solid #eee;
  3075. .flex_center {
  3076. flex: 1;
  3077. display: flex;
  3078. justify-content: center;
  3079. align-items: center;
  3080. flex-direction: column;
  3081. margin: 0 200rpx;
  3082. font-size: 24rpx;
  3083. color: #999999;
  3084. .up-icon {
  3085. margin-bottom: 18rpx;
  3086. width: 100%;
  3087. display: flex;
  3088. justify-content: center;
  3089. image {
  3090. width: 58rpx;
  3091. height: 21rpx;
  3092. }
  3093. }
  3094. }
  3095. }
  3096. .boxSty {
  3097. padding: 44rpx 41rpx 0rpx;
  3098. }
  3099. .liListSty {
  3100. border: 1rpx solid #eeeeee;
  3101. width: 88rpx;
  3102. height: 88rpx;
  3103. border-radius: 32rpx;
  3104. text-align: center;
  3105. line-height: 88rpx;
  3106. color: #333;
  3107. font-size: 32rpx;
  3108. float: left;
  3109. margin: 20rpx 23rpx;
  3110. &.isRight {
  3111. border: 1rpx solid #eeeeee;
  3112. color: #fff;
  3113. background: #36c75a;
  3114. }
  3115. &.isWrong {
  3116. border: 1rpx solid #eeeeee;
  3117. color: #fff;
  3118. background: #ff3b30;
  3119. }
  3120. &.isPart {
  3121. border: 1rpx solid #eeeeee;
  3122. color: #fff;
  3123. background: #ffc53d;
  3124. }
  3125. &.isOver {
  3126. border: 1rpx solid #eeeeee;
  3127. color: #fff;
  3128. background: blue;
  3129. }
  3130. &.check_ans {
  3131. border: 1rpx solid #eeeeee;
  3132. color: #fff;
  3133. background: #007aff;
  3134. }
  3135. }
  3136. .answerInfos {
  3137. padding: 25rpx 25rpx 25rpx 23rpx;
  3138. }
  3139. .answerTitle {
  3140. margin-bottom: 28rpx;
  3141. color: #666;
  3142. font-size: 30rpx;
  3143. }
  3144. .answerContent {
  3145. font-size: 30rpx;
  3146. color: #666;
  3147. }
  3148. .textChild {
  3149. display: inline-block;
  3150. vertical-align: middle;
  3151. }
  3152. .dialog {
  3153. position: fixed;
  3154. left: 0;
  3155. top: 0;
  3156. width: 100%;
  3157. height: 100%;
  3158. background-color: rgba(0, 0, 0, 0.8);
  3159. display: flex;
  3160. flex-direction: column;
  3161. align-items: center;
  3162. justify-content: center;
  3163. z-index: 20000;
  3164. .text {
  3165. font-size: 32rpx;
  3166. color: #ffffff;
  3167. text-align: center;
  3168. }
  3169. .btn {
  3170. width: 242rpx;
  3171. height: 82rpx;
  3172. border: 2rpx solid #ffffff;
  3173. border-radius: 16rpx;
  3174. text-align: center;
  3175. line-height: 82rpx;
  3176. margin: 41rpx auto;
  3177. color: #fff;
  3178. font-size: 32rpx;
  3179. }
  3180. }
  3181. .dialog-arrow {
  3182. padding-top: 124rpx;
  3183. position: fixed;
  3184. left: 0;
  3185. top: 0;
  3186. width: 100%;
  3187. height: 100%;
  3188. background-color: rgba(0, 0, 0, 0.8);
  3189. z-index: 20000;
  3190. .pointer {
  3191. margin-left: 87rpx;
  3192. display: block;
  3193. width: 95rpx;
  3194. height: 98rpx;
  3195. }
  3196. .text {
  3197. padding-left: 177rpx;
  3198. font-size: 32rpx;
  3199. color: #ffffff;
  3200. }
  3201. .btn {
  3202. width: 242rpx;
  3203. height: 82rpx;
  3204. border: 2rpx solid #ffffff;
  3205. border-radius: 16rpx;
  3206. text-align: center;
  3207. line-height: 82rpx;
  3208. margin: 500rpx auto 0;
  3209. color: #fff;
  3210. font-size: 32rpx;
  3211. }
  3212. }
  3213. .dialog_wrap {
  3214. position: fixed;
  3215. left: 0;
  3216. top: 0;
  3217. width: 100%;
  3218. height: 100%;
  3219. z-index: 9999999999;
  3220. .bg {
  3221. background: rgba(0, 0, 0, 0.3);
  3222. position: absolute;
  3223. left: 0;
  3224. top: 0;
  3225. width: 100%;
  3226. height: 100%;
  3227. }
  3228. .dialog {
  3229. position: absolute;
  3230. left: 50%;
  3231. top: 50%;
  3232. transform: translate3D(-50%, -50%, 0);
  3233. width: 640rpx;
  3234. height: 439rpx;
  3235. background: #ffffff;
  3236. border-radius: 24rpx;
  3237. .title {
  3238. font-size: 30rpx;
  3239. font-weight: bold;
  3240. color: #333333;
  3241. line-height: 48rpx;
  3242. text-align: center;
  3243. margin-top: 40rpx;
  3244. }
  3245. .content {
  3246. margin: 35rpx 35rpx 0;
  3247. font-size: 30rpx;
  3248. color: #666666;
  3249. line-height: 48rpx;
  3250. }
  3251. .btns {
  3252. margin-top: 35rpx;
  3253. display: flex;
  3254. align-items: center;
  3255. justify-content: center;
  3256. .btn {
  3257. width: 200rpx;
  3258. height: 80rpx;
  3259. line-height: 80rpx;
  3260. text-align: center;
  3261. background: #f5f5f5;
  3262. border-radius: 40rpx;
  3263. font-size: 30rpx;
  3264. color: rgba(0, 122, 255, 1);
  3265. background: #f5f5f5;
  3266. margin: 0 20rpx;
  3267. &.active {
  3268. color: #f5f5f5;
  3269. background: rgba(0, 122, 255, 1);
  3270. }
  3271. }
  3272. }
  3273. }
  3274. }
  3275. .popboxs {
  3276. width: 100%;
  3277. height: 100%;
  3278. display: flex;
  3279. flex-direction: column;
  3280. align-items: center;
  3281. }
  3282. .classTops {
  3283. flex-shrink: 0;
  3284. padding: 39rpx 0rpx 4rpx;
  3285. font-weight: bold;
  3286. color: #333;
  3287. font-size: 30rpx;
  3288. }
  3289. .textStys {
  3290. width: 100%;
  3291. flex: 1;
  3292. padding: 36rpx;
  3293. }
  3294. .classFootsty {
  3295. flex-shrink: 0;
  3296. display: flex;
  3297. align-items: center;
  3298. justify-content: center;
  3299. padding: 10rpx 0rpx 40rpx;
  3300. .btnsty {
  3301. width: 200rpx;
  3302. height: 80rpx;
  3303. border-radius: 40rpx;
  3304. font-weight: bold;
  3305. font-size: 30rpx;
  3306. text-align: center;
  3307. line-height: 80rpx;
  3308. }
  3309. .btns1 {
  3310. background-color: #f5f5f5;
  3311. color: #007aff;
  3312. }
  3313. .btns2 {
  3314. margin-left: 40rpx;
  3315. background-color: #007aff;
  3316. color: #ffffff;
  3317. }
  3318. }
  3319. </style>