Commit 348c4e92 authored by Facius's avatar Facius

fix: bug修复

parent 071a7a7c
......@@ -11,11 +11,11 @@
</view>
<view
v-else
:class="[rightKey.includes(item.sort) ? 'success' : 'error']"
:class="[data.rightKey.includes(item.sort) ? 'success' : 'error']"
></view>
<view class="text">{{ item.text }}</view>
</view>
<view class="btn" v-if="rightKey.length > 1 && btnStatus">
<view class="btn" v-if="data.rightKey.length > 1 && btnStatus">
<view
:class="['confirm', { active: getCheckedNum }]"
@click="confirmMultiple"
......@@ -43,22 +43,28 @@ const equar = (a, b) => {
export default {
name: 'answerSheet',
props: {
answerList: {
type: Array,
default: [],
},
multiple: {
type: Boolean,
default: false,
},
rightKey: {
type: Array,
default: [],
},
submitStatus: {
type: Boolean,
default: false,
data: {
type: Object,
default() {
return {}
}
},
// answerList: {
// type: Array,
// default: [],
// },
// multiple: {
// type: Boolean,
// default: false,
// },
// rightKey: {
// type: Array,
// default: [],
// },
// submitStatus: {
// type: Boolean,
// default: false,
// },
btnStatus: {
type: Boolean,
default: true,
......@@ -73,7 +79,7 @@ export default {
}
},
watch: {
answerList: {
'data.answerList': {
handler: function(newValue, oldValue) {
if (newValue.length > 0) {
this.lists = newValue
......@@ -86,18 +92,21 @@ export default {
getCheckedNum() {
const num = this.lists.filter((v) => v.checked)
return num.length > 1 ? true : false
}
},
multiple() {
return this.data.type == 3
},
},
methods: {
select(index) {
// 已选定
if (this.submitStatus) return
if (this.data.submitStatus) return
if (!this.multiple) {
// 非多选处理
this.lists.forEach((v) => {
v.checked = false // 勾选
v.confirm = false // 确认答案
if (this.rightKey.includes(v.sort)) {
if (this.data.rightKey.includes(v.sort)) {
this.$set(v, 'checked', true)
this.$set(v, 'confirm', true)
}
......@@ -106,7 +115,7 @@ export default {
// 用户选的答案
this.userAnswer = this.lists[index].sort
// 判断所选答案是否正确
this.answer = this.rightKey.includes(this.lists[index].sort)
this.answer = this.data.rightKey.includes(this.lists[index].sort)
? 'pass'
: 'fail'
}
......@@ -117,6 +126,7 @@ export default {
},
// 多选提交答案
confirmMultiple() {
if (this.data.submitStatus) return
const num = this.lists.filter((v) => v.checked)
if (num.length > 1) {
// 判断所选答案是否正确
......@@ -124,11 +134,11 @@ export default {
// 用户选的答案
this.userAnswer = checkedList.join(',')
// 判断所选答案是否正确
this.answer = equar(checkedList, this.rightKey) ? 'pass' : 'fail'
this.answer = equar(checkedList, this.data.rightKey) ? 'pass' : 'fail'
// 处理显示逻辑
this.lists.forEach((v) => {
if (v.checked) this.$set(v, 'confirm', true)
if (this.rightKey.includes(v.sort)) this.$set(v, 'checked', true)
if (this.data.rightKey.includes(v.sort)) this.$set(v, 'checked', true)
})
this.submitAnswer()
}
......
......@@ -14,10 +14,7 @@
<view class="content">
<answer-sheet
ref="answerSheet"
:answerList="item.answerList"
:rightKey="item.rightKey"
:multiple="item.type === 3"
:submitStatus="item.submitStatus"
:data="item"
:btnStatus="false"
@change="answerChange"
></answer-sheet>
......
......@@ -13,10 +13,7 @@
<view class="content" v-if="item.answerList">
<answer-sheet
ref="answerSheet"
:answerList="item.answerList"
:rightKey="item.rightKey"
:multiple="item.type === 3"
:submitStatus="item.submitStatus"
:data="item"
@change="answerChange"
></answer-sheet>
</view>
......@@ -116,7 +113,6 @@ export default {
methods: {
init (defaulaIndex) {
let list = JSON.parse(JSON.stringify(this.list))
console.log('bbb:', list)
if (list == null || list.length == 0) {
return
}
......@@ -220,7 +216,7 @@ export default {
let realIndex = list.findIndex(item => item.index == defaultIndex)
let currentItem = list[realIndex]
let swiperList = []
swiperList[current] = currentItem
swiperList[current] = this.initItem(currentItem)
swiperList[this.getLastSwiperChangeIndex(current)] = this.getLastSwiperNeedItem(currentItem, list)
swiperList[this.getNextSwiperChangeIndex(current)] = this.getNextSwiperNeedItem(currentItem, list)
console.log("swiperList", swiperList)
......@@ -247,7 +243,7 @@ export default {
let realIndex = list.findIndex(item => item.index == listNeedIndex)
if (realIndex == -1) return null
let item = listNeedIndex == -1 ? null : list[realIndex]
return item
return this.initItem(item)
},
/**
* 获取下一个要替换的list中的item
......@@ -259,7 +255,24 @@ export default {
if (realIndex == -1) return null
let total = this.total != 0 ? this.total : list.length
let item = listNeedIndex == total ? null : list[realIndex]
return item
return this.initItem(item)
},
initItem(data) {
if (this.type === 2 && data.userAnswer && !data.submitStatus) {
data.submitStatus = true,
data.result = data.userAnswer == data.answer ? 'pass' : 'fail'
data.errShow = true
let userAnswers = data.userAnswer.split(',')
let answers = data.answer.split(',')
for (var item of data.answerList) {
if (userAnswers.indexOf(item.sort) != -1 || answers.indexOf(item.sort) != -1) {
item.checked = true
item.confirm = true
}
}
}
return data
}
},
}
......
......@@ -6,9 +6,6 @@
mode="center"
width="654rpx"
:mask-close-able="false"
closeable
close-icon-size="32"
@close="handleClose"
>
<image
:src="tanchuangdingbuImage"
......@@ -16,6 +13,7 @@
mode="widthFix"
></image>
<view class="toast-pop">
<u-icon class="close-icon" name="close" @click="handleClose"></u-icon>
<view class="pop-title">
<text>{{ title }}</text>
</view>
......@@ -133,7 +131,6 @@ export default {
this.$emit('click', this.type)
},
handleClose() {
console.log('aaaa:', this.visible)
this.changeVisibleValue(false)
}
},
......@@ -155,6 +152,12 @@ export default {
// background-size: 100% 240rpx;
// background-repeat: no-repeat;
text-align: center;
.close-icon {
top: 30rpx;
right: 30rpx;
position: absolute;
font-size: 32rpx;
}
.pop-title {
font-size: 40rpx;
text-align: center;
......
......@@ -135,6 +135,7 @@ export default {
this.list = res
if (this.list.length == 1) {
this.selectedData = this.list[0].echoMap.questionWarehouseId
this.cardData = this.list[0].echoMap.cardId
}
})
.catch((err) => {
......
......@@ -624,7 +624,7 @@ export default {
},
checkToken() {
if (this.vuex_token) {
return true
return !this.loading
} else {
this.$u.route({
url: 'pages/login/index',
......
......@@ -390,7 +390,7 @@ export default {
return accumulator
}, 0)
if (count > 0) {
const noStart = this.list.filter((v) => !v.result).length // 未做题数
const noStart = this.list.filter((v) => !v.userAnswer).length // 未做题数
// 显示暂停弹窗
this.pauseData = {
answered: this.list.length - noStart,
......@@ -509,7 +509,7 @@ export default {
item.result = status
item.errShow = this.type === 2 ? true : status === 'fail'
item.userAnswer = userAnswer
// 保存答案
if (this.model === 1) this.saveAnswer(item)
......@@ -556,13 +556,12 @@ export default {
// 如果回答正确或者是考试模式,自动进入下一题
if ((status === 'pass' && this.model !== 2) || this.type === 2) {
if (this.currentIndex + 1 > this.total - 1) {
// 最后一题回答后
if (this.type === 2) {
// 统计分数,交卷
this.handPapers(1)
this.submit()
}
let count = this.list.filter((v) => v.userAnswer).length
// 最后一题回答后
if (count >= this.total && this.type === 2) {
// 统计分数,交卷
this.handPapers(1)
this.submit()
return
}
setTimeout(() => {
......@@ -611,8 +610,8 @@ export default {
},
// 统计分数
handPapers(type) {
const fail = this.list.filter((v) => v.result === 'fail').length // 错题数
const noStart = this.list.filter((v) => !v.result).length // 未做题数
const fail = this.list.filter((v) => v.userAnswer && v.userAnswer !== v.answer).length // 错题数
const noStart = this.list.filter((v) => !v.userAnswer).length // 未做题数
const fraction = this.total - noStart - fail // 分数
this.complete.result = [fail, noStart, fraction]
this.complete.type = fraction < this.passPoint ? 'fail' : 'pass'
......@@ -938,6 +937,10 @@ export default {
font-size: 28rpx;
.c-list {
display: flex;
width: 200rpx;
justify-content: center;
height: 80rpx;
align-items: center;
text {
padding-left: 10rpx;
}
......
......@@ -64,8 +64,6 @@ function request({ currentPage, size, onSuccess, onFailed }, vm) {
type: type,
collectionFlag: info.collectionFlag,
userAnswer: info.userAnswer,
submitStatus: info.userAnswer ? true : null,
result: info.userAnswer ? (info.userAnswer == info.answer ? 'pass' : 'fail') : null
}
// 回显已答题目
if (vm.source === 1) { // 练习模式回显
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment