questionBank.vue 67 KB

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