questionBank.vue 69 KB

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