|
|
|
<template>
|
|
|
|
<view>
|
|
|
|
<u-loading-page :loading="loading" :loading-text="loadTxt"></u-loading-page>
|
|
|
|
<view v-if="!loading">
|
|
|
|
<j-navbar>{{navTitle}}</j-navbar>
|
|
|
|
<Question ref="question" :tabsList="tabsList" :isShowAll="isShowAll" :subject="subject" :navTitle="navTitle"
|
|
|
|
@changeTab="changeTab"></Question>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import {
|
|
|
|
mapState,
|
|
|
|
mapActions
|
|
|
|
} from 'pinia' //引入映射函数
|
|
|
|
import useQuestionStore from '@/jtools/store/question' //引入store
|
|
|
|
import useUserStore from '@/jtools/store/user'
|
|
|
|
import Question from './components/Question.vue';
|
|
|
|
import {
|
|
|
|
queryQuestion,
|
|
|
|
queryQuestionId
|
|
|
|
} from '@/jtools/api/question';
|
|
|
|
import storage from '@/jtools/storage';
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Question
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
loadTxt: '加载中...',
|
|
|
|
collectList: storage.get(`collectList_subject${this.subject}`) || [],
|
|
|
|
loading: false,
|
|
|
|
isShowAll: true,
|
|
|
|
needVip: false,
|
|
|
|
subject: 1,
|
|
|
|
navTitle: '',
|
|
|
|
tabsList: [{
|
|
|
|
label: "答题",
|
|
|
|
value: 0
|
|
|
|
}, {
|
|
|
|
label: "背题",
|
|
|
|
value: 1
|
|
|
|
}],
|
|
|
|
questionArr: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async onLoad(op) {
|
|
|
|
this.loading = true
|
|
|
|
if (op.needVip) {
|
|
|
|
this.needVip = op.needVip
|
|
|
|
}
|
|
|
|
if (op.subject) {
|
|
|
|
this.subject = op.subject
|
|
|
|
}
|
|
|
|
if (op && op.navTitle) {
|
|
|
|
this.navTitle = op.navTitle
|
|
|
|
let arr = []
|
|
|
|
let param = {}
|
|
|
|
if (op.needVip) {
|
|
|
|
this.isShowAll = !Boolean(op.needVip == 'true')
|
|
|
|
}
|
|
|
|
arr = [...this[`orderQuestion_subject${this.subject}`]]
|
|
|
|
let questionObj={}
|
|
|
|
arr.forEach(item => {
|
|
|
|
item.isChoose=false
|
|
|
|
questionObj[item.questionId]=item
|
|
|
|
})
|
|
|
|
if(op.navTitle==='顺序答题'){
|
|
|
|
this.questionArr=arr
|
|
|
|
}else if (op.questionIdList) {
|
|
|
|
const idList = JSON.parse(op.questionIdList)
|
|
|
|
if(idList&&idList.length>0){
|
|
|
|
idList.forEach(item=>{
|
|
|
|
this.questionArr.push(questionObj[item])
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.loading = false
|
|
|
|
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr), this.navTitle)
|
|
|
|
this.$refs.question.getOriginArr(JSON.stringify(this.questionArr))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(useQuestionStore, ["orderQuestion_subject1", "orderQuestion_subject4", "version"]), //映射函数,取出tagslist
|
|
|
|
...mapState(useUserStore, ["vipOnList", "token"]),
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(useUserStore, ['searchUserVip']),
|
|
|
|
...mapActions(useQuestionStore, ['getAllQuestion']),
|
|
|
|
changeTab(val) {
|
|
|
|
if (val == 1) {
|
|
|
|
let list = JSON.parse(JSON.stringify(this.questionArr))
|
|
|
|
list = list.map(item => {
|
|
|
|
return {
|
|
|
|
...item,
|
|
|
|
clickAnswer: item.trueAnswer,
|
|
|
|
isChoose: true,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.$refs.question.isShowBest(true)
|
|
|
|
this.$refs.question.getQuestionList(JSON.stringify(list), this.navTitle)
|
|
|
|
} else {
|
|
|
|
this.$refs.question.isShowBest(false)
|
|
|
|
this.$refs.question.getQuestionList()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
rightClick() {
|
|
|
|
console.log('返回');
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|