collectTypeBank.vue 35 KB

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