questionBank.vue 68 KB

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