questionBankTest.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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 class="pageContent">
  6. <view class="pad_8 titBox">
  7. <view class="firstLetter">
  8. <view class="leftLetters">
  9. <view class="btnType">单选</view>
  10. <text>1/{{current}}</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 class="">
  17. <view v-if="ques[bankIndex] ">
  18. <view v-for="(item, index) in bank" :key="index"
  19. class="lisSty">
  20. <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>
  21. {{ item.label }}
  22. </view>
  23. </view>
  24. <view v-if="!ques[bankIndex]">
  25. <view v-for="(item, index) in bank" :key="index" @click="click" :data-value="item.value" class="lisSty">
  26. <text class="activeTI">{{ ast[index] }}</text>
  27. {{ item.label }}
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view v-if="ques[bankIndex]">
  33. <view class="pad_8 answer">
  34. <view>正确答案:{{ans[bankIndex]}}</view>
  35. <view>我的答案:{{ques[bankIndex]}}</view>
  36. </view>
  37. <view class="pad_8 answerInfos">
  38. <view class="answerTitle">答案解析</view>
  39. <view class="answerContent">
  40. 建造师执业资格注册有效期一般为3年,有效期满前3个月,持证者应到原注册管理机构办理再次注册手续。在注册有效期内,变更执业单位者,应当及时办理变更手续。
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </swiper-item>
  46. </swiper>
  47. <view class="footer_btn">
  48. <view @click="collect">收藏</view>
  49. <view @click="openFooterTab">答题卡</view>
  50. <view @click="submit">交卷</view>
  51. </view>
  52. <u-popup v-model="show" mode="bottom" border-radius="14" height="680rpx">
  53. <view class="popupView">
  54. <view class="popupTops">
  55. <view class="topIcon"></view>
  56. 点击编号即可跳转至对应题目
  57. </view>
  58. <view class="popupContent">
  59. <scroll-view scroll-y="true" style="height: 506rpx;">
  60. <view class="boxSty">
  61. <view v-for="(item, index) in 10" :key="index" :data-index="index" @click="changeIndex" :class="{disabled:index>=5}" class="liListSty">{{ index + 1 }}</view>
  62. </view>
  63. </scroll-view>
  64. </view>
  65. </view>
  66. </u-popup>
  67. <view class="dialog" v-if="showDialog">
  68. <view class="text">左右滑动切换上下题</view>
  69. <view class="btn" @click="hideDialog">我知道了</view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. data() {
  76. return {
  77. current:0,
  78. ast: ['A', 'B', 'C', 'D',],
  79. ans:[1,2,3,4,1],
  80. ques:['','','','',''],
  81. show: false,
  82. showDialog:true,
  83. bankList: [
  84. [
  85. {
  86. label: '1',
  87. value: 1
  88. },
  89. {
  90. label: '2',
  91. value: 2
  92. },
  93. {
  94. label: '3',
  95. value: 3
  96. },
  97. {
  98. label: '4',
  99. value: 4
  100. }
  101. ],
  102. [
  103. {
  104. label: '5',
  105. value: 1
  106. },
  107. {
  108. label: '6',
  109. value: 2
  110. },
  111. {
  112. label: '7',
  113. value: 3
  114. },
  115. {
  116. label: '8',
  117. value: 4
  118. }
  119. ],
  120. [
  121. {
  122. label: '9',
  123. value: 1
  124. },
  125. {
  126. label: '10',
  127. value: 2
  128. },
  129. {
  130. label: '11',
  131. value: 3
  132. },
  133. {
  134. label: '12',
  135. value: 4
  136. }
  137. ],
  138. [
  139. {
  140. label: '13',
  141. value: 1
  142. },
  143. {
  144. label: '14',
  145. value: 2
  146. },
  147. {
  148. label: '15',
  149. value: 3
  150. },
  151. {
  152. label: '17',
  153. value: 4
  154. }
  155. ],
  156. [
  157. {
  158. label: '18',
  159. value: 1
  160. },
  161. {
  162. label: '19',
  163. value: 2
  164. },
  165. {
  166. label: '21',
  167. value: 3
  168. },
  169. {
  170. label: '22',
  171. value: 4
  172. }
  173. ]
  174. ]
  175. };
  176. },
  177. methods: {
  178. openFooterTab() {
  179. this.show = true;
  180. },
  181. hideDialog() {
  182. this.showDialog = false
  183. },
  184. changeIndex(e) {
  185. let index = e.currentTarget.dataset.index
  186. if(index >= 5) {
  187. uni.showToast({
  188. title: '返回详情购买后即可继续',
  189. duration: 2000,
  190. icon:'none'
  191. });
  192. return;
  193. }
  194. this.current = e.currentTarget.dataset.index
  195. },
  196. swiperChange(e) {
  197. this.current = e.detail.current;
  198. },
  199. submit() {
  200. uni.showToast({
  201. title: '不能试做返回详情购买后即可交卷~',
  202. duration: 2000,
  203. icon:'none'
  204. });
  205. return;
  206. },
  207. collect() {
  208. uni.showToast({
  209. title: '返回详情购买后即可收藏~',
  210. duration: 2000,
  211. icon:'none'
  212. });
  213. return;
  214. },
  215. click(e) {
  216. if(this.ques[this.current]) return;
  217. let value = e.currentTarget.dataset.value;
  218. this.ques[this.current] = value;
  219. this.ques = Object.assign({},this.ques)
  220. }
  221. }
  222. };
  223. </script>
  224. <style lang="scss" scoped>
  225. .swiper {
  226. width:100%;
  227. height:100vh;
  228. }
  229. .lisSty {
  230. margin-bottom: 16rpx;
  231. }
  232. .activeTI {
  233. vertical-align: middle;
  234. display: inline-block;
  235. border: 1rpx solid #eee;
  236. border-radius: 50rpx;
  237. height: 48rpx;
  238. line-height: 46rpx;
  239. text-align: center;
  240. width: 48rpx;
  241. margin-right: 15rpx;
  242. color: #666;
  243. font-size: 30rpx;
  244. &.right {
  245. color:#fff;
  246. background:green;
  247. }
  248. &.wrong {
  249. color:#fff;
  250. background:red;
  251. }
  252. }
  253. .titles {
  254. margin-bottom: 24rpx;
  255. }
  256. .titBox {
  257. padding: 41rpx 25rpx 24rpx 25rpx;
  258. }
  259. .firstLetter {
  260. display: flex;
  261. justify-content: space-between;
  262. align-items: center;
  263. margin-bottom: 30rpx;
  264. .leftLetters {
  265. display: flex;
  266. align-items: center;
  267. width: 220rpx;
  268. .btnType {
  269. padding: 5rpx 10rpx;
  270. border: 1rpx solid #007aff;
  271. border-radius: 10rpx;
  272. background-color: rgba(0, 122, 255, 0.1);
  273. font-size: 28rpx;
  274. color: #007aff;
  275. margin-right: 15rpx;
  276. }
  277. }
  278. }
  279. .popupView {
  280. height: 100%;
  281. padding-bottom: 100rpx;
  282. .popupTops {
  283. height: 77rpx;
  284. border-bottom: 1rpx solid #eee;
  285. text-align: center;
  286. line-height: 77rpx;
  287. font-size: 24rpx;
  288. color: #999;
  289. position: relative;
  290. .topIcon {
  291. position: absolute;
  292. top: 10rpx;
  293. left: 50%;
  294. transform: translateX(-50%);
  295. width: 80rpx;
  296. height: 8rpx;
  297. background-color: #999;
  298. border-radius: 4rpx;
  299. }
  300. }
  301. .popupContent {
  302. }
  303. }
  304. .pageContent {
  305. background-color: #eaeef1;
  306. min-height: 100vh;
  307. padding-top: 8rpx;
  308. padding-bottom: 100rpx;
  309. }
  310. .pad_8 {
  311. background-color: #fff;
  312. margin: 0rpx 8rpx 8rpx;
  313. border-radius: 16rpx;
  314. }
  315. .answer {
  316. height: 80rpx;
  317. line-height: 80rpx;
  318. padding: 0rpx 24rpx;
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. color: #666;
  323. font-size: 30rpx;
  324. }
  325. .footer_btn {
  326. background-color: #fff;
  327. z-index: 10078;
  328. position: fixed;
  329. bottom: 0rpx;
  330. display: flex;
  331. align-items: center;
  332. justify-content: space-between;
  333. width: 100%;
  334. height: 98rpx;
  335. padding: 0rpx 38rpx;
  336. border-top: 1rpx solid #eee;
  337. }
  338. .boxSty {
  339. padding: 44rpx 41rpx 0rpx;
  340. }
  341. .liListSty {
  342. width: 88rpx;
  343. height: 88rpx;
  344. border-radius: 32rpx;
  345. background-color: #ff3b30;
  346. text-align: center;
  347. line-height: 88rpx;
  348. color: #fff;
  349. font-size: 32rpx;
  350. float: left;
  351. margin: 20rpx 23rpx;
  352. &.disabled {
  353. border:1rpx solid #EEEEEE;
  354. color:#EEEEEE;
  355. background: none;
  356. }
  357. }
  358. .answerInfos {
  359. padding: 25rpx 25rpx 25rpx 23rpx;
  360. }
  361. .answerTitle {
  362. margin-bottom: 28rpx;
  363. color: #666;
  364. font-size: 30rpx;
  365. }
  366. .answerContent {
  367. font-size: 30rpx;
  368. color: #666;
  369. }
  370. .dialog {
  371. position: fixed;
  372. left:0;
  373. top:0;
  374. width:100%;
  375. height:100%;
  376. background-color: rgba(0,0,0,0.8);
  377. display: flex;
  378. flex-direction: column;
  379. align-items: center;
  380. justify-content: center;
  381. z-index: 20000;
  382. .text {
  383. font-size: 32rpx;
  384. color: #FFFFFF;
  385. text-align: center;
  386. }
  387. .btn {
  388. width: 242rpx;
  389. height: 82rpx;
  390. border: 2rpx solid #FFFFFF;
  391. border-radius: 16rpx;
  392. text-align: center;
  393. line-height: 82rpx;
  394. margin:41rpx auto;
  395. color:#fff;
  396. font-size: 32rpx;
  397. }
  398. }
  399. </style>