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

1 month ago
5 days ago
1 month ago
2 weeks ago
1 month ago
1 month ago
2 weeks ago
5 days ago
1 month ago
1 month ago
5 days ago
1 month ago
1 month ago
5 days ago
1 month ago
  1. import {defineStore} from 'pinia';
  2. import { myVip } from '@/config/api.js'
  3. const carStore = defineStore(
  4. 'car',
  5. {
  6. state: () => ({
  7. carInfo: {
  8. carType: 'car',//车型
  9. stepType: '1',//科目几
  10. carTypeName: '小车',
  11. contentType: '',//图片还是文字
  12. sift: '', //是否精选
  13. volume: '', //是否是密卷
  14. knowType: '',//分类
  15. chapter: '',//章节
  16. types: '',//题型
  17. city: '0',
  18. cityName: ''
  19. },
  20. webLink: 'https://www.baidu.com/',
  21. vipInfo: {},
  22. }),
  23. actions: {
  24. setCar(key, value) {
  25. // 类型只选一个
  26. let arr = ['knowType', 'chapter', 'types', 'sift']
  27. if(arr.includes(key)) {
  28. arr.forEach(item=>{
  29. this.carInfo[item] = ''
  30. })
  31. }
  32. this.carInfo[key] = value
  33. },
  34. async getVipInfo() {
  35. let {data: res} = await myVip(this.carInfo.carType).catch((err)=>{console.log(err)})
  36. this.vipInfo = res
  37. }
  38. },
  39. getters: {
  40. isVip(state) {
  41. let {type, endTime, endTime4 } = state.vipInfo
  42. if(!type) return false
  43. let str = type==4? endTime4: endTime
  44. let time = new Date(str).getTime() > new Date().getTime()
  45. if(!time) return false
  46. return true
  47. }
  48. }
  49. })
  50. export default carStore