questionBank.vue 52 KB

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