questionBank.vue 49 KB

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