questionBank.vue 51 KB

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