wrongTypeBank.vue 33 KB

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