questionBank.vue 51 KB

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