collectBank.vue 33 KB

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