wrongTypeBank.vue 36 KB

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