|
@@ -41,32 +41,65 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async mounted() {
|
|
async mounted() {
|
|
- await this.getData()
|
|
|
|
- if (this.hotspotData && this.hotspotData.content) {
|
|
|
|
|
|
+ let url = `https://super.4dage.com/data/${this.$route.query.id}/hot/js/data.js?time=${Math.random()}`
|
|
|
|
+ let result = (await this.$http.get(url)).data
|
|
|
|
+ this.hotspotData = result[this.$route.query.m]
|
|
|
|
+ if (!this.hotspotData) {
|
|
|
|
+ return alert("热点解析错误")
|
|
|
|
+ }
|
|
|
|
+ console.log('热点数据:', this.hotspotData)
|
|
|
|
+ // this.bgAudioUrl = this.hotspotData.backgroundMusic
|
|
|
|
+
|
|
|
|
+ const answerRecord = await globalApi.getAnswerRecord()
|
|
|
|
+
|
|
|
|
+ let recordOnThisHotspot = []
|
|
|
|
+ if (answerRecord.length) {
|
|
|
|
+ recordOnThisHotspot = answerRecord.filter((item) => {
|
|
|
|
+ return item.num.split('.')[0] === this.hotspotData.content
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (recordOnThisHotspot.length === 0 ) { //没答过这个点位的题
|
|
|
|
+ const newId = globalUtils.getNextQuestionId(this.hotspotData.content)
|
|
const quizInfo = quizData.find((item) => {
|
|
const quizInfo = quizData.find((item) => {
|
|
- return item.id === this.hotspotData.content
|
|
|
|
|
|
+ return item.id === newId
|
|
})
|
|
})
|
|
this.setQuestionInfo(quizInfo)
|
|
this.setQuestionInfo(quizInfo)
|
|
- if (quizInfo.questionType === '判断题') {
|
|
|
|
|
|
+ this.$router.push({ name: 'QuestionJudge' })
|
|
|
|
+ } else { //答过这个点位的题,可能要找到最近答的那道题,恢复现场
|
|
|
|
+ const latestRecord = recordOnThisHotspot.reduce((accu, curr) => {
|
|
|
|
+ if (new Date(accu.updateTime).getTime() <= new Date(curr.updateTime).getTime()) {
|
|
|
|
+ return curr
|
|
|
|
+ } else {
|
|
|
|
+ return accu
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if (!globalUtils.getRemainingQuestionNumber(latestRecord.num)) { // 上次答的是最后一题,重新回到第一题
|
|
|
|
+ const newId = globalUtils.getNextQuestionId(this.hotspotData.content)
|
|
|
|
+ const quizInfo = quizData.find((item) => {
|
|
|
|
+ return item.id === newId
|
|
|
|
+ })
|
|
|
|
+ this.setQuestionInfo(quizInfo)
|
|
|
|
+ this.$router.push({ name: 'QuestionJudge' })
|
|
|
|
+ } else {
|
|
|
|
+ const quizInfo = quizData.find((item) => {
|
|
|
|
+ return item.id === latestRecord.num
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.setAnswerRecord(latestRecord)
|
|
|
|
+ this.setIsSubmitted(true)
|
|
|
|
+ this.setQuestionInfo(quizInfo)
|
|
|
|
+ // if (quizInfo.questionType === '判断题') {
|
|
this.$router.push({ name: 'QuestionJudge' })
|
|
this.$router.push({ name: 'QuestionJudge' })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
...globalMapMutations([
|
|
...globalMapMutations([
|
|
- 'setQuestionInfo'
|
|
|
|
|
|
+ 'setQuestionInfo',
|
|
|
|
+ 'setAnswerRecord',
|
|
|
|
+ 'setIsSubmitted',
|
|
]),
|
|
]),
|
|
- async getData() {
|
|
|
|
- let url = `https://super.4dage.com/data/${this.$route.query.id}/hot/js/data.js?time=${Math.random()}`
|
|
|
|
- let result = (await this.$http.get(url)).data
|
|
|
|
- this.hotspotData = result[this.$route.query.m]
|
|
|
|
- if (!this.hotspotData) {
|
|
|
|
- return alert("热点解析错误")
|
|
|
|
- }
|
|
|
|
- console.log('热点数据:', this.hotspotData)
|
|
|
|
-
|
|
|
|
- // this.bgAudioUrl = this.hotspotData.backgroundMusic
|
|
|
|
- },
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|