Files
jwl-applet/src/pages/questionBank/questionBank.vue

117 lines
2.9 KiB
Vue
Raw Normal View History

2023-08-12 22:15:27 +08:00
<template>
<view>
2023-09-06 00:28:46 +08:00
<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>
2023-08-24 16:53:11 +08:00
</view>
</template>
2023-08-12 22:15:27 +08:00
<script>
2023-08-15 23:45:00 +08:00
import {
mapState,
mapActions
} from 'pinia' //引入映射函数
import useQuestionStore from '@/jtools/store/question' //引入store
2023-08-22 17:27:54 +08:00
import useUserStore from '@/jtools/store/user'
2023-08-15 23:45:00 +08:00
import Question from './components/Question.vue';
2023-08-21 09:10:50 +08:00
import {
2023-09-06 00:28:46 +08:00
queryQuestion,
queryQuestionId
2023-08-21 09:10:50 +08:00
} from '@/jtools/api/question';
import storage from '@/jtools/storage';
2023-08-12 22:15:27 +08:00
export default {
2023-08-15 23:45:00 +08:00
components: {
Question
},
2023-08-12 22:15:27 +08:00
data() {
return {
2023-09-07 09:47:38 +08:00
loadTxt: '加载中...',
2023-09-06 00:28:46 +08:00
collectList: storage.get(`collectList_subject${this.subject}`) || [],
2023-09-07 09:47:38 +08:00
loading: false,
2023-08-24 16:53:11 +08:00
isShowAll: true,
needVip: false,
subject: 1,
navTitle: '',
tabsList: [{
label: "答题",
value: 0
}, {
label: "背题",
value: 1
2023-08-20 01:59:40 +08:00
}],
2023-08-24 16:53:11 +08:00
questionArr: []
2023-08-12 22:15:27 +08:00
}
},
2023-08-22 17:27:54 +08:00
async onLoad(op) {
2023-09-07 09:47:38 +08:00
this.loading = true
2023-08-24 16:53:11 +08:00
if (op.needVip) {
this.needVip = op.needVip
2023-08-22 17:27:54 +08:00
}
2023-09-06 00:28:46 +08:00
if (op.subject) {
this.subject = op.subject
2023-08-25 15:06:46 +08:00
}
2023-08-24 16:53:11 +08:00
if (op && op.navTitle) {
this.navTitle = op.navTitle
2023-09-07 09:47:38 +08:00
let arr = []
let param = {}
if (op.needVip) {
this.isShowAll = !Boolean(op.needVip == 'true')
2023-08-22 17:27:54 +08:00
}
2023-09-07 09:47:38 +08:00
arr = [...this[`orderQuestion_subject${this.subject}`]]
let questionObj={}
2023-09-06 00:28:46 +08:00
arr.forEach(item => {
2023-09-07 09:47:38 +08:00
item.isChoose=false
questionObj[item.questionId]=item
2023-09-06 00:28:46 +08:00
})
2023-09-07 09:47:38 +08:00
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
2023-10-17 12:00:58 +08:00
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr), this.navTitle , this.subject)
2023-09-06 00:28:46 +08:00
this.$refs.question.getOriginArr(JSON.stringify(this.questionArr))
2023-08-21 09:10:50 +08:00
}
2023-08-15 23:45:00 +08:00
},
computed: {
2023-09-07 09:47:38 +08:00
...mapState(useQuestionStore, ["orderQuestion_subject1", "orderQuestion_subject4", "version"]), //映射函数取出tagslist
2023-09-06 00:28:46 +08:00
...mapState(useUserStore, ["vipOnList", "token"]),
2023-08-15 23:45:00 +08:00
},
2023-08-12 22:15:27 +08:00
methods: {
2023-08-24 16:53:11 +08:00
...mapActions(useUserStore, ['searchUserVip']),
2023-09-06 00:28:46 +08:00
...mapActions(useQuestionStore, ['getAllQuestion']),
2023-08-24 16:53:11 +08:00
changeTab(val) {
if (val == 1) {
let list = JSON.parse(JSON.stringify(this.questionArr))
list = list.map(item => {
return {
2023-08-23 21:42:21 +08:00
...item,
2023-09-06 00:28:46 +08:00
clickAnswer: item.trueAnswer,
isChoose: true,
2023-08-23 21:42:21 +08:00
}
})
2023-08-26 14:10:16 +08:00
this.$refs.question.isShowBest(true)
2023-09-07 09:47:38 +08:00
this.$refs.question.getQuestionList(JSON.stringify(list), this.navTitle)
2023-08-24 16:53:11 +08:00
} else {
2023-08-26 14:10:16 +08:00
this.$refs.question.isShowBest(false)
2023-08-28 02:02:46 +08:00
this.$refs.question.getQuestionList()
2023-08-23 21:42:21 +08:00
}
},
2023-08-15 23:45:00 +08:00
rightClick() {
2023-08-12 22:15:27 +08:00
console.log('返回');
2023-08-19 14:04:52 +08:00
},
2023-08-12 22:15:27 +08:00
}
}
</script>
2023-08-19 14:04:52 +08:00
<style scoped>
2023-08-12 22:15:27 +08:00
2023-08-24 16:53:11 +08:00
</style>