// src/axios/api.js
import ApiConstant from "@/utils/ApiConstant";
import axiosInstance from '@/utils/http';

//获取院校的专业列表
export const getSchoolMajorList =async (params:{schoolCode:string}) =>{
  let scoreInfo = localStorage.getItem('scoreInfo')
  let cognitioPolyclinic =JSON.parse(scoreInfo as string).cognitioPolyclinic
  try {
    const response = await axiosInstance({
      url: ApiConstant.Major.schoolMajorList,
      method: 'get',
      params: {schoolCode:params.schoolCode,cognitioPolyclinic:cognitioPolyclinic},
      showLoading: false, // 是否显示加载图标
    });
    const data = response.data;
    if (data.success) {
      return data.result;
    } else {
      return [];
    }
  } catch (error) {
    console.log(error);
    return [];
  }
}

//获取院校的专业列表
export const getTestCultural =async (params:{schoolCode:string,year:string}) =>{
  try {
    const response = await axiosInstance({
      url: ApiConstant.Major.testCultural,
      method: 'get',
      params: {schoolCode:params.schoolCode,year:params.year},
      showLoading: false, // 是否显示加载图标
    });
    const data = response.data;
    if (data.success) {
      return data.result;
    } else {
      return [];
    }
  } catch (error) {
    console.log(error);
    return [];
  }
}

// // 登录
// export const Login = (data) => {
//   return service({
//     url: "/login",
//     method: "post",
//     data,
//   });
// };

// // Get请求
// export const Get = (url, data) => {
//   return service({
//     url,
//     method: "get",
//     params: data,
//   });
// };

// // Delete请求
// export const Delete = (url) => {
//   return service({
//     url,
//     method: "delete",
//   });
// };

// // Post请求
// export const Post = (url, data) => {
//   return service({
//     url,
//     method: "post",
//     data,
//   });
// };

// // 上传文件请求
// export const PostFile = (url, data, onUploadProgress) => {
//   return service({
//     url,
//     method: "post",
//     data,
//     headers: {
//       "Content-Type": "multipart/form-data",
//     },
//     onUploadProgress,
//   });
// };

// // Put请求
// export const Put = (url, data) => {
//   return service({
//     url,
//     method: "put",
//     data,
//   });
// };

// // Patch请求
// export const Patch = (url, data) => {
//   return service({
//     url,
//     method: "patch",
//     data,
//   });
// };
