wrongBank.vue 35 KB

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