import { defineStore } from "pinia";
import { request } from "../api";

export const useCollectStore = defineStore({
  id: "collect",
  state: () => {
    return {
      lists: [],
      pagination: {
        dictLevel: "",
        endTime: "",
        pageNum: 0,
        pageSize: 0,
        searchKey: "",
        startTime: "",
      },
    };
  },
  getters: {},
  actions: {
    async getCollectList(page) {
      this.pagination.pageNum = page || 1;
      const { data, status } = await request.post("/show/goods/pageList", {
        ...this.pagination,
      });
      if (data.code === 0) {
        const { records, total, current, page } = data.data;
        this.lists = records;
        this.pagination.total = total;
        this.pagination.current = current;
        this.pagination.page = page;
      }
    },
  },
});
