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.
 
 
 

53 lines
1.2 KiB

import {defineStore} from 'pinia';
import { myVip } from '@/config/api.js'
const carStore = defineStore(
'car',
{
state: () => ({
carInfo: {
carType: 'car',//车型
stepType: '1',//科目几
carTypeName: '小车',
contentType: '',//图片还是文字
sift: '', //是否精选
volume: '', //是否是密卷
knowType: '',//分类
chapter: '',//章节
types: '',//题型
city: '0',
cityName: ''
},
webLink: 'https://www.baidu.com/',
vipInfo: {},
}),
actions: {
setCar(key, value) {
// 类型只选一个
let arr = ['knowType', 'chapter', 'types', 'sift']
if(arr.includes(key)) {
arr.forEach(item=>{
this.carInfo[item] = ''
})
}
this.carInfo[key] = value
},
async getVipInfo() {
let {data: res} = await myVip(this.carInfo.carType).catch((err)=>{console.log(err)})
this.vipInfo = res
}
},
getters: {
isVip(state) {
let {type, endTime, endTime4 } = state.vipInfo
if(!type) return false
let str = type==4? endTime4: endTime
let time = new Date(str).getTime() > new Date().getTime()
if(!time) return false
return true
}
}
})
export default carStore