questionBank.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <template>
  2. <view id="questionBank">
  3. <swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
  4. <swiper-item v-for="(bank,bankIndex) in bankList">
  5. <view v-if="bank.type == 'text'" class="pageContent">
  6. <view class="pad_8 titBox">
  7. <view class="firstLetter">
  8. <view class="leftLetters">
  9. <view class="btnType">简答</view>
  10. <text>{{bankIndex}}/{{bankList.length}}</text>
  11. </view>
  12. <view style="color: #666;font-size: 28rpx;">03:25:06</view>
  13. <view class="leftLetters"></view>
  14. </view>
  15. <view class="titles">论述我国中央人民政府和特别行政区的关系。</view>
  16. </view>
  17. <view class="ans">
  18. <view class="ans_input" v-if="!ques[bankIndex]">
  19. <view class="top flex">
  20. <image :data-index="bankIndex" class="icon" @click="chooseImg" src="/static/08-10_032.jpg" mode=""></image>
  21. <view class="progress">0/4</view>
  22. <view class="submit" @click="submitAns" data-type='text' :data-bankIndex="bankIndex" >确认答案</view>
  23. </view>
  24. <view class="textarea">
  25. <textarea v-model="bank.text" placeholder="在此输入答案"></textarea>
  26. </view>
  27. <view class="imgs">
  28. <view class="img" v-for="(img,imgIndex) in bank.arr" >
  29. <text @click="deleteImg" :data-imgIndex="imgIndex" :data-bankIndex="bankIndex">x</text>
  30. <image :src="img"></image>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="ans_submit answerInfos" v-if="ques[bankIndex]">
  35. <view class="answerTitle">答案我的</view>
  36. {{ques[bankIndex].text}}
  37. <view class="imgs">
  38. <image class="img" v-for="ques in ques[bankIndex].arr" :src="ques"></image>
  39. </view>
  40. </view>
  41. </view>
  42. <view v-if="ques[bankIndex]">
  43. <view class="pad_8 answerInfos">
  44. <view class="answerTitle">答案解析</view>
  45. <view class="answerContent">
  46. 这是官方答案解析文本,卡片高度根据内容自动调整,我实在编不出来内容了,我实在编不出来内容了,我实在编不出来内容了,我实在编不出来内容了,就这样吧。
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view v-if="bank.type == 'checkbox'" class="pageContent">
  52. <view class="pad_8 titBox">
  53. <view class="firstLetter">
  54. <view class="leftLetters">
  55. <view class="btnType">多选</view>
  56. <text>{{bankIndex}}/{{bankList.length}}</text>
  57. </view>
  58. <view style="color: #666;font-size: 28rpx;">03:25:06</view>
  59. <view class="leftLetters"></view>
  60. </view>
  61. <view class="titles">建造师执业资格注册的有效期一般为( )年。</view>
  62. <view class="">
  63. <view v-if="ques[bankIndex] ">
  64. <view v-for="(item, index) in bank.arr" :key="index"
  65. class="lisSty">
  66. <view :class="{right: (item.value == ques[bankIndex]) && (ques[bankIndex] == ans[bankIndex]),wrong:(item.value == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</view>
  67. {{ item.label }}
  68. </view>
  69. </view>
  70. <view v-if="!ques[bankIndex]">
  71. <view v-for="(item, index) in bank.arr" :key="index" @click="click" :data-value="item.value" class="lisSty">
  72. <text class="activeTI">{{ ast[index] }}</text>
  73. {{ item.label }}
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- <view v-if="!ques[bankIndex]" class="submit_checkbox" @click="submitAns" data-type="checkbox" :data-bankIndex="bankIndex">
  79. 确认答案
  80. </view> -->
  81. <view v-if="ques[bankIndex]">
  82. <view class="pad_8 answer">
  83. <view>正确答案:{{ans[bankIndex]}}</view>
  84. <view>我的答案:{{ques[bankIndex]}}</view>
  85. </view>
  86. <view class="pad_8 answerInfos">
  87. <view class="answerTitle">答案解析</view>
  88. <view class="answerContent">
  89. 建造师执业资格注册有效期一般为3年,有效期满前3个月,持证者应到原注册管理机构办理再次注册手续。在注册有效期内,变更执业单位者,应当及时办理变更手续。
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. <view v-if="bank.type == 'radio'" class="pageContent">
  95. <view class="pad_8 titBox">
  96. <view class="firstLetter">
  97. <view class="leftLetters">
  98. <view class="btnType">单选</view>
  99. <text>{{bankIndex}}/{{bankList.length}}</text>
  100. </view>
  101. <view style="color: #666;font-size: 28rpx;">03:25:06</view>
  102. <view class="leftLetters"></view>
  103. </view>
  104. <view class="titles">建造师执业资格注册的有效期一般为( )年。</view>
  105. <view class="">
  106. <view v-if="ques[bankIndex] ">
  107. <view v-for="(item, index) in bank.arr" :key="index"
  108. class="lisSty">
  109. <view :class="{right:(item.value == ques[bankIndex]) && (ques[bankIndex] == ans[bankIndex]),wrong:(item.value == ques[bankIndex]) && (ques[bankIndex] != ans[bankIndex])}" class="activeTI">{{ ast[index] }}</view>
  110. {{ item.label }}
  111. </view>
  112. </view>
  113. <view v-if="!ques[bankIndex]">
  114. <view v-for="(item, index) in bank.arr" :key="index" @click="click" :data-value="item.value" class="lisSty">
  115. <text class="activeTI">{{ ast[index] }}</text>
  116. {{ item.label }}
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <view v-if="ques[bankIndex]">
  122. <view class="pad_8 answer">
  123. <view>正确答案:{{ans[bankIndex]}}</view>
  124. <view>我的答案:{{ques[bankIndex]}}</view>
  125. </view>
  126. <view class="pad_8 answerInfos">
  127. <view class="answerTitle">答案解析</view>
  128. <view class="answerContent">
  129. 建造师执业资格注册有效期一般为3年,有效期满前3个月,持证者应到原注册管理机构办理再次注册手续。在注册有效期内,变更执业单位者,应当及时办理变更手续。
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. </swiper-item>
  135. </swiper>
  136. <view class="footer-start">开始做答</view>
  137. <view class="footer_btn">
  138. <view @click="collect">收藏</view>
  139. <view @click="openFooterTab">答题卡</view>
  140. <navigator url="/pages2/bank/question_report" open-type="redirect">
  141. <view>交卷</view>
  142. </navigator>
  143. </view>
  144. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  145. <view class="popupView">
  146. <view class="popupTops">
  147. <view class="topIcon"></view>
  148. 点击编号即可跳转至对应题目
  149. </view>
  150. <view class="popupContent">
  151. <scroll-view scroll-y="true" style="height: 506rpx;">
  152. <view class="boxSty">
  153. <view v-for="(item, index) in bankList" :key="index" :data-index="index" @click="changeIndex" class="liListSty">{{ index + 1 }}</view>
  154. </view>
  155. </scroll-view>
  156. </view>
  157. </view>
  158. </u-popup>
  159. </view>
  160. </template>
  161. <script>
  162. export default {
  163. data() {
  164. return {
  165. current:0,
  166. ast: ['A', 'B', 'C', 'D',],
  167. ans:['',1,3,4,1],
  168. ques:['','','','',''],
  169. show: false,
  170. bankList: [
  171. {
  172. type:'text',
  173. arr:[],
  174. text:''
  175. },
  176. {
  177. type:'checkbox',
  178. arr:[
  179. {
  180. label: '9',
  181. value: 1,
  182. checked:false,
  183. },
  184. {
  185. label: '10',
  186. value: 2,
  187. checked:false,
  188. },
  189. {
  190. label: '11',
  191. value: 3,
  192. checked:false,
  193. },
  194. {
  195. label: '12',
  196. value: 4,
  197. checked:false,
  198. }
  199. ],
  200. },
  201. {
  202. type:'radio',
  203. arr:[{
  204. label: '13',
  205. value: 1
  206. },
  207. {
  208. label: '14',
  209. value: 2
  210. },
  211. {
  212. label: '15',
  213. value: 3
  214. },
  215. {
  216. label: '17',
  217. value: 4
  218. }],
  219. },
  220. {
  221. type:'radio',
  222. arr:[{
  223. label: '13',
  224. value: 1
  225. },
  226. {
  227. label: '14',
  228. value: 2
  229. },
  230. {
  231. label: '15',
  232. value: 3
  233. },
  234. {
  235. label: '17',
  236. value: 4
  237. }],
  238. },
  239. {
  240. type:'radio',
  241. arr:[{
  242. label: '13',
  243. value: 1
  244. },
  245. {
  246. label: '14',
  247. value: 2
  248. },
  249. {
  250. label: '15',
  251. value: 3
  252. },
  253. {
  254. label: '17',
  255. value: 4
  256. }],
  257. }]
  258. };
  259. },
  260. methods: {
  261. openFooterTab() {
  262. this.show = true;
  263. },
  264. hideDialog() {
  265. this.showDialog = false
  266. },
  267. changeIndex(e) {
  268. let index = e.currentTarget.dataset.index
  269. this.current = e.currentTarget.dataset.index
  270. },
  271. swiperChange(e) {
  272. this.current = e.detail.current;
  273. },
  274. submit() {
  275. uni.showToast({
  276. title: '交卷成功',
  277. duration: 2000,
  278. icon:'none'
  279. });
  280. return;
  281. },
  282. collect() {
  283. uni.showToast({
  284. title: '收藏成功',
  285. duration: 2000,
  286. icon:'none'
  287. });
  288. return;
  289. },
  290. click(e) {
  291. if(this.ques[this.current]) return;
  292. let value = e.currentTarget.dataset.value;
  293. this.ques[this.current] = value;
  294. this.ques = Object.assign({},this.ques)
  295. },
  296. clickCheckbox(e) {
  297. },
  298. chooseImg(e) {
  299. uni.chooseImage({
  300. count: 1, //默认9
  301. sizeType: ['original', ], //可以指定是原图还是压缩图,默认二者都有
  302. sourceType: ['album','camera'], //从相册选择
  303. success: (res) => {
  304. // console.log(JSON.stringify(res.tempFilePaths));
  305. this.bankList[e.currentTarget.dataset.index].arr.push(res.tempFilePaths)
  306. console.log(this.bankList[e.currentTarget.dataset.index])
  307. }
  308. })
  309. },
  310. deleteImg(e) {
  311. var imgIndex = e.currentTarget.dataset.imgindex;
  312. var bankIndex = e.currentTarget.dataset.bankindex;
  313. this.bankList[bankIndex].arr.splice(imgIndex,1)
  314. },
  315. submitAns(e) {
  316. let type = e.currentTarget.dataset.type;
  317. let bankindex = e.currentTarget.dataset.bankindex;
  318. if(type == 'text') {
  319. if(!this.bankList[bankindex].text || !this.bankList[bankindex].arr.length) {
  320. uni.showToast({
  321. title: '请输入内容',
  322. duration: 2000,
  323. icon:'none'
  324. });
  325. return
  326. }
  327. this.$set(this.ques,bankindex,{
  328. arr:this.bankList[bankindex].arr,
  329. text:this.bankList[bankindex].text,
  330. })
  331. } else if(type == 'checkbox') {
  332. } else {
  333. if(this.ques[this.bankindex]) return;
  334. let value = e.currentTarget.dataset.value;
  335. this.ques[this.bankindex] = value;
  336. this.ques = Object.assign({},this.ques)
  337. }
  338. }
  339. }
  340. };
  341. </script>
  342. <style lang="scss" scoped>
  343. .swiper {
  344. width:100%;
  345. height:100vh;
  346. }
  347. .lisSty {
  348. margin-bottom: 16rpx;
  349. }
  350. .activeTI {
  351. vertical-align: middle;
  352. display: inline-block;
  353. border: 1rpx solid #eee;
  354. border-radius: 50rpx;
  355. height: 48rpx;
  356. line-height: 46rpx;
  357. text-align: center;
  358. width: 48rpx;
  359. margin-right: 15rpx;
  360. color: #666;
  361. font-size: 30rpx;
  362. &.right {
  363. color:#fff;
  364. background:green;
  365. }
  366. &.wrong {
  367. color:#fff;
  368. background:red;
  369. }
  370. }
  371. .titles {
  372. margin-bottom: 24rpx;
  373. }
  374. .titBox {
  375. padding: 41rpx 25rpx 24rpx 25rpx;
  376. }
  377. .ans {
  378. margin:8rpx 8rpx 8rpx;
  379. .ans_input {
  380. border-radius: 16rpx;
  381. background:#fff;
  382. .top {
  383. border-bottom:1rpx solid #EEEEEE;
  384. padding: 16rpx;
  385. display: flex;
  386. align-items: center;
  387. .icon {
  388. margin-right:20rpx;
  389. width: 40rpx;
  390. height: 38rpx;
  391. }
  392. .progress {
  393. flex:1;
  394. }
  395. .submit {
  396. width: 168rpx;
  397. height: 48rpx;
  398. line-height: 48rpx;
  399. text-align: center;
  400. color:#fff;
  401. font-size: 30rpx;
  402. background: #007AFF;
  403. border-radius: 24rpx;
  404. }
  405. }
  406. .textarea {
  407. textarea {
  408. width:100%;
  409. height:287rpx;
  410. padding:10rpx;
  411. }
  412. }
  413. .imgs {
  414. overflow: hidden;
  415. display: flex;
  416. width:100%;
  417. .img {
  418. width: 104rpx;
  419. height: 104rpx;
  420. border-radius: 8rpx;
  421. position:relative;
  422. margin:20rpx;
  423. text {
  424. position:absolute;
  425. right:-15rpx;
  426. top:-15rpx;
  427. width:30rpx;
  428. height:30rpx;
  429. text-align: center;
  430. line-height: 30rpx;
  431. color:#fff;
  432. background:red;
  433. border-radius:50%;
  434. }
  435. image {
  436. width:100%;
  437. height:100%;
  438. }
  439. }
  440. }
  441. }
  442. .ans_submit {
  443. padding:16rpx;
  444. border-radius: 16rpx;
  445. background:#fff;
  446. .imgs {
  447. overflow: hidden;
  448. display: flex;
  449. width:100%;
  450. .img {
  451. width: 104rpx;
  452. height: 104rpx;
  453. border-radius: 8rpx;
  454. position:relative;
  455. margin:20rpx;
  456. image {
  457. width:100%;
  458. height:100%;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. .firstLetter {
  465. display: flex;
  466. justify-content: space-between;
  467. align-items: center;
  468. margin-bottom: 30rpx;
  469. .leftLetters {
  470. display: flex;
  471. align-items: center;
  472. width: 220rpx;
  473. .btnType {
  474. padding: 5rpx 10rpx;
  475. border: 1rpx solid #007aff;
  476. border-radius: 10rpx;
  477. background-color: rgba(0, 122, 255, 0.1);
  478. font-size: 28rpx;
  479. color: #007aff;
  480. margin-right: 15rpx;
  481. }
  482. }
  483. }
  484. .popupView {
  485. height: 100%;
  486. padding-bottom: 100rpx;
  487. .popupTops {
  488. height: 77rpx;
  489. border-bottom: 1rpx solid #eee;
  490. text-align: center;
  491. line-height: 77rpx;
  492. font-size: 24rpx;
  493. color: #999;
  494. position: relative;
  495. .topIcon {
  496. position: absolute;
  497. top: 10rpx;
  498. left: 50%;
  499. transform: translateX(-50%);
  500. width: 80rpx;
  501. height: 8rpx;
  502. background-color: #999;
  503. border-radius: 4rpx;
  504. }
  505. }
  506. .popupContent {
  507. }
  508. }
  509. .pageContent {
  510. background-color: #eaeef1;
  511. min-height: 100vh;
  512. padding-top: 8rpx;
  513. padding-bottom: 100rpx;
  514. }
  515. .pad_8 {
  516. background-color: #fff;
  517. margin: 0rpx 8rpx 8rpx;
  518. border-radius: 16rpx;
  519. }
  520. .answer {
  521. height: 80rpx;
  522. line-height: 80rpx;
  523. padding: 0rpx 24rpx;
  524. display: flex;
  525. align-items: center;
  526. justify-content: space-between;
  527. color: #666;
  528. font-size: 30rpx;
  529. }
  530. .footer-start {
  531. position:fixed;
  532. bottom:100rpx;
  533. left:50%;
  534. transform: translateX(-50%);
  535. width: 526rpx;
  536. height: 80rpx;
  537. background: rgba(0, 122, 255, 0.6);
  538. color:#fff;
  539. text-align: center;
  540. line-height: 80rpx;
  541. font-size: 30rpx;
  542. border-radius: 40rpx;
  543. }
  544. .submit_checkbox {
  545. margin:20rpx auto;
  546. width: 526rpx;
  547. height: 80rpx;
  548. background: rgba(0, 122, 255, 1);
  549. color:#fff;
  550. text-align: center;
  551. line-height: 80rpx;
  552. font-size: 30rpx;
  553. border-radius: 40rpx;
  554. }
  555. .footer_btn {
  556. background-color: #fff;
  557. z-index: 10078;
  558. position: fixed;
  559. bottom: 0rpx;
  560. display: flex;
  561. align-items: center;
  562. justify-content: space-between;
  563. width: 100%;
  564. height: 98rpx;
  565. padding: 0rpx 38rpx;
  566. border-top: 1rpx solid #eee;
  567. }
  568. .boxSty {
  569. padding: 44rpx 41rpx 0rpx;
  570. }
  571. .liListSty {
  572. width: 88rpx;
  573. height: 88rpx;
  574. border-radius: 32rpx;
  575. background-color: #ff3b30;
  576. text-align: center;
  577. line-height: 88rpx;
  578. color: #fff;
  579. font-size: 32rpx;
  580. float: left;
  581. margin: 20rpx 23rpx;
  582. &.disabled {
  583. border:1rpx solid #EEEEEE;
  584. color:#EEEEEE;
  585. background: none;
  586. }
  587. }
  588. .answerInfos {
  589. padding: 25rpx 25rpx 25rpx 23rpx;
  590. }
  591. .answerTitle {
  592. margin-bottom: 28rpx;
  593. color: #666;
  594. font-size: 30rpx;
  595. }
  596. .answerContent {
  597. font-size: 30rpx;
  598. color: #666;
  599. }
  600. </style>