questionBank.vue 99 KB

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