questionBankTest.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. id:'',
  78. current:0,
  79. ast: ['A', 'B', 'C', 'D',],
  80. ans:[1,2,3,4,1],
  81. ques:['','','','',''],
  82. show: false,
  83. showDialog:true,
  84. bankList: [
  85. [
  86. {
  87. label: '1',
  88. value: 1
  89. },
  90. {
  91. label: '2',
  92. value: 2
  93. },
  94. {
  95. label: '3',
  96. value: 3
  97. },
  98. {
  99. label: '4',
  100. value: 4
  101. }
  102. ],
  103. [
  104. {
  105. label: '5',
  106. value: 1
  107. },
  108. {
  109. label: '6',
  110. value: 2
  111. },
  112. {
  113. label: '7',
  114. value: 3
  115. },
  116. {
  117. label: '8',
  118. value: 4
  119. }
  120. ],
  121. [
  122. {
  123. label: '9',
  124. value: 1
  125. },
  126. {
  127. label: '10',
  128. value: 2
  129. },
  130. {
  131. label: '11',
  132. value: 3
  133. },
  134. {
  135. label: '12',
  136. value: 4
  137. }
  138. ],
  139. [
  140. {
  141. label: '13',
  142. value: 1
  143. },
  144. {
  145. label: '14',
  146. value: 2
  147. },
  148. {
  149. label: '15',
  150. value: 3
  151. },
  152. {
  153. label: '17',
  154. value: 4
  155. }
  156. ],
  157. [
  158. {
  159. label: '18',
  160. value: 1
  161. },
  162. {
  163. label: '19',
  164. value: 2
  165. },
  166. {
  167. label: '21',
  168. value: 3
  169. },
  170. {
  171. label: '22',
  172. value: 4
  173. }
  174. ]
  175. ]
  176. };
  177. },
  178. onLoad(option){
  179. this.id = option.id;
  180. this.goodsQuestionList()
  181. },
  182. methods: {
  183. goodsQuestionList() {
  184. this.$api.goodsQuestionList({
  185. examId:this.id
  186. }).then(res => {
  187. console.log(res)
  188. })
  189. },
  190. openFooterTab() {
  191. this.show = true;
  192. },
  193. hideDialog() {
  194. this.showDialog = false
  195. },
  196. changeIndex(e) {
  197. let index = e.currentTarget.dataset.index
  198. if(index >= 5) {
  199. uni.showToast({
  200. title: '返回详情购买后即可继续',
  201. duration: 2000,
  202. icon:'none'
  203. });
  204. return;
  205. }
  206. this.current = e.currentTarget.dataset.index
  207. },
  208. swiperChange(e) {
  209. this.current = e.detail.current;
  210. },
  211. submit() {
  212. uni.showToast({
  213. title: '不能试做返回详情购买后即可交卷~',
  214. duration: 2000,
  215. icon:'none'
  216. });
  217. return;
  218. },
  219. collect() {
  220. uni.showToast({
  221. title: '返回详情购买后即可收藏~',
  222. duration: 2000,
  223. icon:'none'
  224. });
  225. return;
  226. },
  227. click(e) {
  228. if(this.ques[this.current]) return;
  229. let value = e.currentTarget.dataset.value;
  230. this.ques[this.current] = value;
  231. this.ques = Object.assign({},this.ques)
  232. }
  233. }
  234. };
  235. </script>
  236. <style lang="scss" scoped>
  237. .swiper {
  238. width:100%;
  239. height:100vh;
  240. }
  241. .lisSty {
  242. margin-bottom: 16rpx;
  243. }
  244. .activeTI {
  245. vertical-align: middle;
  246. display: inline-block;
  247. border: 1rpx solid #eee;
  248. border-radius: 50rpx;
  249. height: 48rpx;
  250. line-height: 46rpx;
  251. text-align: center;
  252. width: 48rpx;
  253. margin-right: 15rpx;
  254. color: #666;
  255. font-size: 30rpx;
  256. &.right {
  257. color:#fff;
  258. background:green;
  259. }
  260. &.wrong {
  261. color:#fff;
  262. background:red;
  263. }
  264. }
  265. .titles {
  266. margin-bottom: 24rpx;
  267. }
  268. .titBox {
  269. padding: 41rpx 25rpx 24rpx 25rpx;
  270. }
  271. .firstLetter {
  272. display: flex;
  273. justify-content: space-between;
  274. align-items: center;
  275. margin-bottom: 30rpx;
  276. .leftLetters {
  277. display: flex;
  278. align-items: center;
  279. width: 220rpx;
  280. .btnType {
  281. padding: 5rpx 10rpx;
  282. border: 1rpx solid #007aff;
  283. border-radius: 10rpx;
  284. background-color: rgba(0, 122, 255, 0.1);
  285. font-size: 28rpx;
  286. color: #007aff;
  287. margin-right: 15rpx;
  288. }
  289. }
  290. }
  291. .popupView {
  292. height: 100%;
  293. padding-bottom: 100rpx;
  294. .popupTops {
  295. height: 77rpx;
  296. border-bottom: 1rpx solid #eee;
  297. text-align: center;
  298. line-height: 77rpx;
  299. font-size: 24rpx;
  300. color: #999;
  301. position: relative;
  302. .topIcon {
  303. position: absolute;
  304. top: 10rpx;
  305. left: 50%;
  306. transform: translateX(-50%);
  307. width: 80rpx;
  308. height: 8rpx;
  309. background-color: #999;
  310. border-radius: 4rpx;
  311. }
  312. }
  313. .popupContent {
  314. }
  315. }
  316. .pageContent {
  317. background-color: #eaeef1;
  318. min-height: 100vh;
  319. padding-top: 8rpx;
  320. padding-bottom: 100rpx;
  321. }
  322. .pad_8 {
  323. background-color: #fff;
  324. margin: 0rpx 8rpx 8rpx;
  325. border-radius: 16rpx;
  326. }
  327. .answer {
  328. height: 80rpx;
  329. line-height: 80rpx;
  330. padding: 0rpx 24rpx;
  331. display: flex;
  332. align-items: center;
  333. justify-content: space-between;
  334. color: #666;
  335. font-size: 30rpx;
  336. }
  337. .footer_btn {
  338. background-color: #fff;
  339. z-index: 10078;
  340. position: fixed;
  341. bottom: 0rpx;
  342. display: flex;
  343. align-items: center;
  344. justify-content: space-between;
  345. width: 100%;
  346. height: 98rpx;
  347. padding: 0rpx 38rpx;
  348. border-top: 1rpx solid #eee;
  349. }
  350. .boxSty {
  351. padding: 44rpx 41rpx 0rpx;
  352. }
  353. .liListSty {
  354. width: 88rpx;
  355. height: 88rpx;
  356. border-radius: 32rpx;
  357. background-color: #ff3b30;
  358. text-align: center;
  359. line-height: 88rpx;
  360. color: #fff;
  361. font-size: 32rpx;
  362. float: left;
  363. margin: 20rpx 23rpx;
  364. &.disabled {
  365. border:1rpx solid #EEEEEE;
  366. color:#EEEEEE;
  367. background: none;
  368. }
  369. }
  370. .answerInfos {
  371. padding: 25rpx 25rpx 25rpx 23rpx;
  372. }
  373. .answerTitle {
  374. margin-bottom: 28rpx;
  375. color: #666;
  376. font-size: 30rpx;
  377. }
  378. .answerContent {
  379. font-size: 30rpx;
  380. color: #666;
  381. }
  382. .dialog {
  383. position: fixed;
  384. left:0;
  385. top:0;
  386. width:100%;
  387. height:100%;
  388. background-color: rgba(0,0,0,0.8);
  389. display: flex;
  390. flex-direction: column;
  391. align-items: center;
  392. justify-content: center;
  393. z-index: 20000;
  394. .text {
  395. font-size: 32rpx;
  396. color: #FFFFFF;
  397. text-align: center;
  398. }
  399. .btn {
  400. width: 242rpx;
  401. height: 82rpx;
  402. border: 2rpx solid #FFFFFF;
  403. border-radius: 16rpx;
  404. text-align: center;
  405. line-height: 82rpx;
  406. margin:41rpx auto;
  407. color:#fff;
  408. font-size: 32rpx;
  409. }
  410. }
  411. </style>