questionBankTest.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  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 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 :key="ansItemIndex" v-for="(ansItem,ansItemIndex) in bank.ans">{{ast[ansItem-1]}}</text>
  71. </view>
  72. <view>我的答案:
  73. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) 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" :key="imgIndex" >
  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" :key="quesIndex" v-for="(ques,quesIndex) 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="childIndex" 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 :key="ansItemIndex1" v-for="(ansItem1,ansItemIndex1) in bank.ans[ansIndex]">{{ast[ansItem1-1]}}</text>
  201. </view>
  202. <view>我的答案:
  203. <text :key="quesItemIndex" v-for="(quesItem,quesItemIndex) 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" :key="imgIndex" >
  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" :key="quesIndex" v-for="(ques,quesIndex) 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. ast: ['A', 'B', 'C', 'D','E','F','G'],
  332. judge:['错误','正确'],
  333. show: false,
  334. showDialog:false,
  335. bankList: [],
  336. collectList:[],
  337. goodsId:'',
  338. num:0,
  339. };
  340. },
  341. onLoad(option){
  342. this.id = option.id;
  343. this.goodsId = option.goodsid;
  344. this.num = +option.num;
  345. let showDialog = uni.getStorageSync('showDialog');
  346. if(showDialog) {
  347. this.showDialog = false;
  348. } else {
  349. this.showDialog = true;
  350. uni.setStorageSync('showDialog','1');
  351. }
  352. this.goodsQuestionList();
  353. },
  354. onUnload() {
  355. },
  356. methods: {
  357. /**
  358. * 是否有上传图片
  359. */
  360. hasImgs(bank) {
  361. return bank.ansText.imageList.length == 0;
  362. },
  363. /**
  364. * 请求题目列表
  365. */
  366. goodsQuestionList() {
  367. this.$api.goodsQuestionList({
  368. examId:this.id
  369. }).then(res => {
  370. res.data.data.forEach((item,index) => {
  371. if(typeof item.jsonStr == 'string') {
  372. item.jsonStr = JSON.parse(item.jsonStr)
  373. if(item.type == 2) { //多选
  374. item.jsonStr.forEach(str => {
  375. str.optionsId = ''+str.optionsId;
  376. })
  377. let arr = item.answerQuestion.split(',');
  378. arr.forEach((a,i) => {
  379. arr[i] = ''+a;
  380. })
  381. item.ans = arr;
  382. return;
  383. } else if(item.type == 5) { //简答题
  384. item.ansText = {
  385. text: '',
  386. imageList: []
  387. }
  388. } else if(item.type == 4) { //案例题
  389. console.log(item.jsonStr)
  390. item.ques = []
  391. item.current = 0;
  392. let ansArr = [];
  393. item.jsonStr.forEach((json,index) => {
  394. if(json.type == 1) {
  395. ansArr[index] = json.answerQuestion;
  396. } else if(json.type == 2) {
  397. json.optionsList.forEach(str => {
  398. str.optionsId = ''+str.optionsId;
  399. })
  400. let arr = json.answerQuestion.split(',');
  401. arr.forEach((a,i) => {
  402. arr[i] = ''+a;
  403. })
  404. ansArr[index] = arr
  405. } else if(json.type == 3) {
  406. ansArr[index] = json.answerQuestion;
  407. } else if(json.type == 5) {
  408. ansArr[index] = {
  409. text: '',
  410. imageList: []
  411. }
  412. json.ansText = {
  413. text: '',
  414. imageList: []
  415. }
  416. }
  417. })
  418. item.ans = ansArr
  419. return;
  420. }
  421. item.ans = item.answerQuestion
  422. }
  423. })
  424. this.questionList = res.data.data;
  425. })
  426. },
  427. /**
  428. * @param {Object} e单选点击
  429. */
  430. radioSelect(optionsId,bindex) {
  431. if(this.questionList[bindex].ques) return;
  432. this.$set(this.questionList[bindex],'ques',optionsId)
  433. },
  434. /**
  435. * @param {Object} e案例单选点击
  436. */
  437. radioSelectChild(optionsId,ansIndex,bindex) {
  438. if(this.questionList[bindex].ques[ansIndex]) return;
  439. this.$set(this.questionList[bindex].ques,ansIndex,optionsId)
  440. },
  441. /**
  442. * @param {Object} 多选点击
  443. */
  444. checkboxSelect(optionsId,bindex,index) {
  445. this.$set(this.questionList[bindex].jsonStr[index],'checked',!this.questionList[bindex].jsonStr[index].checked)
  446. },
  447. /**
  448. * @param {Object} 案例多选点击
  449. */
  450. checkboxSelectChild(bindex,ansIndex,childIndex) {
  451. this.$set(this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex],'checked',!this.questionList[bindex].jsonStr[ansIndex].optionsList[childIndex].checked)
  452. },
  453. /**
  454. * @param {Object} 多选确认
  455. */
  456. checkboxSubmit(bindex) {
  457. if(this.questionList[bindex].ques) return;
  458. let arr = [];
  459. this.questionList[bindex].jsonStr.forEach(item => {
  460. if(item.checked) {
  461. arr.push(item.optionsId)
  462. }
  463. })
  464. this.$set(this.questionList[bindex],'ques',arr)
  465. },
  466. /**
  467. * @param {Object} 案例多选确认
  468. */
  469. checkboxSubmitChild(bindex,ansIndex) {
  470. if(this.questionList[bindex].ques[ansIndex]) return;
  471. let arr = [];
  472. this.questionList[bindex].jsonStr[ansIndex].optionsList.forEach(item => {
  473. if(item.checked) {
  474. arr.push(item.optionsId)
  475. }
  476. })
  477. this.$set(this.questionList[bindex].ques,ansIndex,arr)
  478. },
  479. /**
  480. * @param {Object} index
  481. * @param {Object} bindex
  482. * 判断题
  483. */
  484. judgeSelect(index,bindex) {
  485. if(this.questionList[bindex].ques) return;
  486. this.$set(this.questionList[bindex],'ques',index+'')
  487. },
  488. /**
  489. * @param {Object} ansindex
  490. * @param {Object} childindex
  491. * @param {Object} bindex
  492. * 案例判断题
  493. */
  494. judgeSelectChild(ansindex,childindex,bindex) {
  495. if(this.questionList[bindex].ques[ansindex]) return;
  496. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  497. },
  498. openFooterTab() {
  499. this.show = true;
  500. },
  501. hideDialog() {
  502. this.showDialog = false;
  503. },
  504. changeIndex(index) {
  505. if(index <= (this.num-1)) {
  506. this.current = index
  507. } else {
  508. uni.showModal({
  509. title: '提示',
  510. content: '试做题目已结束,够买题卷可作答所有题目',
  511. cancelText:'返回详情',
  512. cancelColor:'',
  513. confirmText:'继续作答',
  514. confirmColor:'',
  515. success: (res) => {
  516. if (res.confirm) {
  517. } else if (res.cancel) {
  518. uni.navigateBack({
  519. delta:1
  520. })
  521. console.log('返回详情');
  522. }
  523. }
  524. });
  525. }
  526. },
  527. swiperChange(e) {
  528. this.current = e.detail.current;
  529. if(this.current > this.num -1) {
  530. uni.showModal({
  531. title: '提示',
  532. content: '试做题目已结束,够买题卷可作答所有题目',
  533. cancelText:'返回详情',
  534. cancelColor:'',
  535. confirmText:'继续作答',
  536. confirmColor:'',
  537. success: (res) => {
  538. if (res.confirm) {
  539. this.current = this.num - 1;
  540. } else if (res.cancel) {
  541. uni.navigateBack({
  542. delta:1
  543. })
  544. console.log('返回详情');
  545. }
  546. }
  547. });
  548. }
  549. },
  550. /**
  551. * 提交数据
  552. */
  553. submit() {
  554. uni.showToast({
  555. title: '不能试做返回详情购买后即可交卷~',
  556. duration: 2000,
  557. icon:'none'
  558. });
  559. return;
  560. },
  561. /**
  562. * @param {Object} state
  563. * @param {Object} index
  564. * 收藏
  565. */
  566. collect(state,index) {
  567. uni.showToast({
  568. title: '返回详情购买后即可收藏~',
  569. duration: 2000,
  570. icon:'none'
  571. });
  572. return;
  573. },
  574. /**
  575. * @param {Object} imgIndex
  576. * @param {Object} bankIndex
  577. * 删除简答图片
  578. */
  579. deleteImg(imgIndex,bankIndex) {
  580. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  581. },
  582. /**
  583. * @param {Object} imgIndex
  584. * @param {Object} bankIndex
  585. * @param {Object} ansIndex
  586. * 删除案例题简答图片
  587. */
  588. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  589. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  590. },
  591. /**
  592. * @param {Object} bankindex
  593. * 选择上传图片
  594. */
  595. chooseImg(bankindex) {
  596. uni.chooseImage({
  597. count: 1, //默认9
  598. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  599. sourceType: ['album','camera'], //从相册选择
  600. success: (res) => {
  601. let self = this;
  602. // console.log(JSON.stringify(res.tempFilePaths));
  603. let img = res.tempFilePaths[0];
  604. uni.getImageInfo({
  605. src: img,
  606. success: async res => {
  607. let canvasWidth = res.width; //图片原始长宽
  608. let canvasHeight = res.height;
  609. if (canvasWidth > 1000 || canvasHeight > 1000) {
  610. uni.compressImage({
  611. src: img,
  612. quality: 75,
  613. width: '50%',
  614. height: '50%',
  615. success: async rest => {
  616. const dir = await self.uploadFile(rest.tempFilePath, 0);
  617. this.questionList[bankindex].ansText.imageList.push(dir)
  618. }
  619. });
  620. } else {
  621. const dir = await self.uploadFile(img, 0);
  622. this.questionList[bankindex].ansText.imageList.push(dir)
  623. }
  624. }
  625. });
  626. }
  627. })
  628. },
  629. /**
  630. * @param {Object} bankindex
  631. * @param {Object} ansindex
  632. * 案例题选择上传图片
  633. */
  634. chooseImgChild(bankindex,ansindex) {
  635. uni.chooseImage({
  636. count: 1, //默认9
  637. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  638. sourceType: ['album','camera'], //从相册选择
  639. success: (res) => {
  640. let self = this;
  641. // console.log(JSON.stringify(res.tempFilePaths));
  642. let img = res.tempFilePaths[0];
  643. uni.getImageInfo({
  644. src: img,
  645. success: async res => {
  646. let canvasWidth = res.width; //图片原始长宽
  647. let canvasHeight = res.height;
  648. if (canvasWidth > 1000 || canvasHeight > 1000) {
  649. uni.compressImage({
  650. src: img,
  651. quality: 75,
  652. width: '50%',
  653. height: '50%',
  654. success: async rest => {
  655. const dir = await self.uploadFile(rest.tempFilePath, 0);
  656. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  657. }
  658. });
  659. } else {
  660. const dir = await self.uploadFile(img, 0);
  661. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  662. }
  663. }
  664. });
  665. }
  666. })
  667. },
  668. uploadFile(options, int) {
  669. var self = this;
  670. return new Promise((resolve, reject) => {
  671. var data = {
  672. imageStatus: int
  673. };
  674. self.$api.aliyunpolicy(data).then(res => {
  675. console.log(res.data,6)
  676. if(res.data.code!=200){
  677. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  678. return
  679. }
  680. var ossToken = res.data.data.resultContent;
  681. if(ossToken.host==null||ossToken.host==undefined){
  682. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  683. return
  684. }
  685. uni.uploadFile({
  686. url: ossToken.host,
  687. name: 'file',
  688. filePath: options,
  689. fileType: 'image',
  690. header: {
  691. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  692. },
  693. formData: {
  694. key: ossToken.dir,
  695. OSSAccessKeyId: ossToken.accessid,
  696. policy: ossToken.policy,
  697. Signature: ossToken.signature,
  698. callback: ossToken.callback,
  699. success_action_status: 200
  700. },
  701. success: result => {
  702. if (result.statusCode === 200) {
  703. resolve(ossToken.dir);
  704. } else {
  705. uni.showToast({
  706. title: '上传失败',
  707. icon: 'none'
  708. });
  709. return;
  710. }
  711. },
  712. fail: error => {
  713. uni.showToast({
  714. title: '上传接口报错'+error,
  715. icon: 'none'
  716. });
  717. return;
  718. }
  719. });
  720. });
  721. });
  722. },
  723. /**
  724. * @param {Object} type
  725. * @param {Object} bankindex
  726. * 简答题答案确认
  727. */
  728. submitAns(bankindex) {
  729. console.log(this.questionList[bankindex])
  730. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  731. uni.showToast({
  732. title: '请输入内容或上传图片',
  733. duration: 2000,
  734. icon:'none'
  735. });
  736. return
  737. }
  738. this.$set(this.questionList[bankindex],'ques',{
  739. imageList:this.questionList[bankindex].ansText.imageList,
  740. text:this.questionList[bankindex].ansText.text,
  741. })
  742. },
  743. /**
  744. * @param {Object} bankindex
  745. * @param {Object} ansindex
  746. * 案例题简答答案确认
  747. */
  748. submitAnsChild(bankindex,ansindex) {
  749. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  750. uni.showToast({
  751. title: '请输入内容或上传图片',
  752. duration: 2000,
  753. icon:'none'
  754. });
  755. return
  756. }
  757. this.$set(this.questionList[bankindex].ques,ansindex,{
  758. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  759. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  760. })
  761. },
  762. isRight(item,index) {
  763. //单选
  764. if(this.questionList[index].ques) {
  765. if(item.type == 1) {
  766. return this.questionList[index].ques == this.questionList[index].ans;
  767. //多选
  768. } else if(item.type == 2) {
  769. //每一项都相等
  770. return this.questionList[index].ques.every((item,i) => {
  771. return item == this.questionList[index].ans[i];
  772. })
  773. //判断
  774. } else if(item.type == 3) {
  775. return this.questionList[index].ques == this.questionList[index].ans;
  776. } else {
  777. return false;
  778. }
  779. } else {
  780. return false;
  781. }
  782. },
  783. right(bankIndex,ansIndex,option) {
  784. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  785. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  786. return true
  787. } else {
  788. return false;
  789. }
  790. } else {
  791. return false;
  792. }
  793. },
  794. wrong(bankIndex,ansIndex,option) {
  795. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  796. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  797. return true;
  798. } else {
  799. return false;
  800. }
  801. } else {
  802. return false;
  803. }
  804. },
  805. isWrong(item,index) {
  806. if(this.questionList[index].ques) {
  807. //单选
  808. if(item.type == 1) {
  809. return this.questionList[index].ques != this.questionList[index].ans;
  810. //多选
  811. } else if(item.type == 2) {
  812. //每一项都相等
  813. return this.questionList[index].ques.some((item,index) => {
  814. return item != this.questionList[index].ans;
  815. })
  816. //判断
  817. } else if(item.type == 3) {
  818. return this.questionList[index].ques != this.questionList[index].ans;
  819. } else {
  820. return false;
  821. }
  822. } else {
  823. return false;
  824. }
  825. },
  826. tabSelect(index,bankindex) {
  827. this.$set(this.questionList[bankindex],'current',index)
  828. },
  829. }
  830. };
  831. </script>
  832. <style lang="scss" scoped>
  833. .swiper {
  834. width:100%;
  835. height:100vh;
  836. }
  837. .lisSty {
  838. margin-bottom: 16rpx;
  839. display: flex;
  840. .flex_auto {
  841. flex:1;
  842. }
  843. }
  844. .activeTI {
  845. vertical-align: middle;
  846. display: inline-block;
  847. border: 1rpx solid #eee;
  848. border-radius: 50rpx;
  849. height: 48rpx;
  850. line-height: 46rpx;
  851. text-align: center;
  852. width: 48rpx;
  853. margin-right: 15rpx;
  854. color: #666;
  855. font-size: 30rpx;
  856. &.right {
  857. color:#fff;
  858. background:green;
  859. }
  860. &.wrong {
  861. color:#fff;
  862. background:red;
  863. }
  864. &.checked {
  865. color:#fff;
  866. background:blue;
  867. }
  868. }
  869. .submit_checkbox {
  870. margin:20rpx auto;
  871. width: 526rpx;
  872. height: 80rpx;
  873. background: rgba(0, 122, 255, 1);
  874. color:#fff;
  875. text-align: center;
  876. line-height: 80rpx;
  877. font-size: 30rpx;
  878. border-radius: 40rpx;
  879. }
  880. .titles {
  881. overflow: hidden;
  882. margin-bottom: 24rpx;
  883. }
  884. .titBox {
  885. padding: 41rpx 25rpx 24rpx 25rpx;
  886. }
  887. .tabs {
  888. margin:10rpx;
  889. display: flex;
  890. .tab {
  891. margin:0 10rpx;
  892. width: 96rpx;
  893. height: 48rpx;
  894. line-height: 48rpx;
  895. text-align: center;
  896. color:#007AFF;
  897. font-size: 28rpx;
  898. border-radius: 16rpx;
  899. &.current {
  900. color:#fff;
  901. background: #007AFF;
  902. }
  903. }
  904. }
  905. .ans {
  906. margin:8rpx 8rpx 8rpx;
  907. .ans_input {
  908. border-radius: 16rpx;
  909. background:#fff;
  910. .top {
  911. border-bottom:1rpx solid #EEEEEE;
  912. padding: 16rpx;
  913. display: flex;
  914. align-items: center;
  915. .icon {
  916. margin-right:20rpx;
  917. width: 40rpx;
  918. height: 38rpx;
  919. }
  920. .progress {
  921. flex:1;
  922. }
  923. .submit {
  924. width: 168rpx;
  925. height: 48rpx;
  926. line-height: 48rpx;
  927. text-align: center;
  928. color:#fff;
  929. font-size: 30rpx;
  930. background: #007AFF;
  931. border-radius: 24rpx;
  932. &.disabled {
  933. opacity: 0.6;
  934. }
  935. }
  936. }
  937. .textarea {
  938. textarea {
  939. width:100%;
  940. height:287rpx;
  941. padding:10rpx;
  942. }
  943. }
  944. .imgs {
  945. overflow: hidden;
  946. display: flex;
  947. width:100%;
  948. .img {
  949. width: 104rpx;
  950. height: 104rpx;
  951. border-radius: 8rpx;
  952. position:relative;
  953. margin:20rpx;
  954. text {
  955. position:absolute;
  956. right:-15rpx;
  957. top:-15rpx;
  958. width:30rpx;
  959. height:30rpx;
  960. text-align: center;
  961. line-height: 30rpx;
  962. color:#fff;
  963. background:red;
  964. border-radius:50%;
  965. }
  966. image {
  967. width:100%;
  968. height:100%;
  969. }
  970. }
  971. }
  972. }
  973. .ans_submit {
  974. padding:16rpx;
  975. border-radius: 16rpx;
  976. background:#fff;
  977. .imgs {
  978. overflow: hidden;
  979. display: flex;
  980. width:100%;
  981. .img {
  982. width: 104rpx;
  983. height: 104rpx;
  984. border-radius: 8rpx;
  985. position:relative;
  986. margin:20rpx;
  987. image {
  988. width:100%;
  989. height:100%;
  990. }
  991. }
  992. }
  993. }
  994. }
  995. .firstLetter {
  996. display: flex;
  997. justify-content: space-between;
  998. align-items: center;
  999. margin-bottom: 30rpx;
  1000. .leftLetters {
  1001. display: flex;
  1002. align-items: center;
  1003. width: 220rpx;
  1004. .btnType {
  1005. padding: 5rpx 10rpx;
  1006. border: 1rpx solid #007aff;
  1007. border-radius: 10rpx;
  1008. background-color: rgba(0, 122, 255, 0.1);
  1009. font-size: 28rpx;
  1010. color: #007aff;
  1011. margin-right: 15rpx;
  1012. }
  1013. }
  1014. }
  1015. .popupView {
  1016. height: 100%;
  1017. padding-bottom: 100rpx;
  1018. .popupTops {
  1019. height: 77rpx;
  1020. border-bottom: 1rpx solid #eee;
  1021. text-align: center;
  1022. line-height: 77rpx;
  1023. font-size: 24rpx;
  1024. color: #999;
  1025. position: relative;
  1026. .topIcon {
  1027. position: absolute;
  1028. top: 10rpx;
  1029. left: 50%;
  1030. transform: translateX(-50%);
  1031. width: 80rpx;
  1032. height: 8rpx;
  1033. background-color: #999;
  1034. border-radius: 4rpx;
  1035. }
  1036. }
  1037. .popupContent {
  1038. }
  1039. }
  1040. .pageContent {
  1041. position:relative;
  1042. background-color: #eaeef1;
  1043. min-height: 100vh;
  1044. padding-top: 8rpx;
  1045. padding-bottom: 100rpx;
  1046. }
  1047. .pad_8 {
  1048. background-color: #fff;
  1049. margin: 0rpx 8rpx 8rpx;
  1050. border-radius: 16rpx;
  1051. }
  1052. .answer {
  1053. height: 80rpx;
  1054. line-height: 80rpx;
  1055. padding: 0rpx 24rpx;
  1056. display: flex;
  1057. align-items: center;
  1058. justify-content: space-between;
  1059. color: #666;
  1060. font-size: 30rpx;
  1061. }
  1062. .footer_btn {
  1063. background-color: #fff;
  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. z-index: 9999999;
  1074. .flex_center {
  1075. flex:1;
  1076. display: flex;
  1077. justify-content: center;
  1078. align-items: center;
  1079. flex-direction: column;
  1080. margin:0 200rpx;
  1081. font-size: 24rpx;
  1082. color: #999999;
  1083. .up-icon {
  1084. margin-bottom:18rpx;
  1085. width:100%;
  1086. display: flex;
  1087. justify-content: center;
  1088. image {
  1089. width:58rpx;
  1090. height:21rpx;
  1091. }
  1092. }
  1093. }
  1094. .collect {
  1095. >view {
  1096. display: flex;
  1097. flex-direction: column;
  1098. align-items: center;
  1099. justify-content: center;
  1100. image {
  1101. width:32rpx;
  1102. height:32rpx;
  1103. margin-bottom:6rpx;
  1104. }
  1105. view {
  1106. font-size: 24rpx;
  1107. color: #999999;
  1108. }
  1109. }
  1110. }
  1111. }
  1112. .boxSty {
  1113. padding: 44rpx 41rpx 0rpx;
  1114. }
  1115. .liListSty {
  1116. border:1rpx solid #EEEEEE;
  1117. width: 88rpx;
  1118. height: 88rpx;
  1119. border-radius: 32rpx;
  1120. text-align: center;
  1121. line-height: 88rpx;
  1122. color: #333;
  1123. font-size: 32rpx;
  1124. float: left;
  1125. margin: 20rpx 23rpx;
  1126. &.isRight {
  1127. border:0;
  1128. color:#fff;
  1129. background: green;
  1130. }
  1131. &.isWrong {
  1132. border:0;
  1133. color:#fff;
  1134. background: red;
  1135. }
  1136. &.disabled {
  1137. color:#EEEEEE;
  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>