collectBank.vue 35 KB

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