import { defineStore } from 'pinia' import { reactive } from 'vue' import { createCollection, deleteCollection, queryCollection, updateCollection } from '@/api/collection' export const collectionOperate = defineStore('payment', () => { // 定义数据 const paymentList = reactive([]) // 定义修改数据的方法 const getPaymentList = (code) => { queryCollection(code).then(res => { if (res.code === 0) { paymentList.length = 0 paymentList.push(...res.data) console.log(paymentList) } }) } const postCollection = (data) => { createCollection(data).then(res => { if (res.code === 0) { console.log(res.data) } }) } const putCollection = (data) => { updateCollection(data).then(res => { if (res.code === 0) { console.log(res.data) } }) } const delCollection = (data) => { deleteCollection(data).then(res => { if (res.code === 0) { console.log(res.data) } }) } return { paymentList, getPaymentList, postCollection, putCollection, delCollection } })