collectBank.vue 30 KB

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