feat: 调整行业请求数据结构

This commit is contained in:
zdl
2025-10-23 14:24:26 +08:00
parent d2988d1a33
commit 9dcd4bfbf3
7 changed files with 848 additions and 179 deletions

View File

@@ -5,25 +5,25 @@ import axios from 'axios';
// 判断当前是否是生产环境
const isProduction = process.env.NODE_ENV === 'production';
const API_BASE_URL = getApiBase();
// 配置 axios 默认包含 credentials
axios.defaults.withCredentials = true;
export const industryService = {
// 获取所有行业分类体系
async getClassifications() {
const res = await axios.get(`${API_BASE_URL}/api/classifications`);
return res.data;
},
// 获取指定体系下的多级行业
async getLevels({ classification, level = 1, level1_name, level2_name, level3_name }) {
let url = `${API_BASE_URL}/api/levels?classification=${encodeURIComponent(classification)}&level=${level}`;
if (level1_name) url += `&level1_name=${encodeURIComponent(level1_name)}`;
if (level2_name) url += `&level2_name=${encodeURIComponent(level2_name)}`;
if (level3_name) url += `&level3_name=${encodeURIComponent(level3_name)}`;
/**
* 获取行业分类完整树形结构
* @param {string} classification - 可选,指定分类体系名称,不传则返回所有
* @returns {Promise} 返回树形结构数据
*/
async getClassifications(classification) {
let url = `${API_BASE_URL}/api/classifications`;
if (classification) {
url += `?classification=${encodeURIComponent(classification)}`;
}
const res = await axios.get(url);
return res.data;
}
// 注意getLevels 接口已废弃,使用 getClassifications 替代
};