collectBank.vue 35 KB

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