提交 92279b93 authored 作者: lihuihui's avatar lihuihui

答题安卓机卡优化

上级 cb75452d
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
:key="dIndex+dItem.id" :key="dIndex+dItem.id"
:data-dId="dItem.id" :data-dId="dItem.id"
:data-cId="item.id" :data-cId="item.id"
:indexs="dItem.num"> v-if="dItem.num <= countPage.currentPage * countPage.showQuestionNum && dItem.num >= countPage.currentPage * countPage.showQuestionNum - 20"
:data-num="dItem.num">
<!-- v-if="dItem.num <= countPage.currentPage * countPage.showQuestionNum && dItem.num >= countPage.currentPage * countPage.showQuestionNum - 20" --> <!-- v-if="dItem.num <= countPage.currentPage * countPage.showQuestionNum && dItem.num >= countPage.currentPage * countPage.showQuestionNum - 20" -->
<div class="title"> <div class="title">
<div class="type" v-if="item.type == 1">单选题</div> <div class="type" v-if="item.type == 1">单选题</div>
...@@ -242,43 +243,49 @@ export default { ...@@ -242,43 +243,49 @@ export default {
}, 500) }, 500)
}, },
slideChangeTransitionStart: function() { slideChangeTransitionStart: function() {
const dataNum = this.slides[this.activeIndex].attributes['data-num']
_this.sildesHeightCount() _this.sildesHeightCount()
_this.setCurrentCollect() _this.setCurrentCollect()
_this.getIsSign() _this.getIsSign()
if (this.activeIndex === _this.questionsData.sheet.question_count) { if (!dataNum) {
_this.topicCard.isShow = true _this.topicCard.isShow = true
} else { } else {
_this.topicCard.isShow = false _this.topicCard.isShow = false
} }
document.getElementById('bottom-view').scrollTop = 0 document.getElementById('bottom-view').scrollTop = 0
_this.isAnalysis = false _this.isAnalysis = false
_this.currentNum = this.activeIndex + 1 dataNum && (_this.currentNum = parseInt(dataNum.nodeValue))
_this.currentNum === _this.questionsData.sheet.question_count ? _this.nextBtnShow = false : _this.nextBtnShow = true _this.currentNum === _this.questionsData.sheet.question_count ? _this.nextBtnShow = false : _this.nextBtnShow = true
_this.requestData.answerPage = this.activeIndex dataNum && (_this.requestData.answerPage = parseInt(dataNum.nodeValue))
}, },
slidePrevTransitionEnd: function() { slidePrevTransitionEnd: function() {
// if (this.activeIndex === 0) { if (this.activeIndex === this.slides.length - 2) {
// _this.prevQuestionLoading() for (let i = 0; i < this.slides.length; i++) {
// } if (this.slides[i].attributes['data-num']) {
if (this.activeIndex === _this.questionsData.sheet.question_count - 1) { if (parseInt(this.slides[i].attributes['data-num'].nodeValue) === parseInt(_this.swiperSign)) {
this.slideTo(_this.swiperSign, 0, false) this.slideTo(i, 0, false)
_this.currentNum = this.activeIndex + 1 }
}
}
_this.currentNum = parseInt(this.slides[this.activeIndex].attributes['data-num'].nodeValue)
_this.currentNum === _this.questionsData.sheet.question_count ? _this.nextBtnShow = false : _this.nextBtnShow = true _this.currentNum === _this.questionsData.sheet.question_count ? _this.nextBtnShow = false : _this.nextBtnShow = true
_this.sildesHeightCount() _this.sildesHeightCount()
_this.setCurrentCollect() _this.setCurrentCollect()
_this.getIsSign() _this.getIsSign()
} else {
if (this.activeIndex === 0 && parseInt(this.slides[this.activeIndex].attributes['data-num'].nodeValue !== 1)) {
_this.prevQuestionLoading()
}
} }
}, },
slideNextTransitionEnd: function() { slideNextTransitionEnd: function() {
// if (this.activeIndex === this.slides.length - 2) { const dataNum = this.slides[this.activeIndex].attributes['data-num']
// _this.nextQuestionLoading() if (!dataNum) {
// }
if (this.activeIndex === _this.questionsData.sheet.question_count - 1) {
_this.swiperSign = _this.questionsData.sheet.question_count - 1
}
if (this.activeIndex === _this.questionsData.sheet.question_count) {
_this.clickStatus = Date.parse(new Date()) _this.clickStatus = Date.parse(new Date())
_this.requestData.answerPage = _this.questionsData.sheet.question_count - 1 } else {
if (this.activeIndex === this.slides.length - 2 && parseInt(dataNum.nodeValue) !== parseInt(_this.questionsData.sheet.question_count)) {
_this.nextQuestionLoading()
}
} }
} }
} }
...@@ -334,15 +341,23 @@ export default { ...@@ -334,15 +341,23 @@ export default {
}, },
methods: { methods: {
prevQuestionLoading() { prevQuestionLoading() {
Toast.loading({
message: '加载中...',
duration: 1000,
loadingType: 'spinner'
})
const dId = this.swiper.slides[this.swiper.activeIndex].attributes['data-dId'].nodeValue const dId = this.swiper.slides[this.swiper.activeIndex].attributes['data-dId'].nodeValue
if (this.countPage.currentPage !== 1) {
this.countPage.currentPage-- this.countPage.currentPage--
}
this.$nextTick(() => { this.$nextTick(() => {
for (let i = 0; i < this.swiper.slides.length; i++) { for (let i = 0; i < this.swiper.slides.length; i++) {
if (this.swiper.slides[i].attributes['data-dId']) { if (this.swiper.slides[i].attributes['data-dId']) {
this.swiper.slides[i].attributes['data-dId'].nodeValue === dId && (this.swiper.slideTo(i, 0, false)) this.swiper.slides[i].attributes['data-dId'].nodeValue === dId && (this.swiper.slideTo(i, 0, false))
} }
this.currentNum = this.swiper.activeIndex
} }
this.currentNum = parseInt(this.slides[this.activeIndex].attributes['data-num'].nodeValue)
Toast.clear()
}) })
}, },
nextQuestionLoading() { nextQuestionLoading() {
...@@ -492,17 +507,24 @@ export default { ...@@ -492,17 +507,24 @@ export default {
}, },
// 答题卡点击跳题 // 答题卡点击跳题
cardChange(data) { cardChange(data) {
Toast.loading({
message: '加载中...',
duration: 3000,
loadingType: 'spinner'
})
const e = data.id const e = data.id
this.countPage.currentPage = data.num this.countPage.currentPage = data.num + 1
for (let i = 0; i < this.questionsData.sheet.question_count; i++) { this.$nextTick(() => {
for (let i = 0; i < this.swiper.slides.length; i++) {
if (this.swiper.slides[i].attributes['data-dId']) {
if (this.swiper.slides[i].attributes['data-dId'].nodeValue === e) { if (this.swiper.slides[i].attributes['data-dId'].nodeValue === e) {
setTimeout(() => { setTimeout(() => {
document.getElementById('bottom-view').scrollTop = 0 document.getElementById('bottom-view').scrollTop = 0
this.swiper.slideTo(i, 0, false) this.swiper.slideTo(i, 0, false)
this.topicCard.isShow = false this.topicCard.isShow = false
setTimeout(() => { setTimeout(() => {
this.requestData.answerPage = this.swiper.activeIndex this.requestData.answerPage = this.swiper.slides[i].attributes['data-num'].nodeValue
this.currentNum = this.swiper.activeIndex + 1 this.currentNum = parseInt(this.swiper.slides[i].attributes['data-num'].nodeValue)
this.currentNum === this.questionsData.sheet.question_count this.currentNum === this.questionsData.sheet.question_count
? this.nextBtnShow = false ? this.nextBtnShow = false
: this.nextBtnShow = true : this.nextBtnShow = true
...@@ -512,18 +534,17 @@ export default { ...@@ -512,18 +534,17 @@ export default {
}, 200) }, 200)
} }
} }
}
})
}, },
showCard() { showCard() {
this.requestData.answerPage = this.swiper.activeIndex const dataNum = parseInt(this.swiper.slides[this.swiper.activeIndex].attributes['data-num'].nodeValue)
this.requestData.answerPage = dataNum
this.swiperSign = dataNum
this.clickStatus = Date.parse(new Date()) this.clickStatus = Date.parse(new Date())
if (this.swiper.activeIndex !== this.questionsData.sheet.question_count) {
this.swiperSign = this.swiper.activeIndex
} else {
this.swiperSign = this.swiper.activeIndex - 1
}
document.getElementById('bottom-view').scrollTop = 0 document.getElementById('bottom-view').scrollTop = 0
this.topicCard.isShow = true this.topicCard.isShow = true
this.swiper.slideTo(this.questionsData.sheet.question_count, 0, false) this.swiper.slideTo(this.swiper.slides.length - 1, 0, false)
}, },
// 标记 // 标记
signQuestion() { signQuestion() {
...@@ -722,11 +743,16 @@ export default { ...@@ -722,11 +743,16 @@ export default {
: this.nextBtnShow = true : this.nextBtnShow = true
if (res.answers !== null) { if (res.answers !== null) {
if (res.answers.answerPage !== undefined && this.$route.query.id === undefined && res.answers.answerPage !== this.questionsData.sheet.question_count) { if (res.answers.answerPage !== undefined && this.$route.query.id === undefined && res.answers.answerPage !== this.questionsData.sheet.question_count) {
setTimeout(() => { this.countPage.currentPage = parseInt(res.answers.answerPage / 10) + 1
this.currentNum = res.answers.answerPage + 1 this.$nextTick(() => {
this.swiper.slideTo(res.answers.answerPage, 0, false) for (let i = 0; i < this.swiper.slides.length; i++) {
if (this.swiper.slides[i].attributes['data-num']) {
parseInt(this.swiper.slides[i].attributes['data-num'].nodeValue) === parseInt(res.answers.answerPage) && (this.swiper.slideTo(i, 0, false))
}
}
this.currentNum = res.answers.answerPage
this.currentNum === this.questionsData.sheet.question_count ? this.nextBtnShow = false : this.nextBtnShow = true this.currentNum === this.questionsData.sheet.question_count ? this.nextBtnShow = false : this.nextBtnShow = true
}, 100) })
} }
const datas = res.answers const datas = res.answers
if (datas.length === 0) { if (datas.length === 0) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论