questionBank.vue 49 KB

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