collectTypeBank.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320
  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 in bank.ans">{{ast[ansItem-1]}}</text>
  76. </view>
  77. <view v-if="!explain">我的答案:
  78. <text v-for="quesItem in bank.ques">{{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" >
  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" v-for="ques 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="index" 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:!this.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 in bank.ans[ansIndex]">{{ast[ansItem1-1]}}</text>
  229. </view>
  230. <view v-if="!explain">我的答案:
  231. <text v-for="quesItem in bank.ques[ansIndex]">{{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" >
  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" v-for="ques 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. 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. type:'',
  368. explain:'',
  369. orderGoodsId:'',
  370. };
  371. },
  372. onLoad(option){
  373. this.orderGoodsId = option.orderGoodsId || '';
  374. this.type = option.type;
  375. this.explain = option.explain;
  376. let showDialog = uni.getStorageSync('showDialog');
  377. if(showDialog) {
  378. this.showDialog = false;
  379. } else {
  380. this.showDialog = true;
  381. uni.setStorageSync('showDialog','1');
  382. }
  383. this.goodsCollectList();
  384. },
  385. onUnload() {
  386. },
  387. methods: {
  388. /**
  389. * 是否有上传图片
  390. */
  391. hasImgs(bank) {
  392. return bank.ansText.imageList.length == 0;
  393. },
  394. goodsCollectList() {
  395. this.$api.goodsCollectList({
  396. type:this.type
  397. }).then(res => {
  398. res.data.rows.forEach((item,index) => {
  399. if(typeof item.jsonStr == 'string') {
  400. item.jsonStr = JSON.parse(item.jsonStr)
  401. if(item.type == 2) { //多选
  402. item.jsonStr.forEach(str => {
  403. str.optionsId = ''+str.optionsId;
  404. })
  405. let arr = item.answerQuestion.split(',');
  406. arr.forEach((a,i) => {
  407. arr[i] = ''+a;
  408. })
  409. item.ans = arr;
  410. if(this.explain) {
  411. item.ques = item.ans;
  412. }
  413. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  414. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  415. return;
  416. } else if(item.type == 5) {
  417. item.ansText = {
  418. text: '',
  419. imageList: []
  420. }
  421. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  422. item.content && (item.content = item.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  423. if(this.explain) {
  424. item.ques = {
  425. text:item.analysisContent
  426. }
  427. return;
  428. }
  429. } else if(item.type == 4) {
  430. console.log(item.jsonStr)
  431. item.ques = []
  432. item.current = 0;
  433. let ansArr = [];
  434. item.jsonStr.forEach((json,index) => {
  435. if(json.type == 1) {
  436. ansArr[index] = json.answerQuestion;
  437. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  438. } else if(json.type == 2) {
  439. json.optionsList.forEach(str => {
  440. str.optionsId = ''+str.optionsId;
  441. })
  442. let arr = json.answerQuestion.split(',');
  443. arr.forEach((a,i) => {
  444. arr[i] = ''+a;
  445. })
  446. ansArr[index] = arr
  447. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  448. } else if(json.type == 3) {
  449. ansArr[index] = json.answerQuestion;
  450. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  451. } else if(json.type == 5) {
  452. ansArr[index] = {
  453. text: '',
  454. imageList: []
  455. }
  456. json.ansText = {
  457. text: '',
  458. imageList: []
  459. }
  460. json.content && (json.content = json.content.replace(/<img/gi, '<img style="max-width:100%;"'));
  461. }
  462. })
  463. item.ans = ansArr
  464. item.analysisContent && (item.analysisContent = item.analysisContent.replace(/<img/gi, '<img style="max-width:100%;"'));
  465. item.content && (item.content = item.content.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>