examcard.vue
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<template >
<div class="body">
<img src="../../assets/img/bg3.png" class="bg3" alt="">
<nav-bar class="examnavbar">
<div slot="left" class="back" @click="goBack">
<img src="../../assets/img/back.png" alt="">
</div>
<div slot="center" class="center display-flex" v-if="time">
<div class="cardtitle">倒计时</div>
<van-count-down :time="time" @change="change"/>
</div>
<div slot="right" class="picker"></div>
</nav-bar>
<div :style="{height:+height+'px'}" class="scrollcont">
<Scroll
style="height: 100%"
ref="scroll"
:scrollX="scrollX"
:probeType=3
:pullup="true"
>
<div class="cardss">
<div class="title">答题卡</div>
<div class="display-flex cards">
<!-- @click="item.active=!item.active" -->
<div
@click="startAnswer(item,index)"
:class="item.active?'activecard':''"
v-for="(item,index) in card"
:key="index"
class="card_one">
{{ index + 1 }}
<img v-if="item.iftrue!=''||item.user_answer" src="../../assets/img/yes.png" class="status" alt="">
<!-- <img v-if="item.iftrue==2" src="../../assets/img/no.png" class="status" alt=""> -->
</div>
</div>
</div>
</Scroll>
</div>
</div>
</template>
<script>
import Scroll from '@/components/scroll.vue'
export default {
components: {
Scroll
},
data () {
return {
time: 60 * 1000,
card: [],
arr: [],
number: 0,
timelo: '',
scrollX: false,
height: ''
}
},
created () {
localStorage.setItem('card',true);
this.height = document.documentElement.clientHeight
},
mounted () {
if (this.$route.query.time) {
let timelo = localStorage.getItem('timelo')
this.time = timelo ? timelo*1000 : this.$route.query.time// 所有题
} else {
this.time = false
}
let alltest = localStorage.getItem('alltest')
this.card = alltest ? JSON.parse(alltest) :this.$route.query.alltest // 所有题
},
methods: {
goBack () {
this.$router.go(-1)
localStorage.removeItem('timelo')
localStorage.setItem('timelo', this.timelo/1000)
},
change (e) {
this.timelo = (e.hours * 3600 + e.minutes * 60 + e.seconds) * 1000;
localStorage.setItem('timelo',this.timelo/1000);
},
startAnswer (item, index) {
localStorage.removeItem('testindex')
localStorage.setItem('testindex', index)
if (this.time) {
localStorage.setItem('timelo', this.timelo/1000)
}
this.$router.go(-1)
}
}
}
</script>
<style lang="scss">
.body{
height: 100vh;
overflow: hidden;
background: #f7f8fa;
}
.scrollcont{
width: 100%;
position: fixed;
left: 50%;
transform: translate(-50%,0);
top: 1rem;
overflow: hidden;
padding-bottom: 0.32rem;
}
.bg3{
width: 100%;
height: 5.48rem;
position: absolute;
top: 0;
z-index: 0;
}
.examnavbar{
position: fixed;
top: 0;
z-index: 9;
}
.picker,.back{
width: 1.6rem;
}
.back img{
width: 0.48rem;
height: 0.48rem;
}
.center{
color: rgba(51,51,51,1);
font-size: 0.34rem;
font-weight: 700;
justify-content: center;
}
.cardtitle{
margin-right: 0.2rem;
}
.cardss{
width: 100%;
height: auto;
padding:0.0 0.32rem 0.48rem;
box-sizing: border-box;
}
.title{
color: rgba(50,50,51,1);
font-size: 0.48rem;
font-weight: 600;
}
.cards{
flex-wrap: wrap;
margin-top: 0.4rem;
padding-bottom: 0.32rem;
}
.card_one{
width: 1.52rem;
height: 1.52rem;
border-radius: 0.08rem;
opacity: 1;
text-align: center;
line-height: 1.52rem;
margin:0 0.2rem 0.26rem 0;
font-size: 0.72rem;
font-weight: 600;
background: rgba(255,255,255,1);
color: #000;
border: 0.01rem solid #fff;
position: relative;
}
.status{
position: absolute;
top: 0.01rem;
left: 0.01rem;
width:0.4rem;
height: 0.4rem;
}
.card_one:nth-child(4n){
margin-right: 0;
}
.activecard{
color: rgba(37.19,124.31,255,1);
border: 0.01rem solid #257CFF;
background: rgba(37.19,124.31,255,0.08);
}
</style>