questionBank.vue 99 KB

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