questionBank.vue 51 KB

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