优化后,再次提交
This commit is contained in:
@@ -351,4 +351,34 @@ export function getInspectionWarningList(params) {
|
||||
method: 'GET',
|
||||
data: params
|
||||
});
|
||||
}
|
||||
|
||||
// AI图片分析接口 - 分析隐患图片
|
||||
export function analyzeHazardImage(params) {
|
||||
return requestAPI({
|
||||
url: '/frontend/ai/analyze-hazard',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
loadingText: 'AI自动识别隐患中'
|
||||
});
|
||||
}
|
||||
|
||||
// AI生成整改方案
|
||||
export function generateRectifyPlan(params) {
|
||||
return requestAPI({
|
||||
url: '/frontend/ai/generate-rectify-plan',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
loadingText: 'AI生成整改方案中'
|
||||
});
|
||||
}
|
||||
|
||||
// AI生成销号方案
|
||||
export function generateWriteoffContent(params) {
|
||||
return requestAPI({
|
||||
url: '/frontend/ai/generate-writeoff-content',
|
||||
method: 'POST',
|
||||
data: params,
|
||||
loadingText: 'AI生成销号方案中'
|
||||
});
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import Request from './luch-request/index.js';
|
||||
const baseUrl = 'https://yingji.hexieapi.com/prod-api';
|
||||
// const baseUrl = 'http://192.168.1.168:5004';
|
||||
|
||||
// 图片/文件资源域名:去掉 /prod-api,便于 <image> / previewImage / downloadFile 直接访问
|
||||
const imageBaseUrl = baseUrl.replace(/\/prod-api\/?$/, '');
|
||||
|
||||
const http = new Request({
|
||||
baseURL: baseUrl,
|
||||
timeout: 10000
|
||||
@@ -45,15 +48,17 @@ function showToast(title) {
|
||||
// 请求
|
||||
const requestAPI = (config) => {
|
||||
// 支持对象参数或传统参数
|
||||
let { url, method = 'GET', data = {}, noAuth = false } = typeof config === 'object' && config.url ? config : { url: config, method: arguments[1] || 'GET', data: arguments[2] || {} };
|
||||
let { url, method = 'GET', data = {}, noAuth = false, loadingText } = typeof config === 'object' && config.url ? config : { url: config, method: arguments[1] || 'GET', data: arguments[2] || {} };
|
||||
|
||||
if (method == 'GET' && !isEmptyObject(data)) {
|
||||
url += '?' + objectToQueryString(data);
|
||||
}
|
||||
// 显示加载状态
|
||||
uni.showLoading({
|
||||
title: '加载中...'
|
||||
});
|
||||
// 显示加载状态(loadingText 为 false 时不显示)
|
||||
if (loadingText !== false) {
|
||||
uni.showLoading({
|
||||
title: loadingText || '加载中...'
|
||||
});
|
||||
}
|
||||
|
||||
// 构建 header,登录等接口不需要 Authorization
|
||||
const header = {
|
||||
@@ -130,4 +135,25 @@ const requestAPI = (config) => {
|
||||
};
|
||||
|
||||
// 文件末尾应该导出
|
||||
export { requestAPI, baseUrl, getToken };
|
||||
export { requestAPI, baseUrl, getToken };
|
||||
|
||||
// 把附件 filePath 转成可用于图片预览/下载的 url
|
||||
// filePath 可能是:
|
||||
// 1) 绝对 http(s) 链接
|
||||
// 2) 相对路径(以 / 开头)
|
||||
// 3) 可能带 /prod-api 的拼接结果(兼容处理)
|
||||
export const toImageUrl = (filePath) => {
|
||||
if (!filePath) return '';
|
||||
|
||||
const p = String(filePath);
|
||||
if (p.startsWith('http://') || p.startsWith('https://')) {
|
||||
// 兼容:如果后端返回的是带 /prod-api 的资源地址,直接去掉
|
||||
return p.replace(/\/prod-api(?=\/|$)/, '');
|
||||
}
|
||||
|
||||
// 相对路径:统一拼到 imageBaseUrl 上
|
||||
const normalized = p.startsWith('/') ? p : `/${p}`;
|
||||
return imageBaseUrl + normalized;
|
||||
};
|
||||
|
||||
export { imageBaseUrl };
|
||||
Reference in New Issue
Block a user