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