collectTypeBank.vue 35 KB

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