questionBankTest.vue 33 KB

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