questionBankTest.vue 33 KB

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