questionBankTest.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. <template>
  2. <view id="questionBank">
  3. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  4. <swiper-item v-for="(bank,bankIndex) in questionList" :key="bankIndex">
  5. <view class="pageContent">
  6. <view class="pad_8 titBox" >
  7. <view class="firstLetter">
  8. <view class="leftLetters">
  9. <view class="btnType">
  10. <text v-if="bank.type==1">单选</text>
  11. <text v-if="bank.type==2">多选</text>
  12. <text v-if="bank.type==3">判断</text>
  13. <text v-if="bank.type==4">案例题</text>
  14. <text v-if="bank.type==5">简答题</text>
  15. </view>
  16. <text>1/{{current}}</text>
  17. </view>
  18. <view style="color: #666;font-size: 28rpx;">03:25:06</view>
  19. <view class="leftLetters"></view>
  20. </view>
  21. <view class="titles">
  22. <rich-text :nodes="bank.content"></rich-text>
  23. </view>
  24. </view>
  25. <view class="pad_8 titBox">
  26. <template v-if="bank.type == 1">
  27. <view v-if="!ques[bankIndex]">
  28. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect" :data-index="index" :data-bindex="bankIndex" :data-optionsId="item.optionsId">
  29. <view class="activeTI">{{ ast[index] }}</view>
  30. {{ item.content }}
  31. </view>
  32. </view>
  33. <view v-if="ques[bankIndex]">
  34. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  35. <text :class="{right:(item.optionsId == ques[bankIndex]) || (item.optionsId == ans[bankIndex]),wrong:(item.optionsId == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</text>
  36. {{ item.content }}
  37. </view>
  38. </view>
  39. <view v-if="ques[bankIndex]">
  40. <view class="pad_8 answer">
  41. <view>正确答案:{{ast[ans[bankIndex]-1]}}</view>
  42. <view>我的答案:{{ast[ques[bankIndex]-1]}}</view>
  43. </view>
  44. <view class="pad_8 answerInfos">
  45. <view class="answerTitle">答案解析</view>
  46. <view class="answerContent">
  47. <rich-text :nodes="bank.analysisContent"></rich-text>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <template v-if="bank.type == 2">
  53. <view v-if="!ques[bankIndex]">
  54. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect" :data-index="index" :data-bindex="bankIndex" :data-optionsId="item.optionsId">
  55. <view :class="{checked:item.checked}" class="activeTI">{{ ast[index] }}</view>
  56. {{ item.content }}
  57. </view>
  58. </view>
  59. <view v-if="!ques[bankIndex]" class="submit_checkbox" @click="checkboxSubmit" :data-bindex="bankIndex">
  60. 确认答案
  61. </view>
  62. <view v-if="ques[bankIndex]">
  63. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  64. <text :class="{right:(ques[bankIndex].indexOf(item.optionsId) != -1 ) || (ans[bankIndex].indexOf(item.optionsId) != -1),wrong:(ques[bankIndex].indexOf(item.optionsId) != -1 ) && (ans[bankIndex].indexOf(item.optionsId) == -1)}" class="activeTI">{{ ast[index] }}</text>
  65. {{ item.content }}
  66. </view>
  67. </view>
  68. <view v-if="ques[bankIndex]">
  69. <view class="pad_8 answer">
  70. <view>正确答案:
  71. <text v-for="ansItem in ans[bankIndex]">{{ast[ansItem-1]}}</text>
  72. </view>
  73. <view>我的答案:
  74. <text v-for="quesItem in ques[bankIndex]">{{ast[quesItem-1]}}</text>
  75. </view>
  76. </view>
  77. <view class="pad_8 answerInfos">
  78. <view class="answerTitle">答案解析</view>
  79. <view class="answerContent">
  80. <rich-text :nodes="bank.analysisContent"></rich-text>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <template v-if="bank.type == 3">
  86. <view v-if="!ques[bankIndex]">
  87. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect" :data-index="index" :data-bindex="bankIndex" >
  88. <view class="activeTI">{{ ast[index] }}</view>
  89. {{ item }}
  90. </view>
  91. </view>
  92. <view v-if="ques[bankIndex]">
  93. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  94. <text :class="{right:(index == ques[bankIndex]) || (index == ans[bankIndex]),wrong:(index == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</text>
  95. {{ item }}
  96. </view>
  97. </view>
  98. <view v-if="ques[bankIndex]">
  99. <view class="pad_8 answer">
  100. <view>正确答案:{{ast[ans[bankIndex]]}}</view>
  101. <view>我的答案:{{ast[ques[bankIndex]]}}</view>
  102. </view>
  103. <view class="pad_8 answerInfos">
  104. <view class="answerTitle">答案解析</view>
  105. <view class="answerContent">
  106. <rich-text :nodes="bank.analysisContent"></rich-text>
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <!-- 简答题 -->
  112. <template v-if="bank.type == 5">
  113. <view class="ans">
  114. <view class="ans_input" v-if="!ques[bankIndex]">
  115. <view class="top flex">
  116. <image :data-index="bankIndex" class="icon" :data-bindex="bankIndex" @click="chooseImg" src="/static/08-10_032.jpg" mode=""></image>
  117. <view class="progress">0/4</view>
  118. <view class="submit" @click="submitAns" :data-bindex="bankIndex" >确认答案</view>
  119. </view>
  120. <view class="textarea">
  121. <textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea>
  122. </view>
  123. <view class="imgs">
  124. <view class="img" v-for="(img,imgIndex) in bank.ansText.imageList" >
  125. <text @click="deleteImg" :data-imgIndex="imgIndex" :data-bindex="bankIndex">x</text>
  126. <image :src="img"></image>
  127. </view>
  128. </view>
  129. </view>
  130. <view class="ans_submit answerInfos" v-if="ques[bankIndex]">
  131. <view class="answerTitle">答案我的</view>
  132. {{ques[bankIndex].text}}
  133. <view class="imgs">
  134. <image class="img" v-for="ques in ques[bankIndex].imageList" :src="ques"></image>
  135. </view>
  136. </view>
  137. </view>
  138. <view v-if="ques[bankIndex]">
  139. <view class="pad_8 answerInfos">
  140. <view class="answerTitle">答案解析</view>
  141. <view class="answerContent">
  142. <rich-text :nodes="bank.analysisContent"></rich-text>
  143. </view>
  144. </view>
  145. </view>
  146. </template>
  147. <!-- 案例题 -->
  148. <template v-if="bank.type == 4">
  149. <view class="tabs">
  150. <view class="tab" :class="{current:tabIndex == bank.current}" :data-bindex="bankIndex" :data-index="tabIndex" :key="tabIndex" v-for="(tab,tabIndex) in bank.jsonStr" @click="tabSelect">问题{{tabIndex}}</view>
  151. </view>
  152. <view v-for="(ansItem,ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  153. <view class="titles">
  154. <rich-text :nodes="ans.content"></rich-text>
  155. </view>
  156. <template v-if="ansItem.type == 1">
  157. <view v-if="!ques[bankIndex][ansIndex]">
  158. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty" @click="radioSelectChild" :data-ansIndex="ansIndex" :data-bindex="bankIndex" :data-optionsId="option.optionsId">
  159. <view class="activeTI">{{ ast[childIndex] }}</view>
  160. <rich-text class="textChild" :nodes="option.content"></rich-text>
  161. </view>
  162. </view>
  163. <view v-if="ques[bankIndex][ansIndex]">
  164. <view v-for="(option, childIndex) in ansItem.optionsList" :key="index" class="lisSty">
  165. <text :class="{right:(option.optionsId == ques[bankIndex][ansIndex]) || (option.optionsId == ans[bankIndex][ansIndex]),wrong:(option.optionsId == ques[bankIndex][ansIndex]) && (ques[bankIndex][ansIndex] != ans[bankIndex][ansIndex])}" class="activeTI">{{ ast[childIndex] }}</text>
  166. <rich-text :nodes="option.content"></rich-text>
  167. </view>
  168. </view>
  169. <view v-if="ques[bankIndex][ansIndex]">
  170. <view class="pad_8 answer">
  171. <view>正确答案:{{ast[ans[bankIndex][ansIndex]-1]}}</view>
  172. <view>我的答案:{{ast[ques[bankIndex][ansIndex]-1]}}</view>
  173. </view>
  174. <view class="pad_8 answerInfos">
  175. <view class="answerTitle">答案解析</view>
  176. <view class="answerContent">
  177. <rich-text :nodes="option.analysisContent"></rich-text>
  178. </view>
  179. </view>
  180. </view>
  181. </template>
  182. <template v-if="ansItem.type == 2">
  183. <view v-if="!ques[bankIndex][ansIndex]">
  184. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" :data-childindex="childindex" class="lisSty" @click="checkboxSelectChild" :data-ansIndex="ansIndex" :data-bindex="bankIndex" :data-optionsId="ans.optionsId">
  185. <view :class="{checked:option.checked}" class="activeTI">{{ ast[childindex] }}</view>
  186. <rich-text :nodes="option.content"></rich-text>
  187. </view>
  188. </view>
  189. <view v-if="!ques[bankIndex][ansIndex]" :data-ansindex="ansIndex" class="submit_checkbox" @click="checkboxSubmitChild" :data-bindex="bankIndex">
  190. 确认答案
  191. </view>
  192. <view v-if="ques[bankIndex] && ques[bankIndex][ansIndex]">
  193. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  194. <text :class="{right:right(bankIndex,ansIndex,option),wrong:wrong(bankIndex,ansIndex,option)}" class="activeTI">{{ ast[childindex] }}</text>
  195. <rich-text :nodes="option.content"></rich-text>
  196. </view>
  197. </view>
  198. <view v-if="ques[bankIndex][ansIndex]">
  199. <view class="pad_8 answer">
  200. <view>正确答案:
  201. <text v-for="ansItem1 in ans[bankIndex][ansIndex]">{{ast[ansItem1-1]}}</text>
  202. </view>
  203. <view>我的答案:
  204. <text v-for="quesItem in ques[bankIndex][ansIndex]">{{ast[quesItem-1]}}</text>
  205. </view>
  206. </view>
  207. <view class="pad_8 answerInfos">
  208. <view class="answerTitle">答案解析</view>
  209. <view class="answerContent">
  210. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  211. </view>
  212. </view>
  213. </view>
  214. </template>
  215. <template v-if="ansItem.type == 3">
  216. <view v-if="!ques[bankIndex][ansIndex]">
  217. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild" :data-ansIndex="ansIndex" :data-childindex="childindex" :data-bindex="bankIndex" >
  218. <view class="activeTI">{{ ast[childindex] }}</view>
  219. {{ option }}
  220. </view>
  221. </view>
  222. <view v-if="ques[bankIndex][ansIndex]">
  223. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  224. <text :class="{right:(childindex == ques[bankIndex][ansIndex]) || (childindex == ans[bankIndex][ansIndex]),wrong:(childindex == ques[bankIndex][ansIndex]) && (ques[bankIndex][ansIndex] != ans[bankIndex][ansIndex])}" class="activeTI">{{ ast[childindex] }}</text>
  225. {{ option }}
  226. </view>
  227. </view>
  228. <view v-if="ques[bankIndex][ansIndex]">
  229. <view class="pad_8 answer">
  230. <view>正确答案:{{ast[ans[bankIndex][ansIndex]]}}</view>
  231. <view>我的答案:{{ast[ques[bankIndex][ansIndex]]}}</view>
  232. </view>
  233. <view class="pad_8 answerInfos">
  234. <view class="answerTitle">答案解析</view>
  235. <view class="answerContent">
  236. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  237. </view>
  238. </view>
  239. </view>
  240. </template>
  241. <!-- 简答题 -->
  242. <template v-if="ansItem.type == 5">
  243. <view class="ans">
  244. <view class="ans_input" v-if="!ques[bankIndex][ansIndex]">
  245. <view class="top flex">
  246. <image :data-ansindex="ansIndex" class="icon" :data-bindex="bankIndex" @click="chooseImgChild" src="/static/08-10_032.jpg" mode=""></image>
  247. <view class="progress">0/4</view>
  248. <view class="submit" @click="submitAnsChild" :data-ansindex="ansIndex" :data-index="ansIndex" :data-bindex="bankIndex" >确认答案</view>
  249. </view>
  250. <view class="textarea">
  251. <textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea>
  252. </view>
  253. <view class="imgs">
  254. <view class="img" v-for="(img,imgIndex) in ansItem.ansText.imageList" >
  255. <text @click="deleteImgChild" :data-imgIndex="imgIndex" :data-ansindex="ansIndex" :data-bindex="bankIndex">x</text>
  256. <image :src="img"></image>
  257. </view>
  258. </view>
  259. </view>
  260. <view class="ans_submit answerInfos" v-if="ques[bankIndex][ansIndex]">
  261. <view class="answerTitle">答案我的</view>
  262. {{ques[bankIndex][ansIndex].text}}
  263. <view class="imgs">
  264. <image class="img" v-for="ques in ques[bankIndex][ansIndex].imageList" :src="ques"></image>
  265. </view>
  266. </view>
  267. </view>
  268. <view v-if="ques[bankIndex][ansIndex]">
  269. <view class="pad_8 answerInfos">
  270. <view class="answerTitle">答案解析</view>
  271. <view class="answerContent">
  272. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  273. </view>
  274. </view>
  275. </view>
  276. </template>
  277. </view>
  278. </template>
  279. </view>
  280. </view>
  281. </swiper-item>
  282. </swiper>
  283. <view class="footer_btn">
  284. <view @click="collect">收藏</view>
  285. <view @click="openFooterTab">答题卡</view>
  286. <view @click="submit">交卷</view>
  287. </view>
  288. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  289. <view class="popupView">
  290. <view class="popupTops">
  291. <view class="topIcon"></view>
  292. 点击编号即可跳转至对应题目
  293. </view>
  294. <view class="popupContent">
  295. <scroll-view scroll-y="true" style="height: 506rpx;">
  296. <view class="boxSty">
  297. <view v-for="(item, index) in questionList" :key="index" :data-index="index" @click="changeIndex" :class="{isRight:isRight(item,index),isWrong:isWrong(item,index)}" class="liListSty">{{ index + 1 }}</view>
  298. </view>
  299. </scroll-view>
  300. </view>
  301. </view>
  302. </u-popup>
  303. <view class="dialog" v-if="showDialog">
  304. <view class="text">左右滑动切换上下题</view>
  305. <view class="btn" @click="hideDialog">我知道了</view>
  306. </view>
  307. </view>
  308. </template>
  309. <script>
  310. export default {
  311. data() {
  312. return {
  313. id:'',
  314. current:0,
  315. questionList:[],
  316. ast: ['A', 'B', 'C', 'D','E','F','G'],
  317. judge:['错误','正确'],
  318. ans:[],
  319. ques:[],
  320. show: false,
  321. showDialog:true,
  322. bankList: []
  323. };
  324. },
  325. onLoad(option){
  326. this.id = option.id;
  327. this.goodsQuestionList()
  328. },
  329. methods: {
  330. goodsQuestionList() {
  331. this.$api.goodsQuestionList({
  332. examId:this.id
  333. }).then(res => {
  334. console.log(res)
  335. res.data.data.forEach((item,index) => {
  336. item.jsonStr = JSON.parse(item.jsonStr)
  337. if(item.type == 2) { //多选
  338. item.jsonStr.forEach(str => {
  339. str.optionsId = ''+str.optionsId;
  340. })
  341. let arr = item.answerQuestion.split(',');
  342. arr.forEach((a,i) => {
  343. arr[i] = ''+a;
  344. })
  345. this.$set(this.ans,index,arr);
  346. return;
  347. } else if(item.type == 5) {
  348. item.ansText = {
  349. text: '',
  350. imageList: []
  351. }
  352. } else if(item.type == 4) {
  353. console.log(item.jsonStr)
  354. this.$set(this.ques,index,[])
  355. item.current = 0;
  356. let ansArr = [];
  357. item.jsonStr.forEach((json,index) => {
  358. if(json.type == 1) {
  359. ansArr[index] = json.answerQuestion;
  360. } else if(json.type == 2) {
  361. json.optionsList.forEach(str => {
  362. str.optionsId = ''+str.optionsId;
  363. })
  364. let arr = json.answerQuestion.split(',');
  365. arr.forEach((a,i) => {
  366. arr[i] = ''+a;
  367. })
  368. ansArr[index] = arr
  369. } else if(json.type == 3) {
  370. ansArr[index] = json.answerQuestion;
  371. } else if(json.type == 5) {
  372. ansArr[index] = {
  373. text: '',
  374. imageList: []
  375. }
  376. json.ansText = {
  377. text: '',
  378. imageList: []
  379. }
  380. }
  381. })
  382. this.$set(this.ans,index,ansArr);
  383. return;
  384. }
  385. this.$set(this.ans,index,item.answerQuestion);
  386. })
  387. this.questionList = res.data.data;
  388. })
  389. },
  390. /**
  391. * @param {Object} e单选点击
  392. */
  393. radioSelect(e) {
  394. let optionsId = e.currentTarget.dataset.optionsid;
  395. let bindex = e.currentTarget.dataset.bindex;
  396. if(this.ques[bindex]) return;
  397. this.$set(this.ques,bindex,optionsId)
  398. },
  399. /**
  400. * @param {Object} e单选点击
  401. */
  402. radioSelectChild(e) {
  403. console.log(e.currentTarget.dataset)
  404. let optionsId = e.currentTarget.dataset.optionsid;
  405. let ansIndex = e.currentTarget.dataset.ansindex;
  406. let bindex = e.currentTarget.dataset.bindex;
  407. if(this.ques[bindex][ansIndex]) return;
  408. this.$set(this.ques[bindex],ansIndex,optionsId)
  409. },
  410. /**
  411. * @param {Object} 多选点击
  412. */
  413. checkboxSelect(e) {
  414. let optionsId = e.currentTarget.dataset.optionsid;
  415. let bindex = e.currentTarget.dataset.bindex;
  416. let index = e.currentTarget.dataset.index;
  417. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  418. },
  419. /**
  420. * @param {Object} 多选点击
  421. */
  422. checkboxSelectChild(e) {
  423. let optionsId = e.currentTarget.dataset.optionsid;
  424. let bindex = e.currentTarget.dataset.bindex;
  425. let ansIndex = e.currentTarget.dataset.ansindex;
  426. let childIndex = e.currentTarget.dataset.childindex;
  427. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  428. },
  429. /**
  430. * @param {Object} 多选确认
  431. */
  432. checkboxSubmit(e) {
  433. let bindex = e.currentTarget.dataset.bindex;
  434. if(this.ques[bindex]) return;
  435. let arr = [];
  436. this.questionList[bindex].jsonStr.forEach(item => {
  437. console.log(item)
  438. if(item.checked) {
  439. arr.push(item.optionsId)
  440. }
  441. })
  442. this.$set(this.ques,bindex,arr)
  443. },
  444. /**
  445. * @param {Object} 多选确认
  446. */
  447. checkboxSubmitChild(e) {
  448. let bindex = e.currentTarget.dataset.bindex;
  449. let ansIndex = e.currentTarget.dataset.ansindex;
  450. if(this.ques[bindex][ansIndex]) return;
  451. let arr = [];
  452. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  453. if(item.checked) {
  454. arr.push(item.optionsId)
  455. }
  456. })
  457. this.$set(this.ques[bindex],ansIndex,arr)
  458. },
  459. judgeSelect(e) {
  460. let index = e.currentTarget.dataset.index;
  461. let bindex = e.currentTarget.dataset.bindex;
  462. if(this.ques[bindex]) return;
  463. this.$set(this.ques,bindex,index+'')
  464. },
  465. judgeSelectChild(e) {
  466. let ansindex = e.currentTarget.dataset.ansindex;
  467. let childindex = e.currentTarget.dataset.childindex;
  468. let bindex = e.currentTarget.dataset.bindex;
  469. if(this.ques[bindex][ansindex]) return;
  470. this.$set(this.ques[bindex],ansindex,childindex+'')
  471. },
  472. openFooterTab() {
  473. this.show = true;
  474. },
  475. hideDialog() {
  476. this.showDialog = false
  477. },
  478. changeIndex(e) {
  479. let index = e.currentTarget.dataset.index
  480. if(index >= 5) {
  481. uni.showToast({
  482. title: '返回详情购买后即可继续',
  483. duration: 2000,
  484. icon:'none'
  485. });
  486. return;
  487. }
  488. this.current = e.currentTarget.dataset.index
  489. },
  490. swiperChange(e) {
  491. this.current = e.detail.current;
  492. },
  493. submit() {
  494. uni.showToast({
  495. title: '不能试做返回详情购买后即可交卷~',
  496. duration: 2000,
  497. icon:'none'
  498. });
  499. return;
  500. },
  501. collect() {
  502. // uni.showToast({
  503. // title: '返回详情购买后即可收藏~',
  504. // duration: 2000,
  505. // icon:'none'
  506. // });
  507. this.collectQuestion()
  508. return;
  509. },
  510. click(e) {
  511. if(this.ques[this.current]) return;
  512. let value = e.currentTarget.dataset.value;
  513. this.ques[this.current] = value;
  514. this.ques = Object.assign({},this.ques)
  515. },
  516. deleteImg(e) {
  517. var imgIndex = e.currentTarget.dataset.imgindex;
  518. var bankIndex = e.currentTarget.dataset.bankindex;
  519. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  520. },
  521. deleteImgChild(e) {
  522. var imgIndex = e.currentTarget.dataset.imgindex;
  523. var bankIndex = e.currentTarget.dataset.bankindex;
  524. var ansIndex = e.currentTarget.dataset.ansindex;
  525. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  526. },
  527. chooseImg(e) {
  528. console.log(e.currentTarget.dataset)
  529. let bankindex = e.currentTarget.dataset.bindex;
  530. uni.chooseImage({
  531. count: 1, //默认9
  532. sizeType: ['original', ], //可以指定是原图还是压缩图,默认二者都有
  533. sourceType: ['album','camera'], //从相册选择
  534. success: (res) => {
  535. // console.log(JSON.stringify(res.tempFilePaths));
  536. this.questionList[bankindex].ansText.imageList.push(res.tempFilePaths)
  537. }
  538. })
  539. },
  540. chooseImgChild(e) {
  541. let bankindex = e.currentTarget.dataset.bindex;
  542. let ansindex = e.currentTarget.dataset.ansindex;
  543. uni.chooseImage({
  544. count: 1, //默认9
  545. sizeType: ['original', ], //可以指定是原图还是压缩图,默认二者都有
  546. sourceType: ['album','camera'], //从相册选择
  547. success: (res) => {
  548. // console.log(JSON.stringify(res.tempFilePaths));
  549. console.log(this.questionList[bankindex].jsonStr[ansindex])
  550. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(res.tempFilePaths)
  551. }
  552. })
  553. },
  554. submitAns(e) {
  555. let type = e.currentTarget.dataset.type;
  556. let bankindex = e.currentTarget.dataset.bindex;
  557. console.log(this.questionList[bankindex])
  558. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  559. uni.showToast({
  560. title: '请输入内容或上传图片',
  561. duration: 2000,
  562. icon:'none'
  563. });
  564. return
  565. }
  566. this.$set(this.ques,bankindex,{
  567. imageList:this.questionList[bankindex].ansText.imageList,
  568. text:this.questionList[bankindex].ansText.text,
  569. })
  570. },
  571. submitAnsChild(e) {
  572. let type = e.currentTarget.dataset.type;
  573. let bankindex = e.currentTarget.dataset.bindex;
  574. let ansindex = e.currentTarget.dataset.ansindex;
  575. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  576. uni.showToast({
  577. title: '请输入内容或上传图片',
  578. duration: 2000,
  579. icon:'none'
  580. });
  581. return
  582. }
  583. this.$set(this.ques[bankindex],ansindex,{
  584. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  585. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  586. })
  587. },
  588. isRight(item,index) {
  589. //单选
  590. if(this.ques[index]) {
  591. if(item.type == 1) {
  592. return this.ques[index] == this.ans[index];
  593. //多选
  594. } else if(item.type == 2) {
  595. //每一项都相等
  596. return this.ques.every((item,index) => {
  597. return item == this.ans[index];
  598. })
  599. //判断
  600. } else if(item.type == 3) {
  601. return this.ques[index] == this.ans[index];
  602. } else {
  603. return false;
  604. }
  605. } else {
  606. return false;
  607. }
  608. },
  609. right(bankIndex,ansIndex,option) {
  610. console.log(this.ques[bankIndex][ansIndex] || this.ans[bankIndex][ansIndex] )
  611. if(this.ques[bankIndex][ansIndex] && this.ans[bankIndex][ansIndex]) {
  612. if((this.ques[bankIndex][ansIndex].indexOf(option.optionsId) != -1 ) || (this.ans[bankIndex][ansIndex].indexOf(option.optionsId) != -1)) {
  613. return true
  614. } else {
  615. return false;
  616. }
  617. } else {
  618. return false;
  619. }
  620. },
  621. wrong(bankIndex,ansIndex,option) {
  622. console.log(this.ques[bankIndex][ansIndex] || this.ans[bankIndex][ansIndex] )
  623. if(this.ques[bankIndex][ansIndex] && this.ans[bankIndex][ansIndex]) {
  624. if((this.ques[bankIndex][ansIndex].indexOf(option.optionsId) != -1 ) && (this.ans[bankIndex][ansIndex].indexOf(option.optionsId) == -1)) {
  625. return true;
  626. } else {
  627. return false;
  628. }
  629. } else {
  630. return false;
  631. }
  632. },
  633. isWrong(item,index) {
  634. if(this.ques[index]) {
  635. //单选
  636. if(item.type == 1) {
  637. return this.ques[index] != this.ans[index];
  638. //多选
  639. } else if(item.type == 2) {
  640. //每一项都相等
  641. return this.ques.some((item,index) => {
  642. return item != this.ans[index];
  643. })
  644. //判断
  645. } else if(item.type == 3) {
  646. return this.ques[index] != this.ans[index];
  647. } else {
  648. return false;
  649. }
  650. } else {
  651. return false;
  652. }
  653. },
  654. tabSelect(e) {
  655. let index = e.currentTarget.dataset.index;
  656. let bankindex = e.currentTarget.dataset.bindex;
  657. this.$set(this.questionList[bankindex],'current',index)
  658. console.log(this.questionList[bankindex])
  659. },
  660. collectQuestion() {
  661. this.$api.collectQuestion({
  662. examId:this.id
  663. }).then(res => {
  664. if(res.data.code==200){
  665. uni.showToast({
  666. title: '收藏成功',
  667. duration: 2000,
  668. icon:'none'
  669. });
  670. }
  671. })
  672. }
  673. }
  674. };
  675. </script>
  676. <style lang="scss" scoped>
  677. .swiper {
  678. width:100%;
  679. height:100vh;
  680. }
  681. .lisSty {
  682. margin-bottom: 16rpx;
  683. display: flex;
  684. }
  685. .activeTI {
  686. vertical-align: middle;
  687. display: inline-block;
  688. border: 1rpx solid #eee;
  689. border-radius: 50rpx;
  690. height: 48rpx;
  691. line-height: 46rpx;
  692. text-align: center;
  693. width: 48rpx;
  694. margin-right: 15rpx;
  695. color: #666;
  696. font-size: 30rpx;
  697. &.right {
  698. color:#fff;
  699. background:green;
  700. }
  701. &.wrong {
  702. color:#fff;
  703. background:red;
  704. }
  705. &.checked {
  706. color:#fff;
  707. background:blue;
  708. }
  709. }
  710. .submit_checkbox {
  711. margin:20rpx auto;
  712. width: 526rpx;
  713. height: 80rpx;
  714. background: rgba(0, 122, 255, 1);
  715. color:#fff;
  716. text-align: center;
  717. line-height: 80rpx;
  718. font-size: 30rpx;
  719. border-radius: 40rpx;
  720. }
  721. .titles {
  722. overflow: hidden;
  723. margin-bottom: 24rpx;
  724. }
  725. .titBox {
  726. padding: 41rpx 25rpx 24rpx 25rpx;
  727. }
  728. .tabs {
  729. margin:10rpx;
  730. display: flex;
  731. .tab {
  732. margin:0 10rpx;
  733. width: 96rpx;
  734. height: 48rpx;
  735. line-height: 48rpx;
  736. text-align: center;
  737. color:#007AFF;
  738. font-size: 28rpx;
  739. border-radius: 16rpx;
  740. &.current {
  741. color:#fff;
  742. background: #007AFF;
  743. }
  744. }
  745. }
  746. .ans {
  747. margin:8rpx 8rpx 8rpx;
  748. .ans_input {
  749. border-radius: 16rpx;
  750. background:#fff;
  751. .top {
  752. border-bottom:1rpx solid #EEEEEE;
  753. padding: 16rpx;
  754. display: flex;
  755. align-items: center;
  756. .icon {
  757. margin-right:20rpx;
  758. width: 40rpx;
  759. height: 38rpx;
  760. }
  761. .progress {
  762. flex:1;
  763. }
  764. .submit {
  765. width: 168rpx;
  766. height: 48rpx;
  767. line-height: 48rpx;
  768. text-align: center;
  769. color:#fff;
  770. font-size: 30rpx;
  771. background: #007AFF;
  772. border-radius: 24rpx;
  773. }
  774. }
  775. .textarea {
  776. textarea {
  777. width:100%;
  778. height:287rpx;
  779. padding:10rpx;
  780. }
  781. }
  782. .imgs {
  783. overflow: hidden;
  784. display: flex;
  785. width:100%;
  786. .img {
  787. width: 104rpx;
  788. height: 104rpx;
  789. border-radius: 8rpx;
  790. position:relative;
  791. margin:20rpx;
  792. text {
  793. position:absolute;
  794. right:-15rpx;
  795. top:-15rpx;
  796. width:30rpx;
  797. height:30rpx;
  798. text-align: center;
  799. line-height: 30rpx;
  800. color:#fff;
  801. background:red;
  802. border-radius:50%;
  803. }
  804. image {
  805. width:100%;
  806. height:100%;
  807. }
  808. }
  809. }
  810. }
  811. .ans_submit {
  812. padding:16rpx;
  813. border-radius: 16rpx;
  814. background:#fff;
  815. .imgs {
  816. overflow: hidden;
  817. display: flex;
  818. width:100%;
  819. .img {
  820. width: 104rpx;
  821. height: 104rpx;
  822. border-radius: 8rpx;
  823. position:relative;
  824. margin:20rpx;
  825. image {
  826. width:100%;
  827. height:100%;
  828. }
  829. }
  830. }
  831. }
  832. }
  833. .firstLetter {
  834. display: flex;
  835. justify-content: space-between;
  836. align-items: center;
  837. margin-bottom: 30rpx;
  838. .leftLetters {
  839. display: flex;
  840. align-items: center;
  841. width: 220rpx;
  842. .btnType {
  843. padding: 5rpx 10rpx;
  844. border: 1rpx solid #007aff;
  845. border-radius: 10rpx;
  846. background-color: rgba(0, 122, 255, 0.1);
  847. font-size: 28rpx;
  848. color: #007aff;
  849. margin-right: 15rpx;
  850. }
  851. }
  852. }
  853. .popupView {
  854. height: 100%;
  855. padding-bottom: 100rpx;
  856. .popupTops {
  857. height: 77rpx;
  858. border-bottom: 1rpx solid #eee;
  859. text-align: center;
  860. line-height: 77rpx;
  861. font-size: 24rpx;
  862. color: #999;
  863. position: relative;
  864. .topIcon {
  865. position: absolute;
  866. top: 10rpx;
  867. left: 50%;
  868. transform: translateX(-50%);
  869. width: 80rpx;
  870. height: 8rpx;
  871. background-color: #999;
  872. border-radius: 4rpx;
  873. }
  874. }
  875. .popupContent {
  876. }
  877. }
  878. .pageContent {
  879. background-color: #eaeef1;
  880. min-height: 100vh;
  881. padding-top: 8rpx;
  882. padding-bottom: 100rpx;
  883. }
  884. .pad_8 {
  885. background-color: #fff;
  886. margin: 0rpx 8rpx 8rpx;
  887. border-radius: 16rpx;
  888. }
  889. .answer {
  890. height: 80rpx;
  891. line-height: 80rpx;
  892. padding: 0rpx 24rpx;
  893. display: flex;
  894. align-items: center;
  895. justify-content: space-between;
  896. color: #666;
  897. font-size: 30rpx;
  898. }
  899. .footer_btn {
  900. background-color: #fff;
  901. z-index: 10078;
  902. position: fixed;
  903. bottom: 0rpx;
  904. display: flex;
  905. align-items: center;
  906. justify-content: space-between;
  907. width: 100%;
  908. height: 98rpx;
  909. padding: 0rpx 38rpx;
  910. border-top: 1rpx solid #eee;
  911. }
  912. .boxSty {
  913. padding: 44rpx 41rpx 0rpx;
  914. }
  915. .liListSty {
  916. border:1rpx solid #EEEEEE;
  917. width: 88rpx;
  918. height: 88rpx;
  919. border-radius: 32rpx;
  920. text-align: center;
  921. line-height: 88rpx;
  922. color: #333;
  923. font-size: 32rpx;
  924. float: left;
  925. margin: 20rpx 23rpx;
  926. &.isRight {
  927. border:1rpx solid #EEEEEE;
  928. color:#fff;
  929. background: green;
  930. }
  931. &.isWrong {
  932. border:1rpx solid #EEEEEE;
  933. color:#fff;
  934. background: red;
  935. }
  936. }
  937. .answerInfos {
  938. padding: 25rpx 25rpx 25rpx 23rpx;
  939. }
  940. .answerTitle {
  941. margin-bottom: 28rpx;
  942. color: #666;
  943. font-size: 30rpx;
  944. }
  945. .answerContent {
  946. font-size: 30rpx;
  947. color: #666;
  948. }
  949. .textChild {
  950. display: inline-block;
  951. vertical-align: middle;
  952. }
  953. .dialog {
  954. position: fixed;
  955. left:0;
  956. top:0;
  957. width:100%;
  958. height:100%;
  959. background-color: rgba(0,0,0,0.8);
  960. display: flex;
  961. flex-direction: column;
  962. align-items: center;
  963. justify-content: center;
  964. z-index: 20000;
  965. .text {
  966. font-size: 32rpx;
  967. color: #FFFFFF;
  968. text-align: center;
  969. }
  970. .btn {
  971. width: 242rpx;
  972. height: 82rpx;
  973. border: 2rpx solid #FFFFFF;
  974. border-radius: 16rpx;
  975. text-align: center;
  976. line-height: 82rpx;
  977. margin:41rpx auto;
  978. color:#fff;
  979. font-size: 32rpx;
  980. }
  981. }
  982. </style>