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