questionBank.vue 66 KB

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