questionBankExplain.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415
  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. <template v-if="bank.type == 1">
  26. <view class="pad_8 titBox no-margin">
  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. </view>
  52. </template>
  53. <template v-if="bank.type == 2">
  54. <view class="pad_8 titBox no-margin">
  55. <view v-if="!bank.ques">
  56. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty" @click="checkboxSelect(item.optionsId,bankIndex,index)">
  57. <view :class="{checked:item.checked}" class="activeTI">{{ ast[index] }}</view>
  58. <view class="flex_auto">{{ item.content }}</view>
  59. </view>
  60. </view>
  61. <view v-if="!bank.ques" class="submit_checkbox" @click="checkboxSubmit(bankIndex)">
  62. 确认答案
  63. </view>
  64. <view v-if="bank.ques">
  65. <view v-for="(item, index) in bank.jsonStr" :key="index" class="lisSty">
  66. <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>
  67. <view class="flex_auto">{{ item.content }}</view>
  68. </view>
  69. </view>
  70. <view v-if="bank.ques">
  71. <view class="pad_8 answer">
  72. <view>正确答案:
  73. <text v-for="ansItem in bank.ans">{{ast[ansItem-1]}}</text>
  74. </view>
  75. <view v-if="!explain">我的答案:
  76. <text v-for="quesItem in bank.ques">{{ast[quesItem-1]}}</text>
  77. </view>
  78. </view>
  79. <view class="pad_8 answerInfos">
  80. <view class="answerTitle">答案解析</view>
  81. <view class="answerContent">
  82. <rich-text :nodes="bank.analysisContent"></rich-text>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <template v-if="bank.type == 3">
  89. <view class="pad_8 titBox no-margin">
  90. <view v-if="!bank.ques">
  91. <view v-for="(item, index) in judge" :key="index" class="lisSty" @click="judgeSelect(index,bankIndex)">
  92. <view class="activeTI">{{ ast[index] }}</view>
  93. {{ item }}
  94. </view>
  95. </view>
  96. <view v-if="bank.ques">
  97. <view v-for="(item, index) in judge" :key="index" class="lisSty">
  98. <text :class="{right:(index == bank.ques) || (index == bank.ans),wrong:(index == bank.ques) && (bank.ques != bank.ans)}" class="activeTI">{{ ast[index] }}</text>
  99. {{ item }}
  100. </view>
  101. </view>
  102. <view v-if="bank.ques">
  103. <view class="pad_8 answer">
  104. <view>正确答案:{{ast[bank.ans]}}</view>
  105. <view v-if="!explain">我的答案:{{ast[bank.ques]}}</view>
  106. </view>
  107. <view class="pad_8 answerInfos">
  108. <view class="answerTitle">答案解析</view>
  109. <view class="answerContent">
  110. <rich-text :nodes="bank.analysisContent"></rich-text>
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. </template>
  116. <!-- 简答题 -->
  117. <template v-if="bank.type == 5">
  118. <view class="pad_8 titBox">
  119. <view class="ans">
  120. <view class="ans_input" v-if="!bank.ques">
  121. <view class="top flex">
  122. <image :data-index="bankIndex" class="icon" @click="chooseImg(bankIndex)" src="/static/camera.png" mode=""></image>
  123. <view class="progress">{{bank.ansText.imageList.length || '0'}}/4</view>
  124. <view class="submit" @click="submitAns(bankIndex)" >确认答案</view>
  125. </view>
  126. <view class="textarea">
  127. <textarea v-model="bank.ansText.text" placeholder="在此输入答案"></textarea>
  128. </view>
  129. <view class="imgs">
  130. <view class="img" v-for="(img,imgIndex) in bank.ansText.imageList" >
  131. <text @click="deleteImg(imgIndex,bankIndex)">x</text>
  132. <image :src="$method.splitImgHost(img, true)"></image>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="ans_submit answerInfos" v-if="bank.ques && !explain">
  137. <view class="answerTitle">答案我的</view>
  138. {{bank.ques.text}}
  139. <view class="imgs">
  140. <image class="img" v-for="ques in bank.ques.imageList" :src="$method.splitImgHost(ques,true)"></image>
  141. </view>
  142. </view>
  143. </view>
  144. <view v-if="bank.ques">
  145. <view class="pad_8 answerInfos">
  146. <view class="answerTitle">答案解析</view>
  147. <view class="answerContent">
  148. <rich-text :nodes="bank.analysisContent"></rich-text>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. </template>
  154. <!-- 案例题 -->
  155. <template v-if="bank.type == 4">
  156. <view class="pad_8 titBox">
  157. <view class="tabs">
  158. <view class="tab" :class="{current:tabIndex == bank.current}" :key="tabIndex" v-for="(tab,tabIndex) in bank.jsonStr" @click="tabSelect(tabIndex,bankIndex)">问题{{tabIndex}}</view>
  159. </view>
  160. <view v-for="(ansItem,ansIndex) in bank.jsonStr" v-if="bank.current == ansIndex" :key="ansIndex">
  161. <view class="titles">
  162. <rich-text :nodes="ansItem.content"></rich-text>
  163. </view>
  164. <template v-if="ansItem.type == 1">
  165. <view v-if="!bank.ques[ansIndex]">
  166. <view v-for="(option, childIndex) in ansItem.optionsList" :key="childIndex" class="lisSty" @click="radioSelectChild(option.optionsId,ansIndex,bankIndex)">
  167. <view class="activeTI">{{ ast[childIndex] }}</view>
  168. <rich-text class="textChild" :nodes="option.content"></rich-text>
  169. </view>
  170. </view>
  171. <view v-if="bank.ques[ansIndex]">
  172. <view v-for="(option, childIndex) in ansItem.optionsList" :key="index" class="lisSty">
  173. <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>
  174. <rich-text :nodes="option.content"></rich-text>
  175. </view>
  176. </view>
  177. <view v-if="bank.ques[ansIndex]">
  178. <view class="pad_8 answer">
  179. <view>正确答案:{{ast[bank.ans[ansIndex]-1]}}</view>
  180. <view v-if="!explain">我的答案:{{ast[bank.ques[ansIndex]-1]}}</view>
  181. </view>
  182. <view class="pad_8 answerInfos">
  183. <view class="answerTitle">答案解析</view>
  184. <view class="answerContent">
  185. <rich-text :nodes="option.analysisContent"></rich-text>
  186. </view>
  187. </view>
  188. </view>
  189. </template>
  190. <template v-if="ansItem.type == 2">
  191. <view v-if="!bank.ques[ansIndex]">
  192. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty" @click="checkboxSelectChild(bankIndex,ansIndex,childindex)">
  193. <view :class="{checked:option.checked}" class="activeTI">{{ ast[childindex] }}</view>
  194. <rich-text :nodes="option.content"></rich-text>
  195. </view>
  196. </view>
  197. <view v-if="!bank.ques[ansIndex]" class="submit_checkbox" @click="checkboxSubmitChild(bankIndex,ansIndex)">
  198. 确认答案
  199. </view>
  200. <view v-if="bank.ques && bank.ques[ansIndex]">
  201. <view v-for="(option, childindex) in ansItem.optionsList" :key="childindex" class="lisSty">
  202. <text :class="{right:right(bankIndex,ansIndex,option),wrong:wrong(bankIndex,ansIndex,option)}" class="activeTI">{{ ast[childindex] }}</text>
  203. <rich-text :nodes="option.content"></rich-text>
  204. </view>
  205. </view>
  206. <view v-if="bank.ques[ansIndex]">
  207. <view class="pad_8 answer">
  208. <view>正确答案:
  209. <text v-for="ansItem1 in bank.ans[ansIndex]">{{ast[ansItem1-1]}}</text>
  210. </view>
  211. <view v-if="!explain">我的答案:
  212. <text v-for="quesItem in bank.ques[ansIndex]">{{ast[quesItem-1]}}</text>
  213. </view>
  214. </view>
  215. <view class="pad_8 answerInfos">
  216. <view class="answerTitle">答案解析</view>
  217. <view class="answerContent">
  218. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  219. </view>
  220. </view>
  221. </view>
  222. </template>
  223. <template v-if="ansItem.type == 3">
  224. <view v-if="!bank.ques[ansIndex]">
  225. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty" @click="judgeSelectChild(ansIndex,childindex,bankIndex)">
  226. <view class="activeTI">{{ ast[childindex] }}</view>
  227. {{ option }}
  228. </view>
  229. </view>
  230. <view v-if="bank.ques[ansIndex]">
  231. <view v-for="(option, childindex) in judge" :key="childindex" class="lisSty">
  232. <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>
  233. {{ option }}
  234. </view>
  235. </view>
  236. <view v-if="bank.ques[ansIndex]">
  237. <view class="pad_8 answer">
  238. <view>正确答案:{{ast[bank.ans[ansIndex]]}}</view>
  239. <view v-if="!explain">我的答案:{{ast[bank.ques[ansIndex]]}}</view>
  240. </view>
  241. <view class="pad_8 answerInfos">
  242. <view class="answerTitle">答案解析</view>
  243. <view class="answerContent">
  244. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  245. </view>
  246. </view>
  247. </view>
  248. </template>
  249. <!-- 简答题 -->
  250. <template v-if="ansItem.type == 5">
  251. <view class="ans">
  252. <view class="ans_input" v-if="!bank.ques[ansIndex]">
  253. <view class="top flex">
  254. <image class="icon" @click="chooseImgChild(bankIndex,ansIndex)" src="/static/08-10_032.jpg" mode=""></image>
  255. <view class="progress">0/4</view>
  256. <view class="submit" @click="submitAnsChild(bankIndex,ansIndex)">确认答案</view>
  257. </view>
  258. <view class="textarea">
  259. <textarea v-model="ansItem.ansText.text" placeholder="在此输入答案"></textarea>
  260. </view>
  261. <view class="imgs">
  262. <view class="img" v-for="(img,imgIndex) in ansItem.ansText.imageList" >
  263. <text @click="deleteImgChild(imgIndex,bankIndex,ansIndex)">x</text>
  264. <image :src="$method.splitImgHost(img, true)"></image>
  265. </view>
  266. </view>
  267. </view>
  268. <view class="ans_submit answerInfos" v-if="bank.ques[ansIndex] && !explain">
  269. <view class="answerTitle">答案我的</view>
  270. {{bank.ques[ansIndex].text}}
  271. <view class="imgs">
  272. <image class="img" v-for="ques in bank.ques[ansIndex].imageList" :src="$method.splitImgHost(ques,true)"></image>
  273. </view>
  274. </view>
  275. </view>
  276. <view v-if="bank.ques[ansIndex]">
  277. <view class="pad_8 answerInfos">
  278. <view class="answerTitle">答案解析</view>
  279. <view class="answerContent">
  280. <rich-text :nodes="ansItem.analysisContent"></rich-text>
  281. </view>
  282. </view>
  283. </view>
  284. </template>
  285. </view>
  286. </view>
  287. </template>
  288. <view class="footer_btn" v-if="isContinue || !isHistory">
  289. <view class="collect" :class="{ show: goodsId ? true : false }" @click="collect(collectList[bankIndex], bankIndex)">
  290. <view v-if="collectList[bankIndex]">
  291. <image src="/static/icon/collected.png" mode=""></image>
  292. <view>取消收藏</view>
  293. </view>
  294. <view v-if="!collectList[bankIndex]">
  295. <image src="/static/icon/collect.png" mode=""></image>
  296. <view>收藏</view>
  297. </view>
  298. </view>
  299. <view class="flex_center" @click="openFooterTab">
  300. <view class="up-icon">
  301. <image src="/static/up.png"></image>
  302. </view>
  303. 答题卡
  304. </view>
  305. <view class="collect" :class="{ show: explain ? false : true }" @click="submit">
  306. <view>
  307. <image src="/static/jj.png" mode=""></image>
  308. <view>交卷</view>
  309. </view>
  310. </view>
  311. </view>
  312. </view>
  313. </swiper-item>
  314. </swiper>
  315. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  316. <view class="popupView">
  317. <view class="popupTops">
  318. <view class="topIcon"></view>
  319. 点击编号即可跳转至对应题目
  320. </view>
  321. <view class="popupContent">
  322. <scroll-view scroll-y="true" style="height: 506rpx;">
  323. <view class="boxSty">
  324. <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>
  325. </view>
  326. </scroll-view>
  327. </view>
  328. </view>
  329. </u-popup>
  330. <view class="dialog" v-if="showDialog">
  331. <view class="text">左右滑动切换上下题</view>
  332. <view class="btn" @click="hideDialog">我知道了</view>
  333. </view>
  334. </view>
  335. </template>
  336. <script>
  337. export default {
  338. data() {
  339. return {
  340. id:'',
  341. current:0,
  342. questionList:[],
  343. ast: ['A', 'B', 'C', 'D','E','F','G'],
  344. judge:['错误','正确'],
  345. show: false,
  346. showDialog:true,
  347. bankList: [],
  348. collectList:[],
  349. goodsId:'',
  350. explain:'', //是否显示答案
  351. isContinue:'', //是否继续做题
  352. chapterId:'',
  353. moduleId:'',
  354. isHistory:'', //是否显示历史答题记录
  355. isSubmit:false,
  356. };
  357. },
  358. onLoad(option){
  359. this.id = option.id;
  360. this.explain = option.explain;
  361. this.isContinue = option.continue;
  362. this.goodsId = option.goodsid;
  363. this.chapterId = option.chapterId;
  364. this.moduleId = option.moduleId;
  365. this.recordId = option.recordId;
  366. this.isHistory = option.isHistory;
  367. this.goodsQuestionList();
  368. },
  369. onUnload() {
  370. if(this.isSubmit || this.isHistory) {
  371. return
  372. }
  373. this.examRecordEdit();
  374. },
  375. methods: {
  376. /**
  377. * @param {Object} state
  378. * @param {Object} index
  379. * 收藏
  380. */
  381. collect(state, index) {
  382. if (!state) {
  383. this.$api
  384. .collectQuestion({
  385. examId: this.id,
  386. questionId: this.questionList[index].questionId,
  387. goodsId: this.goodsId || ''
  388. })
  389. .then(res => {
  390. if (res.data.code == 200) {
  391. this.$set(this.collectList, index, true);
  392. uni.showToast({
  393. title: '收藏成功',
  394. duration: 2000,
  395. icon: 'none'
  396. });
  397. this.getCollectInfo(index)
  398. }
  399. });
  400. } else {
  401. this.$api.deleteCollectQuestion(this.collectList[index].collectQuestionId).then(res => {
  402. if (res.data.code == 200) {
  403. this.$set(this.collectList, index, false);
  404. uni.showToast({
  405. title: '取消收藏成功',
  406. duration: 2000,
  407. icon: 'none'
  408. });
  409. }
  410. });
  411. }
  412. return;
  413. },
  414. goodsQuestionList() {
  415. //继续答题
  416. if(this.isContinue || this.isHistory) {
  417. console.log(this.isContinue,"历史做题")
  418. this.$api.examReport(this.recordId).then(res => {
  419. let json = JSON.parse(res.data.data.historyExamJson)
  420. this.questionList = json;
  421. })
  422. } else { //解析
  423. this.$api.goodsQuestionList({
  424. examId:this.id
  425. }).then(res => {
  426. res.data.data.forEach((item,index) => {
  427. if(typeof item.jsonStr == 'string') {
  428. item.jsonStr = JSON.parse(item.jsonStr)
  429. if(item.type == 2) { //多选
  430. item.jsonStr.forEach(str => {
  431. str.optionsId = ''+str.optionsId;
  432. })
  433. let arr = item.answerQuestion.split(',');
  434. arr.forEach((a,i) => {
  435. arr[i] = ''+a;
  436. })
  437. item.ans = arr;
  438. if(this.explain) {
  439. item.ques = item.ans;
  440. }
  441. return;
  442. } else if(item.type == 5) {
  443. item.ansText = {
  444. text: '',
  445. imageList: []
  446. }
  447. if(this.explain) {
  448. item.ques = {
  449. text:item.analysisContent
  450. }
  451. return;
  452. }
  453. } else if(item.type == 4) {
  454. console.log(item.jsonStr)
  455. item.ques = []
  456. item.current = 0;
  457. let ansArr = [];
  458. item.jsonStr.forEach((json,index) => {
  459. if(json.type == 1) {
  460. ansArr[index] = json.answerQuestion;
  461. } else if(json.type == 2) {
  462. json.optionsList.forEach(str => {
  463. str.optionsId = ''+str.optionsId;
  464. })
  465. let arr = json.answerQuestion.split(',');
  466. arr.forEach((a,i) => {
  467. arr[i] = ''+a;
  468. })
  469. ansArr[index] = arr
  470. } else if(json.type == 3) {
  471. ansArr[index] = json.answerQuestion;
  472. } else if(json.type == 5) {
  473. ansArr[index] = {
  474. text: '',
  475. imageList: []
  476. }
  477. json.ansText = {
  478. text: '',
  479. imageList: []
  480. }
  481. }
  482. })
  483. item.ans = ansArr
  484. if(this.explain) {
  485. item.ques = item.ans;
  486. }
  487. return;
  488. }
  489. item.ans = item.answerQuestion
  490. if(this.explain) {
  491. item.ques = item.ans;
  492. }
  493. } else {
  494. if(this.explain) {
  495. item.ques = item.ans;
  496. }
  497. }
  498. })
  499. this.questionList = res.data.data;
  500. this.getCollectInfo(this.current);
  501. console.log(this.questionList)
  502. })
  503. }
  504. },
  505. /**
  506. * @param {Object} current
  507. * 获取收藏信息
  508. */
  509. getCollectInfo(current) {
  510. this.$api
  511. .getCollectInfo({
  512. examId: this.id,
  513. questionId: this.questionList[current].questionId,
  514. goodsId: this.goodsId
  515. })
  516. .then(res => {
  517. if (res.data.code == 500) {
  518. this.$set(this.collectList, current, false);
  519. } else if (res.data.code == 200) {
  520. this.$set(this.collectList, current, res.data.data);
  521. }
  522. });
  523. },
  524. /**
  525. * @param {Object} e单选点击
  526. */
  527. radioSelect(optionsId,bindex) {
  528. if(this.questionList[bindex].ques) return;
  529. this.$set(this.questionList[bindex],'ques',optionsId)
  530. },
  531. examRecordEdit() {
  532. if(!this.isSubmit) {
  533. let number = 0;
  534. let score = 0;
  535. this.questionList.length && this.questionList.forEach((item,index) => {
  536. if(item.type == 1) {
  537. if(item.ques == item.ans) {
  538. score += item.score;
  539. number++
  540. }
  541. } else if(item.type == 2) {
  542. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  543. return item.ques[quesIndex] == item.ans[quesIndex]
  544. })
  545. if(isRight) {
  546. score += item.score;
  547. number++
  548. }
  549. } else if(item.type == 3) {
  550. if(item.ques == item.ans) {
  551. score += item.score;
  552. number++
  553. }
  554. }
  555. })
  556. this.$api.examRecordEdit({
  557. examId:this.id,
  558. goodsId:this.goodsId,
  559. recordId: this.recordId,
  560. rightQuestionNum:number,
  561. status:0,
  562. historyExamJson:JSON.stringify(this.questionList)
  563. }).then(res => {
  564. })
  565. }
  566. },
  567. /**
  568. * @param {Object} e单选点击
  569. */
  570. radioSelectChild(optionsId,ansIndex,bindex) {
  571. if(this.questionList[bindex].ques[ansIndex]) return;
  572. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  573. },
  574. /**
  575. * @param {Object} 多选点击
  576. */
  577. checkboxSelect(optionsId,bindex,index) {
  578. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  579. },
  580. /**
  581. * @param {Object} 多选点击
  582. */
  583. checkboxSelectChild(bindex,ansIndex,childIndex) {
  584. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  585. },
  586. /**
  587. * 提交数据
  588. */
  589. submit() {
  590. let score = 0; //计算总分
  591. let reportStatus = 0;
  592. let number = 0;
  593. let allScore = 0;
  594. let passScore = 0;
  595. this.questionList.forEach((item,index) => {
  596. passScore = item.passScore
  597. if(item.type == 1) {
  598. if(item.ques == item.ans) {
  599. score += item.score;
  600. number++
  601. }
  602. allScore += item.score
  603. } else if(item.type == 2) {
  604. let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
  605. return item.ques[quesIndex] == item.ans[quesIndex]
  606. })
  607. if(isRight) {
  608. score += item.score;
  609. number++
  610. }
  611. allScore += item.score
  612. } else if(item.type == 3) {
  613. if(item.ques == item.ans) {
  614. score += item.score;
  615. number++
  616. }
  617. allScore += item.score
  618. }
  619. })
  620. if(score >= passScore) {
  621. reportStatus = 1
  622. } else {
  623. reportStatus = 0
  624. }
  625. this.$api.examRecordEdit({
  626. examId:this.id,
  627. goodsId:this.goodsId,
  628. reportStatus:reportStatus,
  629. totalScore:allScore,
  630. recordId: this.recordId,
  631. rightQuestionNum:number,
  632. status:1,
  633. performance:score,
  634. historyExamJson:JSON.stringify(this.questionList)
  635. }).then(res => {
  636. this.isSubmit = true;
  637. if(res.data.code == 200) {
  638. uni.showToast({
  639. title: '交卷成功',
  640. duration: 2000,
  641. icon:'none'
  642. });
  643. setTimeout(() => {
  644. uni.redirectTo({
  645. url:'/pages2/bank/question_report?id='+this.recordId+'&examId='+this.id
  646. })
  647. },2000)
  648. }
  649. })
  650. },
  651. /**
  652. * @param {Object} 多选确认
  653. */
  654. checkboxSubmit(bindex) {
  655. if(this.questionList[bindex].ques) return;
  656. let arr = [];
  657. this.questionList[bindex].jsonStr.forEach(item => {
  658. if(item.checked) {
  659. arr.push(item.optionsId)
  660. }
  661. })
  662. this.$set(this.questionList[bindex],'ques',arr)
  663. },
  664. /**
  665. * @param {Object} 多选确认
  666. */
  667. checkboxSubmitChild(bindex,ansIndex) {
  668. if(this.questionList[bindex].ques[ansIndex]) return;
  669. let arr = [];
  670. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  671. if(item.checked) {
  672. arr.push(item.optionsId)
  673. }
  674. })
  675. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  676. },
  677. judgeSelect(index,bindex) {
  678. if(this.questionList[bindex].ques) return;
  679. this.$set(this.questionList[bindex],'ques',index+'')
  680. },
  681. judgeSelectChild(ansindex,childindex,bindex) {
  682. if(this.questionList[bindex].ques[ansindex]) return;
  683. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  684. },
  685. openFooterTab() {
  686. this.show = true;
  687. },
  688. hideDialog() {
  689. this.showDialog = false
  690. },
  691. changeIndex(index) {
  692. this.current = index
  693. },
  694. swiperChange(e) {
  695. this.current = e.detail.current;
  696. },
  697. deleteImg(imgIndex,bankIndex) {
  698. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  699. },
  700. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  701. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  702. },
  703. chooseImg(bankindex) {
  704. uni.chooseImage({
  705. count: 1, //默认9
  706. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  707. sourceType: ['album','camera'], //从相册选择
  708. success: (res) => {
  709. let self = this;
  710. // console.log(JSON.stringify(res.tempFilePaths));
  711. let img = res.tempFilePaths[0];
  712. uni.getImageInfo({
  713. src: img,
  714. success: async res => {
  715. let canvasWidth = res.width; //图片原始长宽
  716. let canvasHeight = res.height;
  717. if (canvasWidth > 1000 || canvasHeight > 1000) {
  718. uni.compressImage({
  719. src: img,
  720. quality: 75,
  721. width: '50%',
  722. height: '50%',
  723. success: async rest => {
  724. const dir = await self.uploadFile(rest.tempFilePath, 0);
  725. this.questionList[bankindex].ansText.imageList.push(dir)
  726. }
  727. });
  728. } else {
  729. const dir = await self.uploadFile(img, 0);
  730. this.questionList[bankindex].ansText.imageList.push(dir)
  731. }
  732. }
  733. });
  734. }
  735. })
  736. },
  737. chooseImgChild(bankindex,ansindex) {
  738. uni.chooseImage({
  739. count: 1, //默认9
  740. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  741. sourceType: ['album','camera'], //从相册选择
  742. success: (res) => {
  743. let self = this;
  744. // console.log(JSON.stringify(res.tempFilePaths));
  745. let img = res.tempFilePaths[0];
  746. uni.getImageInfo({
  747. src: img,
  748. success: async res => {
  749. let canvasWidth = res.width; //图片原始长宽
  750. let canvasHeight = res.height;
  751. if (canvasWidth > 1000 || canvasHeight > 1000) {
  752. uni.compressImage({
  753. src: img,
  754. quality: 75,
  755. width: '50%',
  756. height: '50%',
  757. success: async rest => {
  758. const dir = await self.uploadFile(rest.tempFilePath, 0);
  759. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  760. }
  761. });
  762. } else {
  763. const dir = await self.uploadFile(img, 0);
  764. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  765. }
  766. }
  767. });
  768. }
  769. })
  770. },
  771. uploadFile(options, int) {
  772. var self = this;
  773. return new Promise((resolve, reject) => {
  774. var data = {
  775. imageStatus: int
  776. };
  777. self.$api.aliyunpolicy(data).then(res => {
  778. console.log(res.data,6)
  779. if(res.data.code!=200){
  780. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  781. return
  782. }
  783. var ossToken = res.data.data.resultContent;
  784. if(ossToken.host==null||ossToken.host==undefined){
  785. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  786. return
  787. }
  788. uni.uploadFile({
  789. url: ossToken.host,
  790. name: 'file',
  791. filePath: options,
  792. fileType: 'image',
  793. header: {
  794. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  795. },
  796. formData: {
  797. key: ossToken.dir,
  798. OSSAccessKeyId: ossToken.accessid,
  799. policy: ossToken.policy,
  800. Signature: ossToken.signature,
  801. callback: ossToken.callback,
  802. success_action_status: 200
  803. },
  804. success: result => {
  805. if (result.statusCode === 200) {
  806. resolve(ossToken.dir);
  807. } else {
  808. uni.showToast({
  809. title: '上传失败',
  810. icon: 'none'
  811. });
  812. return;
  813. }
  814. },
  815. fail: error => {
  816. uni.showToast({
  817. title: '上传接口报错'+error,
  818. icon: 'none'
  819. });
  820. return;
  821. }
  822. });
  823. });
  824. });
  825. },
  826. submitAns(bankindex) {
  827. console.log(this.questionList[bankindex])
  828. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  829. uni.showToast({
  830. title: '请输入内容或上传图片',
  831. duration: 2000,
  832. icon:'none'
  833. });
  834. return
  835. }
  836. this.$set(this.questionList[bankindex],'ques',{
  837. imageList:this.questionList[bankindex].ansText.imageList,
  838. text:this.questionList[bankindex].ansText.text,
  839. })
  840. },
  841. submitAnsChild(bankindex,ansindex) {
  842. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  843. uni.showToast({
  844. title: '请输入内容或上传图片',
  845. duration: 2000,
  846. icon:'none'
  847. });
  848. return
  849. }
  850. this.$set(this.questionList[bankindex].ques,ansindex,{
  851. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  852. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  853. })
  854. },
  855. isRight(item,index) {
  856. //单选
  857. if(this.questionList[index].ques) {
  858. if(item.type == 1) {
  859. return this.questionList[index].ques == this.questionList[index].ans;
  860. //多选
  861. } else if(item.type == 2) {
  862. //每一项都相等
  863. return this.questionList[index].ques.every((item,i) => {
  864. console.log(item == this.questionList[index].ans[i])
  865. return item == this.questionList[index].ans[i];
  866. })
  867. //判断
  868. } else if(item.type == 3) {
  869. return this.questionList[index].ques == this.questionList[index].ans;
  870. } else {
  871. return false;
  872. }
  873. } else {
  874. return false;
  875. }
  876. },
  877. right(bankIndex,ansIndex,option) {
  878. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  879. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  880. return true
  881. } else {
  882. return false;
  883. }
  884. } else {
  885. return false;
  886. }
  887. },
  888. wrong(bankIndex,ansIndex,option) {
  889. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  890. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  891. return true;
  892. } else {
  893. return false;
  894. }
  895. } else {
  896. return false;
  897. }
  898. },
  899. isWrong(item,index) {
  900. if(this.questionList[index].ques) {
  901. //单选
  902. if(item.type == 1) {
  903. return this.questionList[index].ques != this.questionList[index].ans;
  904. //多选
  905. } else if(item.type == 2) {
  906. //每一项都相等
  907. return this.questionList[index].ques.some((item,i) => {
  908. return item != this.questionList[index].ans[i];
  909. })
  910. //判断
  911. } else if(item.type == 3) {
  912. return this.questionList[index].ques != this.questionList[index].ans;
  913. } else {
  914. return false;
  915. }
  916. } else {
  917. return false;
  918. }
  919. },
  920. tabSelect(index,bankindex) {
  921. this.$set(this.questionList[bankindex],'current',index)
  922. },
  923. }
  924. };
  925. </script>
  926. <style lang="scss" scoped>
  927. .swiper {
  928. width:100%;
  929. height:100vh;
  930. }
  931. .lisSty {
  932. margin-bottom: 16rpx;
  933. display: flex;
  934. .flex_auto {
  935. flex:1;
  936. }
  937. }
  938. .activeTI {
  939. vertical-align: middle;
  940. display: inline-block;
  941. border: 1rpx solid #eee;
  942. border-radius: 50rpx;
  943. height: 48rpx;
  944. line-height: 46rpx;
  945. text-align: center;
  946. width: 48rpx;
  947. margin-right: 15rpx;
  948. color: #666;
  949. font-size: 30rpx;
  950. &.right {
  951. color:#fff;
  952. background:green;
  953. }
  954. &.wrong {
  955. color:#fff;
  956. background:red;
  957. }
  958. &.checked {
  959. color:#fff;
  960. background:blue;
  961. }
  962. }
  963. .submit_checkbox {
  964. margin:20rpx auto;
  965. width: 526rpx;
  966. height: 80rpx;
  967. background: rgba(0, 122, 255, 1);
  968. color:#fff;
  969. text-align: center;
  970. line-height: 80rpx;
  971. font-size: 30rpx;
  972. border-radius: 40rpx;
  973. }
  974. .titles {
  975. overflow: hidden;
  976. margin-bottom: 24rpx;
  977. }
  978. .titBox {
  979. padding: 41rpx 25rpx 24rpx 25rpx;
  980. }
  981. .tabs {
  982. margin:10rpx;
  983. display: flex;
  984. .tab {
  985. margin:0 10rpx;
  986. width: 96rpx;
  987. height: 48rpx;
  988. line-height: 48rpx;
  989. text-align: center;
  990. color:#007AFF;
  991. font-size: 28rpx;
  992. border-radius: 16rpx;
  993. &.current {
  994. color:#fff;
  995. background: #007AFF;
  996. }
  997. }
  998. }
  999. .ans {
  1000. margin:8rpx 8rpx 8rpx;
  1001. .ans_input {
  1002. border-radius: 16rpx;
  1003. background:#fff;
  1004. .top {
  1005. border-bottom:1rpx solid #EEEEEE;
  1006. padding: 16rpx;
  1007. display: flex;
  1008. align-items: center;
  1009. .icon {
  1010. margin-right:20rpx;
  1011. width: 40rpx;
  1012. height: 38rpx;
  1013. }
  1014. .progress {
  1015. flex:1;
  1016. }
  1017. .submit {
  1018. width: 168rpx;
  1019. height: 48rpx;
  1020. line-height: 48rpx;
  1021. text-align: center;
  1022. color:#fff;
  1023. font-size: 30rpx;
  1024. background: #007AFF;
  1025. border-radius: 24rpx;
  1026. }
  1027. }
  1028. .textarea {
  1029. textarea {
  1030. width:100%;
  1031. height:287rpx;
  1032. padding:10rpx;
  1033. }
  1034. }
  1035. .imgs {
  1036. overflow: hidden;
  1037. display: flex;
  1038. width:100%;
  1039. .img {
  1040. width: 104rpx;
  1041. height: 104rpx;
  1042. border-radius: 8rpx;
  1043. position:relative;
  1044. margin:20rpx;
  1045. text {
  1046. position:absolute;
  1047. right:-15rpx;
  1048. top:-15rpx;
  1049. width:30rpx;
  1050. height:30rpx;
  1051. text-align: center;
  1052. line-height: 30rpx;
  1053. color:#fff;
  1054. background:red;
  1055. border-radius:50%;
  1056. }
  1057. image {
  1058. width:100%;
  1059. height:100%;
  1060. }
  1061. }
  1062. }
  1063. }
  1064. .ans_submit {
  1065. padding:16rpx;
  1066. border-radius: 16rpx;
  1067. background:#fff;
  1068. .imgs {
  1069. overflow: hidden;
  1070. display: flex;
  1071. width:100%;
  1072. .img {
  1073. width: 104rpx;
  1074. height: 104rpx;
  1075. border-radius: 8rpx;
  1076. position:relative;
  1077. margin:20rpx;
  1078. image {
  1079. width:100%;
  1080. height:100%;
  1081. }
  1082. }
  1083. }
  1084. }
  1085. }
  1086. .firstLetter {
  1087. display: flex;
  1088. justify-content: space-between;
  1089. align-items: center;
  1090. margin-bottom: 30rpx;
  1091. .leftLetters {
  1092. display: flex;
  1093. align-items: center;
  1094. width: 220rpx;
  1095. .btnType {
  1096. padding: 5rpx 10rpx;
  1097. border: 1rpx solid #007aff;
  1098. border-radius: 10rpx;
  1099. background-color: rgba(0, 122, 255, 0.1);
  1100. font-size: 28rpx;
  1101. color: #007aff;
  1102. margin-right: 15rpx;
  1103. }
  1104. }
  1105. }
  1106. .popupView {
  1107. height: 100%;
  1108. padding-bottom: 100rpx;
  1109. .popupTops {
  1110. height: 77rpx;
  1111. border-bottom: 1rpx solid #eee;
  1112. text-align: center;
  1113. line-height: 77rpx;
  1114. font-size: 24rpx;
  1115. color: #999;
  1116. position: relative;
  1117. .topIcon {
  1118. position: absolute;
  1119. top: 10rpx;
  1120. left: 50%;
  1121. transform: translateX(-50%);
  1122. width: 80rpx;
  1123. height: 8rpx;
  1124. background-color: #999;
  1125. border-radius: 4rpx;
  1126. }
  1127. }
  1128. .popupContent {
  1129. }
  1130. }
  1131. .pageContent {
  1132. position:relative;
  1133. background-color: #eaeef1;
  1134. height: 100%;
  1135. overflow-y: scroll;
  1136. padding-top: 8rpx;
  1137. padding-bottom: 100rpx;
  1138. }
  1139. .pad_8 {
  1140. background-color: #fff;
  1141. margin: 0rpx 8rpx 8rpx;
  1142. border-radius: 16rpx;
  1143. &.no-margin {
  1144. margin-top:-16rpx;
  1145. border-radius: 0 0 16rpx 16rpx;
  1146. }
  1147. }
  1148. .answer {
  1149. height: 80rpx;
  1150. line-height: 80rpx;
  1151. padding: 0rpx 24rpx;
  1152. display: flex;
  1153. align-items: center;
  1154. justify-content: space-between;
  1155. color: #666;
  1156. font-size: 30rpx;
  1157. }
  1158. .footer_btn {
  1159. background-color: #fff;
  1160. z-index: 10078;
  1161. position: fixed;
  1162. bottom: 0rpx;
  1163. display: flex;
  1164. align-items: center;
  1165. justify-content: space-between;
  1166. width: 100%;
  1167. height: 98rpx;
  1168. padding: 0rpx 38rpx;
  1169. border-top: 1rpx solid #eee;
  1170. .flex_center {
  1171. flex:1;
  1172. display: flex;
  1173. justify-content: center;
  1174. align-items: center;
  1175. flex-direction: column;
  1176. margin:0 200rpx;
  1177. font-size: 24rpx;
  1178. color: #999999;
  1179. .up-icon {
  1180. margin-bottom:18rpx;
  1181. width:100%;
  1182. display: flex;
  1183. justify-content: center;
  1184. image {
  1185. width:58rpx;
  1186. height:21rpx;
  1187. }
  1188. }
  1189. }
  1190. .collect {
  1191. visibility: hidden;
  1192. width:100rpx;
  1193. &.show {
  1194. visibility: visible;
  1195. }
  1196. >view {
  1197. display: flex;
  1198. flex-direction: column;
  1199. align-items: center;
  1200. justify-content: center;
  1201. image {
  1202. width:32rpx;
  1203. height:32rpx;
  1204. margin-bottom:6rpx;
  1205. }
  1206. view {
  1207. font-size: 24rpx;
  1208. color: #999999;
  1209. }
  1210. }
  1211. }
  1212. }
  1213. .boxSty {
  1214. padding: 44rpx 41rpx 0rpx;
  1215. }
  1216. .liListSty {
  1217. border:1rpx solid #EEEEEE;
  1218. width: 88rpx;
  1219. height: 88rpx;
  1220. border-radius: 32rpx;
  1221. text-align: center;
  1222. line-height: 88rpx;
  1223. color: #333;
  1224. font-size: 32rpx;
  1225. float: left;
  1226. margin: 20rpx 23rpx;
  1227. &.isRight {
  1228. border:1rpx solid #EEEEEE;
  1229. color:#fff;
  1230. background: green;
  1231. }
  1232. &.isWrong {
  1233. border:1rpx solid #EEEEEE;
  1234. color:#fff;
  1235. background: red;
  1236. }
  1237. }
  1238. .answerInfos {
  1239. padding: 25rpx 25rpx 25rpx 23rpx;
  1240. }
  1241. .answerTitle {
  1242. margin-bottom: 28rpx;
  1243. color: #666;
  1244. font-size: 30rpx;
  1245. }
  1246. .answerContent {
  1247. font-size: 30rpx;
  1248. color: #666;
  1249. }
  1250. .textChild {
  1251. display: inline-block;
  1252. vertical-align: middle;
  1253. }
  1254. .dialog {
  1255. position: fixed;
  1256. left:0;
  1257. top:0;
  1258. width:100%;
  1259. height:100%;
  1260. background-color: rgba(0,0,0,0.8);
  1261. display: flex;
  1262. flex-direction: column;
  1263. align-items: center;
  1264. justify-content: center;
  1265. z-index: 20000;
  1266. .text {
  1267. font-size: 32rpx;
  1268. color: #FFFFFF;
  1269. text-align: center;
  1270. }
  1271. .btn {
  1272. width: 242rpx;
  1273. height: 82rpx;
  1274. border: 2rpx solid #FFFFFF;
  1275. border-radius: 16rpx;
  1276. text-align: center;
  1277. line-height: 82rpx;
  1278. margin:41rpx auto;
  1279. color:#fff;
  1280. font-size: 32rpx;
  1281. }
  1282. }
  1283. </style>