questionBankTest.vue 31 KB

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