You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jwl-applet/src/pages/questionBank/questionBank.vue

129 lines
3.2 KiB

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