questionBankTest.vue 36 KB

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