This commit is contained in:
2023-08-24 16:53:11 +08:00
14 changed files with 197 additions and 134 deletions

View File

@@ -3,9 +3,10 @@
<!-- <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>
<Question ref="question" :tabsList="tabsList" :isShowAll="isShowAll" :subject="subject" :navTitle="navTitle"
@changeTab="changeTab"></Question>
</view>
</template>
<script>
import {
@@ -25,58 +26,64 @@
},
data() {
return {
isShowAll:true,
needVip:false,
subject:1,
navTitle:'',
tabsList:[{
label:"答题",
value:0
},{
label:"背题",
value:1
isShowAll: true,
needVip: false,
subject: 1,
navTitle: '',
tabsList: [{
label: "答题",
value: 0
}, {
label: "背题",
value: 1
}],
questionArr:[]
questionArr: []
}
},
async onLoad(op) {
if(op.needVip){
this.needVip=op.needVip
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){
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.subject==this.subject)
if(!res){
this.questionArr=this.questionArr.slice(0,3)
this.isShowAll=false
const res = this.vipOnList.some(item => item.subjects == this.subject)
if (!res) {
this.questionArr = this.questionArr.slice(0, 3)
this.isShowAll = false
}
}else{
} else {
uni.redirectTo({
url: '/pages/login/login'
url: '/pages/login/login'
});
}
}
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr))
}else{
if(this.navTitle==='错题本'){
param.questionIdList=storage.get(`wrongList_subject${this.subject}`) || []
}else if(this.navTitle==='收藏夹'){
param.questionIdList=storage.get(`collectList_subject${this.subject}`) || []
} else {
if (!storage.get('token')) {
uni.navigateTo({
url: '/pages/login/login'
})
return
}
if(op.questionList){
param.questionIdList=JSON.parse(op.questionList)
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.chapter){
param.chapter=op.chapter
if (op.questionList) {
param.questionIdList = JSON.parse(op.questionList)
}
if(op.examKey){
param.examKey=op.examKey
if (op.chapter) {
param.chapter = op.chapter
}
if (op.examKey) {
param.examKey = op.examKey
}
queryQuestion(param).then(res => {
if (res.code == '0000') {
@@ -86,27 +93,27 @@
})
}
}
if(op.subject){
this.subject=op.subject
if (op.subject) {
this.subject = op.subject
}
},
computed: {
...mapState(useQuestionStore, ["orderQuestion"]) ,//映射函数取出tagslist
...mapState(useUserStore, ["vipOnList","token"])
...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{
...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
clickAnswer: item.trueAnswer
}
})
this.$refs.question.getQuestionList(JSON.stringify(list))
}else{
} else {
this.$refs.question.getQuestionList(JSON.stringify(this.questionArr))
}
},
@@ -119,4 +126,4 @@
<style scoped>
</style>
</style>