提交
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
<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>
|
||||
<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>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -17,7 +18,8 @@
|
||||
import useUserStore from '@/jtools/store/user'
|
||||
import Question from './components/Question.vue';
|
||||
import {
|
||||
queryQuestion
|
||||
queryQuestion,
|
||||
queryQuestionId
|
||||
} from '@/jtools/api/question';
|
||||
import storage from '@/jtools/storage';
|
||||
export default {
|
||||
@@ -26,6 +28,9 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loadTxt:'加载中...',
|
||||
collectList: storage.get(`collectList_subject${this.subject}`) || [],
|
||||
loading:false,
|
||||
isShowAll: true,
|
||||
needVip: false,
|
||||
subject: 1,
|
||||
@@ -41,94 +46,89 @@
|
||||
}
|
||||
},
|
||||
async onLoad(op) {
|
||||
this.loading=true
|
||||
if (op.needVip) {
|
||||
this.needVip = op.needVip
|
||||
}
|
||||
if(op.subject){
|
||||
this.subject=op.subject
|
||||
if (op.subject) {
|
||||
this.subject = op.subject
|
||||
}
|
||||
if (op && op.navTitle) {
|
||||
this.navTitle = op.navTitle
|
||||
const param = {}
|
||||
let arr=[]
|
||||
let param={}
|
||||
if(op.needVip){
|
||||
this.isShowAll = !Boolean(op.needVip=='true')
|
||||
}
|
||||
if (this.navTitle === '顺序答题') {
|
||||
if(this.subject=='1'){
|
||||
this.questionArr = [...this.orderQuestion_subject1]
|
||||
}else if(this.subject=='4'){
|
||||
this.questionArr = [...this.orderQuestion_subject4]
|
||||
}
|
||||
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}`) || []
|
||||
}
|
||||
if (op.questionList) {
|
||||
param.questionIdList = JSON.parse(op.questionList)
|
||||
}
|
||||
if (op.chapter) {
|
||||
param.chapter = op.chapter
|
||||
}
|
||||
if (op.examKey) {
|
||||
param.examKey = op.examKey
|
||||
}
|
||||
if(op.isError&&op.isError=='1'){
|
||||
param.isError=Number(op.isError)
|
||||
}
|
||||
if(op.isNew&&op.isNew=='1'){
|
||||
param.isNew=Number(op.isNew)
|
||||
}
|
||||
if(op.type){
|
||||
param.type=op.type
|
||||
}
|
||||
if(op.isImage){
|
||||
param.isImage=op.isImage
|
||||
if (this.subject == '1') {
|
||||
arr = [...this.orderQuestion_subject1]
|
||||
} else if (this.subject == '4') {
|
||||
arr = [...this.orderQuestion_subject4]
|
||||
}
|
||||
} else if(op.questionIdList){
|
||||
const idList=JSON.parse(op.questionIdList)
|
||||
arr = this[`orderQuestion_subject${this.subject}`].filter(qItem=>idList.includes(qItem.questionId))
|
||||
}else{
|
||||
if(op.isVip){
|
||||
param.isVip=op.isVip
|
||||
}
|
||||
param.subject=this.subject
|
||||
param.carTypeId=storage.get('carType') || '1001'
|
||||
queryQuestion(param).then(async (res) => {
|
||||
if (res.code == '0000') {
|
||||
this.questionArr = res.data
|
||||
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))
|
||||
}
|
||||
const resp=await queryQuestionId({
|
||||
subject:this.subject,
|
||||
carTypeId:storage.get('carType') || '1001',
|
||||
versionId:this.version,
|
||||
...params
|
||||
})
|
||||
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))
|
||||
}
|
||||
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))
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useQuestionStore, ["orderQuestion_subject1","orderQuestion_subject4"]), //映射函数,取出tagslist
|
||||
...mapState(useUserStore, ["vipOnList", "token"])
|
||||
...mapState(useQuestionStore, ["orderQuestion_subject1", "orderQuestion_subject4","version"]), //映射函数,取出tagslist
|
||||
...mapState(useUserStore, ["vipOnList", "token"]),
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useUserStore, ['searchUserVip']),
|
||||
...mapActions(useQuestionStore, ['getAllQuestion']),
|
||||
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,
|
||||
isChoose: true,
|
||||
}
|
||||
})
|
||||
this.$refs.question.isShowBest(true)
|
||||
this.$refs.question.getQuestionList(JSON.stringify(list))
|
||||
this.$refs.question.getQuestionList(JSON.stringify(list),this.navTitle)
|
||||
} else {
|
||||
this.$refs.question.isShowBest(false)
|
||||
this.$refs.question.getQuestionList()
|
||||
|
||||
Reference in New Issue
Block a user