wrongTypeBank.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267
  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>{{bankIndex+1}}/{{questionList.length}}</text>
  17. </view>
  18. <view style="color: #666;font-size: 28rpx;"></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="!bank.ques">
  28. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="radioSelect(item.optionsId,bankIndex)">
  29. <view class="activeTI">{{ ast[index] }}</view>
  30. <view class="flex_auto">{{ item.content }}</view>
  31. </view>
  32. </view>
  33. <view v-if="bank.ques">
  34. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  35. <text :class="{right:(item.optionsId == bank.ques) || (item.optionsId == bank.ans),wrong:(item.optionsId == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  36. <view class="flex_auto">{{ item.content }}</view>
  37. </view>
  38. </view>
  39. <view v-if="bank.ques">
  40. <view class="pad_8 answer">
  41. <view>正确答案:{{ast[bank.ans-1]}}</view>
  42. <view v-if="!explain">我的答案:{{ast[bank.ques-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="!bank.ques">
  54. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId,bankIndex,index)">
  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="!bank.ques" class="submit_checkbox" @click="checkboxSubmit(bankIndex)">
  60. 确认答案
  61. </view>
  62. <view v-if="bank.ques">
  63. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  64. <text :class="{right:(bank.ques.indexOf(item.optionsId) != -1 ) || (bank.ans.indexOf(item.optionsId) != -1),wrong:(bank.ques.indexOf(item.optionsId) != -1 ) && (bank.ans.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="bank.ques">
  69. <view class="pad_8 answer">
  70. <view>正确答案:
  71. <text v-for="ansItem in bank.ans">{{ast[ansItem-1]}}</text>
  72. </view>
  73. <view v-if="!explain">我的答案:
  74. <text v-for="quesItem in bank.ques">{{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="!bank.ques">
  87. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index,bankIndex)">
  88. <view class="activeTI">{{ ast[index] }}</view>
  89. {{ item }}
  90. </view>
  91. </view>
  92. <view v-if="bank.ques">
  93. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  94. <text :class="{right:(index == bank.ques) || (index == bank.ans),wrong:(index == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  95. {{ item }}
  96. </view>
  97. </view>
  98. <view v-if="bank.ques">
  99. <view class="pad_8 answer">
  100. <view>正确答案:{{ast[bank.ans]}}</view>
  101. <view v-if="!explain">我的答案:{{ast[bank.ques]}}</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="!bank.ques">
  115. <view class="top flex">
  116. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/08-10_032.jpg" mode=""></image>
  117. <view class="progress">{{bank.ansText.imageList.length || '0'}}/4</view>
  118. <view class="submit" @click="submitAns(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" :key="imgIndex">
  125. <text @click="deleteImg(imgIndex,bankIndex)">x</text>
  126. <image :src="$method.splitImgHost(img, true)"></image>
  127. </view>
  128. </view>
  129. </view>
  130. <view class="ans_submit answerInfos" v-if="bank.ques && !explain">
  131. <view class="answerTitle">我的答案:</view>
  132. {{bank.ques.text}}
  133. <view class="imgs">
  134. <image class="img" :key="quesIndex" v-for="(ques,quesIndex) in bank.ques.imageList" :src="$method.splitImgHost(ques,true)"></image>
  135. </view>
  136. </view>
  137. </view>
  138. <view v-if="bank.ques">
  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}" :key="tabIndex" v-for="(tab,tabIndex) in bank.jsonStr" @click="tabSelect(tabIndex,bankIndex)">问题{{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="ansItem.content"></rich-text>
  155. </view>
  156. <template v-if="ansItem.type == 1">
  157. <view v-if="!bank.ques[ansIndex]">
  158. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty" @click="radioSelectChild(option.optionsId,ansIndex,bankIndex)">
  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="bank.ques[ansIndex]">
  164. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty">
  165. <text :class="{right:(option.optionsId == bank.ques[ansIndex]) || (option.optionsId == bank.ans[ansIndex]),wrong:(option.optionsId == bank.ques[ansIndex]) && (bank.ques[ansIndex] != bank.ans[ansIndex])}" class="activeTI">{{ ast[childIndex] }}</text>
  166. <rich-text :nodes="option.content"></rich-text>
  167. </view>
  168. </view>
  169. <view v-if="bank.ques[ansIndex]">
  170. <view class="pad_8 answer">
  171. <view>正确答案:{{ast[bank.ans[ansIndex]-1]}}</view>
  172. <view v-if="!explain">我的答案:{{ast[bank.ques[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="!bank.ques[ansIndex]">
  184. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty" @click="checkboxSelectChild(bankIndex,ansIndex,childindex)">
  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="!bank.ques[ansIndex]" class="submit_checkbox" @click="checkboxSubmitChild(bankIndex,ansIndex)">
  190. 确认答案
  191. </view>
  192. <view v-if="bank.ques && bank.ques[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="bank.ques[ansIndex]">
  199. <view class="pad_8 answer">
  200. <view>正确答案:
  201. <text :key="ansItemIndex1" v-for="(ansItem1,ansItemIndex1) in bank.ans[ansIndex]">{{ast[ansItem1-1]}}</text>
  202. </view>
  203. <view v-if="!explain">我的答案:
  204. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) in bank.ques[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="!bank.ques[ansIndex]">
  217. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex,childindex,bankIndex)">
  218. <view class="activeTI">{{ ast[childindex] }}</view>
  219. {{ option }}
  220. </view>
  221. </view>
  222. <view v-if="bank.ques[ansIndex]">
  223. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  224. <text :class="{right:(childindex == bank.ques[ansIndex]) || (childindex == bank.ans[ansIndex]),wrong:(childindex == bank.ques[ansIndex]) && (bank.ques[ansIndex] != bank.ans[ansIndex])}" class="activeTI">{{ ast[childindex] }}</text>
  225. {{ option }}
  226. </view>
  227. </view>
  228. <view v-if="bank.ques[ansIndex]">
  229. <view class="pad_8 answer">
  230. <view>正确答案:{{ast[bank.ans[ansIndex]]}}</view>
  231. <view v-if="!explain">我的答案:{{ast[bank.ques[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="!bank.ques[ansIndex]">
  245. <view class="top flex">
  246. <image class="icon" @click="chooseImgChild(bankIndex,ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  247. <view class="progress">{{ansItem.ansText.imageList.length || '0'}}/4</view>
  248. <view class="submit" @click="submitAnsChild(bankIndex,ansIndex)">确认答案</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" :key="imgIndex">
  255. <text @click="deleteImgChild(imgIndex,bankIndex,ansIndex)">x</text>
  256. <image :src="$method.splitImgHost(img, true)"></image>
  257. </view>
  258. </view>
  259. </view>
  260. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex] && !explain">
  261. <view class="answerTitle">我的答案</view>
  262. {{bank.ques[ansIndex].text}}
  263. <view class="imgs">
  264. <image class="img" :key="quesIndex" v-for="(ques,quesIndex) in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques,true)"></image>
  265. </view>
  266. </view>
  267. </view>
  268. <view v-if="bank.ques[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 class="footer_btn">
  281. <view class="flex_center" @click="openFooterTab">
  282. <view class="up-icon">
  283. <image src="/static/up.png"></image>
  284. </view>
  285. 答题卡
  286. </view>
  287. <view class="collect" :class="{show:!explain}" @click="pdsubmit">
  288. <view>
  289. <image src="/static/jj.png" mode=""></image>
  290. <view>交卷</view>
  291. </view>
  292. </view>
  293. </view>
  294. </view>
  295. </swiper-item>
  296. </swiper>
  297. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  298. <view class="popupView">
  299. <view class="popupTops">
  300. <view class="topIcon"></view>
  301. 点击编号即可跳转至对应题目
  302. </view>
  303. <view class="popupContent">
  304. <scroll-view scroll-y="true" style="height: 506rpx;">
  305. <view class="boxSty">
  306. <view v-for="(item, index) in questionList" :key="index" @click="changeIndex(index)" :class="{isRight:isRight(item,index),isWrong:isWrong(item,index)}" class="liListSty">{{ index + 1 }}</view>
  307. </view>
  308. </scroll-view>
  309. </view>
  310. </view>
  311. </u-popup>
  312. <view class="dialog" v-if="showDialog">
  313. <image class="pointer" src="/static/pointer.png"></image>
  314. <view class="text">左右滑动切换上下题</view>
  315. <view class="btn" @click="hideDialog">我知道了</view>
  316. </view>
  317. </view>
  318. </template>
  319. <script>
  320. export default {
  321. data() {
  322. return {
  323. current:0,
  324. questionList:[],
  325. ast: ['A', 'B', 'C', 'D','E','F','G'],
  326. judge:['错误','正确'],
  327. show: false,
  328. showDialog:false,
  329. bankList: [],
  330. collectList:[],
  331. type:'',
  332. explain:''
  333. };
  334. },
  335. onLoad(option){
  336. this.type = option.type;
  337. this.explain = option.explain;
  338. let showDialog = uni.getStorageSync('showDialog');
  339. if(showDialog) {
  340. this.showDialog = false;
  341. } else {
  342. this.showDialog = true;
  343. uni.setStorageSync('showDialog','1');
  344. }
  345. this.wrongRecordTypeQuestionList();
  346. },
  347. onUnload() {
  348. },
  349. methods: {
  350. wrongRecordTypeQuestionList() {
  351. this.$api.wrongRecordTypeQuestionList({
  352. type:this.type
  353. }).then(res => {
  354. res.data.rows.forEach((item,index) => {
  355. if(typeof item.jsonStr == 'string') {
  356. item.jsonStr = JSON.parse(item.jsonStr)
  357. if(item.type == 2) { //多选
  358. item.jsonStr.forEach(str => {
  359. str.optionsId = ''+str.optionsId;
  360. })
  361. let arr = item.answerQuestion.split(',');
  362. arr.forEach((a,i) => {
  363. arr[i] = ''+a;
  364. })
  365. item.ans = arr;
  366. if(this.explain) {
  367. item.ques = item.ans;
  368. }
  369. return;
  370. } else if(item.type == 5) {
  371. item.ansText = {
  372. text: '',
  373. imageList: []
  374. }
  375. if(this.explain) {
  376. item.ques = {
  377. text:item.analysisContent
  378. }
  379. return;
  380. }
  381. } else if(item.type == 4) {
  382. console.log(item.jsonStr)
  383. item.ques = []
  384. item.current = 0;
  385. let ansArr = [];
  386. item.jsonStr.forEach((json,index) => {
  387. if(json.type == 1) {
  388. ansArr[index] = json.answerQuestion;
  389. } else if(json.type == 2) {
  390. json.optionsList.forEach(str => {
  391. str.optionsId = ''+str.optionsId;
  392. })
  393. let arr = json.answerQuestion.split(',');
  394. arr.forEach((a,i) => {
  395. arr[i] = ''+a;
  396. })
  397. ansArr[index] = arr
  398. } else if(json.type == 3) {
  399. ansArr[index] = json.answerQuestion;
  400. } else if(json.type == 5) {
  401. ansArr[index] = {
  402. text: '',
  403. imageList: []
  404. }
  405. json.ansText = {
  406. text: '',
  407. imageList: []
  408. }
  409. }
  410. })
  411. item.ans = ansArr
  412. if(this.explain) {
  413. item.ques = item.ans;
  414. }
  415. return;
  416. }
  417. item.ans = item.answerQuestion
  418. if(this.explain) {
  419. item.ques = item.ans;
  420. }
  421. } else {
  422. if(this.explain) {
  423. item.ques = item.ans;
  424. }
  425. }
  426. })
  427. this.questionList = res.data.rows;
  428. })
  429. },
  430. /**
  431. * @param {Object} e单选点击
  432. */
  433. radioSelect(optionsId,bindex) {
  434. if(this.questionList[bindex].ques) return;
  435. this.$set(this.questionList[bindex],'ques',optionsId)
  436. // 回答错误
  437. if(this.questionList[bindex].ques != this.questionList[bindex].ans) {
  438. } else {
  439. this.$api.wrongRecordDelete({
  440. "examId": this.questionList[bindex].examId,
  441. "goodsId": this.questionList[bindex].goodsId,
  442. "questionId": this.questionList[bindex].questionId,
  443. }).then(res => {
  444. })
  445. }
  446. },
  447. /**
  448. * @param {Object} e单选点击
  449. */
  450. radioSelectChild(optionsId,ansIndex,bindex) {
  451. if(this.questionList[bindex].ques[ansIndex]) return;
  452. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  453. },
  454. /**
  455. * @param {Object} 多选点击
  456. */
  457. checkboxSelect(optionsId,bindex,index) {
  458. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  459. },
  460. /**
  461. * @param {Object} 多选点击
  462. */
  463. checkboxSelectChild(bindex,ansIndex,childIndex) {
  464. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  465. },
  466. /**
  467. * @param {Object} 多选确认
  468. */
  469. checkboxSubmit(bindex) {
  470. if(this.questionList[bindex].ques) return;
  471. let arr = [];
  472. this.questionList[bindex].jsonStr.forEach(item => {
  473. if(item.checked) {
  474. arr.push(item.optionsId)
  475. }
  476. })
  477. this.$set(this.questionList[bindex],'ques',arr)
  478. let isWrong = this.questionList[bindex].ques.some((quesItem,quesIndex) => {
  479. return this.questionList[bindex].ques[quesIndex] != this.questionList[bindex].ans[quesIndex]
  480. })
  481. // 回答错误
  482. if(isWrong) {
  483. } else {
  484. let question = this.questionList.find(item => item.questionId == this.questionList[bindex].questionId);
  485. if(question) {
  486. this.$api.wrongRecordDelete({
  487. "examId": question.examId,
  488. "goodsId": question.goodsId,
  489. "questionId": question.questionId,
  490. }).then(res => {
  491. })
  492. }
  493. }
  494. },
  495. /**
  496. * @param {Object} 多选确认
  497. */
  498. checkboxSubmitChild(bindex,ansIndex) {
  499. if(this.questionList[bindex].ques[ansIndex]) return;
  500. let arr = [];
  501. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  502. if(item.checked) {
  503. arr.push(item.optionsId)
  504. }
  505. })
  506. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  507. },
  508. judgeSelect(index,bindex) {
  509. if(this.questionList[bindex].ques) return;
  510. this.$set(this.questionList[bindex],'ques',index+'')
  511. // 回答错误
  512. if(this.questionList[bindex].ques != this.questionList[bindex].ans) {
  513. } else {
  514. this.$api.wrongRecordDelete({
  515. "examId": this.questionList[bindex].examId,
  516. "goodsId": this.questionList[bindex].goodsId,
  517. "questionId": this.questionList[bindex].questionId,
  518. }).then(res => {
  519. })
  520. }
  521. },
  522. judgeSelectChild(ansindex,childindex,bindex) {
  523. if(this.questionList[bindex].ques[ansindex]) return;
  524. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  525. },
  526. openFooterTab() {
  527. this.show = true;
  528. },
  529. hideDialog() {
  530. this.showDialog = false
  531. },
  532. changeIndex(index) {
  533. this.current = index
  534. },
  535. swiperChange(e) {
  536. this.current = e.detail.current;
  537. },
  538. deleteImg(imgIndex,bankIndex) {
  539. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  540. },
  541. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  542. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  543. },
  544. chooseImg(bankindex) {
  545. uni.chooseImage({
  546. count: 1, //默认9
  547. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  548. sourceType: ['album','camera'], //从相册选择
  549. success: (res) => {
  550. let self = this;
  551. // console.log(JSON.stringify(res.tempFilePaths));
  552. let img = res.tempFilePaths[0];
  553. uni.getImageInfo({
  554. src: img,
  555. success: async res => {
  556. let canvasWidth = res.width; //图片原始长宽
  557. let canvasHeight = res.height;
  558. if (canvasWidth > 1000 || canvasHeight > 1000) {
  559. uni.compressImage({
  560. src: img,
  561. quality: 75,
  562. width: '50%',
  563. height: '50%',
  564. success: async rest => {
  565. const dir = await self.uploadFile(rest.tempFilePath, 0);
  566. this.questionList[bankindex].ansText.imageList.push(dir)
  567. }
  568. });
  569. } else {
  570. const dir = await self.uploadFile(img, 0);
  571. this.questionList[bankindex].ansText.imageList.push(dir)
  572. }
  573. }
  574. });
  575. }
  576. })
  577. },
  578. chooseImgChild(bankindex,ansindex) {
  579. uni.chooseImage({
  580. count: 1, //默认9
  581. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  582. sourceType: ['album','camera'], //从相册选择
  583. success: (res) => {
  584. let self = this;
  585. // console.log(JSON.stringify(res.tempFilePaths));
  586. let img = res.tempFilePaths[0];
  587. uni.getImageInfo({
  588. src: img,
  589. success: async res => {
  590. let canvasWidth = res.width; //图片原始长宽
  591. let canvasHeight = res.height;
  592. if (canvasWidth > 1000 || canvasHeight > 1000) {
  593. uni.compressImage({
  594. src: img,
  595. quality: 75,
  596. width: '50%',
  597. height: '50%',
  598. success: async rest => {
  599. const dir = await self.uploadFile(rest.tempFilePath, 0);
  600. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  601. }
  602. });
  603. } else {
  604. const dir = await self.uploadFile(img, 0);
  605. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  606. }
  607. }
  608. });
  609. }
  610. })
  611. },
  612. uploadFile(options, int) {
  613. var self = this;
  614. return new Promise((resolve, reject) => {
  615. var data = {
  616. imageStatus: int
  617. };
  618. self.$api.aliyunpolicy(data).then(res => {
  619. console.log(res.data,6)
  620. if(res.data.code!=200){
  621. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  622. return
  623. }
  624. var ossToken = res.data.data.resultContent;
  625. if(ossToken.host==null||ossToken.host==undefined){
  626. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  627. return
  628. }
  629. uni.uploadFile({
  630. url: ossToken.host,
  631. name: 'file',
  632. filePath: options,
  633. fileType: 'image',
  634. header: {
  635. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  636. },
  637. formData: {
  638. key: ossToken.dir,
  639. OSSAccessKeyId: ossToken.accessid,
  640. policy: ossToken.policy,
  641. Signature: ossToken.signature,
  642. callback: ossToken.callback,
  643. success_action_status: 200
  644. },
  645. success: result => {
  646. if (result.statusCode === 200) {
  647. resolve(ossToken.dir);
  648. } else {
  649. uni.showToast({
  650. title: '上传失败',
  651. icon: 'none'
  652. });
  653. return;
  654. }
  655. },
  656. fail: error => {
  657. uni.showToast({
  658. title: '上传接口报错'+error,
  659. icon: 'none'
  660. });
  661. return;
  662. }
  663. });
  664. });
  665. });
  666. },
  667. submitAns(bankindex) {
  668. console.log(this.questionList[bankindex])
  669. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  670. uni.showToast({
  671. title: '请输入内容或上传图片',
  672. duration: 2000,
  673. icon:'none'
  674. });
  675. return
  676. }
  677. this.$set(this.questionList[bankindex],'ques',{
  678. imageList:this.questionList[bankindex].ansText.imageList,
  679. text:this.questionList[bankindex].ansText.text,
  680. })
  681. },
  682. submitAnsChild(bankindex,ansindex) {
  683. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  684. uni.showToast({
  685. title: '请输入内容或上传图片',
  686. duration: 2000,
  687. icon:'none'
  688. });
  689. return
  690. }
  691. this.$set(this.questionList[bankindex].ques,ansindex,{
  692. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  693. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  694. })
  695. },
  696. isRight(item,index) {
  697. //单选
  698. if(this.questionList[index].ques) {
  699. if(item.type == 1) {
  700. return this.questionList[index].ques == this.questionList[index].ans;
  701. //多选
  702. } else if(item.type == 2) {
  703. //每一项都相等
  704. return this.questionList[index].ques.every((item,i) => {
  705. return item == this.questionList[index].ans[i];
  706. })
  707. //判断
  708. } else if(item.type == 3) {
  709. return this.questionList[index].ques == this.questionList[index].ans;
  710. } else {
  711. return false;
  712. }
  713. } else {
  714. return false;
  715. }
  716. },
  717. right(bankIndex,ansIndex,option) {
  718. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  719. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  720. return true
  721. } else {
  722. return false;
  723. }
  724. } else {
  725. return false;
  726. }
  727. },
  728. wrong(bankIndex,ansIndex,option) {
  729. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  730. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  731. return true;
  732. } else {
  733. return false;
  734. }
  735. } else {
  736. return false;
  737. }
  738. },
  739. isWrong(item,index) {
  740. if(this.questionList[index].ques) {
  741. //单选
  742. if(item.type == 1) {
  743. return this.questionList[index].ques != this.questionList[index].ans;
  744. //多选
  745. } else if(item.type == 2) {
  746. //每一项都相等
  747. return this.questionList[index].ques.some((item,index) => {
  748. return item != this.questionList[index].ans;
  749. })
  750. //判断
  751. } else if(item.type == 3) {
  752. return this.questionList[index].ques != this.questionList[index].ans;
  753. } else {
  754. return false;
  755. }
  756. } else {
  757. return false;
  758. }
  759. },
  760. tabSelect(index,bankindex) {
  761. this.$set(this.questionList[bankindex],'current',index)
  762. },
  763. pdsubmit() {
  764. uni.showToast({
  765. icon:'none',
  766. title:'交卷成功',
  767. duration:1000,
  768. })
  769. setTimeout(() => {
  770. uni.navigateBack({
  771. delta:1
  772. })
  773. },1000)
  774. }
  775. }
  776. };
  777. </script>
  778. <style lang="scss" scoped>
  779. .swiper {
  780. width:100%;
  781. height:100vh;
  782. }
  783. .lisSty {
  784. margin-bottom: 16rpx;
  785. display: flex;
  786. .flex_auto {
  787. flex:1;
  788. }
  789. }
  790. .activeTI {
  791. vertical-align: middle;
  792. display: inline-block;
  793. border: 1rpx solid #eee;
  794. border-radius: 50rpx;
  795. height: 48rpx;
  796. line-height: 46rpx;
  797. text-align: center;
  798. width: 48rpx;
  799. margin-right: 15rpx;
  800. color: #666;
  801. font-size: 30rpx;
  802. &.right {
  803. color:#fff;
  804. background:green;
  805. }
  806. &.wrong {
  807. color:#fff;
  808. background:red;
  809. }
  810. &.checked {
  811. color:#fff;
  812. background:blue;
  813. }
  814. }
  815. .submit_checkbox {
  816. margin:20rpx auto;
  817. width: 526rpx;
  818. height: 80rpx;
  819. background: rgba(0, 122, 255, 1);
  820. color:#fff;
  821. text-align: center;
  822. line-height: 80rpx;
  823. font-size: 30rpx;
  824. border-radius: 40rpx;
  825. }
  826. .titles {
  827. overflow: hidden;
  828. margin-bottom: 24rpx;
  829. }
  830. .titBox {
  831. padding: 41rpx 25rpx 24rpx 25rpx;
  832. }
  833. .tabs {
  834. margin:10rpx;
  835. display: flex;
  836. .tab {
  837. margin:0 10rpx;
  838. width: 96rpx;
  839. height: 48rpx;
  840. line-height: 48rpx;
  841. text-align: center;
  842. color:#007AFF;
  843. font-size: 28rpx;
  844. border-radius: 16rpx;
  845. &.current {
  846. color:#fff;
  847. background: #007AFF;
  848. }
  849. }
  850. }
  851. .ans {
  852. margin:8rpx 8rpx 8rpx;
  853. .ans_input {
  854. border-radius: 16rpx;
  855. background:#fff;
  856. .top {
  857. border-bottom:1rpx solid #EEEEEE;
  858. padding: 16rpx;
  859. display: flex;
  860. align-items: center;
  861. .icon {
  862. margin-right:20rpx;
  863. width: 40rpx;
  864. height: 38rpx;
  865. }
  866. .progress {
  867. flex:1;
  868. }
  869. .submit {
  870. width: 168rpx;
  871. height: 48rpx;
  872. line-height: 48rpx;
  873. text-align: center;
  874. color:#fff;
  875. font-size: 30rpx;
  876. background: #007AFF;
  877. border-radius: 24rpx;
  878. }
  879. }
  880. .textarea {
  881. textarea {
  882. width:100%;
  883. height:287rpx;
  884. padding:10rpx;
  885. }
  886. }
  887. .imgs {
  888. overflow: hidden;
  889. display: flex;
  890. width:100%;
  891. .img {
  892. width: 104rpx;
  893. height: 104rpx;
  894. border-radius: 8rpx;
  895. position:relative;
  896. margin:20rpx;
  897. text {
  898. position:absolute;
  899. right:-15rpx;
  900. top:-15rpx;
  901. width:30rpx;
  902. height:30rpx;
  903. text-align: center;
  904. line-height: 30rpx;
  905. color:#fff;
  906. background:red;
  907. border-radius:50%;
  908. }
  909. image {
  910. width:100%;
  911. height:100%;
  912. }
  913. }
  914. }
  915. }
  916. .ans_submit {
  917. padding:16rpx;
  918. border-radius: 16rpx;
  919. background:#fff;
  920. .imgs {
  921. overflow: hidden;
  922. display: flex;
  923. width:100%;
  924. .img {
  925. width: 104rpx;
  926. height: 104rpx;
  927. border-radius: 8rpx;
  928. position:relative;
  929. margin:20rpx;
  930. image {
  931. width:100%;
  932. height:100%;
  933. }
  934. }
  935. }
  936. }
  937. }
  938. .firstLetter {
  939. display: flex;
  940. justify-content: space-between;
  941. align-items: center;
  942. margin-bottom: 30rpx;
  943. .leftLetters {
  944. display: flex;
  945. align-items: center;
  946. width: 220rpx;
  947. .btnType {
  948. padding: 5rpx 10rpx;
  949. border: 1rpx solid #007aff;
  950. border-radius: 10rpx;
  951. background-color: rgba(0, 122, 255, 0.1);
  952. font-size: 28rpx;
  953. color: #007aff;
  954. margin-right: 15rpx;
  955. }
  956. }
  957. }
  958. .popupView {
  959. height: 100%;
  960. padding-bottom: 100rpx;
  961. .popupTops {
  962. height: 77rpx;
  963. border-bottom: 1rpx solid #eee;
  964. text-align: center;
  965. line-height: 77rpx;
  966. font-size: 24rpx;
  967. color: #999;
  968. position: relative;
  969. .topIcon {
  970. position: absolute;
  971. top: 10rpx;
  972. left: 50%;
  973. transform: translateX(-50%);
  974. width: 80rpx;
  975. height: 8rpx;
  976. background-color: #999;
  977. border-radius: 4rpx;
  978. }
  979. }
  980. .popupContent {
  981. }
  982. }
  983. .pageContent {
  984. position:relative;
  985. background-color: #eaeef1;
  986. height: 100%;
  987. overflow-y: scroll;
  988. padding-top: 8rpx;
  989. padding-bottom: 100rpx;
  990. }
  991. .pad_8 {
  992. background-color: #fff;
  993. margin: 0rpx 8rpx 8rpx;
  994. border-radius: 16rpx;
  995. }
  996. .answer {
  997. height: 80rpx;
  998. line-height: 80rpx;
  999. padding: 0rpx 24rpx;
  1000. display: flex;
  1001. align-items: center;
  1002. justify-content: space-between;
  1003. color: #666;
  1004. font-size: 30rpx;
  1005. }
  1006. .footer_btn {
  1007. background-color: #fff;
  1008. z-index: 10078;
  1009. position: fixed;
  1010. bottom: 0rpx;
  1011. display: flex;
  1012. align-items: center;
  1013. justify-content: space-between;
  1014. width: 100%;
  1015. height: 98rpx;
  1016. padding: 0rpx 38rpx;
  1017. border-top: 1rpx solid #eee;
  1018. .flex_center {
  1019. flex:1;
  1020. display: flex;
  1021. justify-content: center;
  1022. align-items: center;
  1023. flex-direction: column;
  1024. margin:0 200rpx;
  1025. font-size: 24rpx;
  1026. color: #999999;
  1027. .up-icon {
  1028. margin-bottom:18rpx;
  1029. width:100%;
  1030. display: flex;
  1031. justify-content: center;
  1032. image {
  1033. width:58rpx;
  1034. height:21rpx;
  1035. }
  1036. }
  1037. }
  1038. .collect {
  1039. visibility: hidden;
  1040. &.show {
  1041. visibility: visible;
  1042. }
  1043. >view {
  1044. display: flex;
  1045. flex-direction: column;
  1046. align-items: center;
  1047. justify-content: center;
  1048. image {
  1049. width:32rpx;
  1050. height:32rpx;
  1051. margin-bottom:6rpx;
  1052. }
  1053. view {
  1054. font-size: 24rpx;
  1055. color: #999999;
  1056. }
  1057. }
  1058. }
  1059. }
  1060. .boxSty {
  1061. padding: 44rpx 41rpx 0rpx;
  1062. }
  1063. .liListSty {
  1064. border:1rpx solid #EEEEEE;
  1065. width: 88rpx;
  1066. height: 88rpx;
  1067. border-radius: 32rpx;
  1068. text-align: center;
  1069. line-height: 88rpx;
  1070. color: #333;
  1071. font-size: 32rpx;
  1072. float: left;
  1073. margin: 20rpx 23rpx;
  1074. &.isRight {
  1075. border:1rpx solid #EEEEEE;
  1076. color:#fff;
  1077. background: green;
  1078. }
  1079. &.isWrong {
  1080. border:1rpx solid #EEEEEE;
  1081. color:#fff;
  1082. background: red;
  1083. }
  1084. }
  1085. .answerInfos {
  1086. padding: 25rpx 25rpx 25rpx 23rpx;
  1087. }
  1088. .answerTitle {
  1089. margin-bottom: 28rpx;
  1090. color: #666;
  1091. font-size: 30rpx;
  1092. }
  1093. .answerContent {
  1094. font-size: 30rpx;
  1095. color: #666;
  1096. }
  1097. .textChild {
  1098. display: inline-block;
  1099. vertical-align: middle;
  1100. }
  1101. .dialog {
  1102. position: fixed;
  1103. left:0;
  1104. top:0;
  1105. width:100%;
  1106. height:100%;
  1107. background-color: rgba(0,0,0,0.8);
  1108. display: flex;
  1109. flex-direction: column;
  1110. align-items: center;
  1111. justify-content: center;
  1112. z-index: 20000;
  1113. .pointer {
  1114. width:338rpx;
  1115. height:240rpx;
  1116. }
  1117. .text {
  1118. font-size: 32rpx;
  1119. color: #FFFFFF;
  1120. text-align: center;
  1121. }
  1122. .btn {
  1123. width: 242rpx;
  1124. height: 82rpx;
  1125. border: 2rpx solid #FFFFFF;
  1126. border-radius: 16rpx;
  1127. text-align: center;
  1128. line-height: 82rpx;
  1129. margin:41rpx auto;
  1130. color:#fff;
  1131. font-size: 32rpx;
  1132. }
  1133. }
  1134. </style>