|
@@ -46,100 +46,100 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
export default {
|
|
export default {
|
|
- data() {
|
|
|
|
- return {
|
|
|
|
- bg: require('../../public/img/contest/bg.png'),
|
|
|
|
- conTop: {
|
|
|
|
- backgroundImage: 'url(' + require('../../public/img/contest/confirm-bg.png') + ')',
|
|
|
|
- backgroundRepeat: 'no-repeat',
|
|
|
|
- backgroundSize: 'cover'
|
|
|
|
- },
|
|
|
|
- icon: require('../../public/img/contest/success.png'),
|
|
|
|
- page: 1,
|
|
|
|
- questions: [],
|
|
|
|
- chooseList: [],
|
|
|
|
- paperId: null,
|
|
|
|
- timer: null,
|
|
|
|
- paperDuration: 0,
|
|
|
|
- submitState: 0 // 0 正常 1 警告 2 完成
|
|
|
|
- }
|
|
|
|
|
|
+ data () {
|
|
|
|
+ return {
|
|
|
|
+ bg: require('../../public/img/contest/bg.png'),
|
|
|
|
+ conTop: {
|
|
|
|
+ backgroundImage: 'url(' + require('../../public/img/contest/confirm-bg.png') + ')',
|
|
|
|
+ backgroundRepeat: 'no-repeat',
|
|
|
|
+ backgroundSize: 'cover'
|
|
|
|
+ },
|
|
|
|
+ icon: require('../../public/img/contest/success.png'),
|
|
|
|
+ page: 1,
|
|
|
|
+ questions: [],
|
|
|
|
+ chooseList: [],
|
|
|
|
+ paperId: null,
|
|
|
|
+ timer: null,
|
|
|
|
+ paperDuration: 0,
|
|
|
|
+ submitState: 0 // 0 正常 1 警告 2 完成
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ answerList () {
|
|
|
|
+ let {
|
|
|
|
+ questions,
|
|
|
|
+ page
|
|
|
|
+ } = this.$data
|
|
|
|
+ return this.submitState ? [] : questions.filter((itx, num) => num >= (page - 1) * 10 && num < page * 10)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ page () {
|
|
|
|
+ document.body.scrollIntoView()
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ getAttendContest () {
|
|
|
|
+ this.$api.post('/mCompetition/attendContest', {
|
|
|
|
+ userId: 7
|
|
|
|
+ }).then(r => {
|
|
|
|
+ this.questions = r.object.questions
|
|
|
|
+ this.paperId = r.object.paperId
|
|
|
|
+ })
|
|
},
|
|
},
|
|
- computed: {
|
|
|
|
- answerList() {
|
|
|
|
- let {
|
|
|
|
- questions,
|
|
|
|
- page
|
|
|
|
- } = this.$data
|
|
|
|
- return this.submitState ? [] : questions.filter((itx, num) => num >= (page - 1) * 10 && num < page * 10)
|
|
|
|
- }
|
|
|
|
|
|
+ // q 问题下标 a 选择答案下标
|
|
|
|
+ clickChoose (q, a) {
|
|
|
|
+ this.$set(this.chooseList, q, a)
|
|
},
|
|
},
|
|
- watch: {
|
|
|
|
- page() {
|
|
|
|
- document.body.scrollIntoView()
|
|
|
|
|
|
+ // false 需确认 true 直接请求
|
|
|
|
+ submit (type) {
|
|
|
|
+ if (!type) {
|
|
|
|
+ if (!this.chooseList.every(item => item || item === 0)) {
|
|
|
|
+ return this.submitState = 1
|
|
}
|
|
}
|
|
- },
|
|
|
|
- methods: {
|
|
|
|
- getAttendContest() {
|
|
|
|
- this.$api.post('/mCompetition/attendContest', {
|
|
|
|
- userId: 7
|
|
|
|
- }).then(r => {
|
|
|
|
- this.questions = r.object.questions
|
|
|
|
- this.paperId = r.object.paperId
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // q 问题下标 a 选择答案下标
|
|
|
|
- clickChoose(q, a) {
|
|
|
|
- this.$set(this.chooseList, q, a)
|
|
|
|
|
|
+ }
|
|
|
|
+ let paperScore = 0
|
|
|
|
+ let questionWrong = []
|
|
|
|
+ let {
|
|
|
|
+ paperDuration,
|
|
|
|
+ paperId,
|
|
|
|
+ questions,
|
|
|
|
+ chooseList
|
|
|
|
+ } = this.$data
|
|
|
|
+ questions.forEach((item, index) => {
|
|
|
|
+ (chooseList[index] || chooseList[index] === 0) && item.options[chooseList[index]].optionAnswer
|
|
|
|
+ ? paperScore += 2
|
|
|
|
+ : questionWrong.push({
|
|
|
|
+ [item.id]: (chooseList[index] || chooseList[index] === 0) ? item.options[chooseList[index]].optionId : ''
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ this.$api.post('/mCompetition/submitUserAnswer', {
|
|
|
|
+ reqdata: {
|
|
|
|
+ paperId,
|
|
|
|
+ paperDuration,
|
|
|
|
+ paperScore,
|
|
|
|
+ questionWrong: JSON.stringify(questionWrong),
|
|
|
|
+ userId: 7
|
|
},
|
|
},
|
|
- // false 需确认 true 直接请求
|
|
|
|
- submit(type) {
|
|
|
|
- if (!type) {
|
|
|
|
- if (!this.chooseList.every(item => item || item === 0)) {
|
|
|
|
- return this.submitState = 1
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- let paperScore = 0
|
|
|
|
- let questionWrong = []
|
|
|
|
- let {
|
|
|
|
- paperDuration,
|
|
|
|
- paperId,
|
|
|
|
- questions,
|
|
|
|
- chooseList
|
|
|
|
- } = this.$data
|
|
|
|
- questions.forEach((item, index) => {
|
|
|
|
- (chooseList[index] || chooseList[index] === 0) && item.options[chooseList[index]].optionAnswer ?
|
|
|
|
- paperScore += 2 :
|
|
|
|
- questionWrong.push({
|
|
|
|
- [item.id]: (chooseList[index] || chooseList[index] === 0) ? item.options[chooseList[index]].optionId : ''
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- this.$api.post('/mCompetition/submitUserAnswer', {
|
|
|
|
- reqdata: {
|
|
|
|
- paperId,
|
|
|
|
- paperDuration,
|
|
|
|
- paperScore,
|
|
|
|
- questionWrong: JSON.stringify(questionWrong),
|
|
|
|
- userId: 7
|
|
|
|
- },
|
|
|
|
- userId: 7
|
|
|
|
- }).then(r => {
|
|
|
|
- this.submitState = 2
|
|
|
|
- clearInterval(this.timer)
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- mounted() {
|
|
|
|
- this.getAttendContest()
|
|
|
|
- },
|
|
|
|
- created() {
|
|
|
|
- this.timer = setInterval(() => {
|
|
|
|
- this.paperDuration += 1
|
|
|
|
- console.log(this.paperDuration)
|
|
|
|
- }, 1000)
|
|
|
|
- },
|
|
|
|
- beforeDestroy() {
|
|
|
|
- this.timer && clearInterval(this.timer)
|
|
|
|
|
|
+ userId: 7
|
|
|
|
+ }).then(r => {
|
|
|
|
+ this.submitState = 2
|
|
|
|
+ clearInterval(this.timer)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ mounted () {
|
|
|
|
+ this.getAttendContest()
|
|
|
|
+ },
|
|
|
|
+ created () {
|
|
|
|
+ this.timer = setInterval(() => {
|
|
|
|
+ this.paperDuration += 1
|
|
|
|
+ console.log(this.paperDuration)
|
|
|
|
+ }, 1000)
|
|
|
|
+ },
|
|
|
|
+ beforeDestroy () {
|
|
|
|
+ this.timer && clearInterval(this.timer)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|