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

146 lines
3.7 KiB

2 years ago
<template>
<view>
2 years ago
<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>
2 years ago
</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 {
2 years ago
queryQuestion,
queryQuestionId
2 years ago
} 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
loadTxt:'加载中...',
collectList: storage.get(`collectList_subject${this.subject}`) || [],
loading:false,
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
this.loading=true
2 years ago
if (op.needVip) {
this.needVip = op.needVip
2 years ago
}
2 years ago
if (op.subject) {
this.subject = op.subject
2 years ago
}
2 years ago
if (op && op.navTitle) {
this.navTitle = op.navTitle
2 years ago
let arr=[]
let param={}
if(op.needVip){
this.isShowAll = !Boolean(op.needVip=='true')
}
2 years ago
if (this.navTitle === '顺序答题') {
2 years ago
if (this.subject == '1') {
arr = [...this.orderQuestion_subject1]
} else if (this.subject == '4') {
arr = [...this.orderQuestion_subject4]
2 years ago
}
2 years ago
} else if(op.questionIdList){
const idList=JSON.parse(op.questionIdList)
arr = this[`orderQuestion_subject${this.subject}`].filter(qItem=>idList.includes(qItem.questionId))
}else{
2 years ago
if(op.isVip){
param.isVip=op.isVip
}
2 years ago
const resp=await queryQuestionId({
subject:this.subject,
carTypeId:storage.get('carType') || '1001',
versionId:this.version,
...params
2 years ago
})
2 years ago
let list=[]
if(resp.code==='0000'){
await this.searchUserVip()
const res = this.vipOnList.some(item => item.subjects.includes(this.subject))
if (!res) {
list=resp.data.slice(0,3)
}else{
list=resp.data
}
}
if(op.needVip){
this.isShowAll = op.needVip
}
arr=this[`orderQuestion_subject${this.subject}`].filter(qItem=>list.includes(qItem.questionId))
2 years ago
}
2 years ago
arr.forEach(item => {
let isCollect = false
if (this.collectList.includes(item.questionId)) {
isCollect = true
}
this.questionArr.push({
isChoose: false,
isCollect: isCollect,
...item
})
})
this.loading=false
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr),this.navTitle)
this.$refs.question.getOriginArr(JSON.stringify(this.questionArr))
2 years ago
}
2 years ago
},
computed: {
2 years ago
...mapState(useQuestionStore, ["orderQuestion_subject1", "orderQuestion_subject4","version"]), //映射函数,取出tagslist
...mapState(useUserStore, ["vipOnList", "token"]),
2 years ago
},
2 years ago
methods: {
2 years ago
...mapActions(useUserStore, ['searchUserVip']),
2 years ago
...mapActions(useQuestionStore, ['getAllQuestion']),
2 years ago
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,
isChoose: true,
2 years ago
}
})
2 years ago
this.$refs.question.isShowBest(true)
2 years ago
this.$refs.question.getQuestionList(JSON.stringify(list),this.navTitle)
2 years ago
} else {
2 years ago
this.$refs.question.isShowBest(false)
2 years ago
this.$refs.question.getQuestionList()
2 years ago
}
},
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>