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/index/index.vue

79 lines
2.3 KiB

2 years ago
<template>
<view>
<u-sticky bgColor="#fff">
2 years ago
<u-tabs :list="categoryList" :current="curTab" :scrollable="false" @change="changeCategory"></u-tabs>
2 years ago
</u-sticky>
<view style="height: 100vh;background-color: rgb(245, 245, 245);">
2 years ago
<template v-if="tIndex===0 || tIndex===3">
2 years ago
<Subject1 :subject="tIndex+1" :rightList="rightList" :wrongList="wrongList" />
2 years ago
</template>
<template v-else>
2 years ago
<subject2 :subject="tIndex+1" ref="subjectRef" />
2 years ago
</template>
2 years ago
</view>
</view>
</template>
<script>
2 years ago
import { mapState,mapActions } from 'pinia' //引入映射函数
import useQuestionStore from '@/jtools/store/question' //引入store
2 years ago
import storage from '@/jtools/storage';
import Subject1 from "./components/Subject1";
2 years ago
import Subject2 from "./components/Subject2";
2 years ago
export default {
2 years ago
components: {Subject1,Subject2},
2 years ago
data() {
return {
2 years ago
curTab:Number(storage.get('curSubject'))-1,
tIndex:Number(storage.get('curSubject'))-1,
2 years ago
searchValue:'',
cityName:'',
categoryList:[{
name:'科目1'
},{
name:'科目2'
},{
name:'科目3'
},{
name:'科目4'
2 years ago
}],
rightList:storage.get(`rightList_subject${this.tIndex+1}`) || [],
wrongList:storage.get(`wrongList_subject${this.tIndex+1}`) || [],
2 years ago
};
},
2 years ago
onShow() {
if(this.tIndex==0||this.tIndex==3){
this.rightList=storage.get(`rightList_subject${this.tIndex+1}`) || []
this.wrongList=storage.get(`wrongList_subject${this.tIndex+1}`) || []
}
2 years ago
},
methods:{
2 years ago
...mapActions(useQuestionStore,['getOrderQuestion_sub4','getOrderQuestion_sub1','changeSubject']),
2 years ago
//切换科目
2 years ago
async changeCategory(val){
2 years ago
this.tIndex=val.index
2 years ago
if(this.tIndex==0){
2 years ago
await this.getOrderQuestion_sub1()
2 years ago
}else if(this.tIndex==3){
2 years ago
await this.getOrderQuestion_sub4()
2 years ago
}else{
2 years ago
this.changeSubject(val.index+1)
setTimeout(()=>{
this.$refs.subjectRef.getDiverType()
},100)
}
if(this.tIndex==0||this.tIndex==3){
this.rightList=storage.get(`rightList_subject${this.tIndex+1}`) || []
this.wrongList=storage.get(`wrongList_subject${this.tIndex+1}`) || []
2 years ago
}
2 years ago
},
2 years ago
}
2 years ago
}
</script>
<style lang="scss" scoped>
::v-deep .u-tabs__wrapper__nav__line {
background: linear-gradient(90deg, #11DF20 0%, #00B74F 100%) !important;
bottom: 14rpx !important;
}
</style>