collectBank.vue 34 KB

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