Files
dvcp_v2_wechat_app/src/project/qujing/AppLegalLearning/testForm.vue

218 lines
5.8 KiB
Vue
Raw Normal View History

2023-01-31 09:49:26 +08:00
<template>
<div class="testForm">
2023-01-31 16:19:20 +08:00
<u-navbar title="法治学习" :background="backgroundNavbar"></u-navbar>
2023-02-14 17:10:40 +08:00
<div class="testForm_info" >
<div v-for="(item,index) in list" :key="index">
<div v-if="activeIndex === index">
<div class="type">
<div class="type_left">{{ item.type==0? '单选题':item.type==1? '多选题': '判断题' }}</div>
<div><span class="col_blue">{{ activeIndex + 1 }}</span>/{{ list.length }}</div>
</div>
<div class="topic">
<div>
<div >
<!-- 题目 -->
<div>{{ item.title }}</div>
<!-- 单选 -->
<div class="answer_list" v-if="item.type==0">
<!-- 'succeed': clickIndex==inx && opt.checked == 1, 'item-error': clickIndex == inx && item.checked == 0 -->
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
:class="{'Checked': clickIndex == inx}">
{{ opt.sort }}: {{ opt.content}}
</div>
</div>
<!-- 多选 -->
<div class="answer_list" v-if="item.type==1">
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
@click="itemClick(inx)">
{{ opt.sort }}: {{ opt.content}}
</div>
</div>
<!-- 判断 -->
<div class="answer_list" v-if="item.type==2">
<div class="answer_item" v-for="(opt,inx) in item.items" :key="inx"
:class="{'Checked': clickIndex == inx, 'Succeed': showAnalysis && opt.checked == 1, 'Error': showAnalysis && clickIndex == inx && opt.checked == 0}"
@click="itemClick(inx)">
{{ opt.sort }}: {{ opt.content}}
</div>
</div>
2023-02-14 14:06:46 +08:00
</div>
</div>
2023-02-01 18:02:38 +08:00
</div>
2023-02-14 14:06:46 +08:00
2023-02-14 17:10:40 +08:00
<div class="type mar-top" v-if="showAnalysis">
<div class="type_left">答案解析</div>
</div>
<div class="topic mar-top" v-if="showAnalysis">
<div><span>正确答案</span></div>
<div style="margin-top: 8px" v-html="list[activeIndex].analysis"></div>
</div>
</div>
2023-02-10 15:49:13 +08:00
</div>
2023-02-14 14:06:46 +08:00
2023-02-14 17:10:40 +08:00
<div class="btn" @click="nextTopic" v-if="activeIndex < list.length - 1 && showNext">下一题</div>
2023-02-14 14:06:46 +08:00
<div class="btn" v-show="showConfirm" @click="confirm">确定</div>
2023-02-01 18:02:38 +08:00
</div>
2023-01-31 09:49:26 +08:00
</div>
</template>
<script>
export default {
2023-01-31 16:19:20 +08:00
customNavigation: true,
2023-01-31 09:49:26 +08:00
data() {
return {
2023-01-31 16:19:20 +08:00
backgroundNavbar: {
2023-02-10 15:49:13 +08:00
background: "url('https://cdn.cunwuyun.cn/qujing/navbar.png') no-repeat",
backgroundSize: '100% 100%',
2023-01-31 16:19:20 +08:00
},
2023-02-14 14:06:46 +08:00
list: [],
2023-02-02 12:00:35 +08:00
activeIndex: 0, // 当前第几题
2023-02-06 16:06:45 +08:00
endTime: '', // 结束时间
2023-02-14 14:06:46 +08:00
id: '', // 题库id
showConfirm: false,
showNext: false,
clickIndex: '',
showAnalysis: false,
2023-02-14 17:10:40 +08:00
subjectConfigs: [],
2023-01-31 09:49:26 +08:00
}
},
methods: {
2023-02-14 14:06:46 +08:00
getList(id) {
this.$instance.post(`/app/appexaminationinfo/queryDetailById?id=${id}`).then(res=> {
if(res?.data) {
this.list = res.data.questions
2023-02-14 17:10:40 +08:00
this.subjectConfigs = res.data.subjectConfigs
2023-02-14 14:06:46 +08:00
}
})
2023-02-06 16:06:45 +08:00
},
2023-02-14 14:06:46 +08:00
itemClick(i) {
2023-02-14 17:10:40 +08:00
if (this.showAnalysis) return
if(this.list[this.activeIndex].type==0) { // 单选
} else if(this.list[this.activeIndex].type==1) { // 多选
} else if(this.list[this.activeIndex].type==2) { // 判断
2023-02-14 14:06:46 +08:00
this.clickIndex = i
this.showConfirm = true
}
2023-01-31 09:49:26 +08:00
},
2023-02-06 16:06:45 +08:00
nextTopic() {
2023-01-31 09:49:26 +08:00
this.activeIndex ++;
2023-02-14 17:10:40 +08:00
this.clickIndex = ''
this.showAnalysis = false
2023-01-31 16:19:20 +08:00
},
2023-02-02 12:00:35 +08:00
confirm() {
2023-02-14 17:10:40 +08:00
this.showAnalysis = true;
if(this.activeIndex < this.list.length - 1) {
this.showNext = true;
this.showConfirm = false;
} else {
uni.navigateTo({url: './result'})
}
2023-02-02 12:00:35 +08:00
},
2023-01-31 09:49:26 +08:00
},
onReachBottom() {
this.current ++;
},
2023-02-14 14:06:46 +08:00
onLoad(o) {
this.getList(o.id)
2023-02-06 16:06:45 +08:00
}
2023-01-31 09:49:26 +08:00
}
</script>
<style lang="scss" scoped>
.testForm {
2023-02-10 15:49:13 +08:00
.testForm_info {
background: url("https://cdn.cunwuyun.cn/qujing/bg.png") no-repeat;
2023-02-10 15:59:38 +08:00
background-size: 100% auto;
2023-02-10 15:49:13 +08:00
padding: 80px 32px 0 32px;
2023-01-31 16:19:20 +08:00
box-sizing: border-box;
2023-02-10 15:49:13 +08:00
.type {
display: flex;
justify-content: space-between;
font-size: 28px;
color: #333333;
2023-01-31 16:19:20 +08:00
2023-02-10 15:49:13 +08:00
.type_left {
font-weight: 600;
}
2023-01-31 16:19:20 +08:00
2023-02-10 15:49:13 +08:00
.col_blue {
color: #2D7DFF;
}
2023-01-31 09:49:26 +08:00
2023-02-10 15:49:13 +08:00
}
2023-02-06 16:06:45 +08:00
2023-02-10 15:49:13 +08:00
.topic {
background: #FFF;
2023-02-06 16:06:45 +08:00
margin-top: 32px;
2023-02-10 15:49:13 +08:00
padding: 24px;
margin-top: 80px;
border-radius: 16px;
box-shadow: 0 0 8px 0 rgba(0,0,0,0.02);
2023-02-06 16:06:45 +08:00
2023-02-10 15:49:13 +08:00
.answer_list {
margin-top: 32px;
2023-02-06 16:06:45 +08:00
2023-02-10 15:49:13 +08:00
.answer_item {
background: #FBFCFE;
border: 1px solid #CCCCCC;
border-radius: 16px;
padding: 28px 24px;
box-sizing: border-box;
2023-02-14 14:06:46 +08:00
margin-bottom: 24px;
2023-02-10 15:49:13 +08:00
.myChoice {
width: 136px;
height: 48px;
background: #FFFFFF;
border: 1px solid #E23C3C;
border-radius: 8px;
}
2023-02-06 16:06:45 +08:00
}
2023-02-14 14:06:46 +08:00
.Checked {
2023-02-10 15:49:13 +08:00
border: 2px solid #2D7EFE;
color: #2D7DFF;
2023-02-14 14:06:46 +08:00
background: #EAF2FF;
}
.Succeed {
border: 2px solid #3BBC37;
color: #3BBC37;
background: #F5FCF5;
2023-02-10 15:49:13 +08:00
}
2023-02-06 16:06:45 +08:00
2023-02-14 14:06:46 +08:00
.Error {
2023-02-10 15:49:13 +08:00
border: 2px solid #E23C3C;
color: #E23C3C;
2023-02-14 14:06:46 +08:00
background: #FDF4F4;
2023-02-10 15:49:13 +08:00
}
2023-02-06 16:06:45 +08:00
}
}
2023-02-10 15:49:13 +08:00
.mar-top {
margin-top: 32px;
}
2023-02-01 18:02:38 +08:00
2023-02-10 15:49:13 +08:00
.btn {
position: fixed;
left: 50%;
bottom: 0;
transform: translate(-50%, -50%);
width: 320px;
height: 88px;
line-height: 88px;
text-align: center;
background: #2D7DFF;
border-radius: 44px;
font-weight: 500;
font-size: 34px;
color: #FFFFFF;
}
2023-01-31 16:19:20 +08:00
}
2023-01-31 09:49:26 +08:00
}
</style>