questionBankTest.vue 35 KB

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