123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import { defineStore } from "pinia";
- import { getWeather, getProjectObj, queryLastEnergy } from "@/api/index";
- interface projectStoreState {
- weatherCont: any;
- projectId: string;
- projectObj: any;
- lastAllEnergy: any;
- }
- const useProjectStore = defineStore({
- id: "project",
- state: (): projectStoreState => {
- return {
- weatherCont: {}, //天气
- projectId: "Pj1101080259", // "Pj3301100002",
- projectObj: {},
- lastAllEnergy: {},
- };
- },
- getters: {
- floorIdAfter() {},
- },
- actions: {
- setProjectId(param: any) {
- //console.log("this", this);
- //debugger;
- this.projectId = param;
- },
- async setProjectObj() {
- try {
- var res = await getProjectObj();
- var project = res.data.content[0] || {};
- this.projectObj = project;
- } catch (err) {}
- },
- async setWeather() {
- try {
- var res = await getWeather();
- var weatherRes = res.data.content || {};
- this.weatherCont = weatherRes;
- } catch (err) {}
- },
- async setLastAllEnergy() {
- try {
- var res = await queryLastEnergy();
- var resdata = (res.data.content || [])[0] || {};
- this.lastAllEnergy = resdata;
- } catch (err) {}
- },
- },
- });
- export default useProjectStore;
|