wrongTypeBank.vue 35 KB

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