Browse Source

编写了错题界面的页面设计

milestone-20251107-股票知识测评
chenzhen 2 months ago
parent
commit
e34f9f697d
  1. 6
      src/views/HomeView.vue
  2. 181
      src/views/ProblemView.vue
  3. 56
      src/views/TextView.vue

6
src/views/HomeView.vue

@ -18,8 +18,8 @@ export default {
methods:{
async jumpPage(){
const submissionData={
// jwcode:90098890,
jwcode:90098888
// jwcode:90098889,//
jwcode:90098892,//
};
localStorage.setItem('submissionData', JSON.stringify(submissionData));
console.log('存储的数据:', localStorage.getItem('submissionData'));
@ -40,7 +40,7 @@ export default {
},
async mounted(){
localStorage.removeItem('submissionData');
}
},
}
</script>

181
src/views/ProblemView.vue

@ -1,3 +1,67 @@
<script>
import axios from 'axios';
export default {
data() {
return {
problems: [],
showDialog: false,
currentPage: 1,
answers:{},
}
},
computed:{
currentProblem() {
const startIndex = (this.currentPage - 1) * 2;
return this.problems.slice(startIndex, startIndex + 2);
},
},
methods: {
jump() {
this.showDialog = true;
},
closeDialog() {
this.showDialog = false;
},
confirmExit() {
this.showDialog = false;
this.$router.push({ name: 'ReportView' });
},
async problemAnswers() {
const savedData = JSON.parse(localStorage.getItem('submissionData'));
console.log('第一个,存储的数据:', savedData.jwcode);
const submission = {
jwcode: savedData.jwcode
};
try{
const response = await axios.post('http://192.168.40.41:8000/api/knowledge/wrong-questions',submission);
this.problems = response.data.data.list;
console.log("完整响应:", response);
}catch(error){
console.error('获取错误问题失败:', error);
}
},
before(){
if(this.currentPage > 1){
this.currentPage--;
}
},
next(){
if(this.currentPage < 25){
this.currentPage++;
}
},
setAnswer(id, val) {
this.answers[id] = val;
},
getAnswer(id) {
return this.answers[id];
},
},
async mounted(){
await this.problemAnswers();
}
}
</script>
<template>
<div class="home">
<div class="top">
@ -21,53 +85,40 @@
</div>
</div>
<div class="content">
<div class="question-all">
<div class="question-all" v-if="currentProblem.length">
<div v-for="problem in currentProblem" :key="problem.id" class="question-card">
<div class="question">
<span class="text">{{problem.id}}</span>{{ problem.stem }}
<span class="text">{{problem.question.id}}</span>{{ problem.question.stem }}
</div>
<div class="options">
<label class="option" @click="setAnswer(problem.question.id, 'A')" :class="{ 'selected': getAnswer(problem.question.id) === 'A' }">
<input type="radio" :name="'answer' + problem.question.id" value="A"><span class="label">C. {{ problem.question.A }}</span>
</label>
<label class="option" @click="setAnswer(problem.question.id, 'B')" :class="{ 'selected': getAnswer(problem.question.id) === 'B' }">
<input type="radio" :name="'answer' + problem.question.id" value="B"><span class="label">D. {{ problem.question.B }}</span>
</label>
<label class="option" @click="setAnswer(problem.question.id, 'C')" :class="{ 'selected': getAnswer(problem.question.id) === 'C' }">
<input type="radio" :name="'answer' + problem.question.id" value="C"><span class="label">E. {{ problem.question.C }}</span>
</label>
<label class="option" @click="setAnswer(problem.question.id, 'D')" :class="{ 'selected': getAnswer(problem.question.id) === 'D' }">
<input type="radio" :name="'answer' + problem.question.id" value="D"><span class="label">F. {{ problem.question.D }}</span>
</label>
</div>
</div>
<div class="options">
<lable class="option">
<input type="radio">
</lable>
<lable class="option">
<input type="radio">
</lable>
<lable class="option">
<input type="radio">
</lable>
<lable class="option">
<input type="radio">
</lable>
</div>
</div>
<div class="buttons-left">
<button class="before-btn" @click="before" >
上一页
</button>
<span class="page"> {{ currentPage }} / 25 </span>
<button class="next-btn" @click="next" >
下一页
</button>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
showDialog: false
}
},
methods: {
jump() {
this.showDialog = true;
},
closeDialog() {
this.showDialog = false;
},
confirmExit() {
this.showDialog = false;
this.$router.push({ name: 'ReportView' });
}
}
}
</script>
<style scoped>
* {
margin: 0;
@ -172,4 +223,56 @@ p{
flex-direction: column;
gap: 30px;
}
.question{
font-size: 1.3em;
line-height: 1.8;
margin-bottom: 25px;
color: #f1f5f9;
font-weight: 500;
}
.options {
display: flex;
flex-direction: column;
gap: 15px;
}
.option {
border: #183954 solid 2px;
border-radius: 10px;
padding: 12px 15px;
display: flex;
align-items: center;
cursor: pointer;
transition: all 0.3s ease;
background-color: #374151;
}
.option:hover {
border-color: #3b82f6;
background-color: #4b5563;
}
.option input {
margin-right: 15px;
width: 18px;
height: 18px;
accent-color: #3b82f6;
}
.option .label {
font-size: 1.1em;
color: #e5e7eb;
}
.option.selected {
border-color: #3b82f6;
background-color: rgba(59, 130, 246, 0.2);
}
.buttons-left{
text-align: center;
margin: auto;
}
.before-btn{
padding: 12px 30px;
border: none;
border-radius: 8px;
font-size: 1em;
font-weight: bold;
min-width: 100px;
}
</style>

56
src/views/TextView.vue

@ -29,7 +29,6 @@
<div class="questions-container">
<div v-for="question in currentQuestions" :key="question.id" class="question-card">
<div class="question-header">
<!-- <span class="question-number"> {{ getQuestionIndex(question.id) }} </span> -->
<div class="question">
<span class="text-lg font-bold mr-2">{{ question.id }}</span>
{{ question.stem }}
@ -160,14 +159,14 @@
@click="changeNavPage(1)"
:class="{ active: page === 1 }"
>
一页
一页
</button>
<button
class="pagination-btn"
@click="changeNavPage(2)"
:class="{ active: page === 2 }"
>
第二
下一
</button>
</div>
</div>
@ -208,6 +207,11 @@ export default {
showTeam: false,
};
},
created() {
for (let i = 1; i <= this.totalQuestions; i++) {
this.$set(this.answers, i, 0)
}
},
computed: {
//
currentQuestions() {
@ -221,7 +225,9 @@ export default {
return Math.ceil(this.questions.length / this.questionsPerPage);
},
answeredCount() {
return Object.keys(this.answers).length;
return Object.keys(this.answers).filter(
key => this.answers[key] !== 0
).length
},
completionRate() {
return (this.answeredCount / this.totalQuestions) * 100;
@ -242,8 +248,6 @@ export default {
this.questions = response.data.data.list;
} catch (error) {
console.error('获取题目失败:', error);
// 使
this.questions = this.getDefaultQuestions();
}
},
@ -371,14 +375,9 @@ export default {
//
if (remainingMinutes <= 0 && !this.isSubmitted) {
this.isSubmitted = true;
this.autoSubmitTest();
this.submitAnswers();
}
},
//
async autoSubmitTest() {
alert('考试时间已结束,系统将自动提交试卷!');
await this.submitAnswers();
},
//
async submitAnswers() {
try {
@ -462,7 +461,7 @@ export default {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 10px;
margin: auto;
margin: auto 30px;
}
.question-number {
@ -474,7 +473,6 @@ export default {
justify-content: center;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
}
@ -631,22 +629,22 @@ body {
}
.time-module {
border: #274779 solid 2px;
border-radius: 50px;
border-radius: 30px;
padding: 15px;
margin-bottom: 20px;
background-color: #2f374d;
}
.question-nav {
border: #274779 solid 2px;
border-radius: 50px;
padding: 15px;
border-radius: 30px;
padding: 15px 0 15px 19px ;
margin-bottom: 20px;
background-color: #2f374d;
}
.statistics {
height: 150px;
border: #274779 solid 2px;
border-radius: 50px;
border-radius: 30px;
padding: 15px;
margin-bottom: 20px;
background-color: #2f374d;
@ -655,7 +653,7 @@ body {
margin-bottom: 15px;
color: #f1f5f9;
font-size: 1.2em;
border-bottom: 1px solid #374151;
border-bottom: 2px solid #274779;
padding-bottom: 10px;
}
.countdown {
@ -665,9 +663,9 @@ body {
}
.pagination {
display: flex;
justify-content: center;
margin-top: 20px;
gap: 10px;
/* justify-content: center; */
margin: 30px 148px 5px;
gap: 20px;
}
.pagination-btn {
padding: 8px 15px;
@ -678,6 +676,7 @@ body {
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
margin: auto 20px;
}
.pagination-btn:hover {
background-color: #2563eb;
@ -699,8 +698,6 @@ body {
background-color: #3b82f6;
color: white;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 5px;
@ -720,13 +717,12 @@ body {
}
.statistics-item {
display: flex;
font-size: larger;
justify-content: space-between;
margin-bottom: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #374151;
}
.statistics-item:last-child {
border-bottom: none;
margin-top: 30px;
padding-top: 10px;
padding-bottom: 2px;
border-bottom: 2px solid #274779;
}
.statistics-label {
color: #e5e7eb;

Loading…
Cancel
Save