collectBank.vue 35 KB

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