collectTypeBank.vue 33 KB

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