wrongBank.vue 35 KB

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