questionBankTest.vue 30 KB

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