Files
huishou/deploy/dist/build/mp-weixin/stores/price.js
T
2026-07-27 13:37:48 +08:00

2 lines
808 B
JavaScript

"use strict";const e=require("../common/vendor.js"),r=require("../api/index.js"),a=e.defineStore("price",()=>{const a=e.ref([]),i=e.ref(""),c=e.ref(!1),t=async()=>{c.value=!0;try{const e=await r.priceApi.getPrices();e&&(a.value=e.prices,i.value=e.date)}catch(e){console.error("Failed to load prices:",e)}c.value=!1};return{prices:a,date:i,isLoading:c,loadPrices:t,getPriceByCategory:e=>a.value.find(r=>r.category===e),addPrice:async e=>{try{await r.priceApi.addPrice(e),await t()}catch(a){console.error("Failed to add price:",a)}},updatePrice:async(e,a)=>{try{await r.priceApi.updatePrice(e,a),await t()}catch(i){console.error("Failed to update price:",i)}},deletePrice:async e=>{try{await r.priceApi.deletePrice(e),await t()}catch(a){console.error("Failed to delete price:",a)}}}});exports.usePriceStore=a;