parent
eeffd9d43d
commit
ffea1f6c7c
@ -0,0 +1,6 @@
|
|||||||
|
import ajax from "./ajax";
|
||||||
|
|
||||||
|
//通訊錄
|
||||||
|
export const getCardData = async () =>
|
||||||
|
ajax(`/Card/getCardData`);
|
||||||
|
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
import { updateCusCard } from "@/api";
|
||||||
|
|
||||||
|
export const useCardStore = defineStore('card', {
|
||||||
|
state: () => {
|
||||||
|
return {
|
||||||
|
cusCard: '',
|
||||||
|
vipCard: '',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
async updateCusCard(payload) {
|
||||||
|
let res = await updateCusCard(payload);
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.cusCard = payload;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
persist: true
|
||||||
|
})
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
import { createPinia } from 'pinia';
|
||||||
|
|
||||||
|
const pinia = createPinia();
|
||||||
|
|
||||||
|
export default pinia;
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { useCardStore } from '@/store/card.js';
|
||||||
|
import { getCardData } from '@/api/card.js';
|
||||||
|
|
||||||
|
export const initStore = async (pinia) => {
|
||||||
|
const cardStore = useCardStore();
|
||||||
|
|
||||||
|
let res = await getCardData();
|
||||||
|
if (res.code === 200) {
|
||||||
|
cardStore.cusCard = res.data.cus_card;
|
||||||
|
cardStore.vipCard = res.data.vip_card;
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in new issue