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.
 
 
 
 
 

86 lines
2.7 KiB

import { defineStore } from 'pinia'
import { createPinia, PiniaPlugin } from 'pinia'
import { ProductInfo } from '~/types/order'
import { createPersistedState } from 'pinia-plugin-persistedstate'
import {ApplicationDataQuery} from "~/types/merchant";
const pinia = createPinia()
interface AppSate {
stateEvaluationInfo: ProductInfo | null
stateApplicationData: ApplicationDataQuery| null
stateCarNumber: number
stateisShowHeaderMenu: boolean
stateFooterIsIntersecting: boolean
stateIsHomePage: boolean
stateRoutePath:string
stateMerId:number
stateExpressAll: any
}
export const useAppStore = defineStore({
id: 'appStore',
state: (): AppSate => ({
stateEvaluationInfo: null, //评价商品信息
stateApplicationData: null, //商户入驻申请数据
stateCarNumber: 0, //购物车数量
stateisShowHeaderMenu: true, //是否展示头部导航
stateFooterIsIntersecting: true, //底部导航是否出现在可视区域内
stateIsHomePage: false, //是否是首页
stateRoutePath: '', //路由地址
stateMerId: 0, //商户id
stateExpressAll: [] //全部物流公司
}),
persist: true,
getters: {
evaluationInfo: (state) => state.stateEvaluationInfo,
applicationData: (state) => state.stateApplicationData,
carNumber:(state) => state.stateCarNumber,
isShowHeaderMenu: (state) => state.stateisShowHeaderMenu,
footerIsIntersecting: (state) => state.stateFooterIsIntersecting,
isHomePage: (state) => state.stateIsHomePage,
routePath: (state) => state.stateRoutePath,
pcMerId: (state) => state.stateMerId,
expressAll: (state) => state.stateExpressAll
},
actions: {
//评价商品信息
getEvaluationInfo(info: ProductInfo) {
this.stateEvaluationInfo = info
},
//商户入驻申请数据
getApplicationData(info: ApplicationDataQuery) {
this.stateApplicationData = info
},
//购物车数量
getCarNumber(num: number) {
this.stateCarNumber = num
},
//头部是否展示菜单
getIsShowHeaderMenu(bool: boolean) {
this.stateisShowHeaderMenu = bool
},
// 底部导航是否出现在可视区域内
getFooterIsIntersecting(bool: boolean) {
this.stateFooterIsIntersecting = bool
},
//是否是首页
setIsHomePage(bool: boolean) {
this.stateIsHomePage = bool
},
//获取路由地址
getRoutePath(path:string){
this.stateRoutePath = path
},
// 商户id
getMerId(merId:number){
this.stateMerId = merId
},
getExpressList(express:any){
this.stateExpressAll = express
}
},
})
// 添加持久化插件到Pinia中
pinia.use(createPersistedState())
export default pinia