提交 a911af89 authored 作者: lihuihui's avatar lihuihui

错题,收藏题,总做题逻辑修改

上级 d8cde625
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
<div class="circle active2"></div> <div class="circle active2"></div>
<div class="txt">错误</div> <div class="txt">错误</div>
</li> </li>
<li> <!-- <li>
<div class="circle active3"></div> <div class="circle active3"></div>
<div class="txt">未答</div> <div class="txt">未答</div>
</li> </li> -->
</ul> </ul>
</div> </div>
<div class="question"> <div class="question">
...@@ -33,10 +33,11 @@ ...@@ -33,10 +33,11 @@
</template> </template>
</ul> </ul>
<van-empty description="暂无内容" v-if="dataList.length == 0"/> <van-empty description="暂无内容" v-if="dataList.length == 0"/>
<div class="tips" v-if="$route.query.type == 3">未做试题剩余{{unDo}}题</div>
</div> </div>
</div> </div>
</div> </div>
<div class="clear-btn"> <div class="clear-btn" v-if="this.$route.query.type != 3">
<div class="btn" @click="clearQuestion">清空记录,重新答题</div> <div class="btn" @click="clearQuestion">清空记录,重新答题</div>
</div> </div>
<div class="exam_submit" v-if="isPopShow"> <div class="exam_submit" v-if="isPopShow">
...@@ -63,6 +64,7 @@ export default { ...@@ -63,6 +64,7 @@ export default {
}, },
data() { data() {
return { return {
unDo: 0,
questionType: { questionType: {
1: '单选题', 1: '单选题',
2: '多选题', 2: '多选题',
...@@ -76,12 +78,13 @@ export default { ...@@ -76,12 +78,13 @@ export default {
methods: { methods: {
clearQuestion() { clearQuestion() {
const param = { const param = {
type: this.$route.query.type, type: this.$route.query.type === 3,
question_type: this.$route.query.questionType, question_type: this.$route.query.questionType,
clear: 1 clear: 1
} }
api.cacheQuestion(param).then(res => { api.cacheQuestion(param).then(res => {
Toast('清空成功') Toast('清空成功')
window.localStorage.cachequestion = JSON.stringify([])
this.initData() this.initData()
}) })
}, },
...@@ -103,9 +106,10 @@ export default { ...@@ -103,9 +106,10 @@ export default {
duration: 5000, duration: 5000,
loadingType: 'spinner' loadingType: 'spinner'
}) })
api.getAllQuestion({ type: this.$route.query.type, question_type: this.$route.query.questionType }) api.getAllQuestion({ type: parseInt(this.$route.query.type) === 3 ? 0 : this.$route.query.type, question_type: this.$route.query.questionType })
.then(res => { .then(res => {
this.dataList = res this.dataList = res.list
this.unDo = res.un_do
Toast.clear() Toast.clear()
}) })
.catch(() => { .catch(() => {
......
...@@ -197,6 +197,7 @@ export default { ...@@ -197,6 +197,7 @@ export default {
let num = 1 let num = 1
pageCount.indexOf('.') === -1 ? num = pageCount : num = parseInt(pageCount) + 1 pageCount.indexOf('.') === -1 ? num = pageCount : num = parseInt(pageCount) + 1
window.localStorage.myQuestionDetileId = id window.localStorage.myQuestionDetileId = id
window.localStorage.cachequestion = JSON.stringify([])
this.$router.push({ this.$router.push({
path: '/my/questionsDetails', path: '/my/questionsDetails',
query: { query: {
......
...@@ -6,10 +6,6 @@ ...@@ -6,10 +6,6 @@
<div class="num">{{ question.errorTotal }}</div> <div class="num">{{ question.errorTotal }}</div>
<div class="txt">错题总数</div> <div class="txt">错题总数</div>
</div> </div>
<!-- <div :class="activeClass == '1' ? 'right btn active' : 'right btn'" @click="tab('1')">
<div class="num">{{ question.total }}</div>
<div class="txt">做题总数</div>
</div> -->
</div> </div>
<div class="exam-con"> <div class="exam-con">
<div class="sele" @click="screen.isShow = true"> <div class="sele" @click="screen.isShow = true">
...@@ -207,6 +203,7 @@ export default { ...@@ -207,6 +203,7 @@ export default {
let num = 1 let num = 1
pageCount.indexOf('.') === -1 ? num = pageCount : num = parseInt(pageCount) + 1 pageCount.indexOf('.') === -1 ? num = pageCount : num = parseInt(pageCount) + 1
window.localStorage.myQuestionDetileId = id window.localStorage.myQuestionDetileId = id
window.localStorage.cachequestion = JSON.stringify([])
this.$router.push({ this.$router.push({
path: '/my/questionsDetails', path: '/my/questionsDetails',
query: { query: {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<div class="tool-box"> <div class="tool-box">
<div class="time">{{ item.sheet_time }}</div> <div class="time">{{ item.sheet_time }}</div>
<div class="tool-all"> <div class="tool-all">
<div class="tag-box" @click="goAnswerCard" v-if="$route.query.type != 3"> <div class="tag-box" @click="goAnswerCard">
<span style="margin-right:.4rem">答题卡</span> <span style="margin-right:.4rem">答题卡</span>
</div> </div>
<div v-if="$route.query.type != 2" :class="item.is_collection ? 'icon1 active' : 'icon1'" @click="collectQuestion(item.question_id)"></div> <div v-if="$route.query.type != 2" :class="item.is_collection ? 'icon1 active' : 'icon1'" @click="collectQuestion(item.question_id)"></div>
...@@ -25,65 +25,149 @@ ...@@ -25,65 +25,149 @@
<div class="topic" v-html="item.question_content"></div> <div class="topic" v-html="item.question_content"></div>
<ul class="option"> <ul class="option">
<template v-for="(opt, optIndex) in item.question_options"> <template v-for="(opt, optIndex) in item.question_options">
<li <template v-if="$route.query.type != 3">
v-if="$route.query.type != 3" <template v-if="item.question_type == 2 || item.question_type == 5 && item.answer_count > 1">
:key="opt.id" <li
@click="selectOptions(item, opt)" :key="opt.id"
:class="item.user_answer.length != 0 && item.question_answer.find(id => { return id === opt.id }) @click="selectOptions(item, opt)"
? 'active2' :class="findData(item, 'isSelect') && item.user_answer.length && item.question_answer.find(id => { return id === opt.id })
: item.user_answer.find(id => { return id === opt.id }) ? 'active2'
? 'active' : cacheOption.find(cItem => {
: ''" return cItem.answer.find(aItem => { return aItem == opt.id })
> })
<van-icon class="icon" name="checked" v-if="item.user_answer.length != 0 && item.question_answer.find(id => { return id === opt.id })"/> ? 'active'
<div> : ''"
<span v-if="!(item.user_answer.length != 0 && item.question_answer.find(id => { return id === opt.id }))">{{ A_Z[optIndex] }}.</span> >
{{ opt.option }} <van-icon class="icon" name="checked" v-if="findData(item, 'isSelect') && item.question_answer.find(id => { return id === opt.id })"/>
<div>
<span v-if="!(findData(item, 'isSelect') && item.question_answer.find(id => { return id === opt.id }))">{{ A_Z[optIndex] }}.</span>
{{ opt.option }}
</div>
</li>
</template>
<template v-else>
<li
:key="opt.id"
@click="selectOptions(item, opt)"
:class="cacheOption.find(id => { return id.id === item.question_id }) && item.question_answer.find(id => { return id === opt.id })
? 'active2'
: cacheOption.find(cItem => {
return cItem.answer.find(aItem => { return aItem == opt.id })
})
? 'active'
: ''"
>
<van-icon class="icon" name="checked" v-if="cacheOption.find(id => { return id.id === item.question_id }) && item.question_answer.find(id => { return id === opt.id })"/>
<div>
<span v-if="!(cacheOption.find(id => { return id.id === item.question_id }) && item.question_answer.find(id => { return id === opt.id }))">{{ A_Z[optIndex] }}.</span>
{{ opt.option }}
</div>
</li>
</template>
</template>
<template v-else>
<li
:key="opt.id+'=-='"
@click="selectOptions(item, opt)"
:class="item.question_answer.find(id => { return id === opt.id })
? 'active2'
: item.user_answer.find(id => { return id === opt.id })
? 'active'
: ''"
>
<van-icon class="icon" name="checked" v-if="item.user_answer.length != 0 && item.question_answer.find(id => { return id === opt.id })"/>
<div>
<span v-if="!(item.question_answer.find(id => { return id === opt.id }))">{{ A_Z[optIndex] }}.</span>
{{ opt.option }}
</div>
</li>
</template>
</template>
</ul>
<div class="com-btn" @click="confirmSelect(item)" v-if="$route.query.type != 3 && (item.question_type == 2 || item.question_type == 5 && item.answer_count > 1)">确认答案</div>
<template v-if="$route.query.type != 3">
<template v-if="item.question_type == 2 || item.question_type == 5 && item.answer_count > 1">
<div class="analy" v-show="findData(item, 'isSelect') && item.user_answer.length">
<div class="tit">答案解析</div>
<div class="txt">正确答案:
<span>
{{
item.question_answer.map((i, index) => {
return A_Z[item.question_options.findIndex(id => { return id.id === i })]
}).toString().replace(new RegExp(',', 'g'), '')
}}
</span>
</div>
<div class="txt">您的答案:
<span>
{{
findData(item, 'answer').map((i, index) => {
return A_Z[item.question_options.findIndex(id => { return id.id === i })]
}).toString().replace(new RegExp(',', 'g'), '')
}}
</span>
</div>
<div class="exp">
<p class="name">解析:</p>
<p class="nr" v-html="item.question_analysis"></p>
</div> </div>
</li>
<li
v-else
:key="opt.id+'=-='"
@click="selectOptions(item, opt)"
:class="item.question_answer.find(id => { return id === opt.id })
? 'active2'
: item.user_answer.find(id => { return id === opt.id })
? 'active'
: ''"
>
<van-icon class="icon" name="checked" v-if="item.user_answer.length != 0 && item.question_answer.find(id => { return id === opt.id })"/>
<div>
<span v-if="!(item.question_answer.find(id => { return id === opt.id }))">{{ A_Z[optIndex] }}.</span>
{{ opt.option }}
</div> </div>
</li>
</template> </template>
</ul> <template v-else>
<div class="analy" v-show="isAnalysis || item.user_answer.length != 0"> <div class="analy" v-show="isAnalysis || cacheOption.find(id => { return id.id === item.question_id })">
<div class="tit">答案解析</div> <div class="tit">答案解析</div>
<div class="txt">正确答案: <div class="txt">正确答案:
<span> <span>
{{ {{
item.question_answer.map((i, index) => { item.question_answer.map((i, index) => {
return A_Z[item.question_options.findIndex(id => { return id.id === i })] return A_Z[item.question_options.findIndex(id => { return id.id === i })]
}).toString().replace(new RegExp(',', 'g'), '') }).toString().replace(new RegExp(',', 'g'), '')
}} }}
</span> </span>
</div> </div>
<div class="txt">您的答案: <div class="txt">您的答案:
<span> <span>
{{ {{
item.user_answer.map((i, index) => { item.user_answer.map((i, index) => {
return A_Z[item.question_options.findIndex(id => { return id.id === i })] return A_Z[item.question_options.findIndex(id => { return id.id === i })]
}).toString().replace(new RegExp(',', 'g'), '') }).toString().replace(new RegExp(',', 'g'), '')
}} }}
</span> </span>
</div> </div>
<div class="exp"> <div class="exp">
<p class="name">解析:</p> <p class="name">解析:</p>
<p class="nr" v-html="item.question_analysis"></p> <p class="nr" v-html="item.question_analysis"></p>
</div>
</div>
</template>
</template>
<template v-else>
<div class="analy">
<div class="tit">答案解析</div>
<div class="txt">正确答案:
<span>
{{
item.question_answer.map((i, index) => {
return A_Z[item.question_options.findIndex(id => { return id.id === i })]
}).toString().replace(new RegExp(',', 'g'), '')
}}
</span>
</div>
<div class="txt">您的答案:
<span>
{{
item.user_answer.map((i, index) => {
return A_Z[item.question_options.findIndex(id => { return id.id === i })]
}).toString().replace(new RegExp(',', 'g'), '')
}}
</span>
</div>
<div class="exp">
<p class="name">解析:</p>
<p class="nr" v-html="item.question_analysis"></p>
</div>
</div> </div>
</div> </template>
</swiper-slide> </swiper-slide>
</template> </template>
</swiper> </swiper>
...@@ -110,6 +194,7 @@ import { Swiper, SwiperSlide, directive } from 'vue-awesome-swiper' ...@@ -110,6 +194,7 @@ import { Swiper, SwiperSlide, directive } from 'vue-awesome-swiper'
import 'swiper/css/swiper.css' import 'swiper/css/swiper.css'
export default { export default {
beforeDestroy() { beforeDestroy() {
// window.localStorage.isCache = false
clearInterval(this.cacheTime) clearInterval(this.cacheTime)
}, },
metaInfo() { metaInfo() {
...@@ -133,6 +218,8 @@ export default { ...@@ -133,6 +218,8 @@ export default {
data() { data() {
const _this = this const _this = this
return { return {
storageCheckOption: [],
cacheOption: [],
isBtnShow: { isBtnShow: {
currentPage: 1, currentPage: 1,
pageCount: 1 pageCount: 1
...@@ -173,6 +260,7 @@ export default { ...@@ -173,6 +260,7 @@ export default {
} }
_this.isBtnShow.currentPage = item.num _this.isBtnShow.currentPage = item.num
_this.sildesHeightCount() _this.sildesHeightCount()
_this.cacheOption = JSON.parse(window.localStorage.cachequestion)
}, 500) }, 500)
}, },
slideChangeTransitionStart: function() { slideChangeTransitionStart: function() {
...@@ -202,6 +290,15 @@ export default { ...@@ -202,6 +290,15 @@ export default {
computed: { computed: {
swiper() { swiper() {
return this.$refs.mySwiper.$swiper return this.$refs.mySwiper.$swiper
},
findData() {
return function (item, callValue) {
const data = this.cacheOption.find(id => { return id.id === item.question_id })
if (data) {
return data[callValue] || (false)
}
return callValue === 'answer' ? [] : false
}
} }
}, },
methods: { methods: {
...@@ -310,6 +407,7 @@ export default { ...@@ -310,6 +407,7 @@ export default {
} }
}, },
switchPages() { switchPages() {
document.scrollingElement.scrollTop = 0
const qId = this.swiper.slides[this.swiper.activeIndex].attributes['data-id'].nodeValue const qId = this.swiper.slides[this.swiper.activeIndex].attributes['data-id'].nodeValue
window.localStorage.myQuestionDetileId = qId window.localStorage.myQuestionDetileId = qId
const itemNum = this.questionData.list.find(item => { return item.question_id === qId }) const itemNum = this.questionData.list.find(item => { return item.question_id === qId })
...@@ -332,18 +430,57 @@ export default { ...@@ -332,18 +430,57 @@ export default {
this.swiper.slides[this.swiper.activeIndex].style.paddingBottom = '1.2rem' this.swiper.slides[this.swiper.activeIndex].style.paddingBottom = '1.2rem'
} }
}, },
confirmSelect(item) {
// 后台缓存
this.cacheList[item.question_id] = this.storageCheckOption
const data = this.cacheOption.find(d => { return d.id === item.question_id })
data.isSelect = true
window.localStorage.cachequestion = JSON.stringify(this.cacheOption)
},
// 选择选项 // 选择选项
selectOptions(item, opt) { selectOptions(item, opt) {
if (parseInt(this.$route.query.type) !== 3) { if (parseInt(this.$route.query.type) === 3) {
this.isAnalysis = true return false
if (parseInt(item.question_type) === 1 || parseInt(item.question_type) === 6 || (parseInt(item.question_type) === 5 && item.answer_count === 1)) { }
item.user_answer = [opt.id] if (parseInt(item.question_type) === 1 || parseInt(item.question_type) === 6 || (parseInt(item.question_type) === 5 && item.answer_count === 1)) {
} else { const datas = this.cacheOption.find(data => { return data.id === item.question_id })
const fIndex = item.user_answer.findIndex(id => { return id === opt.id }) if (datas) {
fIndex === -1 ? item.user_answer.push(opt.id) : item.user_answer.splice(fIndex, 1) return false
} }
item.isSelect = true
// 后台缓存
item.user_answer = [opt.id]
// 前端缓存
datas ? datas.answer = [opt.id] : this.cacheOption.push({
id: item.question_id,
answer: [opt.id],
isSelect: false
})
this.cacheList[item.question_id] = item.user_answer this.cacheList[item.question_id] = item.user_answer
this.sildesHeightCount() window.localStorage.cachequestion = JSON.stringify(this.cacheOption)
} else {
const datas = this.cacheOption.find(d => { return d.id === item.question_id })
if (datas) {
if (datas.isSelect) {
return false
}
}
const stotageInde = this.storageCheckOption.findIndex(i => { return i === opt.id })
stotageInde === -1 ? this.storageCheckOption.push(opt.id) : this.storageCheckOption.splice(stotageInde, 1)
// 后台缓存
const fIndex = item.user_answer.findIndex(id => { return id === opt.id })
fIndex === -1 ? item.user_answer.push(opt.id) : item.user_answer.splice(fIndex, 1)
// 前端缓存
if (!datas) {
this.cacheOption.push({
id: item.question_id,
answer: [opt.id],
isSelect: false
})
} else {
const index = datas.answer.findIndex(d => { return d === opt.id })
index === -1 ? datas.answer.push(opt.id) : datas.answer.splice(index, 1)
}
} }
}, },
// 初始化数据 || 翻页请求数据 // 初始化数据 || 翻页请求数据
...@@ -748,4 +885,15 @@ export default { ...@@ -748,4 +885,15 @@ export default {
} }
} }
} }
.com-btn{
width:6.7rem;
height:.7rem;
background:rgba(244,120,133,1);
border-radius:.12rem;
margin: 0 auto;
text-align: center;
line-height: .7rem;
font-size: .3rem;
color: #fff;
}
</style> </style>
...@@ -208,6 +208,7 @@ export default { ...@@ -208,6 +208,7 @@ export default {
let num = 1 let num = 1
pageCount.indexOf('.') === -1 ? num = pageCount : num = parseInt(pageCount) + 1 pageCount.indexOf('.') === -1 ? num = pageCount : num = parseInt(pageCount) + 1
window.localStorage.myQuestionDetileId = id window.localStorage.myQuestionDetileId = id
window.localStorage.cachequestion = JSON.stringify([])
this.$router.push({ this.$router.push({
path: '/my/questionsDetails', path: '/my/questionsDetails',
query: { query: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论