collectTypeBank.vue 34 KB

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