import { http } from "/@/utils/http";
import { loadEnv } from "@build/index";
import { ResponseListType, ResponseType } from "../../types";
import { ICateType, IGoodDetail, IGoodType } from "./types";
const { VITE_PROXY_DOMAIN_REAL, VITE_PROXY_USER_REAL } = loadEnv();
const userAPi = VITE_PROXY_DOMAIN_REAL;
const yewuApi = VITE_PROXY_USER_REAL + "/admin/";

// 商品修改列表
export const httpChangeList = (data: object): ResponseListType<IGoodType> => {
  return http.request("post", `${yewuApi}good/list`, {
    data: { ...data, isChange: "1" }
  });
};

// 商品列表
export const httpList = (data: object): ResponseListType<IGoodType> => {
  return http.request("post", `${yewuApi}good/list`, {
    data: { ...data, isZx: 0 }
  });
};

export const httpAbList = (data: object): ResponseListType<IGoodType> => {
  return http.request("post", `${yewuApi}good/list`, {
    data: { ...data, is_diff: "1" }
  });
};

export const httpModifyList = (data: object): ResponseListType<IGoodType> => {
  return http.request("post", `${yewuApi}goodChangeList`, {
    data: { ...data }
  });
};

export const httpModifyDetail = (data: object): ResponseListType<IGoodType> => {
  return http.request("post", `${yewuApi}goodChangeInfo`, {
    data: { ...data, is_diff: "1" }
  });
};

export const httpExport = (data: object): ResponseListType<IGoodType> => {
  return http.request("post", `${yewuApi}good/list`, {
    data: { ...data, is_diff: "1" }
  });
};

// 商品详情
export const httpDetail = (data: object): ResponseType<IGoodDetail> => {
  return http.request("post", `${yewuApi}good/info`, { data });
};

export const httpCatlist = (data: object): ResponseListType<ICateType> => {
  return http.request("post", `${yewuApi}catlist`, { data });
};

//添加商品类目
export const httpAdd = (data: object): ResponseType => {
  return http.request("post", `${yewuApi}good/exam`, { data });
};

export const httpBatch = (data: object): ResponseType => {
  return http.request("post", `${yewuApi}good/exam`, { data });
};

export * from "./types";
