Commit 348c4e92 authored by Facius's avatar Facius

fix: bug修复

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