提交 6eb67cfc authored 作者: lihuihui's avatar lihuihui

updata

上级 8e1d38da
......@@ -77,4 +77,16 @@ export default class ExamAction extends BaseACTION {
return res
})
}
deleteCollect(obj) {
return Exam.deleteCollect(obj).then(res => {
return res
})
}
collectQuestion(obj) {
return Exam.collectQuestion(obj).then(res => {
return res
})
}
}
......@@ -3,4 +3,6 @@ export default class Exam extends BaseAPI {
getExam = (obj, url) => this.get(url, obj)
getPower = (obj, url) => this.post(url, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
examSubmit = (obj, url) => this.post(url, obj, { headers: { 'Content-Type': 'multipart/form-data' } })
deleteCollect = (obj) => this.post('/zy/v2/examination/delete-my-question', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
collectQuestion = (obj) => this.post('/zy/v2/examination/question/add', obj, { headers: { 'Content-Type': 'multipart/form-data' } })
}
......@@ -73,12 +73,11 @@
</swiper>
</div>
<!-- v-if="$route.query.id != undefined || questionCount == 1" -->
<!-- <div v-if="swiper"></div> -->
<template v-if="$route.query.id == undefined">
<div class="btn-box">
<div class="padd" v-if="!topicCard.isShow">
<!-- {{ swiper.slides[swiper.activeIndex].attributes['data-dId'].nodeValue }} -->
<!-- <div class="icon1 active" @click="collectQuestion()"></div> -->
<div :class="collect.currentPages ? 'icon1 active' : 'icon1'" @click="collectQuestion()"></div>
<div class="analysis" @click="analyShow" v-if="$route.query.id == undefined && ($route.query.course_id || $route.query.tag_id)">查看解析</div>
<div class="btn left" @click="switchQuestions('left')" v-show="currentNum !== 1">上一题</div>
<div class="btn right" @click="switchQuestions('right')" v-show="nextBtnShow">下一题</div>
......@@ -94,7 +93,7 @@
<div class="btn-box" v-if="questionCount != 1">
<div class="padd" v-if="!topicCard.isShow">
<!-- {{ swiper.slides[swiper.activeIndex].attributes['data-dId'].nodeValue }} -->
<!-- <div class="icon1 active" @click="collectQuestion()"></div> -->
<div :class="collect.currentPages ? 'icon1 active' : 'icon1'" @click="collectQuestion()"></div>
<div class="analysis" @click="analyShow" v-if="$route.query.id == undefined && ($route.query.course_id || $route.query.tag_id)">查看解析</div>
<div class="btn left" @click="switchQuestions('left')" v-show="currentNum !== 1">上一题</div>
<div class="btn right" @click="switchQuestions('right')" v-show="nextBtnShow">下一题</div>
......@@ -160,7 +159,12 @@ export default {
data () {
const _this = this
return {
currentId: {},
collect: {
currentPages: false,
currentId: '',
currentIdParent: ''
},
currentCollect: false,
clickStatus: 0,
questionCount: Number,
classHide: true,
......@@ -176,6 +180,7 @@ export default {
autoHeight: true,
on: {
slideChangeTransitionStart: function() {
_this.setCurrentCollect()
_this.getIsSign()
if (this.activeIndex === _this.questionsData.sheet.question_count) {
_this.topicCard.isShow = true
......@@ -255,7 +260,41 @@ export default {
this.answerInit()
},
methods: {
collectQuestion() {},
collectQuestion() {
const queIds = this.collect.currentId
this.collect.currentPages ? this.removeColl(queIds, () => {
Toast('取消收藏成功')
this.collect.currentPages = false
this.setCollect(false)
}) : this.addColl(queIds, () => {
Toast('收藏成功')
this.collect.currentPages = true
this.setCollect(true)
})
// console.log(this.questionsData.questions)
},
setCollect(state) {
this.questionsData.questions.map(item => {
if (item.id === this.collect.currentIdParent) {
const data = item.question_list.find(i => { return i.id === this.collect.currentId })
data.is_collection = state
}
})
},
addColl(id, callback) {
Exam.collectQuestion({ question_id: id }).then(res => {
if (res.code === 0) {
callback()
}
})
},
removeColl(id, callback) {
Exam.deleteCollect({ type: 2, question_id: id }).then(res => {
if (res.code === 0) {
callback()
}
})
},
// 页面初始化
answerInit() {
Toast.loading({
......@@ -363,6 +402,7 @@ export default {
this.currentNum === this.questionsData.sheet.question_count
? this.nextBtnShow = false
: this.nextBtnShow = true
this.setCurrentCollect()
}, 100)
this.getIsSign()
}, 200)
......@@ -616,6 +656,7 @@ export default {
setTimeout(() => {
this.currentNum = res.answers.answerPage + 1
this.swiper.slideTo(res.answers.answerPage, 0, false)
this.setCurrentCollect()
this.currentNum === this.questionsData.sheet.question_count ? this.nextBtnShow = false : this.nextBtnShow = true
}, 100)
}
......@@ -628,11 +669,27 @@ export default {
this.requestData = datas
this.requestData2 = Object.keys(datas).length
} else {
setTimeout(() => {
this.setCurrentCollect()
}, 300)
this.requestData = {}
this.requestData2 = 0
}
})
},
setCurrentCollect() {
const itemDid = this.swiper.slides[this.swiper.activeIndex].attributes['data-dId'].nodeValue
const itemCid = this.swiper.slides[this.swiper.activeIndex].attributes['data-cId'].nodeValue
this.questionsData.questions.find(item => {
if (item.id === itemCid) {
const currentItem = item.question_list.find(i => { return i.id === itemDid })
// this.currentCollect = currentItem.is_collection
this.collect.currentPages = currentItem.is_collection
this.collect.currentId = itemDid
this.collect.currentIdParent = itemCid
}
})
},
errorQuestion(data) {
let count = 0
const result = data.questions.map(item => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论