|
|
|
<template>
|
|
|
|
<view>
|
|
|
|
<!-- <u-navbar :title="navTitle" @rightClick="rightClick" :autoBack="true">
|
|
|
|
</u-navbar> -->
|
|
|
|
<j-navbar>{{navTitle}}</j-navbar>
|
|
|
|
<Question ref="question" :tabsList="tabsList" :isShowAll="isShowAll" :subject="subject" :navTitle="navTitle"
|
|
|
|
@changeTab="changeTab"></Question>
|
|
|
|
</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
|
|
|
|
} from '@/jtools/api/question';
|
|
|
|
import storage from '@/jtools/storage';
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Question
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isShowAll: true,
|
|
|
|
needVip: false,
|
|
|
|
subject: 1,
|
|
|
|
navTitle: '',
|
|
|
|
tabsList: [{
|
|
|
|
label: "答题",
|
|
|
|
value: 0
|
|
|
|
}, {
|
|
|
|
label: "背题",
|
|
|
|
value: 1
|
|
|
|
}],
|
|
|
|
questionArr: []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async onLoad(op) {
|
|
|
|
if (op.needVip) {
|
|
|
|
this.needVip = op.needVip
|
|
|
|
}
|
|
|
|
if (op && op.navTitle) {
|
|
|
|
this.navTitle = op.navTitle
|
|
|
|
const param = {}
|
|
|
|
if (this.navTitle === '顺序答题' || this.navTitle === '精简500题') {
|
|
|
|
this.questionArr = [...this.orderQuestion]
|
|
|
|
if (this.needVip === 'true') {
|
|
|
|
if (this.token) {
|
|
|
|
await this.searchUserVip()
|
|
|
|
const res = this.vipOnList.some(item => item.subjects == this.subject)
|
|
|
|
if (!res) {
|
|
|
|
this.questionArr = this.questionArr.slice(0, 3)
|
|
|
|
this.isShowAll = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uni.redirectTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr))
|
|
|
|
} else {
|
|
|
|
if (!storage.get('token')) {
|
|
|
|
uni.navigateTo({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (this.navTitle === '错题本') {
|
|
|
|
param.questionIdList = storage.get(`wrongList_subject${this.subject}`) || []
|
|
|
|
} else if (this.navTitle === '收藏夹') {
|
|
|
|
param.questionIdList = storage.get(`collectList_subject${this.subject}`) || []
|
|
|
|
}
|
|
|
|
if (op.questionList) {
|
|
|
|
param.questionIdList = JSON.parse(op.questionList)
|
|
|
|
}
|
|
|
|
if (op.chapter) {
|
|
|
|
param.chapter = op.chapter
|
|
|
|
}
|
|
|
|
if (op.examKey) {
|
|
|
|
param.examKey = op.examKey
|
|
|
|
}
|
|
|
|
queryQuestion(param).then(res => {
|
|
|
|
if (res.code == '0000') {
|
|
|
|
this.questionArr = res.data
|
|
|
|
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (op.subject) {
|
|
|
|
this.subject = op.subject
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(useQuestionStore, ["orderQuestion"]), //映射函数,取出tagslist
|
|
|
|
...mapState(useUserStore, ["vipOnList", "token"])
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(useUserStore, ['searchUserVip']),
|
|
|
|
changeTab(val) {
|
|
|
|
if (val == 1) {
|
|
|
|
let list = JSON.parse(JSON.stringify(this.questionArr))
|
|
|
|
list = list.map(item => {
|
|
|
|
return {
|
|
|
|
...item,
|
|
|
|
clickAnswer: item.trueAnswer
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.$refs.question.getQuestionList(JSON.stringify(list))
|
|
|
|
} else {
|
|
|
|
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
rightClick() {
|
|
|
|
console.log('返回');
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|