import httpRequest from "~/service/index";

export function useAll() {
  // 商品分类
  async function getGoodsgoryList(query?: any) {
    return await httpRequest.get<any>(`/productCategory/findList`, query);
  }

  // 获取内容
  async function getContent(query: any) {
    return await httpRequest.post<any>(`/show/content`, query);
  }

  async function flqSearch(query: any) {
    return await httpRequest.post<any>(`/product/search`, query);
  }

  async function flqGoodsList(query: any) {
    return await httpRequest.post<any>(`/product/findMap`, query);
  }

  async function flqFindScope(query: any) {
    return await httpRequest.post<any>(`/product/findScope`, query);
  }

  async function flqGetFilter(query: any) {
    return await httpRequest.get<any>(`/product/findMaxAttr`, query);
  }

  // 商品分页
  async function goodsList(query: any) {
    return await httpRequest.post<any>(`/product/findPage`, query);
  }

  // 全局搜索
  async function esFindDevice(query: any) {
    return await httpRequest.post<any>(`/product/es-find-device`, query);
  }

  // 查询封装
  async function esFindFz(query: any) {
    return await httpRequest.get<any>(`/product/find-fz`, query);
  }

  // 查询精度
  async function esFindJd(query: any) {
    return await httpRequest.get<any>(`/product/find-jd`, query);
  }

  // 删除 bom 订单
  async function del_bom_order(query: any) {
    return await httpRequest.post<any>(`/shop/bom/delBomOrder`, query);
  }

  // 留言
  async function addGuestbook(query: any) {
    return await httpRequest.post<any>(`/guestbook/add-guestbook`, query);
  }

  // 新闻列表
  async function getNewsList(query: any) {
    return await httpRequest.post<any>(`/newsArticle/findPage`, query);
  }

  // 新闻详情
  async function getNewsDetail(id: any) {
    return await httpRequest.get<any>(`/newsArticle/getById?id=${id}&language=1`);
  }

  // 新闻上下篇
  async function getPreNext(id: any) {
    return await httpRequest.get<any>(`/newsArticle/getpreNext?id=${id}&language=1&type=1`);
  }

  // 应用领域：列表
  async function getApplicationList(query: any) {
    return await httpRequest.post<any>(`/newsArticle/findPage`, query);
  }

  // 应用领域：详情
  async function getApplicationDetail(id: any) {
    return await httpRequest.get<any>(`/newsArticle/getById?id=${id}&language=1`);
  }

  // 应用领域：上一篇/下一篇getApplicationDetail
  async function getApplicationPreNext(id: any) {
    return await httpRequest.get<any>(`/newsArticle/getpreNext?id=${id}&language=1&type=1`);
  }

  //首页资质专利
  async function menuContent() {
    return await httpRequest.post<any>(`/menuContent/queryList`, {
      "menuId": "7"
    });
  }

  async function supplierSelect(query: any) {
    return await httpRequest.post<any>(`/supplierSelect/findByPage?companyName=${query.companyName}`, query);
  }
  async function devHistory() {
    return await httpRequest.post<any>(`/devHistory/findAll`, {});
  }

  

  return {
    del_bom_order,
    getGoodsgoryList,
    getContent,
    goodsList,
    esFindDevice,
    esFindFz,
    esFindJd,
    addGuestbook,
    getNewsList,
    getNewsDetail,
    getPreNext,
    getApplicationList,
    getApplicationDetail,
    getApplicationPreNext,flqGoodsList,flqFindScope,flqGetFilter,flqSearch,menuContent,supplierSelect,devHistory
  };
}