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 @click="collect">收藏</view>
  281. <view class="flex_center" @click="openFooterTab">
  282. <view class="up-icon">
  283. <image src="/static/up.png"></image>
  284. </view>
  285. 答题卡
  286. </view>
  287. <view class="collect show" @click="submit">
  288. <view>
  289. <image src="/static/jj.png" mode=""></image>
  290. <view>交卷</view>
  291. </view>
  292. </view>
  293. </view>
  294. </view>
  295. </swiper-item>
  296. </swiper>
  297. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  298. <view class="popupView">
  299. <view class="popupTops">
  300. <view class="topIcon"></view>
  301. 点击编号即可跳转至对应题目
  302. </view>
  303. <view class="popupContent">
  304. <scroll-view scroll-y="true" style="height: 506rpx;">
  305. <view class="boxSty">
  306. <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>
  307. </view>
  308. </scroll-view>
  309. </view>
  310. </view>
  311. </u-popup>
  312. <view class="dialog" v-if="showDialog">
  313. <view class="text">左右滑动切换上下题</view>
  314. <view class="btn" @click="hideDialog">我知道了</view>
  315. </view>
  316. </view>
  317. </template>
  318. <script>
  319. export default {
  320. data() {
  321. return {
  322. id:'',
  323. current:0,
  324. questionList:[],
  325. newQuestionList:[],
  326. ast: ['A', 'B', 'C', 'D','E','F','G'],
  327. judge:['错误','正确'],
  328. show: false,
  329. showDialog:true,
  330. bankList: [],
  331. collectList:[],
  332. goodsId:'',
  333. num:0,
  334. };
  335. },
  336. onLoad(option){
  337. this.id = option.id;
  338. this.goodsId = option.goodsid;
  339. this.num = +option.num;
  340. this.goodsQuestionList();
  341. },
  342. onUnload() {
  343. },
  344. methods: {
  345. /**
  346. * 请求题目列表
  347. */
  348. goodsQuestionList() {
  349. this.$api.goodsQuestionList({
  350. examId:this.id
  351. }).then(res => {
  352. res.data.data.forEach((item,index) => {
  353. if(typeof item.jsonStr == 'string') {
  354. item.jsonStr = JSON.parse(item.jsonStr)
  355. if(item.type == 2) { //多选
  356. item.jsonStr.forEach(str => {
  357. str.optionsId = ''+str.optionsId;
  358. })
  359. let arr = item.answerQuestion.split(',');
  360. arr.forEach((a,i) => {
  361. arr[i] = ''+a;
  362. })
  363. item.ans = arr;
  364. return;
  365. } else if(item.type == 5) { //简答题
  366. item.ansText = {
  367. text: '',
  368. imageList: []
  369. }
  370. } else if(item.type == 4) { //案例题
  371. console.log(item.jsonStr)
  372. item.ques = []
  373. item.current = 0;
  374. let ansArr = [];
  375. item.jsonStr.forEach((json,index) => {
  376. if(json.type == 1) {
  377. ansArr[index] = json.answerQuestion;
  378. } else if(json.type == 2) {
  379. json.optionsList.forEach(str => {
  380. str.optionsId = ''+str.optionsId;
  381. })
  382. let arr = json.answerQuestion.split(',');
  383. arr.forEach((a,i) => {
  384. arr[i] = ''+a;
  385. })
  386. ansArr[index] = arr
  387. } else if(json.type == 3) {
  388. ansArr[index] = json.answerQuestion;
  389. } else if(json.type == 5) {
  390. ansArr[index] = {
  391. text: '',
  392. imageList: []
  393. }
  394. json.ansText = {
  395. text: '',
  396. imageList: []
  397. }
  398. }
  399. })
  400. item.ans = ansArr
  401. return;
  402. }
  403. item.ans = item.answerQuestion
  404. }
  405. })
  406. this.questionList = res.data.data;
  407. this.newQuestionList = this.questionList.filter((item,index) => {
  408. return index < this.num
  409. })
  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. /**
  465. * @param {Object} index
  466. * @param {Object} bindex
  467. * 判断题
  468. */
  469. judgeSelect(index,bindex) {
  470. if(this.questionList[bindex].ques) return;
  471. this.$set(this.questionList[bindex],'ques',index+'')
  472. },
  473. /**
  474. * @param {Object} ansindex
  475. * @param {Object} childindex
  476. * @param {Object} bindex
  477. * 案例判断题
  478. */
  479. judgeSelectChild(ansindex,childindex,bindex) {
  480. if(this.questionList[bindex].ques[ansindex]) return;
  481. this.$set(this.questionList[bindex].ques,ansindex,childindex+'')
  482. },
  483. openFooterTab() {
  484. this.show = true;
  485. },
  486. hideDialog() {
  487. this.showDialog = false
  488. },
  489. changeIndex(index) {
  490. if(index <= (this.num-1)) {
  491. this.current = index
  492. }
  493. },
  494. swiperChange(e) {
  495. this.current = e.detail.current;
  496. },
  497. /**
  498. * 提交数据
  499. */
  500. submit() {
  501. uni.showToast({
  502. title: '不能试做返回详情购买后即可交卷~',
  503. duration: 2000,
  504. icon:'none'
  505. });
  506. return;
  507. },
  508. /**
  509. * @param {Object} state
  510. * @param {Object} index
  511. * 收藏
  512. */
  513. collect(state,index) {
  514. uni.showToast({
  515. title: '返回详情购买后即可收藏~',
  516. duration: 2000,
  517. icon:'none'
  518. });
  519. return;
  520. },
  521. /**
  522. * @param {Object} imgIndex
  523. * @param {Object} bankIndex
  524. * 删除简答图片
  525. */
  526. deleteImg(imgIndex,bankIndex) {
  527. this.questionList[bankIndex].ansText.imageList.splice(imgIndex,1)
  528. },
  529. /**
  530. * @param {Object} imgIndex
  531. * @param {Object} bankIndex
  532. * @param {Object} ansIndex
  533. * 删除案例题简答图片
  534. */
  535. deleteImgChild(imgIndex,bankIndex,ansIndex) {
  536. this.questionList[bankIndex].jsonStr[ansIndex].ansText.imageList.splice(imgIndex,1)
  537. },
  538. /**
  539. * @param {Object} bankindex
  540. * 选择上传图片
  541. */
  542. chooseImg(bankindex) {
  543. uni.chooseImage({
  544. count: 1, //默认9
  545. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  546. sourceType: ['album','camera'], //从相册选择
  547. success: (res) => {
  548. let self = this;
  549. // console.log(JSON.stringify(res.tempFilePaths));
  550. let img = res.tempFilePaths[0];
  551. uni.getImageInfo({
  552. src: img,
  553. success: async res => {
  554. let canvasWidth = res.width; //图片原始长宽
  555. let canvasHeight = res.height;
  556. if (canvasWidth > 1000 || canvasHeight > 1000) {
  557. uni.compressImage({
  558. src: img,
  559. quality: 75,
  560. width: '50%',
  561. height: '50%',
  562. success: async rest => {
  563. const dir = await self.uploadFile(rest.tempFilePath, 0);
  564. this.questionList[bankindex].ansText.imageList.push(dir)
  565. }
  566. });
  567. } else {
  568. const dir = await self.uploadFile(img, 0);
  569. this.questionList[bankindex].ansText.imageList.push(dir)
  570. }
  571. }
  572. });
  573. }
  574. })
  575. },
  576. /**
  577. * @param {Object} bankindex
  578. * @param {Object} ansindex
  579. * 案例题选择上传图片
  580. */
  581. chooseImgChild(bankindex,ansindex) {
  582. uni.chooseImage({
  583. count: 1, //默认9
  584. sizeType: ['compressed', ], //可以指定是原图还是压缩图,默认二者都有
  585. sourceType: ['album','camera'], //从相册选择
  586. success: (res) => {
  587. let self = this;
  588. // console.log(JSON.stringify(res.tempFilePaths));
  589. let img = res.tempFilePaths[0];
  590. uni.getImageInfo({
  591. src: img,
  592. success: async res => {
  593. let canvasWidth = res.width; //图片原始长宽
  594. let canvasHeight = res.height;
  595. if (canvasWidth > 1000 || canvasHeight > 1000) {
  596. uni.compressImage({
  597. src: img,
  598. quality: 75,
  599. width: '50%',
  600. height: '50%',
  601. success: async rest => {
  602. const dir = await self.uploadFile(rest.tempFilePath, 0);
  603. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  604. }
  605. });
  606. } else {
  607. const dir = await self.uploadFile(img, 0);
  608. this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.push(dir)
  609. }
  610. }
  611. });
  612. }
  613. })
  614. },
  615. uploadFile(options, int) {
  616. var self = this;
  617. return new Promise((resolve, reject) => {
  618. var data = {
  619. imageStatus: int
  620. };
  621. self.$api.aliyunpolicy(data).then(res => {
  622. console.log(res.data,6)
  623. if(res.data.code!=200){
  624. self.$method.showToast('签名错误'+JSON.stringify(res.data))
  625. return
  626. }
  627. var ossToken = res.data.data.resultContent;
  628. if(ossToken.host==null||ossToken.host==undefined){
  629. self.$method.showToast('上传路径报错'+JSON.stringify(res.data))
  630. return
  631. }
  632. uni.uploadFile({
  633. url: ossToken.host,
  634. name: 'file',
  635. filePath: options,
  636. fileType: 'image',
  637. header: {
  638. AuthorizationToken: 'WX ' + uni.getStorageSync('token')
  639. },
  640. formData: {
  641. key: ossToken.dir,
  642. OSSAccessKeyId: ossToken.accessid,
  643. policy: ossToken.policy,
  644. Signature: ossToken.signature,
  645. callback: ossToken.callback,
  646. success_action_status: 200
  647. },
  648. success: result => {
  649. if (result.statusCode === 200) {
  650. resolve(ossToken.dir);
  651. } else {
  652. uni.showToast({
  653. title: '上传失败',
  654. icon: 'none'
  655. });
  656. return;
  657. }
  658. },
  659. fail: error => {
  660. uni.showToast({
  661. title: '上传接口报错'+error,
  662. icon: 'none'
  663. });
  664. return;
  665. }
  666. });
  667. });
  668. });
  669. },
  670. /**
  671. * @param {Object} type
  672. * @param {Object} bankindex
  673. * 简答题答案确认
  674. */
  675. submitAns(bankindex) {
  676. console.log(this.questionList[bankindex])
  677. if(!this.questionList[bankindex].ansText.text && !this.questionList[bankindex].ansText.imageList.length) {
  678. uni.showToast({
  679. title: '请输入内容或上传图片',
  680. duration: 2000,
  681. icon:'none'
  682. });
  683. return
  684. }
  685. this.$set(this.questionList[bankindex],'ques',{
  686. imageList:this.questionList[bankindex].ansText.imageList,
  687. text:this.questionList[bankindex].ansText.text,
  688. })
  689. },
  690. /**
  691. * @param {Object} bankindex
  692. * @param {Object} ansindex
  693. * 案例题简答答案确认
  694. */
  695. submitAnsChild(bankindex,ansindex) {
  696. if(!this.questionList[bankindex].jsonStr[ansindex].ansText.text && !this.questionList[bankindex].jsonStr[ansindex].ansText.imageList.length) {
  697. uni.showToast({
  698. title: '请输入内容或上传图片',
  699. duration: 2000,
  700. icon:'none'
  701. });
  702. return
  703. }
  704. this.$set(this.questionList[bankindex].ques,ansindex,{
  705. imageList:this.questionList[bankindex].jsonStr[ansindex].ansText.imageList,
  706. text:this.questionList[bankindex].jsonStr[ansindex].ansText.text,
  707. })
  708. },
  709. isRight(item,index) {
  710. //单选
  711. if(this.questionList[index].ques) {
  712. if(item.type == 1) {
  713. return this.questionList[index].ques == this.questionList[index].ans;
  714. //多选
  715. } else if(item.type == 2) {
  716. //每一项都相等
  717. return this.questionList[index].ques.every((item,i) => {
  718. return item == this.questionList[index].ans[i];
  719. })
  720. //判断
  721. } else if(item.type == 3) {
  722. return this.questionList[index].ques == this.questionList[index].ans;
  723. } else {
  724. return false;
  725. }
  726. } else {
  727. return false;
  728. }
  729. },
  730. right(bankIndex,ansIndex,option) {
  731. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  732. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) || (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) != -1)) {
  733. return true
  734. } else {
  735. return false;
  736. }
  737. } else {
  738. return false;
  739. }
  740. },
  741. wrong(bankIndex,ansIndex,option) {
  742. if(this.questionList[bankIndex].ques[ansIndex] && this.questionList[bankIndex].ans[ansIndex]) {
  743. if((this.questionList[bankIndex].ques[ansIndex].indexOf(option.optionsId) != -1 ) && (this.questionList[bankIndex].ans[ansIndex].indexOf(option.optionsId) == -1)) {
  744. return true;
  745. } else {
  746. return false;
  747. }
  748. } else {
  749. return false;
  750. }
  751. },
  752. isWrong(item,index) {
  753. if(this.questionList[index].ques) {
  754. //单选
  755. if(item.type == 1) {
  756. return this.questionList[index].ques != this.questionList[index].ans;
  757. //多选
  758. } else if(item.type == 2) {
  759. //每一项都相等
  760. return this.questionList[index].ques.some((item,index) => {
  761. return item != this.questionList[index].ans;
  762. })
  763. //判断
  764. } else if(item.type == 3) {
  765. return this.questionList[index].ques != this.questionList[index].ans;
  766. } else {
  767. return false;
  768. }
  769. } else {
  770. return false;
  771. }
  772. },
  773. tabSelect(index,bankindex) {
  774. this.$set(this.questionList[bankindex],'current',index)
  775. },
  776. }
  777. };
  778. </script>
  779. <style lang="scss" scoped>
  780. .swiper {
  781. width:100%;
  782. height:100vh;
  783. }
  784. .lisSty {
  785. margin-bottom: 16rpx;
  786. display: flex;
  787. .flex_auto {
  788. flex:1;
  789. }
  790. }
  791. .activeTI {
  792. vertical-align: middle;
  793. display: inline-block;
  794. border: 1rpx solid #eee;
  795. border-radius: 50rpx;
  796. height: 48rpx;
  797. line-height: 46rpx;
  798. text-align: center;
  799. width: 48rpx;
  800. margin-right: 15rpx;
  801. color: #666;
  802. font-size: 30rpx;
  803. &.right {
  804. color:#fff;
  805. background:green;
  806. }
  807. &.wrong {
  808. color:#fff;
  809. background:red;
  810. }
  811. &.checked {
  812. color:#fff;
  813. background:blue;
  814. }
  815. }
  816. .submit_checkbox {
  817. margin:20rpx auto;
  818. width: 526rpx;
  819. height: 80rpx;
  820. background: rgba(0, 122, 255, 1);
  821. color:#fff;
  822. text-align: center;
  823. line-height: 80rpx;
  824. font-size: 30rpx;
  825. border-radius: 40rpx;
  826. }
  827. .titles {
  828. overflow: hidden;
  829. margin-bottom: 24rpx;
  830. }
  831. .titBox {
  832. padding: 41rpx 25rpx 24rpx 25rpx;
  833. }
  834. .tabs {
  835. margin:10rpx;
  836. display: flex;
  837. .tab {
  838. margin:0 10rpx;
  839. width: 96rpx;
  840. height: 48rpx;
  841. line-height: 48rpx;
  842. text-align: center;
  843. color:#007AFF;
  844. font-size: 28rpx;
  845. border-radius: 16rpx;
  846. &.current {
  847. color:#fff;
  848. background: #007AFF;
  849. }
  850. }
  851. }
  852. .ans {
  853. margin:8rpx 8rpx 8rpx;
  854. .ans_input {
  855. border-radius: 16rpx;
  856. background:#fff;
  857. .top {
  858. border-bottom:1rpx solid #EEEEEE;
  859. padding: 16rpx;
  860. display: flex;
  861. align-items: center;
  862. .icon {
  863. margin-right:20rpx;
  864. width: 40rpx;
  865. height: 38rpx;
  866. }
  867. .progress {
  868. flex:1;
  869. }
  870. .submit {
  871. width: 168rpx;
  872. height: 48rpx;
  873. line-height: 48rpx;
  874. text-align: center;
  875. color:#fff;
  876. font-size: 30rpx;
  877. background: #007AFF;
  878. border-radius: 24rpx;
  879. }
  880. }
  881. .textarea {
  882. textarea {
  883. width:100%;
  884. height:287rpx;
  885. padding:10rpx;
  886. }
  887. }
  888. .imgs {
  889. overflow: hidden;
  890. display: flex;
  891. width:100%;
  892. .img {
  893. width: 104rpx;
  894. height: 104rpx;
  895. border-radius: 8rpx;
  896. position:relative;
  897. margin:20rpx;
  898. text {
  899. position:absolute;
  900. right:-15rpx;
  901. top:-15rpx;
  902. width:30rpx;
  903. height:30rpx;
  904. text-align: center;
  905. line-height: 30rpx;
  906. color:#fff;
  907. background:red;
  908. border-radius:50%;
  909. }
  910. image {
  911. width:100%;
  912. height:100%;
  913. }
  914. }
  915. }
  916. }
  917. .ans_submit {
  918. padding:16rpx;
  919. border-radius: 16rpx;
  920. background:#fff;
  921. .imgs {
  922. overflow: hidden;
  923. display: flex;
  924. width:100%;
  925. .img {
  926. width: 104rpx;
  927. height: 104rpx;
  928. border-radius: 8rpx;
  929. position:relative;
  930. margin:20rpx;
  931. image {
  932. width:100%;
  933. height:100%;
  934. }
  935. }
  936. }
  937. }
  938. }
  939. .firstLetter {
  940. display: flex;
  941. justify-content: space-between;
  942. align-items: center;
  943. margin-bottom: 30rpx;
  944. .leftLetters {
  945. display: flex;
  946. align-items: center;
  947. width: 220rpx;
  948. .btnType {
  949. padding: 5rpx 10rpx;
  950. border: 1rpx solid #007aff;
  951. border-radius: 10rpx;
  952. background-color: rgba(0, 122, 255, 0.1);
  953. font-size: 28rpx;
  954. color: #007aff;
  955. margin-right: 15rpx;
  956. }
  957. }
  958. }
  959. .popupView {
  960. height: 100%;
  961. padding-bottom: 100rpx;
  962. .popupTops {
  963. height: 77rpx;
  964. border-bottom: 1rpx solid #eee;
  965. text-align: center;
  966. line-height: 77rpx;
  967. font-size: 24rpx;
  968. color: #999;
  969. position: relative;
  970. .topIcon {
  971. position: absolute;
  972. top: 10rpx;
  973. left: 50%;
  974. transform: translateX(-50%);
  975. width: 80rpx;
  976. height: 8rpx;
  977. background-color: #999;
  978. border-radius: 4rpx;
  979. }
  980. }
  981. .popupContent {
  982. }
  983. }
  984. .pageContent {
  985. position:relative;
  986. background-color: #eaeef1;
  987. min-height: 100vh;
  988. padding-top: 8rpx;
  989. padding-bottom: 100rpx;
  990. }
  991. .pad_8 {
  992. background-color: #fff;
  993. margin: 0rpx 8rpx 8rpx;
  994. border-radius: 16rpx;
  995. }
  996. .answer {
  997. height: 80rpx;
  998. line-height: 80rpx;
  999. padding: 0rpx 24rpx;
  1000. display: flex;
  1001. align-items: center;
  1002. justify-content: space-between;
  1003. color: #666;
  1004. font-size: 30rpx;
  1005. }
  1006. .footer_btn {
  1007. background-color: #fff;
  1008. position: fixed;
  1009. bottom: 0rpx;
  1010. display: flex;
  1011. align-items: center;
  1012. justify-content: space-between;
  1013. width: 100%;
  1014. height: 98rpx;
  1015. padding: 0rpx 38rpx;
  1016. border-top: 1rpx solid #eee;
  1017. z-index: 9999999;
  1018. .flex_center {
  1019. flex:1;
  1020. display: flex;
  1021. justify-content: center;
  1022. align-items: center;
  1023. flex-direction: column;
  1024. margin:0 200rpx;
  1025. font-size: 24rpx;
  1026. color: #999999;
  1027. .up-icon {
  1028. margin-bottom:18rpx;
  1029. width:100%;
  1030. display: flex;
  1031. justify-content: center;
  1032. image {
  1033. width:58rpx;
  1034. height:21rpx;
  1035. }
  1036. }
  1037. }
  1038. .collect {
  1039. visibility: hidden;
  1040. &.show {
  1041. visibility: visible;
  1042. }
  1043. >view {
  1044. display: flex;
  1045. flex-direction: column;
  1046. align-items: center;
  1047. justify-content: center;
  1048. image {
  1049. width:32rpx;
  1050. height:32rpx;
  1051. margin-bottom:6rpx;
  1052. }
  1053. view {
  1054. font-size: 24rpx;
  1055. color: #999999;
  1056. }
  1057. }
  1058. }
  1059. }
  1060. .boxSty {
  1061. padding: 44rpx 41rpx 0rpx;
  1062. }
  1063. .liListSty {
  1064. border:1rpx solid #EEEEEE;
  1065. width: 88rpx;
  1066. height: 88rpx;
  1067. border-radius: 32rpx;
  1068. text-align: center;
  1069. line-height: 88rpx;
  1070. color: #333;
  1071. font-size: 32rpx;
  1072. float: left;
  1073. margin: 20rpx 23rpx;
  1074. &.isRight {
  1075. border:0;
  1076. color:#fff;
  1077. background: green;
  1078. }
  1079. &.isWrong {
  1080. border:0;
  1081. color:#fff;
  1082. background: red;
  1083. }
  1084. &.disabled {
  1085. color:#EEEEEE;
  1086. }
  1087. }
  1088. .answerInfos {
  1089. padding: 25rpx 25rpx 25rpx 23rpx;
  1090. }
  1091. .answerTitle {
  1092. margin-bottom: 28rpx;
  1093. color: #666;
  1094. font-size: 30rpx;
  1095. }
  1096. .answerContent {
  1097. font-size: 30rpx;
  1098. color: #666;
  1099. }
  1100. .textChild {
  1101. display: inline-block;
  1102. vertical-align: middle;
  1103. }
  1104. .dialog {
  1105. position: fixed;
  1106. left:0;
  1107. top:0;
  1108. width:100%;
  1109. height:100%;
  1110. background-color: rgba(0,0,0,0.8);
  1111. display: flex;
  1112. flex-direction: column;
  1113. align-items: center;
  1114. justify-content: center;
  1115. z-index: 20000;
  1116. .text {
  1117. font-size: 32rpx;
  1118. color: #FFFFFF;
  1119. text-align: center;
  1120. }
  1121. .btn {
  1122. width: 242rpx;
  1123. height: 82rpx;
  1124. border: 2rpx solid #FFFFFF;
  1125. border-radius: 16rpx;
  1126. text-align: center;
  1127. line-height: 82rpx;
  1128. margin:41rpx auto;
  1129. color:#fff;
  1130. font-size: 32rpx;
  1131. }
  1132. }
  1133. </style>