wrongTypeBank.vue 33 KB

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