wrongTypeBank.vue 36 KB

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