wrongTypeBank.vue 36 KB

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