import { axios } from "./http";

// 后面修改的获取博物馆列表，区分有数据和无数据
export const getMuseumListOrInfoAPI = (type) => {
  return axios({
    url: `/show/museum/filterList/${type}`,
  })
}


// 获取博物馆列表
export function getMuseumList(data, cb) {
  let params = {
    ...data,
  };

  axios({
    method: "post",
    data: params,
    url: `show/museum/list`,
  }).then((res) => {
    if (res && res.data && res.data.records) {
      // 按首字母排序
      res.data.records.sort((item1, item2) => {
        if (item1.initial < item2.initial) {
          return -1
        } else if (item1.initial === item2.initial) {
          return 0
        } else {
          return 1
        }
      })
    }
    cb(res);
  });
}


// 获取展览列表
export function getExhibitionList(data, cb) {
  let params = {
    ...data,
  };

  axios({
    method: "post",
    data: params,
    url: `show/exhibition/list`,
  }).then((res) => {
    cb(res);
  });
}


// 获取文物列表
export function getCollectionList(data, cb) {
  let params = {
    ...data,
  };

  axios({
    method: "post",
    data: params,
    url: `show/goods/list`,
  }).then((res) => {
    cb(res);
  });
}

// 获取城市数量和虚拟虚拟场景数量

export const getCityList = (type) => {
  return axios({
    method: 'get',
    url: `show/${type}/cityList`,
  })
}

// 获取年代
export function getAge(cb) {
  axios({
    method: "get",
    url: `show/goods/getAge`,
  }).then((res) => {
    cb(res);
  });
}


 
// 获取材质
export function getType(cb) {
  axios({
    method: "get",
    url: `show/goods/getType`,
  }).then((res) => {
    cb(res);
  });
}



// 获取博物馆详情
export function getMuseumDetail(data, cb) {

  axios({
    method: "get",
    url: `show/museum/detail/${data.id}`,
  }).then((res) => {
    cb(res);
  });
}

// 获取博物馆详情
export function getExhibitionDetail(data, cb) {

  axios({
    method: "get",
    url: `show/exhibition/detail/${data.id}`,
  }).then((res) => {
    cb(res);
  });
}


// 获取配置详情
export function getConfig(cb) {
  axios({
    method: "get",
    url: `show/getConfig`,
  }).then((res) => {
    cb(res);
  });
}



//获取详情
export function getDetailById(type,data, cb) {
  axios({
    method: "get",
    url: `show/${type}/detail/${data.id}`,
  }).then((res) => {
    cb(res);
  });
}