Files
dvcp_v2_wxcp_app/src/apps/AppOnlineAnswer/AppOnlineAnswer.vue

470 lines
13 KiB
Vue
Raw Normal View History

2021-12-16 19:16:01 +08:00
<template>
2021-12-20 10:09:17 +08:00
<section class="AppOnlineAnswer">
2021-12-16 19:16:01 +08:00
<div class="page" v-if="list.length">
2021-12-24 22:34:18 +08:00
<img src="./static/img/answer-bg.png" alt="" class="bg-img">
2021-12-16 19:16:01 +08:00
<div class="subject-content" v-if="!showAnwser">
2021-12-20 10:09:17 +08:00
<div class="btn" v-if="showTopBtn" @click="confirm()">{{ topBtnText }}</div>
2021-12-16 19:16:01 +08:00
<div class="bg-fff pad-b48">
<div class="title">
<div class="left">
2021-12-20 10:09:17 +08:00
<span class="tips"></span>{{ list[index].type == 1 ? '单选' : '多选' }}
2021-12-16 19:16:01 +08:00
</div>
<div class="right">
2021-12-20 10:09:17 +08:00
<span class="big-num">{{ index + 1 }}</span>/{{ list.length }}
2021-12-16 19:16:01 +08:00
</div>
</div>
2021-12-20 10:09:17 +08:00
<div class="text">{{ list[index].title }}</div>
2021-12-16 19:16:01 +08:00
<!-- 单选 -->
<div v-if="list[index].type == 1">
2021-12-20 10:09:17 +08:00
<div class="item" v-for="(item, i) in list[index].items" :key="i" @click="itemClick(i)"
:class="{ 'item-click': clickIndex === i, 'item-success': showAnalysis && item.checked == 1, 'item-error': showAnalysis && clickIndex == i && item.checked == 0}">
2021-12-24 22:34:18 +08:00
<img src="./static/img/success-icon.png" alt="" v-if="showAnalysis && item.checked == 1">
<img src="./static/img/error-icon.png" alt=""
2021-12-20 10:09:17 +08:00
v-if="showAnalysis && clickIndex == i && item.checked == 0">
{{ item.sort }} &nbsp;{{ item.content }}
2021-12-16 19:16:01 +08:00
</div>
</div>
<!-- 多选 -->
<div v-if="list[index].type == 2">
2021-12-20 10:09:17 +08:00
<div class="item" v-for="(item, i) in list[index].items" :key="i" @click="itemClick(i)"
:class="{ 'item-click': item.isCheked, 'item-success': showAnalysis && item.checked == 1, 'item-error': showAnalysis && item.isCheked && item.checked == 0}">
2021-12-24 22:34:18 +08:00
<img src="./static/img/success-icon.png" alt="" v-if="showAnalysis && item.checked == 1">
<img src="./static/img/error-icon.png" alt=""
2021-12-20 10:09:17 +08:00
v-if="showAnalysis && clickIndex == i && item.checked == 0">
{{ item.sort }} &nbsp;{{ item.content }}
2021-12-16 19:16:01 +08:00
</div>
</div>
<!-- <div class="item item-click">A. 吴起镇</div>
2021-12-20 10:09:17 +08:00
<div class="item item-success"> <img src="./static/img/success-icon.png" alt="">吴起镇</div>
<div class="item item-error"> <img src="./static/img/error-icon.png" alt="">吴起镇</div>
2021-12-16 19:16:01 +08:00
<div class="item">A. 吴起镇</div> -->
</div>
<div class="bg-fff mar-t32" v-if="showAnalysis">
<div class="title">
<div class="left">
<span class="tips"></span>答案解析
</div>
</div>
2021-12-20 10:09:17 +08:00
<div class="success-title">正确答案{{ list[index].answer }}</div>
<div class="success-text">
<u-parse :html="list[index].analysis"></u-parse>
</div>
2021-12-16 19:16:01 +08:00
</div>
</div>
<div class="subject-content" v-else>
<div class="bg-fff pad-b48">
2021-12-24 22:34:18 +08:00
<img src="./static/img/answer-head.png" alt="" class="head-img">
2021-12-16 19:16:01 +08:00
<div class="head-content">
<p>本次答对题目数</p>
2021-12-20 10:09:17 +08:00
<div>{{ resultInfo.right }}</div>
2021-12-16 19:16:01 +08:00
</div>
<div class="info-content">
2021-12-20 10:09:17 +08:00
<span class="info-item">正确率: {{ resultInfo.rate }}</span>
<span class="info-item">用时: {{ useTime }}</span>
<span class="info-item mar-b132">错题数: {{ resultInfo.wrong }}</span>
2021-12-16 19:16:01 +08:00
</div>
<span class="big-btn mar-r22" @click="back">返回</span>
<span class="big-btn bg-red" @click="again">再来一组</span>
</div>
</div>
</div>
2021-12-20 10:09:17 +08:00
<AiEmpty v-if="list.length == 0"/>
2021-12-16 19:16:01 +08:00
</section>
</template>
<script>
2021-12-20 10:09:17 +08:00
import {mapState} from "vuex";
2021-12-16 19:16:01 +08:00
export default {
2021-12-20 10:09:17 +08:00
name: "AppOnlineAnswer",
2022-03-14 12:01:30 +08:00
appName: "党史题库",
2021-12-16 19:16:01 +08:00
computed: {
2022-07-19 18:06:22 +08:00
...mapState(["user"]),
2021-12-16 19:16:01 +08:00
},
data() {
return {
showAnwser: false,
index: 0,
clickIndex: '',
list: [],
showTopBtn: false,
topBtnText: '',
showAnalysis: false,
createdTime: '',
endTime: '',
useTime: '',
resultInfo: {}
};
},
2021-12-20 10:09:17 +08:00
onLoad() {
2021-12-16 19:16:01 +08:00
this.createdTime = Date.parse(new Date())
this.getList()
},
2021-12-24 22:34:18 +08:00
onShow() {
2022-03-14 12:01:30 +08:00
document.title = '党史题库'
2021-12-24 22:34:18 +08:00
},
2021-12-16 19:16:01 +08:00
methods: {
itemClick(i) {
if (this.showAnalysis) return
2021-12-20 10:09:17 +08:00
if (this.list[this.index].type == 1) { //单选
2021-12-16 19:16:01 +08:00
this.clickIndex = i
this.showTopBtn = true
}
2021-12-20 10:09:17 +08:00
if (this.list[this.index].type == 2) { //多选
2021-12-16 19:16:01 +08:00
this.showTopBtn = false
this.list[this.index].items[i].isCheked = !this.list[this.index].items[i].isCheked
this.list[this.index].items.map((item) => {
2021-12-20 10:09:17 +08:00
if (item.isCheked) {
2021-12-16 19:16:01 +08:00
this.showTopBtn = true
}
})
}
this.topBtnText = '确定'
},
confirm() {
2021-12-20 10:09:17 +08:00
if (this.list[this.index].type == 1) { //单选
2021-12-16 19:16:01 +08:00
this.list[this.index].result = this.list[this.index].items[this.clickIndex].sort
}
2021-12-20 10:09:17 +08:00
if (this.list[this.index].type == 2) { //多选
2021-12-16 19:16:01 +08:00
var resultList = []
this.list[this.index].items.map((item) => {
2021-12-20 10:09:17 +08:00
if (item.isCheked) {
2021-12-16 19:16:01 +08:00
resultList.push(item.sort)
}
})
this.list[this.index].result = resultList.join(',')
}
console.log(this.list)
2021-12-20 10:09:17 +08:00
if (this.topBtnText == '下一题') { //next
if (this.index < this.list.length - 1) {
this.index++
2021-12-16 19:16:01 +08:00
this.init()
2021-12-20 10:09:17 +08:00
} else { //答完了
2021-12-16 19:16:01 +08:00
this.showTopBtn = false
2021-12-20 10:09:17 +08:00
this.endTime = Date.parse(new Date());
2021-12-16 19:16:01 +08:00
this.useTime = this.intervalTime(this.endTime - this.createdTime)
this.getResult()
}
}
2021-12-20 10:09:17 +08:00
if (this.topBtnText == '确定') { //确定选项
2021-12-16 19:16:01 +08:00
this.showAnalysis = true
this.topBtnText = '下一题'
}
},
getResult() {
this.$http.post(`/app/apppartyquestion/checkAnswer`, this.list).then((res) => {
if (res.code == 0) {
this.resultInfo = res.data
this.showAnwser = true
}
});
},
getList() {
this.$http.post(`/app/apppartyquestion/getQuestions`).then((res) => {
if (res.code == 0) {
res.data.map((item) => {
item.answerList = []
item.items.map((i) => {
2021-12-20 10:09:17 +08:00
if (i.checked == 1) {
2021-12-16 19:16:01 +08:00
item.answerList.push(i.sort)
}
})
item.answer = item.answerList.join(',')
2021-12-20 10:09:17 +08:00
if (item.type == 2) { //多选
2021-12-16 19:16:01 +08:00
item.isCheck = false
}
})
this.list = res.data
}
});
},
intervalTime(time) {
2021-12-20 10:09:17 +08:00
var leave1 = time % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
2021-12-16 19:16:01 +08:00
var hours = Math.floor(leave1 / (3600 * 1000));
2021-12-20 10:09:17 +08:00
hours = hours < 10 ? '0' + hours : hours
2021-12-16 19:16:01 +08:00
var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
var minutes = Math.floor(leave2 / (60 * 1000));
2021-12-20 10:09:17 +08:00
minutes = minutes < 10 ? '0' + minutes : minutes
2021-12-16 19:16:01 +08:00
var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
var seconds = Math.round(leave3 / 1000);
2021-12-20 10:09:17 +08:00
seconds = seconds < 10 ? '0' + seconds : seconds
return hours + ":" + minutes + ":" + seconds
2021-12-16 19:16:01 +08:00
},
back() {
uni.navigateBack({delta: 1})
},
again() {
this.init()
this.index = 0
this.list = []
this.getList()
this.createdTime = Date.parse(new Date())
},
init() {
this.showAnwser = false
this.clickIndex = ''
this.showTopBtn = false
this.topBtnText = ''
this.showAnalysis = false
2021-12-24 22:34:18 +08:00
},
2021-12-16 19:16:01 +08:00
},
};
</script>
<style scoped lang="scss">
2022-08-09 11:09:32 +08:00
@import "../../common/party";
2021-12-20 10:09:17 +08:00
.AppOnlineAnswer {
2021-12-16 19:16:01 +08:00
width: 100%;
height: 100%;
}
.page {
width: 100%;
height: 100%;
background-color: #F6F6F6;
2021-12-20 10:09:17 +08:00
.bg-img {
2021-12-16 19:16:01 +08:00
width: 100%;
height: 800px;
}
2021-12-20 10:09:17 +08:00
.subject-content {
2021-12-16 19:16:01 +08:00
width: 100%;
border-radius: 4px;
padding: 24px 36px 48px 36px;
box-sizing: border-box;
position: absolute;
top: 124px;
z-index: 9;
2021-12-20 10:09:17 +08:00
.btn {
2021-12-16 19:16:01 +08:00
padding: 0 30px;
height: 64px;
line-height: 64px;
text-align: center;
background: #D03A28;
border-radius: 4px;
font-size: 28px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFF;
position: absolute;
top: -100px;
right: 36px;
z-index: 99;
}
2021-12-20 10:09:17 +08:00
.pad-top {
2021-12-16 19:16:01 +08:00
padding-top: 100px;
}
2021-12-20 10:09:17 +08:00
.pad-b48 {
2021-12-16 19:16:01 +08:00
padding-bottom: 48px;
}
2021-12-20 10:09:17 +08:00
.mar-t32 {
2021-12-16 19:16:01 +08:00
margin-top: 32px;
}
2021-12-20 10:09:17 +08:00
.bg-fff {
2021-12-16 19:16:01 +08:00
width: 100%;
background-color: #fff;
border-radius: 4px;
2021-12-20 10:09:17 +08:00
box-shadow: 0 6px 8px 4px rgba(218, 227, 234, 0.42);
2021-12-16 19:16:01 +08:00
position: relative;
2021-12-20 10:09:17 +08:00
.title {
2021-12-16 19:16:01 +08:00
width: 100%;
height: 100px;
border-bottom: 1px solid #F2F3F5;
padding: 24px 30px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
2021-12-20 10:09:17 +08:00
.left {
2021-12-16 19:16:01 +08:00
font-size: 36px;
font-family: PingFang-SC-Heavy, PingFang-SC;
font-weight: 800;
color: #333;
line-height: 50px;
2021-12-20 10:09:17 +08:00
.tips {
2021-12-16 19:16:01 +08:00
display: inline-block;
width: 8px;
height: 36px;
background: #E02617;
margin-right: 16px;
}
}
2021-12-20 10:09:17 +08:00
.right {
2021-12-16 19:16:01 +08:00
font-size: 34px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #999;
line-height: 48px;
2021-12-20 10:09:17 +08:00
.big-num {
2021-12-16 19:16:01 +08:00
font-size: 72px;
font-family: PingFang-SC-Heavy, PingFang-SC;
font-weight: 800;
color: #333;
}
}
}
2021-12-20 10:09:17 +08:00
.text {
2021-12-16 19:16:01 +08:00
padding: 48px 40px;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333;
line-height: 48px;
word-break: break-all;
}
2021-12-20 10:09:17 +08:00
.item {
2021-12-16 19:16:01 +08:00
width: 612px;
background: #FAFBFC;
border-radius: 12px;
border: 1px solid #F2F3F5;
margin-bottom: 28px;
margin-left: 32px;
padding: 26px 48px;
box-sizing: border-box;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #687178;
line-height: 44px;
2021-12-20 10:09:17 +08:00
img {
2021-12-16 19:16:01 +08:00
width: 36px;
height: 36px;
vertical-align: middle;
margin-right: 14px;
}
}
2021-12-20 10:09:17 +08:00
.item-click {
2021-12-16 19:16:01 +08:00
background: #F5F5F2;
border: 1px solid #AD9B8D;
color: #B7A38E;
}
2021-12-20 10:09:17 +08:00
.item-success {
2021-12-16 19:16:01 +08:00
background: #E9FAF0;
border: 1px solid #E9FAF0;
color: #40BF6F;
}
2021-12-20 10:09:17 +08:00
.item-error {
2021-12-16 19:16:01 +08:00
background: #FDEBEB;
border: 1px solid #FDEBEB;
color: #D03A28;
}
2021-12-20 10:09:17 +08:00
.success-title {
2021-12-16 19:16:01 +08:00
padding: 32px 0 0 40px;
font-size: 32px;
font-family: PingFang-SC-Heavy, PingFang-SC;
font-weight: 800;
color: #333;
line-height: 44px;
}
2021-12-20 10:09:17 +08:00
.success-text {
2021-12-16 19:16:01 +08:00
padding: 32px 40px 56px;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333;
line-height: 48px;
word-break: break-all;
}
2021-12-20 10:09:17 +08:00
.head-img {
2021-12-16 19:16:01 +08:00
width: 100%;
height: 260px;
}
2021-12-20 10:09:17 +08:00
.head-content {
2021-12-16 19:16:01 +08:00
position: absolute;
width: 100%;
height: 260px;
top: 0;
left: 0;
padding: 56px 0 0 72px;
box-sizing: border-box;
2021-12-20 10:09:17 +08:00
p {
2021-12-16 19:16:01 +08:00
font-size: 38px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FBE5E6;
line-height: 52px;
}
2021-12-20 10:09:17 +08:00
div {
2021-12-16 19:16:01 +08:00
font-size: 100px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FBE5E6;
line-height: 140px;
}
}
2021-12-20 10:09:17 +08:00
.info-content {
2021-12-16 19:16:01 +08:00
padding: 88px 32px 40px;
2021-12-20 10:09:17 +08:00
.info-item {
2021-12-16 19:16:01 +08:00
display: inline-block;
width: 300px;
font-size: 34px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666;
line-height: 48px;
margin-bottom: 42px;
}
2021-12-20 10:09:17 +08:00
.mar-b132 {
2021-12-16 19:16:01 +08:00
margin-bottom: 132px;
}
}
2021-12-20 10:09:17 +08:00
.big-btn {
2021-12-16 19:16:01 +08:00
display: inline-block;
width: 296px;
height: 88px;
line-height: 88px;
text-align: center;
border-radius: 4px;
border: 1px solid #E4E5E7;
font-size: 34px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666;
}
2021-12-20 10:09:17 +08:00
.bg-red {
2021-12-16 19:16:01 +08:00
border: 0;
background: #D03A28;
color: #fff;
}
2021-12-20 10:09:17 +08:00
.mar-r22 {
2021-12-16 19:16:01 +08:00
margin: 0 22px 0 32px;
}
}
}
}
</style>