questionBankTest.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  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. <view class="flex_auto">{{ item.content }}</view>
  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. <view class="flex_auto">{{ item.content }}</view>
  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. <view class="flex_auto">{{ item.content }}</view>
  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. <view class="flex_auto">{{ item.content }}</view>
  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. return;
  508. },
  509. click(e) {
  510. if(this.ques[this.current]) return;
  511. let value = e.currentTarget.dataset.value;
  512. this.ques[this.current] = value;
  513. this.ques = Object.assign({},this.ques)
  514. },
  515. deleteImg(e) {
  516. var imgIndex = e.currentTarget.dataset.imgindex;
  517. var bankIndex = e.currentTarget.dataset.bankindex;
  518. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  519. },
  520. deleteImgChild(e) {
  521. var imgIndex = e.currentTarget.dataset.imgindex;
  522. var bankIndex = e.currentTarget.dataset.bankindex;
  523. var ansIndex = e.currentTarget.dataset.ansindex;
  524. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  525. },
  526. chooseImg(e) {
  527. console.log(e.currentTarget.dataset)
  528. let bankindex = e.currentTarget.dataset.bindex;
  529. uni.chooseImage({
  530. count: 1, //默认9
  531. sizeType: ['original', ], //可以指定是原图还是压缩图,默认二者都有
  532. sourceType: ['album','camera'], //从相册选择
  533. success: (res) => {
  534. // console.log(JSON.stringify(res.tempFilePaths));
  535. this.questionList[bankindex].ansText.imageList.push(res.tempFilePaths)
  536. }
  537. })
  538. },
  539. chooseImgChild(e) {
  540. let bankindex = e.currentTarget.dataset.bindex;
  541. let ansindex = e.currentTarget.dataset.ansindex;
  542. uni.chooseImage({
  543. count: 1, //默认9
  544. sizeType: ['original', ], //可以指定是原图还是压缩图,默认二者都有
  545. sourceType: ['album','camera'], //从相册选择
  546. success: (res) => {
  547. // console.log(JSON.stringify(res.tempFilePaths));
  548. console.log(this.questionList[bankindex].jsonStr[ansindex])
  549. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(res.tempFilePaths)
  550. }
  551. })
  552. },
  553. submitAns(e) {
  554. let type = e.currentTarget.dataset.type;
  555. let bankindex = e.currentTarget.dataset.bindex;
  556. console.log(this.questionList[bankindex])
  557. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  558. uni.showToast({
  559. title: '请输入内容或上传图片',
  560. duration: 2000,
  561. icon:'none'
  562. });
  563. return
  564. }
  565. this.$set(this.ques,bankindex,{
  566. imageList:this.questionList[bankindex].ansText.imageList,
  567. text:this.questionList[bankindex].ansText.text,
  568. })
  569. },
  570. submitAnsChild(e) {
  571. let type = e.currentTarget.dataset.type;
  572. let bankindex = e.currentTarget.dataset.bindex;
  573. let ansindex = e.currentTarget.dataset.ansindex;
  574. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  575. uni.showToast({
  576. title: '请输入内容或上传图片',
  577. duration: 2000,
  578. icon:'none'
  579. });
  580. return
  581. }
  582. this.$set(this.ques[bankindex],ansindex,{
  583. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  584. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  585. })
  586. },
  587. isRight(item,index) {
  588. //单选
  589. if(this.ques[index]) {
  590. if(item.type == 1) {
  591. return this.ques[index] == this.ans[index];
  592. //多选
  593. } else if(item.type == 2) {
  594. //每一项都相等
  595. return this.ques.every((item,index) => {
  596. return item == this.ans[index];
  597. })
  598. //判断
  599. } else if(item.type == 3) {
  600. return this.ques[index] == this.ans[index];
  601. } else {
  602. return false;
  603. }
  604. } else {
  605. return false;
  606. }
  607. },
  608. right(bankIndex,ansIndex,option) {
  609. console.log(this.ques[bankIndex][ansIndex] || this.ans[bankIndex][ansIndex] )
  610. if(this.ques[bankIndex][ansIndex] && this.ans[bankIndex][ansIndex]) {
  611. if((this.ques[bankIndex][ansIndex].indexOf(option.optionsId) != -1 ) || (this.ans[bankIndex][ansIndex].indexOf(option.optionsId) != -1)) {
  612. return true
  613. } else {
  614. return false;
  615. }
  616. } else {
  617. return false;
  618. }
  619. },
  620. wrong(bankIndex,ansIndex,option) {
  621. console.log(this.ques[bankIndex][ansIndex] || this.ans[bankIndex][ansIndex] )
  622. if(this.ques[bankIndex][ansIndex] && this.ans[bankIndex][ansIndex]) {
  623. if((this.ques[bankIndex][ansIndex].indexOf(option.optionsId) != -1 ) && (this.ans[bankIndex][ansIndex].indexOf(option.optionsId) == -1)) {
  624. return true;
  625. } else {
  626. return false;
  627. }
  628. } else {
  629. return false;
  630. }
  631. },
  632. isWrong(item,index) {
  633. if(this.ques[index]) {
  634. //单选
  635. if(item.type == 1) {
  636. return this.ques[index] != this.ans[index];
  637. //多选
  638. } else if(item.type == 2) {
  639. //每一项都相等
  640. return this.ques.some((item,index) => {
  641. return item != this.ans[index];
  642. })
  643. //判断
  644. } else if(item.type == 3) {
  645. return this.ques[index] != this.ans[index];
  646. } else {
  647. return false;
  648. }
  649. } else {
  650. return false;
  651. }
  652. },
  653. tabSelect(e) {
  654. let index = e.currentTarget.dataset.index;
  655. let bankindex = e.currentTarget.dataset.bindex;
  656. this.$set(this.questionList[bankindex],'current',index)
  657. console.log(this.questionList[bankindex])
  658. }
  659. }
  660. };
  661. </script>
  662. <style lang="scss" scoped>
  663. .swiper {
  664. width:100%;
  665. height:100vh;
  666. }
  667. .lisSty {
  668. margin-bottom: 16rpx;
  669. display: flex;
  670. .flex_auto {
  671. flex:1;
  672. }
  673. }
  674. .activeTI {
  675. vertical-align: middle;
  676. display: inline-block;
  677. border: 1rpx solid #eee;
  678. border-radius: 50rpx;
  679. height: 48rpx;
  680. line-height: 46rpx;
  681. text-align: center;
  682. width: 48rpx;
  683. margin-right: 15rpx;
  684. color: #666;
  685. font-size: 30rpx;
  686. &.right {
  687. color:#fff;
  688. background:green;
  689. }
  690. &.wrong {
  691. color:#fff;
  692. background:red;
  693. }
  694. &.checked {
  695. color:#fff;
  696. background:blue;
  697. }
  698. }
  699. .submit_checkbox {
  700. margin:20rpx auto;
  701. width: 526rpx;
  702. height: 80rpx;
  703. background: rgba(0, 122, 255, 1);
  704. color:#fff;
  705. text-align: center;
  706. line-height: 80rpx;
  707. font-size: 30rpx;
  708. border-radius: 40rpx;
  709. }
  710. .titles {
  711. overflow: hidden;
  712. margin-bottom: 24rpx;
  713. }
  714. .titBox {
  715. padding: 41rpx 25rpx 24rpx 25rpx;
  716. }
  717. .tabs {
  718. margin:10rpx;
  719. display: flex;
  720. .tab {
  721. margin:0 10rpx;
  722. width: 96rpx;
  723. height: 48rpx;
  724. line-height: 48rpx;
  725. text-align: center;
  726. color:#007AFF;
  727. font-size: 28rpx;
  728. border-radius: 16rpx;
  729. &.current {
  730. color:#fff;
  731. background: #007AFF;
  732. }
  733. }
  734. }
  735. .ans {
  736. margin:8rpx 8rpx 8rpx;
  737. .ans_input {
  738. border-radius: 16rpx;
  739. background:#fff;
  740. .top {
  741. border-bottom:1rpx solid #EEEEEE;
  742. padding: 16rpx;
  743. display: flex;
  744. align-items: center;
  745. .icon {
  746. margin-right:20rpx;
  747. width: 40rpx;
  748. height: 38rpx;
  749. }
  750. .progress {
  751. flex:1;
  752. }
  753. .submit {
  754. width: 168rpx;
  755. height: 48rpx;
  756. line-height: 48rpx;
  757. text-align: center;
  758. color:#fff;
  759. font-size: 30rpx;
  760. background: #007AFF;
  761. border-radius: 24rpx;
  762. }
  763. }
  764. .textarea {
  765. textarea {
  766. width:100%;
  767. height:287rpx;
  768. padding:10rpx;
  769. }
  770. }
  771. .imgs {
  772. overflow: hidden;
  773. display: flex;
  774. width:100%;
  775. .img {
  776. width: 104rpx;
  777. height: 104rpx;
  778. border-radius: 8rpx;
  779. position:relative;
  780. margin:20rpx;
  781. text {
  782. position:absolute;
  783. right:-15rpx;
  784. top:-15rpx;
  785. width:30rpx;
  786. height:30rpx;
  787. text-align: center;
  788. line-height: 30rpx;
  789. color:#fff;
  790. background:red;
  791. border-radius:50%;
  792. }
  793. image {
  794. width:100%;
  795. height:100%;
  796. }
  797. }
  798. }
  799. }
  800. .ans_submit {
  801. padding:16rpx;
  802. border-radius: 16rpx;
  803. background:#fff;
  804. .imgs {
  805. overflow: hidden;
  806. display: flex;
  807. width:100%;
  808. .img {
  809. width: 104rpx;
  810. height: 104rpx;
  811. border-radius: 8rpx;
  812. position:relative;
  813. margin:20rpx;
  814. image {
  815. width:100%;
  816. height:100%;
  817. }
  818. }
  819. }
  820. }
  821. }
  822. .firstLetter {
  823. display: flex;
  824. justify-content: space-between;
  825. align-items: center;
  826. margin-bottom: 30rpx;
  827. .leftLetters {
  828. display: flex;
  829. align-items: center;
  830. width: 220rpx;
  831. .btnType {
  832. padding: 5rpx 10rpx;
  833. border: 1rpx solid #007aff;
  834. border-radius: 10rpx;
  835. background-color: rgba(0, 122, 255, 0.1);
  836. font-size: 28rpx;
  837. color: #007aff;
  838. margin-right: 15rpx;
  839. }
  840. }
  841. }
  842. .popupView {
  843. height: 100%;
  844. padding-bottom: 100rpx;
  845. .popupTops {
  846. height: 77rpx;
  847. border-bottom: 1rpx solid #eee;
  848. text-align: center;
  849. line-height: 77rpx;
  850. font-size: 24rpx;
  851. color: #999;
  852. position: relative;
  853. .topIcon {
  854. position: absolute;
  855. top: 10rpx;
  856. left: 50%;
  857. transform: translateX(-50%);
  858. width: 80rpx;
  859. height: 8rpx;
  860. background-color: #999;
  861. border-radius: 4rpx;
  862. }
  863. }
  864. .popupContent {
  865. }
  866. }
  867. .pageContent {
  868. background-color: #eaeef1;
  869. min-height: 100vh;
  870. padding-top: 8rpx;
  871. padding-bottom: 100rpx;
  872. }
  873. .pad_8 {
  874. background-color: #fff;
  875. margin: 0rpx 8rpx 8rpx;
  876. border-radius: 16rpx;
  877. }
  878. .answer {
  879. height: 80rpx;
  880. line-height: 80rpx;
  881. padding: 0rpx 24rpx;
  882. display: flex;
  883. align-items: center;
  884. justify-content: space-between;
  885. color: #666;
  886. font-size: 30rpx;
  887. }
  888. .footer_btn {
  889. background-color: #fff;
  890. z-index: 10078;
  891. position: fixed;
  892. bottom: 0rpx;
  893. display: flex;
  894. align-items: center;
  895. justify-content: space-between;
  896. width: 100%;
  897. height: 98rpx;
  898. padding: 0rpx 38rpx;
  899. border-top: 1rpx solid #eee;
  900. }
  901. .boxSty {
  902. padding: 44rpx 41rpx 0rpx;
  903. }
  904. .liListSty {
  905. border:1rpx solid #EEEEEE;
  906. width: 88rpx;
  907. height: 88rpx;
  908. border-radius: 32rpx;
  909. text-align: center;
  910. line-height: 88rpx;
  911. color: #333;
  912. font-size: 32rpx;
  913. float: left;
  914. margin: 20rpx 23rpx;
  915. &.isRight {
  916. border:1rpx solid #EEEEEE;
  917. color:#fff;
  918. background: green;
  919. }
  920. &.isWrong {
  921. border:1rpx solid #EEEEEE;
  922. color:#fff;
  923. background: red;
  924. }
  925. }
  926. .answerInfos {
  927. padding: 25rpx 25rpx 25rpx 23rpx;
  928. }
  929. .answerTitle {
  930. margin-bottom: 28rpx;
  931. color: #666;
  932. font-size: 30rpx;
  933. }
  934. .answerContent {
  935. font-size: 30rpx;
  936. color: #666;
  937. }
  938. .textChild {
  939. display: inline-block;
  940. vertical-align: middle;
  941. }
  942. .dialog {
  943. position: fixed;
  944. left:0;
  945. top:0;
  946. width:100%;
  947. height:100%;
  948. background-color: rgba(0,0,0,0.8);
  949. display: flex;
  950. flex-direction: column;
  951. align-items: center;
  952. justify-content: center;
  953. z-index: 20000;
  954. .text {
  955. font-size: 32rpx;
  956. color: #FFFFFF;
  957. text-align: center;
  958. }
  959. .btn {
  960. width: 242rpx;
  961. height: 82rpx;
  962. border: 2rpx solid #FFFFFF;
  963. border-radius: 16rpx;
  964. text-align: center;
  965. line-height: 82rpx;
  966. margin:41rpx auto;
  967. color:#fff;
  968. font-size: 32rpx;
  969. }
  970. }
  971. </style>