collectBank.vue 34 KB

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