questionBank.vue 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535
  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. };
  955. },
  956. watch: {
  957. photoPopup(n) {
  958. // 拍照弹窗和showDialog同时出现时,先展示拍照弹窗再展示showDialog弹窗
  959. if (n) {
  960. this.showDialog && (this.showDialog = false);
  961. } else {
  962. this.originShowDialog && (this.showDialog = true);
  963. }
  964. },
  965. },
  966. async onLoad(option) {
  967. this.examType = option.type;
  968. this.id = option.id;
  969. this.goodsId = option.goodsid;
  970. this.chapterId = option.chapterId;
  971. this.courseId = option.courseId;
  972. this.sectionId = option.sectionId;
  973. this.moduleId = option.moduleId;
  974. this.isFromVideo = option.isFromVideo || "";
  975. this.gradeId = option.gradeId || "";
  976. this.orderGoodsId = Number(option.orderGoodsId);
  977. let isBack = option.isback;
  978. let showDialog = uni.getStorageSync("showDialog");
  979. if (showDialog) {
  980. this.showDialog = false;
  981. } else {
  982. this.showDialog = true;
  983. this.originShowDialog = true;
  984. uni.setStorageSync("showDialog", "1");
  985. }
  986. //考试时候用手势或者返回键 被迫返回做题
  987. if (isBack) {
  988. let app = getApp();
  989. let globalData = app.globalData;
  990. for (var k in globalData.bankData) {
  991. this[k] = globalData.bankData[k];
  992. }
  993. this.showArrow = true;
  994. //需要拍没拍过直接弹出摄像头
  995. if (this.needPhoto && !this.isTakePhoto) {
  996. if (!this.learning && this.examType != 2) {
  997. if (uni.getStorageSync("tabkePhotoShow")) {
  998. // #ifdef MP-WEIXIN
  999. this.photoPopup = true;
  1000. this.isTaking = true;
  1001. // #endif
  1002. this.avatarUrl = "";
  1003. // #ifdef H5
  1004. this.isHadCamera();
  1005. // #endif
  1006. } else {
  1007. this.popupPhotoShow = true;
  1008. uni.setStorageSync("tabkePhotoShow", 1); // 本地缓存用来判断是否已经弹出过弹窗
  1009. }
  1010. }
  1011. } else {
  1012. //不需要拍照
  1013. if (this.lastTime) {
  1014. this.timer = setInterval(() => {
  1015. if (this.lastTime <= 0) {
  1016. clearInterval(this.timer);
  1017. uni.showToast({
  1018. icon: "none",
  1019. mask: true,
  1020. title: "考试时间已到,系统将自动交卷",
  1021. duration: 10000,
  1022. });
  1023. this.submit();
  1024. return;
  1025. }
  1026. this.lastTime--;
  1027. }, 1000);
  1028. }
  1029. }
  1030. } else {
  1031. await this.getGoodsDetail();
  1032. this.needPhoto && (await this.getExamLearnStatus());
  1033. // 请求题目列表
  1034. await this.bankExam();
  1035. this.goodsQuestionList();
  1036. }
  1037. },
  1038. mounted() {},
  1039. onUnload() {
  1040. if (this.isSubmit) {
  1041. clearInterval(this.timer);
  1042. return;
  1043. }
  1044. if (this.needPhoto && !this.isTakePhoto) {
  1045. return;
  1046. }
  1047. //考试试卷 阻止ios手势返回,自动跳回答题页
  1048. if (this.needBack) {
  1049. let app = getApp();
  1050. app.globalData.bankData = this.$data;
  1051. clearInterval(this.timer);
  1052. uni.navigateTo({
  1053. url:
  1054. "/pages2/class/questionBank?id=" +
  1055. this.id +
  1056. "&goodsid=" +
  1057. this.goodsId +
  1058. "&isback=true&orderGoodsId=" +
  1059. this.orderGoodsId,
  1060. });
  1061. } else {
  1062. //点击返回按钮确认允许退出,交卷
  1063. clearInterval(this.timer);
  1064. this.examRecordEdit();
  1065. }
  1066. },
  1067. computed: {
  1068. doMode() {
  1069. // 做题模式 1章卷 2随机练习 3模拟组卷
  1070. return this.examData.simulateStatus ? 3 : undefined;
  1071. },
  1072. },
  1073. methods: {
  1074. getExamLearnStatus() {
  1075. return this.$api
  1076. .getExamLearnStatus({
  1077. goodsId: this.goodsId,
  1078. gradeId: this.gradeId,
  1079. chapterId: this.chapterId,
  1080. courseId: this.courseId,
  1081. moduleId: this.moduleId,
  1082. type: this.examType,
  1083. examId: this.id,
  1084. })
  1085. .then((res) => {
  1086. this.learning = res.data.data;
  1087. return Promise.resolve();
  1088. });
  1089. },
  1090. getGoodsDetail() {
  1091. return new Promise((resolve) => {
  1092. let self = this;
  1093. this.$api.goodsDetail(this.goodsId).then((res) => {
  1094. self.goodsDetail = res.data.data;
  1095. if (self.goodsDetail.goodsPhotoExamConfig) {
  1096. let goodsPhotoExamConfig = JSON.parse(
  1097. self.goodsDetail.goodsPhotoExamConfig
  1098. );
  1099. if (goodsPhotoExamConfig.photograph > 0) {
  1100. self.needPhoto = true;
  1101. }
  1102. }
  1103. resolve();
  1104. });
  1105. });
  1106. },
  1107. reTake() {
  1108. this.isTaking = true;
  1109. // #ifdef H5
  1110. this.faceUrl = "";
  1111. this.getUserMedia({
  1112. video: {
  1113. width: 400,
  1114. height: 300,
  1115. },
  1116. });
  1117. // #endif
  1118. },
  1119. postStudyRecord() {
  1120. let self = this;
  1121. let data = {
  1122. photo: self.ossAvatarUrl,
  1123. recordId: self.recordId,
  1124. };
  1125. if (this.ossAvatarUrl) {
  1126. data.similarity = this.compareFaceData; // 相似度
  1127. }
  1128. // console.log(data, "拍照提交");
  1129. this.$api.studyExamPhotoRecord(data).then((res) => {
  1130. // console.log(res, "拍照提交结果");
  1131. if (res.data.code != 200) {
  1132. uni.showToast({
  1133. icon: "none",
  1134. mask: true,
  1135. title: res.data.msg,
  1136. duration: 10000,
  1137. });
  1138. return;
  1139. }
  1140. self.ossAvatarUrl = "";
  1141. self.isTakePhoto = true;
  1142. //拍照
  1143. if (this.lastTime) {
  1144. this.timer = setInterval(() => {
  1145. if (this.lastTime <= 0) {
  1146. clearInterval(this.timer);
  1147. uni.showToast({
  1148. icon: "none",
  1149. mask: true,
  1150. title: "考试时间已到,系统将自动交卷",
  1151. duration: 10000,
  1152. });
  1153. this.submit();
  1154. return;
  1155. }
  1156. this.lastTime--;
  1157. }, 1000);
  1158. }
  1159. });
  1160. },
  1161. uploadFile(options, int) {
  1162. var self = this;
  1163. return new Promise((resolve, reject) => {
  1164. var data = {
  1165. imageStatus: int,
  1166. gradeId: this.gradeId,
  1167. };
  1168. self.$api.aliyunpolicy(data).then((res) => {
  1169. if (res.data.code != 200) {
  1170. self.$method.showToast("签名错误" + JSON.stringify(res.data));
  1171. return;
  1172. }
  1173. var ossToken = res.data.data.resultContent;
  1174. if (ossToken.host == null || ossToken.host == undefined) {
  1175. self.$method.showToast("上传路径报错" + JSON.stringify(res.data));
  1176. return;
  1177. }
  1178. let filePath = "";
  1179. // #ifdef H5
  1180. var localData = options; //dataUrl为base64位
  1181. let base = atob(localData.substring(localData.indexOf(",") + 1)); // base是将base64编码解码,去掉data:image/png;base64部分
  1182. let length = base.length;
  1183. let url = new Uint8Array(length);
  1184. while (length--) {
  1185. url[length] = base.charCodeAt(length);
  1186. }
  1187. filePath = new File([url], "a.jpg", {
  1188. type: "image/jpg",
  1189. });
  1190. console.log("filePath:", filePath);
  1191. uni.uploadFile({
  1192. url: ossToken.host,
  1193. name: "file",
  1194. file: filePath,
  1195. fileType: "image",
  1196. header: {
  1197. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1198. },
  1199. formData: {
  1200. key: ossToken.dir,
  1201. OSSAccessKeyId: ossToken.accessid,
  1202. policy: ossToken.policy,
  1203. Signature: ossToken.signature,
  1204. callback: ossToken.callback,
  1205. success_action_status: 200,
  1206. },
  1207. success: (result) => {
  1208. this.$u.toast("上传成功");
  1209. this.ossAvatarUrl = ossToken.dir;
  1210. console.log("h5上传成功--:", this.ossAvatarUrl);
  1211. resolve();
  1212. },
  1213. fail: (error) => {
  1214. console.log("h5上传失败:", error);
  1215. uni.showToast({
  1216. title: "上传接口报错,请重新拍照上传" + error,
  1217. icon: "none",
  1218. });
  1219. this.openPhoto();
  1220. return;
  1221. },
  1222. });
  1223. // #endif
  1224. // #ifdef MP-WEIXIN
  1225. uni.uploadFile({
  1226. url: ossToken.host,
  1227. name: "file",
  1228. filePath: options,
  1229. fileType: "image",
  1230. header: {
  1231. AuthorizationToken: "WX " + uni.getStorageSync("token"),
  1232. },
  1233. formData: {
  1234. key: ossToken.dir,
  1235. OSSAccessKeyId: ossToken.accessid,
  1236. policy: ossToken.policy,
  1237. Signature: ossToken.signature,
  1238. callback: ossToken.callback,
  1239. success_action_status: 200,
  1240. },
  1241. success: (result) => {
  1242. // if (result.statusCode === 200) {
  1243. self.ossAvatarUrl = ossToken.dir;
  1244. resolve(ossToken.dir);
  1245. // } else {
  1246. // uni.showToast({
  1247. // title: "上传失败",
  1248. // icon: "none",
  1249. // });
  1250. // return;
  1251. // }
  1252. },
  1253. fail: (error) => {
  1254. uni.showToast({
  1255. title: "上传接口报错" + error,
  1256. icon: "none",
  1257. });
  1258. this.uploadLock = false;
  1259. this.openPhoto();
  1260. return;
  1261. },
  1262. });
  1263. // #endif
  1264. });
  1265. });
  1266. },
  1267. imageInfos() {
  1268. var self = this;
  1269. return new Promise(async (resolve, reject) => {
  1270. // #ifdef MP-WEIXIN
  1271. uni.getImageInfo({
  1272. src: self.avatarUrl,
  1273. success: async (res) => {
  1274. let canvasWidth = res.width; //图片原始长宽
  1275. let canvasHeight = res.height;
  1276. if (canvasWidth > 2000 || canvasHeight > 2000) {
  1277. uni.compressImage({
  1278. src: self.avatarUrl,
  1279. quality: 75,
  1280. width: "35%",
  1281. height: "35%",
  1282. success: async (rest) => {
  1283. const waitUpload = await self.uploadFile(
  1284. rest.tempFilePath,
  1285. 0
  1286. );
  1287. resolve(waitUpload);
  1288. },
  1289. });
  1290. } else if (canvasWidth > 1000 || canvasHeight > 1000) {
  1291. uni.compressImage({
  1292. src: self.avatarUrl,
  1293. quality: 75,
  1294. width: "50%",
  1295. height: "50%",
  1296. success: async (rest) => {
  1297. const waitUpload = await self.uploadFile(
  1298. rest.tempFilePath,
  1299. 0
  1300. );
  1301. resolve(waitUpload);
  1302. },
  1303. });
  1304. } else {
  1305. console.log("无需压缩");
  1306. const waitUpload = await self.uploadFile(self.avatarUrl, 0);
  1307. resolve(waitUpload);
  1308. }
  1309. },
  1310. });
  1311. // #endif
  1312. // #ifdef H5
  1313. const waitUpload = await this.uploadFile(this.faceUrl, 0);
  1314. resolve(waitUpload);
  1315. // #endif
  1316. });
  1317. },
  1318. /**
  1319. * 人脸匹配
  1320. */
  1321. faceRecognition() {
  1322. return new Promise((resolve) => {
  1323. // #ifdef MP-WEIXIN
  1324. let fileSystem = uni.getFileSystemManager();
  1325. fileSystem.readFile({
  1326. filePath: `${this.avatarUrl}`,
  1327. encoding: "base64",
  1328. position: 0,
  1329. success: (res) => {
  1330. let base64 = "data:image/jpg;base64," + res.data;
  1331. console.log("试卷-base64Data人脸识别参数:", {
  1332. imageA: base64,
  1333. orderGoodsId: this.orderGoodsId,
  1334. gradeId: this.gradeId,
  1335. });
  1336. this.CompareFace(base64, resolve);
  1337. },
  1338. fail(err) {
  1339. console.error(err, "err");
  1340. },
  1341. });
  1342. // #endif
  1343. // #ifdef H5
  1344. this.CompareFace(this.faceUrl, resolve);
  1345. // #endif
  1346. });
  1347. },
  1348. CompareFace(url, resolve) {
  1349. let timer = setTimeout(() => {
  1350. uni.showToast({
  1351. icon: "none",
  1352. title: "拍照超时,请重新拍照",
  1353. duration: 2000,
  1354. success: () => {
  1355. setTimeout(() => {
  1356. uni.navigateBack();
  1357. }, 1000);
  1358. },
  1359. });
  1360. }, 10 * 1000);
  1361. this.$api
  1362. .faceCertificationCompareFace({
  1363. imageA: url,
  1364. orderGoodsId: this.orderGoodsId,
  1365. gradeId: this.gradeId,
  1366. })
  1367. .then((res) => {
  1368. clearTimeout(timer);
  1369. console.log(res, "人脸识别成功res");
  1370. resolve(res.data.data);
  1371. })
  1372. .catch((err) => {
  1373. clearTimeout(timer);
  1374. // 当前网络延迟,
  1375. console.log("人脸识别错误:", err);
  1376. uni.showModal({
  1377. content: "当前网络延迟",
  1378. showCancel: false,
  1379. success: (resultst) => {
  1380. if (resultst.confirm) {
  1381. uni.navigateBack();
  1382. }
  1383. },
  1384. });
  1385. });
  1386. },
  1387. toTakePhoto() {
  1388. this.popupPhotoShow = false;
  1389. this.openPhoto();
  1390. },
  1391. takePhTips() {
  1392. this.popupPhotoShow = true;
  1393. this.isTaking = false;
  1394. this.photoPopup = false;
  1395. },
  1396. // 确认拍照
  1397. async submitPhoto() {
  1398. if (this.uploadLock) {
  1399. return;
  1400. }
  1401. this.uploadLock = true;
  1402. let compareFaceData = await this.faceRecognition();
  1403. this.compareFaceData = compareFaceData;
  1404. if (compareFaceData >= 80) {
  1405. const waitYS = await this.imageInfos();
  1406. this.postStudyRecord(); //提交记录
  1407. this.photoPopup = false;
  1408. } else {
  1409. uni.showToast({
  1410. title: "人脸匹配不通过,请重新拍照上传",
  1411. icon: "none",
  1412. duration: 2000,
  1413. });
  1414. setTimeout(() => {
  1415. this.uploadLock = false;
  1416. this.openPhoto();
  1417. }, 2000);
  1418. }
  1419. },
  1420. //拍照
  1421. openPhoto() {
  1422. console.log("开始拍照");
  1423. // this.enableAutoRotation = false;
  1424. // #ifdef MP-WEIXIN
  1425. this.photoPopup = true;
  1426. this.isTaking = true;
  1427. uni.setKeepScreenOn({
  1428. keepScreenOn: true,
  1429. });
  1430. uni.authorize({
  1431. scope: "scope.camera",
  1432. success() {},
  1433. });
  1434. // #endif
  1435. // #ifdef H5
  1436. this.isHadCamera();
  1437. // #endif
  1438. },
  1439. isHadCamera() {
  1440. if (
  1441. (window.navigator.mediaDevices &&
  1442. window.navigator.mediaDevices.getUserMedia) ||
  1443. window.navigator.getUserMedia ||
  1444. window.navigator.webkitGetUserMedia ||
  1445. window.navigator.mozGetUserMedia
  1446. ) {
  1447. console.log("getUserMedia----");
  1448. // 调用用户媒体设备, 访问摄像头
  1449. this.getUserMedia(
  1450. {
  1451. video: {
  1452. width: 400,
  1453. height: 300,
  1454. },
  1455. },
  1456. this.photographSuccess,
  1457. this.photographError
  1458. );
  1459. } else {
  1460. console.log("1111没有摄像");
  1461. this.photographError();
  1462. }
  1463. },
  1464. //确认拍照
  1465. takePhoto() {
  1466. // #ifdef MP-WEIXIN
  1467. const ctx = uni.createCameraContext();
  1468. ctx.takePhoto({
  1469. quality: "high",
  1470. success: (res) => {
  1471. console.log(res.tempImagePath);
  1472. this.avatarUrl = res.tempImagePath;
  1473. // self.submitPhoto();
  1474. this.isTaking = false;
  1475. },
  1476. fail: (err) => {
  1477. console.log(err);
  1478. },
  1479. });
  1480. // #endif
  1481. // #ifdef H5
  1482. const canvas = document.createElement("canvas");
  1483. canvas.width = 400;
  1484. canvas.height = 400;
  1485. const context = canvas.getContext("2d");
  1486. const video = document.querySelector("video");
  1487. context.drawImage(video, 0, 0, 400, 400);
  1488. this.faceUrl = canvas.toDataURL("image/png");
  1489. this.isTaking = false;
  1490. // #endif
  1491. },
  1492. /**
  1493. * 是否有上传图片
  1494. */
  1495. hasImgs(bank) {
  1496. return bank.ansText.imageList.length == 0;
  1497. },
  1498. /**
  1499. * 获取试卷类型2考试,1练习
  1500. */
  1501. bankExam() {
  1502. return this.$api.bankExam(this.id).then((res) => {
  1503. this.bankType = res.data.data.doType;
  1504. this.examData = res.data.data;
  1505. this.allTimes = this.examData.answerTime * 60;
  1506. this.lastTime =
  1507. this.examData.answerTime && this.examData.answerTime * 60;
  1508. if (this.bankType == 2) {
  1509. this.needBack = true;
  1510. }
  1511. return Promise.resolve();
  1512. });
  1513. },
  1514. /**
  1515. * 点击后退按钮
  1516. */
  1517. clickLeft() {
  1518. //需要拍照没有拍直接返回
  1519. if (this.needPhoto && !this.isTakePhoto) {
  1520. this.isSubmit = true;
  1521. uni.navigateBack({
  1522. delta: 1,
  1523. });
  1524. return;
  1525. }
  1526. if (this.bankType == 1) {
  1527. let ansCount = this.questionOverNum(); //已答题数
  1528. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1529. //所有题目答完
  1530. if (this.lastCount == 0) {
  1531. // this.testOver = true;
  1532. this.cgType = 7;
  1533. //未答完
  1534. } else {
  1535. this.cgType = 8;
  1536. // this.isLastCount = true;
  1537. }
  1538. this.showpopups = true;
  1539. } else if (this.bankType == 2) {
  1540. let ansCount = this.questionOverNum(); //已答题数
  1541. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  1542. //所有题目答完
  1543. if (this.lastCount == 0) {
  1544. this.testOver = true;
  1545. //未答完
  1546. } else {
  1547. this.isLastCount = true;
  1548. }
  1549. }
  1550. },
  1551. /**
  1552. * 返回上一页
  1553. */
  1554. backPages() {
  1555. this.needBack = false;
  1556. uni.navigateBack({
  1557. delta: 1,
  1558. });
  1559. },
  1560. /**
  1561. * 获取已经回答的题目数
  1562. * hasSpecail (是否包含简答和案例)
  1563. */
  1564. questionOverNum(hasSpecail) {
  1565. let count = 0;
  1566. this.questionList.forEach((item) => {
  1567. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1568. if (item.ques) {
  1569. count++;
  1570. }
  1571. } else if (item.type == 4) {
  1572. //案例题
  1573. if (hasSpecail) {
  1574. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  1575. if (
  1576. jsonItem.type == 1 ||
  1577. jsonItem.type == 2 ||
  1578. jsonItem.type == 3
  1579. ) {
  1580. if (item.ques[indexs]) {
  1581. return true;
  1582. } else {
  1583. return false;
  1584. }
  1585. } else if (jsonItem.type == 5) {
  1586. console.log(jsonItem, 111);
  1587. if (
  1588. item.ques[indexs] &&
  1589. (item.ques[indexs].text.length ||
  1590. item.ques[indexs].imageList.length)
  1591. ) {
  1592. return true;
  1593. } else {
  1594. return false;
  1595. }
  1596. }
  1597. });
  1598. if (isOver) {
  1599. count++;
  1600. console.log(item, 444);
  1601. }
  1602. }
  1603. } else if (item.type == 5) {
  1604. //简答题
  1605. if (hasSpecail) {
  1606. if (
  1607. item.ques &&
  1608. (item.ques.text.length || item.ques.imageList.length)
  1609. ) {
  1610. count++;
  1611. }
  1612. }
  1613. }
  1614. });
  1615. return count;
  1616. },
  1617. /**
  1618. * 是否做完所有题目
  1619. */
  1620. isDoOver() {
  1621. let questionOverNum = this.questionOverNum(true); //获取已经回答的题目数(包括简答和案例)
  1622. if (this.questionList.length == questionOverNum) {
  1623. //全部做完弹窗
  1624. this.cgType = 9;
  1625. this.showpopups = true;
  1626. }
  1627. },
  1628. /**
  1629. * 暂不交卷
  1630. */
  1631. noSubmit() {
  1632. //设为允许退出页面
  1633. this.needBack = false;
  1634. uni.navigateBack({
  1635. delta: 1,
  1636. });
  1637. },
  1638. /**
  1639. * 不离开
  1640. */
  1641. noLeave() {
  1642. this.isLastCount = false;
  1643. },
  1644. /**
  1645. * 立即离开并交卷
  1646. */
  1647. leaveNow() {
  1648. this.isSubmit = true;
  1649. uni.navigateBack({
  1650. delta: 1,
  1651. });
  1652. //需要拍照没有拍,返回不扣次数
  1653. if (this.needPhoto && !this.isTakePhoto) {
  1654. return;
  1655. }
  1656. this.submit("leaveNow");
  1657. },
  1658. /**
  1659. * 立即交卷
  1660. */
  1661. submitNow() {
  1662. this.showpopups = false;
  1663. this.needBack = false;
  1664. this.submit();
  1665. },
  1666. /**
  1667. * 离开页面统计回答正确题数
  1668. */
  1669. examRecordEdit() {
  1670. if (!this.isSubmit) {
  1671. this.submit("leave");
  1672. }
  1673. },
  1674. /**
  1675. * @param {Object} second倒计时过滤器
  1676. */
  1677. countdown(second) {
  1678. if (second) {
  1679. let h = parseInt((second / 60 / 60) % 24); // 计算小时
  1680. let m = parseInt((second / 60) % 60); // 计算分数
  1681. let s = parseInt(second % 60); // 计算当前秒数
  1682. if (h < 10) h = "0" + h;
  1683. if (m < 10) m = "0" + m;
  1684. if (s < 10) s = "0" + s;
  1685. return h + ":" + m + ":" + s;
  1686. } else {
  1687. return "";
  1688. }
  1689. },
  1690. noListTip(content = "该试卷暂无题目") {
  1691. this.hideDialog();
  1692. uni.showModal({
  1693. showCancel: false,
  1694. content,
  1695. success: (k) => {
  1696. if (k.confirm) {
  1697. this.isSubmit = true;
  1698. uni.navigateBack();
  1699. }
  1700. },
  1701. });
  1702. },
  1703. /**
  1704. * 请求题目列表
  1705. */
  1706. goodsQuestionList() {
  1707. this.$api[
  1708. this.doMode == 3 ? "goodsRandomQuestionList" : "goodsQuestionList"
  1709. ]({
  1710. examId: this.id,
  1711. goodsId: this.goodsId,
  1712. orderGoodsId: this.orderGoodsId,
  1713. from: 2,
  1714. }).then(async (res) => {
  1715. if (res.data.code == 500) {
  1716. return this.noListTip("你已完成所有题目");
  1717. }
  1718. let data = res.data.data;
  1719. if (this.doMode == 3) {
  1720. this.simulateExamId = data.simulateExamId;
  1721. data = data.questionList;
  1722. }
  1723. if (!data.length) {
  1724. return this.noListTip();
  1725. }
  1726. data.forEach((item, index) => {
  1727. if (typeof item.jsonStr == "string") {
  1728. item.jsonStr = JSON.parse(item.jsonStr);
  1729. if (item.type == 2) {
  1730. //多选
  1731. item.jsonStr.forEach((str) => {
  1732. str.optionsId = "" + str.optionsId;
  1733. });
  1734. let arr = item.answerQuestion.split(",");
  1735. arr.forEach((a, i) => {
  1736. arr[i] = "" + a;
  1737. });
  1738. item.ans = arr;
  1739. item.analysisContent &&
  1740. (item.analysisContent = item.analysisContent.replace(
  1741. /<img/gi,
  1742. '<img style="max-width:100%;"'
  1743. ));
  1744. item.content &&
  1745. (item.content = item.content.replace(
  1746. /<img/gi,
  1747. '<img style="max-width:100%;"'
  1748. ));
  1749. return;
  1750. } else if (item.type == 5) {
  1751. //简答题
  1752. item.ansText = {
  1753. text: "",
  1754. imageList: [],
  1755. };
  1756. item.ques = {
  1757. text: "",
  1758. imageList: [],
  1759. };
  1760. item.analysisContent &&
  1761. (item.analysisContent = item.analysisContent.replace(
  1762. /<img/gi,
  1763. '<img style="max-width:100%;"'
  1764. ));
  1765. item.content &&
  1766. (item.content = item.content.replace(
  1767. /<img/gi,
  1768. '<img style="max-width:100%;"'
  1769. ));
  1770. } else if (item.type == 4) {
  1771. //案例题
  1772. console.log(item.jsonStr);
  1773. item.ques = [];
  1774. item.current = 0;
  1775. let ansArr = [];
  1776. item.jsonStr.forEach((json, index) => {
  1777. if (json.type == 1) {
  1778. ansArr[index] = json.answerQuestion;
  1779. json.content &&
  1780. (json.content = json.content.replace(
  1781. /<img/gi,
  1782. '<img style="max-width:100%;"'
  1783. ));
  1784. } else if (json.type == 2) {
  1785. json.optionsList.forEach((str) => {
  1786. str.optionsId = "" + str.optionsId;
  1787. });
  1788. let arr = json.answerQuestion.split(",");
  1789. arr.forEach((a, i) => {
  1790. arr[i] = "" + a;
  1791. });
  1792. ansArr[index] = arr;
  1793. json.content &&
  1794. (json.content = json.content.replace(
  1795. /<img/gi,
  1796. '<img style="max-width:100%;"'
  1797. ));
  1798. } else if (json.type == 3) {
  1799. ansArr[index] = json.answerQuestion;
  1800. json.content &&
  1801. (json.content = json.content.replace(
  1802. /<img/gi,
  1803. '<img style="max-width:100%;"'
  1804. ));
  1805. } else if (json.type == 5) {
  1806. ansArr[index] = {
  1807. text: "",
  1808. imageList: [],
  1809. };
  1810. json.ansText = {
  1811. text: "",
  1812. imageList: [],
  1813. };
  1814. json.content &&
  1815. (json.content = json.content.replace(
  1816. /<img/gi,
  1817. '<img style="max-width:100%;"'
  1818. ));
  1819. }
  1820. });
  1821. item.analysisContent &&
  1822. (item.analysisContent = item.analysisContent.replace(
  1823. /<img/gi,
  1824. '<img style="max-width:100%;"'
  1825. ));
  1826. item.content &&
  1827. (item.content = item.content.replace(
  1828. /<img/gi,
  1829. '<img style="max-width:100%;"'
  1830. ));
  1831. item.ans = ansArr;
  1832. return;
  1833. }
  1834. item.content &&
  1835. (item.content = item.content.replace(
  1836. /<img/gi,
  1837. '<img style="max-width:100%;"'
  1838. ));
  1839. item.ans = item.answerQuestion;
  1840. }
  1841. });
  1842. this.questionList = data;
  1843. this.lastCount = this.questionList.length;
  1844. this.getCollectInfo(this.current);
  1845. await this.examRecord();
  1846. });
  1847. },
  1848. /**
  1849. * 记录总题数,获取recordId
  1850. * hasSpecial (是否包含简答和案例) true 包含 false 不包含
  1851. */
  1852. examRecord(hasSpecial) {
  1853. return new Promise((resolve) => {
  1854. let questionList = 0;
  1855. // if(!hasSpecial) {
  1856. this.questionList.forEach((item, index) => {
  1857. if (item.type == 1 || item.type == 2 || item.type == 3) {
  1858. questionList++;
  1859. }
  1860. });
  1861. // } else {
  1862. // questionList = this.questionList.length;
  1863. // }
  1864. this.$api
  1865. .bankRecord({
  1866. courseId: this.courseId,
  1867. // chapterExamId: this.chapterId || 0,
  1868. // moduleExamId: this.moduleId || 0,
  1869. chapterId: this.chapterId || 0,
  1870. moduleId: this.moduleId || 0,
  1871. sectionId: this.sectionId || 0,
  1872. examId: this.id,
  1873. goodsId: this.goodsId,
  1874. orderGoodsId: this.orderGoodsId,
  1875. gradeId: this.gradeId,
  1876. totalQuestionNum: questionList,
  1877. allQuestionNum: this.questionList.length,
  1878. type: this.examType,
  1879. simulateExamId: this.simulateExamId,
  1880. doMode: this.doMode,
  1881. })
  1882. .then((res) => {
  1883. this.recordId = res.data.data;
  1884. if (this.needPhoto) {
  1885. if (!this.learning && this.examType != 2) {
  1886. if (uni.getStorageSync("tabkePhotoShow")) {
  1887. // #ifdef MP-WEIXIN
  1888. this.photoPopup = true; //拍照
  1889. this.isTaking = true;
  1890. // #endif
  1891. // #ifdef H5
  1892. this.isHadCamera();
  1893. // #endif
  1894. } else {
  1895. this.popupPhotoShow = true;
  1896. uni.setStorageSync("tabkePhotoShow", 1); // 本地缓存用来判断是否已经弹出过弹窗
  1897. }
  1898. }
  1899. } else {
  1900. if (this.lastTime) {
  1901. this.timer = setInterval(() => {
  1902. if (this.lastTime <= 0) {
  1903. clearInterval(this.timer);
  1904. uni.showToast({
  1905. icon: "none",
  1906. mask: true,
  1907. title: "考试时间已到,系统将自动交卷",
  1908. duration: 10000,
  1909. });
  1910. this.submit();
  1911. return;
  1912. }
  1913. this.lastTime--;
  1914. }, 1000);
  1915. }
  1916. resolve();
  1917. }
  1918. });
  1919. });
  1920. },
  1921. /**
  1922. * @param {Object} e单选点击
  1923. */
  1924. radioSelect(optionsId, bindex) {
  1925. // if (this.questionList[bindex].ques) return;
  1926. if (this.questionList[bindex].ques && this.bankType == 1) {
  1927. return;
  1928. }
  1929. this.$set(this.questionList[bindex], "ques", optionsId);
  1930. // if ((bindex + 1) < this.questionList.length) {
  1931. // this.current = bindex + 1
  1932. // }
  1933. this.isDoOver();
  1934. },
  1935. /**
  1936. * @param {Object} e案例单选点击
  1937. */
  1938. radioSelectChild(optionsId, ansIndex, bindex) {
  1939. // if (this.questionList[bindex].ques[ansIndex]) return;
  1940. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1941. return;
  1942. }
  1943. this.$set(this.questionList[bindex].ques, ansIndex, optionsId);
  1944. this.isDoOver();
  1945. },
  1946. /**
  1947. * @param {Object} 多选点击
  1948. */
  1949. checkboxSelect(optionsId, bindex, index) {
  1950. if (this.questionList[bindex].ques && this.bankType == 1) {
  1951. return;
  1952. }
  1953. this.$set(
  1954. this.questionList[bindex].jsonStr[index],
  1955. "checked",
  1956. !this.questionList[bindex].jsonStr[index].checked
  1957. );
  1958. },
  1959. /**
  1960. * @param {Object} 案例多选点击
  1961. */
  1962. checkboxSelectChild(bindex, ansIndex, childIndex) {
  1963. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  1964. return;
  1965. }
  1966. this.$set(
  1967. this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],
  1968. "checked",
  1969. !this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex]
  1970. .checked
  1971. );
  1972. },
  1973. isCheckboxChecked(arr) {
  1974. return arr.some((item) => {
  1975. if (item.checked) {
  1976. return true;
  1977. }
  1978. });
  1979. },
  1980. /**
  1981. * @param {Object} 多选确认
  1982. */
  1983. checkboxSubmit(bindex) {
  1984. // if (this.questionList[bindex].ques) return;
  1985. if (this.questionList[bindex].ques && this.bankType == 1) {
  1986. return;
  1987. }
  1988. let arr = [];
  1989. this.questionList[bindex].jsonStr.forEach((item) => {
  1990. if (item.checked) {
  1991. arr.push(item.optionsId);
  1992. }
  1993. });
  1994. if (!arr.length) {
  1995. delete this.questionList[bindex].ques;
  1996. uni.showToast({
  1997. title: "请选择答案",
  1998. icon: "none",
  1999. });
  2000. return;
  2001. }
  2002. this.$set(this.questionList[bindex], "ques", arr);
  2003. this.$u.toast("已确认答案");
  2004. this.isDoOver();
  2005. // 切换下一题
  2006. if (
  2007. this.bankType != 1 &&
  2008. this.cgType != 9 &&
  2009. bindex != this.questionList.length - 1
  2010. ) {
  2011. this.current = bindex + 1;
  2012. this.getCollectInfo(this.current);
  2013. }
  2014. },
  2015. /**
  2016. * @param {Object} 案例多选确认
  2017. */
  2018. checkboxSubmitChild(bindex, ansIndex) {
  2019. // if (this.questionList[bindex].ques[ansIndex]) return;
  2020. if (this.questionList[bindex].ques[ansIndex] && this.bankType == 1) {
  2021. return;
  2022. }
  2023. let arr = [];
  2024. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(
  2025. (item) => {
  2026. if (item.checked) {
  2027. arr.push(item.optionsId);
  2028. }
  2029. }
  2030. );
  2031. if (!arr.length) {
  2032. delete this.questionList[bindex].ques[ansIndex];
  2033. uni.showToast({
  2034. title: "请选择答案",
  2035. icon: "none",
  2036. });
  2037. return;
  2038. }
  2039. this.$set(this.questionList[bindex].ques, ansIndex, arr);
  2040. this.$u.toast("已确认答案");
  2041. this.isDoOver();
  2042. // 切换下一题
  2043. if (
  2044. this.bankType != 1 &&
  2045. this.cgType != 9 &&
  2046. ansIndex != this.questionList[bindex].ques.length - 1
  2047. ) {
  2048. this.questionList[bindex].current += 1;
  2049. }
  2050. },
  2051. /**
  2052. * @param {Object} index
  2053. * @param {Object} bindex
  2054. * 判断题
  2055. */
  2056. judgeSelect(index, bindex) {
  2057. // if (this.questionList[bindex].ques) return;
  2058. if (this.questionList[bindex].ques && this.bankType == 1) {
  2059. return;
  2060. }
  2061. this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
  2062. this.isDoOver();
  2063. },
  2064. /**
  2065. * @param {Object} ansindex
  2066. * @param {Object} childindex
  2067. * @param {Object} bindex
  2068. * 案例判断题
  2069. */
  2070. judgeSelectChild(ansindex, childindex, bindex) {
  2071. // if (this.questionList[bindex].ques[ansindex]) return;
  2072. if (this.questionList[bindex].ques[ansindex] && this.bankType == 1) {
  2073. return;
  2074. }
  2075. this.$set(
  2076. this.questionList[bindex].ques,
  2077. ansindex,
  2078. childindex == 0 ? "1" : "0"
  2079. );
  2080. this.isDoOver();
  2081. },
  2082. openFooterTab() {
  2083. this.show = true;
  2084. },
  2085. hideDialog() {
  2086. this.showDialog = false;
  2087. },
  2088. changeIndex(index) {
  2089. this.current = index;
  2090. },
  2091. swiperChange(e) {
  2092. this.current = e.detail.current;
  2093. this.getCollectInfo(this.current);
  2094. },
  2095. /**
  2096. * @param {Object} current
  2097. * 获取收藏信息
  2098. */
  2099. getCollectInfo(current) {
  2100. this.$api
  2101. .getCollectInfo({
  2102. examId: this.id,
  2103. questionId: this.questionList[current].questionId,
  2104. goodsId: this.goodsId,
  2105. orderGoodsId: this.orderGoodsId,
  2106. })
  2107. .then((res) => {
  2108. if (res.data.code == 500) {
  2109. this.$set(this.collectList, current, false);
  2110. } else if (res.data.code == 200) {
  2111. this.$set(this.collectList, current, res.data.data);
  2112. }
  2113. });
  2114. },
  2115. /**
  2116. * @param {Object} state
  2117. * @param {Object} index
  2118. * 收藏
  2119. */
  2120. collect(state, index) {
  2121. if (!state) {
  2122. this.$api
  2123. .collectQuestion({
  2124. examId: this.id,
  2125. questionId: this.questionList[index].questionId,
  2126. goodsId: this.goodsId || "",
  2127. orderGoodsId: this.orderGoodsId,
  2128. doMode: this.doMode,
  2129. })
  2130. .then((res) => {
  2131. if (res.data.code == 200) {
  2132. this.$set(this.collectList, index, true);
  2133. uni.showToast({
  2134. title: "收藏成功",
  2135. duration: 2000,
  2136. icon: "none",
  2137. });
  2138. this.getCollectInfo(index);
  2139. }
  2140. });
  2141. } else {
  2142. this.$api
  2143. .deleteCollectQuestion(this.collectList[index].collectQuestionId)
  2144. .then((res) => {
  2145. if (res.data.code == 200) {
  2146. this.$set(this.collectList, index, false);
  2147. uni.showToast({
  2148. title: "取消收藏成功",
  2149. duration: 2000,
  2150. icon: "none",
  2151. });
  2152. }
  2153. });
  2154. }
  2155. return;
  2156. },
  2157. pdsubmit() {
  2158. let ansCount = this.questionOverNum(true); //已答题数
  2159. this.lastCount = this.questionList.length - ansCount; //统计未答完的题数
  2160. //没有答完
  2161. if (this.lastCount !== 0) {
  2162. this.cgType = 6;
  2163. this.showpopups = true;
  2164. return;
  2165. }
  2166. if (this.bankType == 2) {
  2167. if (this.lastTime > 0) {
  2168. let lastTime = this.countdown(this.lastTime);
  2169. uni.showModal({
  2170. title: "提示",
  2171. content: `时间还剩余${lastTime},确定交卷吗?`,
  2172. confirmText: "交卷",
  2173. cancelText: "继续答题",
  2174. success: (res) => {
  2175. if (res.confirm) {
  2176. //确定
  2177. this.submit();
  2178. } else {
  2179. //取消
  2180. }
  2181. },
  2182. });
  2183. return;
  2184. }
  2185. }
  2186. this.submit();
  2187. },
  2188. /**
  2189. * 交卷
  2190. */
  2191. submit(typesubmit) {
  2192. let form = this.$method.calculateScore(this.questionList);
  2193. clearInterval(this.timer);
  2194. //交卷
  2195. this.$api
  2196. .bankRecordEdit({
  2197. moduleId: this.moduleId || 0,
  2198. chapterId: this.chapterId || 0,
  2199. sectionId: this.sectionId || 0,
  2200. gradeId: this.gradeId,
  2201. examId: this.id,
  2202. goodsId: this.goodsId,
  2203. orderGoodsId: this.orderGoodsId,
  2204. recordId: this.recordId,
  2205. courseId: this.courseId,
  2206. status: 1,
  2207. type: this.examType,
  2208. examTime: parseInt(this.allTimes),
  2209. doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
  2210. ...form,
  2211. })
  2212. .then((res) => {
  2213. this.isSubmit = true;
  2214. if (res.data.code == 200) {
  2215. uni.showToast({
  2216. title: "交卷成功",
  2217. duration: 1000,
  2218. mask: true,
  2219. icon: "none",
  2220. });
  2221. if (!typesubmit) {
  2222. console.log("跳转----");
  2223. setTimeout(() => {
  2224. uni.redirectTo({
  2225. url:
  2226. "/pages2/class/question_report?rightQuestionNum=" +
  2227. form.rightQuestionNum +
  2228. "&doWrongQuestionNum=" +
  2229. form.questionIds.length +
  2230. "&score=" +
  2231. form.performance +
  2232. "&totalScore=" +
  2233. form.totalScore +
  2234. "&reportStatus=" +
  2235. form.reportStatus +
  2236. "&lessQuestionNum=" +
  2237. form.lessQuestionNum +
  2238. "&examId=" +
  2239. this.id +
  2240. "&recordId=" +
  2241. this.recordId +
  2242. "&type=" +
  2243. this.examType +
  2244. "&orderGoodsId=" +
  2245. this.orderGoodsId,
  2246. });
  2247. }, 1000);
  2248. }
  2249. }
  2250. });
  2251. //错题集id提交(客观题)
  2252. this.$api
  2253. .examWrongRecord({
  2254. moduleId: this.moduleId || 0,
  2255. chapterId: this.chapterId || 0,
  2256. sectionId: this.sectionId || 0,
  2257. gradeId: this.gradeId,
  2258. courseId: this.courseId,
  2259. examId: this.id,
  2260. goodsId: this.goodsId,
  2261. orderGoodsId: this.orderGoodsId,
  2262. questionIds: form.questionIds,
  2263. recordId: this.recordId,
  2264. type: 2, // 视频课程的传2
  2265. doMode: this.doMode,
  2266. })
  2267. .then((res) => {})
  2268. .catch((err) => {});
  2269. },
  2270. /**
  2271. * @param {Object} imgIndex
  2272. * @param {Object} bankIndex
  2273. * 删除简答图片
  2274. */
  2275. deleteImg(imgIndex, bankIndex) {
  2276. this.questionList[bankIndex].ansText.imageList.splice(imgIndex, 1);
  2277. },
  2278. /**
  2279. * @param {Object} imgIndex
  2280. * @param {Object} bankIndex
  2281. * @param {Object} ansIndex
  2282. * 删除案例题简答图片
  2283. */
  2284. deleteImgChild(imgIndex, bankIndex, ansIndex) {
  2285. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(
  2286. imgIndex,
  2287. 1
  2288. );
  2289. },
  2290. /**
  2291. * @param {Object} bankindex
  2292. * 选择上传图片
  2293. */
  2294. chooseImg(bankindex) {
  2295. if (
  2296. this.questionList[bankindex] &&
  2297. this.questionList[bankindex].ansText &&
  2298. this.questionList[bankindex].ansText.imageList.length >= 4
  2299. ) {
  2300. uni.showToast({
  2301. icon: "none",
  2302. title: "最多选择4张",
  2303. });
  2304. return;
  2305. }
  2306. uni.chooseImage({
  2307. count: 1, //默认9
  2308. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2309. sourceType: ["album", "camera"], //从相册选择
  2310. success: (res) => {
  2311. let self = this;
  2312. // console.log(JSON.stringify(res.tempFilePaths));
  2313. let img = res.tempFilePaths[0];
  2314. uni.getImageInfo({
  2315. src: img,
  2316. success: async (res) => {
  2317. let canvasWidth = res.width; //图片原始长宽
  2318. let canvasHeight = res.height;
  2319. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2320. uni.compressImage({
  2321. src: img,
  2322. quality: 75,
  2323. width: "50%",
  2324. height: "50%",
  2325. success: async (rest) => {
  2326. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2327. this.questionList[bankindex].ansText.imageList.push(dir);
  2328. },
  2329. });
  2330. } else {
  2331. const dir = await self.uploadFile(img, 0);
  2332. this.questionList[bankindex].ansText.imageList.push(dir);
  2333. }
  2334. },
  2335. });
  2336. },
  2337. });
  2338. },
  2339. /**
  2340. * @param {Object} bankindex
  2341. * @param {Object} ansindex
  2342. * 案例题选择上传图片
  2343. */
  2344. chooseImgChild(bankindex, ansindex) {
  2345. uni.chooseImage({
  2346. count: 1, //默认9
  2347. sizeType: ["compressed"], //可以指定是原图还是压缩图,默认二者都有
  2348. sourceType: ["album", "camera"], //从相册选择
  2349. success: (res) => {
  2350. let self = this;
  2351. // console.log(JSON.stringify(res.tempFilePaths));
  2352. let img = res.tempFilePaths[0];
  2353. uni.getImageInfo({
  2354. src: img,
  2355. success: async (res) => {
  2356. let canvasWidth = res.width; //图片原始长宽
  2357. let canvasHeight = res.height;
  2358. if (canvasWidth > 1000 || canvasHeight > 1000) {
  2359. uni.compressImage({
  2360. src: img,
  2361. quality: 75,
  2362. width: "50%",
  2363. height: "50%",
  2364. success: async (rest) => {
  2365. const dir = await self.uploadFile(rest.tempFilePath, 0);
  2366. this.questionList[bankindex].jsonStr[
  2367. ansindex
  2368. ].ansText.imageList.push(dir);
  2369. },
  2370. });
  2371. } else {
  2372. const dir = await self.uploadFile(img, 0);
  2373. this.questionList[bankindex].jsonStr[
  2374. ansindex
  2375. ].ansText.imageList.push(dir);
  2376. }
  2377. },
  2378. });
  2379. },
  2380. });
  2381. },
  2382. /**
  2383. * @param {Object} type
  2384. * @param {Object} bankindex
  2385. * 简答题答案确认
  2386. */
  2387. submitAns(bankindex) {
  2388. console.log(this.questionList[bankindex]);
  2389. if (
  2390. !this.questionList[bankindex].ansText.text &&
  2391. !this.questionList[bankindex].ansText.imageList.length
  2392. ) {
  2393. uni.showToast({
  2394. title: "请输入内容或上传图片",
  2395. duration: 2000,
  2396. icon: "none",
  2397. });
  2398. return;
  2399. }
  2400. this.$set(this.questionList[bankindex], "ques", {
  2401. imageList: this.questionList[bankindex].ansText.imageList,
  2402. text: this.questionList[bankindex].ansText.text,
  2403. });
  2404. this.$u.toast("已确认答案");
  2405. this.isDoOver();
  2406. },
  2407. /**
  2408. * @param {Object} bankindex
  2409. * @param {Object} ansindex
  2410. * 案例题简答答案确认
  2411. */
  2412. submitAnsChild(bankindex, ansindex) {
  2413. if (
  2414. !this.questionList[bankindex].jsonStr[ansindex].ansText.text &&
  2415. !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length
  2416. ) {
  2417. uni.showToast({
  2418. title: "请输入内容或上传图片",
  2419. duration: 2000,
  2420. icon: "none",
  2421. });
  2422. return;
  2423. }
  2424. this.$set(this.questionList[bankindex].ques, ansindex, {
  2425. imageList:
  2426. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  2427. text: this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  2428. });
  2429. this.$u.toast("已确认答案");
  2430. this.isDoOver();
  2431. },
  2432. isCheck(item, index) {
  2433. // 案例题处理
  2434. let { ques, type, ans } = item;
  2435. if (type == 4) {
  2436. return ans.length == ques.length;
  2437. }
  2438. if (ques) {
  2439. return true;
  2440. }
  2441. },
  2442. isRight(item, index) {
  2443. //单选
  2444. if (this.questionList[index].ques) {
  2445. if (item.type == 1) {
  2446. return this.questionList[index].ques == this.questionList[index].ans;
  2447. //多选
  2448. } else if (item.type == 2) {
  2449. //每一项都相等
  2450. return this.questionList[index].ans.every((item, i) => {
  2451. return item == this.questionList[index].ques[i];
  2452. });
  2453. //判断
  2454. } else if (item.type == 3) {
  2455. return this.questionList[index].ques == this.questionList[index].ans;
  2456. // } else if (item.type == 5) {
  2457. // if(this.questionList[index].ques.text){
  2458. // return true
  2459. // }else{
  2460. // return false
  2461. // }
  2462. } else {
  2463. return false;
  2464. }
  2465. } else {
  2466. return false;
  2467. }
  2468. },
  2469. right(bankIndex, ansIndex, option) {
  2470. if (
  2471. this.questionList[bankIndex].ques[ansIndex] &&
  2472. this.questionList[bankIndex].ans[ansIndex]
  2473. ) {
  2474. if (
  2475. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2476. option.optionsId
  2477. ) != -1 ||
  2478. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2479. option.optionsId
  2480. ) != -1
  2481. ) {
  2482. return true;
  2483. } else {
  2484. return false;
  2485. }
  2486. } else {
  2487. return false;
  2488. }
  2489. },
  2490. wrong(bankIndex, ansIndex, option) {
  2491. if (
  2492. this.questionList[bankIndex].ques[ansIndex] &&
  2493. this.questionList[bankIndex].ans[ansIndex]
  2494. ) {
  2495. if (
  2496. this.questionList[bankIndex].ques[ansIndex].indexOf(
  2497. option.optionsId
  2498. ) != -1 &&
  2499. this.questionList[bankIndex].ans[ansIndex].indexOf(
  2500. option.optionsId
  2501. ) == -1
  2502. ) {
  2503. return true;
  2504. } else {
  2505. return false;
  2506. }
  2507. } else {
  2508. return false;
  2509. }
  2510. },
  2511. isWrong(item, index) {
  2512. if (this.questionList[index].ques) {
  2513. //单选
  2514. if (item.type == 1) {
  2515. return this.questionList[index].ques != this.questionList[index].ans;
  2516. //多选
  2517. } else if (item.type == 2) {
  2518. //每一项都相等
  2519. return this.questionList[index].ques.some((item, i) => {
  2520. return this.questionList[index].ans.indexOf(item) == -1;
  2521. });
  2522. //判断
  2523. } else if (item.type == 3) {
  2524. return this.questionList[index].ques != this.questionList[index].ans;
  2525. } else {
  2526. return false;
  2527. }
  2528. } else {
  2529. return false;
  2530. }
  2531. },
  2532. isPart(item, index) {
  2533. if (this.questionList[index].ques) {
  2534. if (item.type == 2) {
  2535. let isWrong = this.questionList[index].ques.some((item, i) => {
  2536. return this.questionList[index].ans.indexOf(item) == -1;
  2537. });
  2538. let isRight = this.questionList[index].ans.every((item, i) => {
  2539. return item == this.questionList[index].ques[i];
  2540. });
  2541. if (!isRight && !isWrong) {
  2542. return true;
  2543. }
  2544. }
  2545. } else {
  2546. return false;
  2547. }
  2548. },
  2549. isOver(item, index) {
  2550. if (this.questionList[index].ques) {
  2551. if (item.type == 4) {
  2552. //案例题
  2553. let isOver = item.jsonStr.every((jsonItem, indexs) => {
  2554. if (
  2555. jsonItem.type == 1 ||
  2556. jsonItem.type == 2 ||
  2557. jsonItem.type == 3
  2558. ) {
  2559. if (item.ques[indexs]) {
  2560. return true;
  2561. } else {
  2562. return false;
  2563. }
  2564. } else if (jsonItem.type == 5) {
  2565. if (
  2566. item.ques[indexs] &&
  2567. (item.ques[indexs].text || item.ques[indexs].imageList.length)
  2568. ) {
  2569. console.log("chil");
  2570. return true;
  2571. } else {
  2572. return false;
  2573. }
  2574. }
  2575. });
  2576. if (isOver) {
  2577. return true;
  2578. } else {
  2579. return false;
  2580. }
  2581. } else if (item.type == 5) {
  2582. //简答题
  2583. //每一项都相等
  2584. if (item.ques && (item.ques.imageList.length || item.ques.text)) {
  2585. return true;
  2586. }
  2587. //判断
  2588. } else {
  2589. return false;
  2590. }
  2591. } else {
  2592. return false;
  2593. }
  2594. },
  2595. tabSelect(index, bankindex) {
  2596. this.$set(this.questionList[bankindex], "current", index);
  2597. },
  2598. /**
  2599. * 退出全屏
  2600. */
  2601. exitFullscreen() {
  2602. try {
  2603. var de = document;
  2604. // console.log(de);
  2605. if (de.exitFullscreen) {
  2606. de.exitFullscreen();
  2607. } else if (de.mozCancelFullScreen) {
  2608. de.mozCancelFullScreen();
  2609. } else if (de.webkitCancelFullScreen) {
  2610. de.webkitCancelFullScreen();
  2611. }
  2612. } catch (err) {}
  2613. },
  2614. fullele() {
  2615. return (
  2616. document.fullscreenElement ||
  2617. document.webkitFullscreenElement ||
  2618. document.msFullscreenElement ||
  2619. document.mozFullScreenElement ||
  2620. null
  2621. );
  2622. },
  2623. //判断是否全屏
  2624. isFullScreen() {
  2625. return !!(document.webkitIsFullScreen || this.fullele());
  2626. },
  2627. getUserMedia(constraints, success, error) {
  2628. console.log("getUserMedia===", constraints, "success:", success);
  2629. if (window.navigator.mediaDevices.getUserMedia) {
  2630. // 最新的标准API
  2631. window.navigator.mediaDevices
  2632. .getUserMedia(constraints)
  2633. .then(success)
  2634. .catch(error);
  2635. } else if (window.navigator.webkitGetUserMedia) {
  2636. // webkit核心浏览器
  2637. window.navigator.webkitGetUserMedia(constraints, success, error);
  2638. } else if (window.navigator.mozGetUserMedia) {
  2639. // firfox浏览器
  2640. window.navigator.mozGetUserMedia(constraints, success, error);
  2641. } else if (window.navigator.getUserMedia) {
  2642. // 旧版API
  2643. window.navigator.getUserMedia(constraints, success, error);
  2644. }
  2645. },
  2646. photographSuccess(stream) {
  2647. console.log("有摄像头---", stream);
  2648. this.photoPopup = true;
  2649. this.isTaking = true;
  2650. this.$nextTick(() => {
  2651. const video = document.querySelector("video");
  2652. console.log("video:", video);
  2653. video.srcObject = stream;
  2654. video.play();
  2655. });
  2656. },
  2657. photographError(err) {
  2658. console.log("没有摄像头:", err);
  2659. uni.showModal({
  2660. title: "提示",
  2661. content:
  2662. "课程学习需要开启摄像头进行拍照,经检测您的设备无摄像头可使用,请检测环境是否支持。",
  2663. cancelText: "取消",
  2664. confirmText: "确定",
  2665. success: (res) => {
  2666. if (res.confirm) {
  2667. uni.navigateBack();
  2668. } else if (res.cancel) {
  2669. }
  2670. },
  2671. });
  2672. },
  2673. },
  2674. };
  2675. </script>
  2676. <style lang="scss" scoped>
  2677. .photoBox {
  2678. width: 100%;
  2679. // background-color: #ffffff;
  2680. // border-radius: 24px 24px 0px 0px;
  2681. .photoTop {
  2682. width: 100%;
  2683. height: 74rpx;
  2684. border-radius: 20px 20px 0px 0px;
  2685. background-color: #ffffff;
  2686. display: flex;
  2687. align-items: center;
  2688. justify-content: center;
  2689. padding: 0rpx 38rpx;
  2690. .sqzz {
  2691. width: 28rpx;
  2692. height: 28rpx;
  2693. display: flex;
  2694. align-items: center;
  2695. justify-content: center;
  2696. }
  2697. .centersq {
  2698. color: #333;
  2699. font-size: 30rpx;
  2700. font-weight: 500;
  2701. }
  2702. }
  2703. .photoCenter {
  2704. width: 750rpx;
  2705. height: 75vh;
  2706. position: relative;
  2707. .center_camera {
  2708. width: 100%;
  2709. height: 75vh;
  2710. position: fixed;
  2711. .head_take {
  2712. width: 100%;
  2713. height: 75vh;
  2714. display: flex;
  2715. flex-direction: column;
  2716. }
  2717. .headTake_up {
  2718. width: 100%;
  2719. height: 100rpx;
  2720. }
  2721. .headTake_minddle {
  2722. display: flex;
  2723. .min_img {
  2724. width: 500rpx;
  2725. height: 550rpx;
  2726. }
  2727. .min_left,
  2728. .min_right {
  2729. flex: 1;
  2730. height: 550rpx;
  2731. }
  2732. }
  2733. .headTake_down {
  2734. width: 100%;
  2735. flex: 1;
  2736. }
  2737. .color {
  2738. background-color: #333;
  2739. opacity: 0.5;
  2740. }
  2741. .photo_v {
  2742. width: 100%;
  2743. height: 100%;
  2744. }
  2745. .mask {
  2746. width: 500rpx;
  2747. height: 550rpx;
  2748. position: absolute;
  2749. top: 100rpx;
  2750. left: 0;
  2751. right: 0;
  2752. bottom: 0;
  2753. margin: 0 auto;
  2754. box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.4);
  2755. }
  2756. }
  2757. .custom {
  2758. width: 750rpx;
  2759. height: 75vh;
  2760. position: absolute;
  2761. z-index: 1000;
  2762. top: 0;
  2763. left: 0;
  2764. image {
  2765. width: 100%;
  2766. height: 100%;
  2767. }
  2768. }
  2769. }
  2770. .photoBoxbtns {
  2771. display: flex;
  2772. .takePhoto_btn {
  2773. width: 100%;
  2774. display: flex;
  2775. align-items: center;
  2776. justify-content: space-between;
  2777. background: #a9a7a9;
  2778. padding: 40rpx 26rpx;
  2779. .middle_btn {
  2780. width: 120rpx;
  2781. height: 120rpx;
  2782. border-radius: 40rpx;
  2783. border: 4rpx solid #ffffff;
  2784. display: flex;
  2785. align-items: center;
  2786. justify-content: center;
  2787. }
  2788. .square {
  2789. width: 96rpx;
  2790. height: 96rpx;
  2791. background: #ffffff;
  2792. border-radius: 28rpx;
  2793. }
  2794. .rights {
  2795. font-size: 32rpx;
  2796. font-weight: 500;
  2797. color: #ffffff;
  2798. }
  2799. }
  2800. .btnResult {
  2801. height: 100rpx;
  2802. width: 100%;
  2803. background-color: #07c160;
  2804. text-align: center;
  2805. line-height: 100rpx;
  2806. color: #fff;
  2807. font-size: 32rpx;
  2808. font-weight: bold;
  2809. }
  2810. }
  2811. }
  2812. .navbar {
  2813. position: relative;
  2814. z-index: 20000;
  2815. }
  2816. .questionBank {
  2817. width: 100%;
  2818. height: 100vh;
  2819. display: flex;
  2820. flex-direction: column;
  2821. }
  2822. .swiper {
  2823. width: 100%;
  2824. flex: 1;
  2825. }
  2826. .lisSty {
  2827. margin-bottom: 16rpx;
  2828. display: flex;
  2829. .flex_auto {
  2830. flex: 1;
  2831. word-break: break-all;
  2832. }
  2833. }
  2834. .activeTI {
  2835. vertical-align: middle;
  2836. display: inline-block;
  2837. border: 1rpx solid #eee;
  2838. border-radius: 50rpx;
  2839. height: 48rpx;
  2840. line-height: 46rpx;
  2841. text-align: center;
  2842. width: 48rpx;
  2843. margin-right: 15rpx;
  2844. color: #666;
  2845. font-size: 30rpx;
  2846. &.right {
  2847. color: #fff;
  2848. background: #36c75a;
  2849. }
  2850. &.wrong {
  2851. color: #fff;
  2852. background: #ff3b30;
  2853. }
  2854. &.checked,
  2855. &.user_choose {
  2856. color: #fff;
  2857. background: #007aff;
  2858. }
  2859. }
  2860. .submit_checkbox {
  2861. position: fixed;
  2862. left: 0;
  2863. right: 0;
  2864. bottom: 120rpx;
  2865. margin: 20rpx auto;
  2866. width: 526rpx;
  2867. height: 80rpx;
  2868. background: rgba(0, 122, 255, 1);
  2869. color: #fff;
  2870. text-align: center;
  2871. line-height: 80rpx;
  2872. font-size: 30rpx;
  2873. border-radius: 40rpx;
  2874. &.disabled {
  2875. opacity: 0.6;
  2876. }
  2877. }
  2878. .titles {
  2879. overflow: hidden;
  2880. margin-bottom: 24rpx;
  2881. }
  2882. .titBox {
  2883. padding: 41rpx 25rpx 24rpx 25rpx;
  2884. }
  2885. .titBox_title {
  2886. padding: 21rpx;
  2887. }
  2888. .tabs {
  2889. margin: 10rpx;
  2890. display: flex;
  2891. .tab {
  2892. margin: 0 4rpx;
  2893. padding: 10rpx 13rpx;
  2894. text-align: center;
  2895. color: #007aff;
  2896. font-size: 28rpx;
  2897. border-radius: 16rpx;
  2898. background: #fff;
  2899. &.current {
  2900. color: #fff;
  2901. background: #007aff;
  2902. }
  2903. }
  2904. }
  2905. .ans {
  2906. margin: 8rpx 8rpx 8rpx;
  2907. .ans_input {
  2908. border-radius: 16rpx;
  2909. background: #fff;
  2910. .top {
  2911. border-bottom: 1rpx solid #eeeeee;
  2912. padding: 16rpx;
  2913. display: flex;
  2914. align-items: center;
  2915. .icon {
  2916. margin-right: 20rpx;
  2917. width: 40rpx;
  2918. height: 38rpx;
  2919. }
  2920. .progress {
  2921. flex: 1;
  2922. }
  2923. .submit {
  2924. width: 168rpx;
  2925. height: 48rpx;
  2926. line-height: 48rpx;
  2927. text-align: center;
  2928. color: #fff;
  2929. font-size: 30rpx;
  2930. background: #007aff;
  2931. border-radius: 24rpx;
  2932. &.disabled {
  2933. opacity: 0.6;
  2934. }
  2935. }
  2936. }
  2937. .textarea {
  2938. textarea {
  2939. width: 100%;
  2940. height: 287rpx;
  2941. padding: 10rpx;
  2942. }
  2943. }
  2944. .imgs {
  2945. overflow: hidden;
  2946. display: flex;
  2947. width: 100%;
  2948. .img {
  2949. width: 104rpx;
  2950. height: 104rpx;
  2951. border-radius: 8rpx;
  2952. position: relative;
  2953. margin: 20rpx;
  2954. text {
  2955. position: absolute;
  2956. right: -15rpx;
  2957. top: -15rpx;
  2958. width: 30rpx;
  2959. height: 30rpx;
  2960. text-align: center;
  2961. line-height: 30rpx;
  2962. color: #fff;
  2963. background: #ff3b30;
  2964. border-radius: 50%;
  2965. }
  2966. image {
  2967. width: 100%;
  2968. height: 100%;
  2969. }
  2970. }
  2971. }
  2972. }
  2973. .ans_submit {
  2974. padding: 16rpx;
  2975. border-radius: 16rpx;
  2976. background: #fff;
  2977. .imgs {
  2978. overflow: hidden;
  2979. display: flex;
  2980. width: 100%;
  2981. .img {
  2982. width: 104rpx;
  2983. height: 104rpx;
  2984. border-radius: 8rpx;
  2985. position: relative;
  2986. margin: 20rpx;
  2987. image {
  2988. width: 100%;
  2989. height: 100%;
  2990. }
  2991. }
  2992. }
  2993. }
  2994. }
  2995. .leftLetters {
  2996. display: flex;
  2997. align-items: center;
  2998. width: 220rpx;
  2999. .btnType {
  3000. padding: 5rpx 10rpx;
  3001. border: 1rpx solid #007aff;
  3002. border-radius: 10rpx;
  3003. background-color: rgba(0, 122, 255, 0.1);
  3004. font-size: 28rpx;
  3005. color: #007aff;
  3006. margin-right: 15rpx;
  3007. }
  3008. }
  3009. .firstLetter {
  3010. display: flex;
  3011. justify-content: space-between;
  3012. align-items: center;
  3013. margin-bottom: 30rpx;
  3014. }
  3015. .popupView {
  3016. height: 100%;
  3017. padding-bottom: 100rpx;
  3018. .popupTops {
  3019. height: 77rpx;
  3020. border-bottom: 1rpx solid #eee;
  3021. text-align: center;
  3022. line-height: 77rpx;
  3023. font-size: 24rpx;
  3024. color: #999;
  3025. position: relative;
  3026. .topIcon {
  3027. position: absolute;
  3028. top: 10rpx;
  3029. left: 50%;
  3030. transform: translateX(-50%);
  3031. width: 80rpx;
  3032. height: 8rpx;
  3033. background-color: #999;
  3034. border-radius: 4rpx;
  3035. }
  3036. }
  3037. .popupContent {
  3038. }
  3039. }
  3040. .pageContent {
  3041. position: relative;
  3042. background-color: #eaeef1;
  3043. height: 100%;
  3044. padding-top: 8rpx;
  3045. padding-bottom: 100rpx;
  3046. overflow-y: scroll;
  3047. }
  3048. .pad_8 {
  3049. background-color: #fff;
  3050. margin: 0rpx 8rpx 8rpx;
  3051. border-radius: 16rpx;
  3052. &.no-margin {
  3053. margin-top: -16rpx;
  3054. border-radius: 0 0 16rpx 16rpx;
  3055. }
  3056. }
  3057. .answer {
  3058. height: 80rpx;
  3059. line-height: 80rpx;
  3060. padding: 0rpx 24rpx;
  3061. display: flex;
  3062. align-items: center;
  3063. justify-content: space-between;
  3064. color: #666;
  3065. font-size: 30rpx;
  3066. }
  3067. .footer_btn {
  3068. background-color: #fff;
  3069. z-index: 10078;
  3070. position: fixed;
  3071. bottom: 0rpx;
  3072. display: flex;
  3073. align-items: center;
  3074. justify-content: space-between;
  3075. width: 100%;
  3076. height: 98rpx;
  3077. padding: 0rpx 38rpx;
  3078. border-top: 1rpx solid #eee;
  3079. .flex_center {
  3080. flex: 1;
  3081. display: flex;
  3082. justify-content: center;
  3083. align-items: center;
  3084. flex-direction: column;
  3085. margin: 0 200rpx;
  3086. font-size: 24rpx;
  3087. color: #999999;
  3088. .up-icon {
  3089. margin-bottom: 18rpx;
  3090. width: 100%;
  3091. display: flex;
  3092. justify-content: center;
  3093. image {
  3094. width: 58rpx;
  3095. height: 21rpx;
  3096. }
  3097. }
  3098. }
  3099. .collect {
  3100. visibility: hidden;
  3101. width: 100rpx;
  3102. &.show {
  3103. visibility: visible;
  3104. }
  3105. > view {
  3106. display: flex;
  3107. flex-direction: column;
  3108. align-items: center;
  3109. justify-content: center;
  3110. image {
  3111. width: 32rpx;
  3112. height: 32rpx;
  3113. margin-bottom: 6rpx;
  3114. }
  3115. view {
  3116. font-size: 24rpx;
  3117. color: #999999;
  3118. }
  3119. }
  3120. }
  3121. }
  3122. .boxSty {
  3123. padding: 44rpx 41rpx 0rpx;
  3124. }
  3125. .liListSty {
  3126. border: 1rpx solid #eeeeee;
  3127. width: 88rpx;
  3128. height: 88rpx;
  3129. border-radius: 32rpx;
  3130. text-align: center;
  3131. line-height: 88rpx;
  3132. color: #333;
  3133. font-size: 32rpx;
  3134. float: left;
  3135. margin: 20rpx 23rpx;
  3136. &.isRight {
  3137. border: 1rpx solid #eeeeee;
  3138. color: #fff;
  3139. background: #36c75a;
  3140. }
  3141. &.isWrong {
  3142. border: 1rpx solid #eeeeee;
  3143. color: #fff;
  3144. background: #ff3b30;
  3145. }
  3146. &.isPart {
  3147. border: 1rpx solid #eeeeee;
  3148. color: #fff;
  3149. background: #ffc53d;
  3150. }
  3151. &.isOver {
  3152. border: 1rpx solid #eeeeee;
  3153. color: #fff;
  3154. background: blue;
  3155. }
  3156. &.check_ans {
  3157. border: 1rpx solid #eeeeee;
  3158. color: #fff;
  3159. background: #007aff;
  3160. }
  3161. }
  3162. .answerInfos {
  3163. padding: 25rpx 25rpx 25rpx 23rpx;
  3164. }
  3165. .answerTitle {
  3166. margin-bottom: 28rpx;
  3167. color: #666;
  3168. font-size: 30rpx;
  3169. }
  3170. .answerContent {
  3171. font-size: 30rpx;
  3172. color: #666;
  3173. }
  3174. .textChild {
  3175. display: inline-block;
  3176. vertical-align: middle;
  3177. }
  3178. .dialog {
  3179. position: fixed;
  3180. left: 0;
  3181. top: 0;
  3182. width: 100%;
  3183. height: 100%;
  3184. background-color: rgba(0, 0, 0, 0.8);
  3185. display: flex;
  3186. flex-direction: column;
  3187. align-items: center;
  3188. justify-content: center;
  3189. z-index: 20000;
  3190. .text {
  3191. font-size: 32rpx;
  3192. color: #ffffff;
  3193. text-align: center;
  3194. }
  3195. .btn {
  3196. width: 242rpx;
  3197. height: 82rpx;
  3198. border: 2rpx solid #ffffff;
  3199. border-radius: 16rpx;
  3200. text-align: center;
  3201. line-height: 82rpx;
  3202. margin: 41rpx auto;
  3203. color: #fff;
  3204. font-size: 32rpx;
  3205. }
  3206. }
  3207. .dialog-arrow {
  3208. padding-top: 124rpx;
  3209. position: fixed;
  3210. left: 0;
  3211. top: 0;
  3212. width: 100%;
  3213. height: 100%;
  3214. background-color: rgba(0, 0, 0, 0.8);
  3215. z-index: 20000;
  3216. .pointer {
  3217. margin-left: 87rpx;
  3218. display: block;
  3219. width: 95rpx;
  3220. height: 98rpx;
  3221. }
  3222. .text {
  3223. padding-left: 177rpx;
  3224. font-size: 32rpx;
  3225. color: #ffffff;
  3226. }
  3227. .btn {
  3228. width: 242rpx;
  3229. height: 82rpx;
  3230. border: 2rpx solid #ffffff;
  3231. border-radius: 16rpx;
  3232. text-align: center;
  3233. line-height: 82rpx;
  3234. margin: 500rpx auto 0;
  3235. color: #fff;
  3236. font-size: 32rpx;
  3237. }
  3238. }
  3239. .dialog_wrap {
  3240. position: fixed;
  3241. left: 0;
  3242. top: 0;
  3243. width: 100%;
  3244. height: 100%;
  3245. z-index: 9999999999;
  3246. .bg {
  3247. background: rgba(0, 0, 0, 0.3);
  3248. position: absolute;
  3249. left: 0;
  3250. top: 0;
  3251. width: 100%;
  3252. height: 100%;
  3253. }
  3254. .dialog {
  3255. position: absolute;
  3256. left: 50%;
  3257. top: 50%;
  3258. transform: translate3D(-50%, -50%, 0);
  3259. width: 640rpx;
  3260. height: 439rpx;
  3261. background: #ffffff;
  3262. border-radius: 24rpx;
  3263. .title {
  3264. font-size: 30rpx;
  3265. font-weight: bold;
  3266. color: #333333;
  3267. line-height: 48rpx;
  3268. text-align: center;
  3269. margin-top: 40rpx;
  3270. }
  3271. .content {
  3272. margin: 35rpx 35rpx 0;
  3273. font-size: 30rpx;
  3274. color: #666666;
  3275. line-height: 48rpx;
  3276. }
  3277. .btns {
  3278. margin-top: 35rpx;
  3279. display: flex;
  3280. align-items: center;
  3281. justify-content: center;
  3282. .btn {
  3283. width: 200rpx;
  3284. height: 80rpx;
  3285. line-height: 80rpx;
  3286. text-align: center;
  3287. background: #f5f5f5;
  3288. border-radius: 40rpx;
  3289. font-size: 30rpx;
  3290. color: rgba(0, 122, 255, 1);
  3291. background: #f5f5f5;
  3292. margin: 0 20rpx;
  3293. &.active {
  3294. color: #f5f5f5;
  3295. background: rgba(0, 122, 255, 1);
  3296. }
  3297. }
  3298. }
  3299. }
  3300. }
  3301. .popboxs {
  3302. width: 100%;
  3303. height: 100%;
  3304. display: flex;
  3305. flex-direction: column;
  3306. align-items: center;
  3307. }
  3308. .classTops {
  3309. flex-shrink: 0;
  3310. padding: 39rpx 0rpx 4rpx;
  3311. font-weight: bold;
  3312. color: #333;
  3313. font-size: 30rpx;
  3314. }
  3315. .textStys {
  3316. width: 100%;
  3317. flex: 1;
  3318. padding: 36rpx;
  3319. }
  3320. .classFootsty {
  3321. flex-shrink: 0;
  3322. display: flex;
  3323. align-items: center;
  3324. justify-content: center;
  3325. padding: 10rpx 0rpx 40rpx;
  3326. .btnsty {
  3327. width: 200rpx;
  3328. height: 80rpx;
  3329. border-radius: 40rpx;
  3330. font-weight: bold;
  3331. font-size: 30rpx;
  3332. text-align: center;
  3333. line-height: 80rpx;
  3334. }
  3335. .btns1 {
  3336. background-color: #f5f5f5;
  3337. color: #007aff;
  3338. }
  3339. .btns2 {
  3340. margin-left: 40rpx;
  3341. background-color: #007aff;
  3342. color: #ffffff;
  3343. }
  3344. }
  3345. </style>