recorddetail.vue
9.6 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<template >
<div >
<img src="../../assets/img/bg3.png" class="bg3" alt="">
<nav-bar class="examnavbar">
<div slot="left" class="backnav" @click="goBack">
<img src="../../assets/img/back.png" alt="">
</div>
<div slot="center" class="center display-flex" >
</div>
<div slot="right" >
<div @click="tocard" class="picker display-flex">
<div>答题卡</div>
<img src="../../assets/img/card.png" alt="">
</div>
</div>
</nav-bar>
<div class="examcont">
<div class="examone">
<div class="exam_title" v-if="!!subjectList.item">({{num+1}}/{{alltest.length}}) {{ subjectList.item.title }}
<span v-if="subjectList.type==2">(多选)</span>
<span v-if="subjectList.type==3">(判断)</span>
<span v-if="subjectList.type==1">(单选)</span>
</div>
<div v-for="(item,index) in options_arr"
:key="index">
<div
v-if="!!item.value"
class="key_one"
:class="subjectList.answer.indexOf(item.option_name)==-1?'':subjectList.item.correct.indexOf(item.option_name)==-1?'red':'active'"
@click="option(item,index)">
<div>{{item.option_name}} . {{item.value}}</div>
<div class="img_list" v-if="item.pic">
<template v-for="(item_pic,index_pic) in item.pic_arr">
<img :src="item_pic" :key="index_pic" alt=""/>
</template>
</div>
</div>
</div>
<div class="footer display-flex-between" ref="footer">
<div v-if="num!=0" class="nexttest display-flex">
<div class="common_handle" @click="upClick">
<img src="../../assets/img/next.png" alt="">
<span>上一题</span>
</div>
</div>
<div v-if="num!=alltest.length-1" class="nexttest display-flex">
<div class="common_handle" @click="nextClick">
<span>下一题</span>
<img src="../../assets/img/last.png" alt="">
</div>
</div>
</div>
</div>
<div class="line"></div>
<div class="correct" v-if="!!subjectList.item">正确答案:{{ subjectList.item.correct }}</div>
<div class="analy" :style="{'margin-bottom': content_bottom+'px'}" v-if="!!subjectList.item">解析: {{subjectList.item.remark}}</div>
</div>
</div>
</template>
<script>
import model from '@/components/model'
export default {
name: 'examDetail',
data () {
return {
disabled: false, // 选项是否禁用
showClose: false,
showClose1: true,
overicon: require('@/assets/img/over2.png'),
ifover: false,
ifsubmit2: false,
iftime: false,
ifsubmit3: false,
time: 60 * 1000,
timelo: '',
active: 0,
alltest: [], // list里所有题
subjectList: {}, // 每一题数据
num: 0, // 题组下标
answerId: '', // 答题id
id: '',
type: '',
options_arr: '',
content_bottom: 0
}
},
methods: {
goBack () {
this.$router.push('record')
localStorage.removeItem('alltest')
localStorage.removeItem('testindex')
localStorage.removeItem('answerId')
localStorage.removeItem('timelo')
},
// 答题卡 (判断当前题目是否提交)
async tocard () {
this.$router.push('/cardmy')
},
// 上一题
upClick () {
--this.num
this.subjectList = this.alltest[this.num]
this.options_arr = this.subjectList.item.options_arr
this.chooseone = this.subjectList.chooseone
localStorage.setItem('testindex', this.num)
},
// 下一题
async nextClick () {
const that = this
++this.num
this.subjectList = this.alltest[this.num]
this.options_arr = this.subjectList.item.options_arr
this.chooseone = this.subjectList.chooseone
localStorage.setItem('testindex', this.num)
},
async getlist () {
const that = this
const params = {
id: that.id
}
const res = await this.api.getrecorddetail(params)
if (res.code === 1) {
that.alltest = res.data.list
localStorage.setItem('alltest', JSON.stringify(this.alltest)) // 本地存储题组
localStorage.setItem('testindex', Number(this.num))
this.subjectList = res.data.list[Number(this.num)]
this.options_arr = this.subjectList.item.options_arr
console.log(this.subjectList)
}
}
},
mounted () {
if (localStorage.getItem('testindex')) {
this.num = Number(localStorage.getItem('testindex'))
this.alltest = JSON.parse(localStorage.getItem('alltest'))
this.subjectList = this.alltest[this.num]
if (this.subjectList.item) {
this.options_arr = this.subjectList.item.options_arr
}
localStorage.removeItem('testindex')
} else {
this.id = this.$route.query.id
this.type = this.$route.query.type
this.num = 0
this.getlist()
}
this.content_bottom = this.$refs.footer.clientHeight;
console.log(this.$refs.footer.clientHeight,123123132);
}
}
</script>
<style lang="scss" scoped>
.bg3{
width: 100%;
height: 5.48rem;
position: absolute;
top: 0;
z-index: 0;
}
.examnavbar{
position: fixed;
top: 0;
z-index: 9;
}
.examcont{
position: relative;
top: 0.88rem;
z-index: 1;
bottom: 1rem;
}
.picker,.backnav{
width: 1.6rem;
}
.backnav{
font-size: 0.48rem;
height: 0.48rem;
}
.backnav img{
width: 0.48rem;
height: 0.48rem;
}
.picker{
justify-content: flex-end;
}
.picker img{
margin-left: 0.2rem;
}
.centernav{
width: 3.6rem;
margin-left: 0.6rem;
color: rgba(51,51,51,1);
font-size: 0.34rem;
font-weight: 700;
justify-content: center;
}
.center_title{
margin-right: 0.2rem;
}
.examone{
width: 100%;
height: auto;
padding: 0 0.32rem;
box-sizing: border-box;
}
.exam_title{
color: rgba(37.19,124.31,255,1);
font-size: 0.36rem;
font-weight: 600;
font-family: "PingFang SC";
text-align: left;
line-height: 0.52rem;
letter-spacing: 0.01rem;
margin: 0.48rem 0;
}
.exam_title span{
color: grey;
font-weight: 400;
font-size: 0.30rem;
}
.key_one{
width: 6.86rem;
height: auto;
border-radius: 0.08rem;
opacity: 1;
background: rgba(255,255,255,1);
color: rgba(50,50,51,1);
border: 0.01rem solid #eee;
font-size: 0.28rem;
font-weight: 400;
font-family: "PingFang SC";
text-align: left;
line-height: 0.44rem;
padding: 0.4rem 0.32rem;
box-sizing: border-box;
margin-bottom: 0.24rem;
}
.img_list {
display: flex;
}
.img_list img{
width: 1rem;
margin-top: .2rem;
margin-right: .1rem;
display: flex;
}
.active{
background: rgba(37.19,124.31,255,0.08);
color:#257CFF ;
border: 0.01rem solid #257CFF;
}
.red{
background: rgba(233,64,90,0.08);
color:#E9405A ;
border: 0.01rem solid #E9405A;
}
.nofaved{
width: 1.28rem;
height: 1.28rem;
border-radius: 0.08rem;
opacity: 1;
background: rgba(255,255,255,1);
color: rgba(150,151,153,1);
font-size: 0.24rem;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
border: 0.01rem solid #eee;
margin: 0.8rem 0.8rem 0 0;
float: right;
}
.faved{
width: 1.28rem;
height: 1.28rem;
border-radius: 0.08rem;
opacity: 1;
background: rgba(255,255,255,1);
color: #257CFF;
font-size: 0.24rem;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
border: 0.01rem solid #257CFF;
margin: 0.8rem 0.8rem 0 0;
float: right;
}
.nofaved img,.faved img{
width: 0.44rem;
height: 0.44rem;
}
.nexttest{
width: 85%;
color: rgba(37.19,124.31,255,1);
font-size: 0.28rem;
}
.nexttest img{
width:0.4rem;
height: 0.4rem;
margin: 0 0.1rem;
}
.nexttest .common_handle {
display: flex;
}
.correct{
width: 3.3rem;
// height: 0.8rem;
line-height: 0.8rem;
text-align: center;
border-radius: 0.08rem;
opacity: 1;
background: rgba(0,231.63,162.14,0.08);
color: rgba(0,231.63,161.44,1);
font-size: 0.36rem;
margin: 0.32rem;
}
.analy{
color: rgba(150,151,153,1);
font-size: 0.28rem;
font-weight: 400;
font-family: "PingFang SC";
text-align: left;
line-height: 0.44rem;
padding:0 0.32rem 0.96rem;
box-sizing: border-box;
}
.footer{
border-top: 0.01rem solid #eee;
padding: 0.32rem 0.32rem;
}
</style>