wrongTypeBank.vue 34 KB

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