questionBankTest.vue 32 KB

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