陪练答题
This commit is contained in:
@@ -596,14 +596,33 @@ import { getApiUrl } from "@/common/config.js";
|
||||
const baseUrl = getApiUrl('/api/audioManagement/list');
|
||||
const url = queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
||||
|
||||
// 获取认证信息
|
||||
let tenantId = '';
|
||||
let token = '';
|
||||
try {
|
||||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||||
token = uni.getStorageSync('backend-token') || '';
|
||||
} catch (e) {
|
||||
console.error('获取认证信息失败:', e);
|
||||
}
|
||||
|
||||
// 构建请求头
|
||||
const headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers['X-Tenant-Id'] = tenantId;
|
||||
}
|
||||
|
||||
const res = await uni.request({
|
||||
url,
|
||||
method: 'POST',
|
||||
data: {}, // POST 请求体为空,参数都在 URL 查询字符串中
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
timeout: 10000
|
||||
header: headers,
|
||||
timeout: 30000 // 增加超时时间到30秒
|
||||
});
|
||||
|
||||
if (res.statusCode === 200 && res.data && res.data.success) {
|
||||
@@ -637,9 +656,19 @@ import { getApiUrl } from "@/common/config.js";
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取服务中列表失败:', error);
|
||||
// 根据错误类型提供更详细的错误信息
|
||||
let errorMessage = '获取服务状态失败,请稍后重试';
|
||||
if (error.errMsg) {
|
||||
if (error.errMsg.includes('timeout')) {
|
||||
errorMessage = '请求超时,请检查网络连接后重试';
|
||||
} else if (error.errMsg.includes('fail')) {
|
||||
errorMessage = '网络请求失败,请检查网络连接';
|
||||
}
|
||||
}
|
||||
uni.showToast({
|
||||
title: '获取服务状态失败,请稍后重试',
|
||||
icon: 'none'
|
||||
title: errorMessage,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
} finally {
|
||||
this.serviceStatusLoading = false;
|
||||
@@ -728,10 +757,31 @@ import { getApiUrl } from "@/common/config.js";
|
||||
this.isFetchingContact = true;
|
||||
// 统一使用 getApiUrl,根据 env.js 配置自动切换环境
|
||||
const url = `${getApiUrl('/api/customerManagement/getByContact')}?contact=${encodeURIComponent(contact)}`;
|
||||
|
||||
// 获取认证信息
|
||||
let tenantId = '';
|
||||
let token = '';
|
||||
try {
|
||||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||||
token = uni.getStorageSync('backend-token') || '';
|
||||
} catch (e) {
|
||||
console.error('获取认证信息失败:', e);
|
||||
}
|
||||
|
||||
// 构建请求头
|
||||
const headers = {};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers['X-Tenant-Id'] = tenantId;
|
||||
}
|
||||
|
||||
const res = await uni.request({
|
||||
url: url,
|
||||
method: 'GET',
|
||||
timeout: 8000
|
||||
header: headers,
|
||||
timeout: 30000 // 增加超时时间到30秒
|
||||
});
|
||||
const list = res.data?.data;
|
||||
if (res.statusCode === 200 && res.data?.success && Array.isArray(list) && list.length) {
|
||||
@@ -857,11 +907,33 @@ import { getApiUrl } from "@/common/config.js";
|
||||
title: "保存中..."
|
||||
});
|
||||
|
||||
// 获取认证信息
|
||||
let tenantId = '';
|
||||
let token = '';
|
||||
try {
|
||||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||||
token = uni.getStorageSync('backend-token') || '';
|
||||
} catch (e) {
|
||||
console.error('获取认证信息失败:', e);
|
||||
}
|
||||
|
||||
// 构建请求头
|
||||
const headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers['X-Tenant-Id'] = tenantId;
|
||||
}
|
||||
|
||||
const res = await uni.request({
|
||||
url: getApiUrl('/api/customerManagement/add'),
|
||||
method: "POST",
|
||||
data: params,
|
||||
timeout: 10000
|
||||
header: headers,
|
||||
timeout: 30000 // 增加超时时间到30秒
|
||||
});
|
||||
|
||||
uni.hideLoading();
|
||||
@@ -927,14 +999,34 @@ import { getApiUrl } from "@/common/config.js";
|
||||
}
|
||||
// 后端接口不支持 GET,改为 POST 传参
|
||||
const url = getApiUrl('/api/industryTags/list');
|
||||
|
||||
// 获取认证信息
|
||||
let tenantId = '';
|
||||
let token = '';
|
||||
try {
|
||||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||||
token = uni.getStorageSync('backend-token') || '';
|
||||
} catch (e) {
|
||||
console.error('获取认证信息失败:', e);
|
||||
}
|
||||
|
||||
// 构建请求头
|
||||
const headers = {
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers['X-Tenant-Id'] = tenantId;
|
||||
}
|
||||
|
||||
const res = await uni.request({
|
||||
url,
|
||||
method: 'POST',
|
||||
data: queryParams,
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
timeout: 10000
|
||||
header: headers,
|
||||
timeout: 30000 // 增加超时时间到30秒
|
||||
});
|
||||
if (res.statusCode === 200 && res.data && res.data.success) {
|
||||
const records = Array.isArray(res.data.data) ? res.data.data : [];
|
||||
@@ -955,9 +1047,19 @@ import { getApiUrl } from "@/common/config.js";
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取标签列表失败:', error);
|
||||
// 根据错误类型提供更详细的错误信息
|
||||
let errorMessage = '获取标签列表失败,请稍后重试';
|
||||
if (error.errMsg) {
|
||||
if (error.errMsg.includes('timeout')) {
|
||||
errorMessage = '请求超时,请检查网络连接后重试';
|
||||
} else if (error.errMsg.includes('fail')) {
|
||||
errorMessage = '网络请求失败,请检查网络连接';
|
||||
}
|
||||
}
|
||||
uni.showToast({
|
||||
title: '获取标签列表失败,请稍后重试',
|
||||
icon: 'none'
|
||||
title: errorMessage,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
} finally {
|
||||
this.tagLoading = false;
|
||||
@@ -1030,10 +1132,31 @@ import { getApiUrl } from "@/common/config.js";
|
||||
});
|
||||
|
||||
const deleteUrl = getApiUrl(`/api/industryTags/delete/${tagId}`);
|
||||
|
||||
// 获取认证信息
|
||||
let tenantId = '';
|
||||
let token = '';
|
||||
try {
|
||||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||||
token = uni.getStorageSync('backend-token') || '';
|
||||
} catch (e) {
|
||||
console.error('获取认证信息失败:', e);
|
||||
}
|
||||
|
||||
// 构建请求头
|
||||
const headers = {};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers['X-Tenant-Id'] = tenantId;
|
||||
}
|
||||
|
||||
const deleteRes = await uni.request({
|
||||
url: deleteUrl,
|
||||
method: 'DELETE',
|
||||
timeout: 10000
|
||||
header: headers,
|
||||
timeout: 30000 // 增加超时时间到30秒
|
||||
});
|
||||
|
||||
uni.hideLoading();
|
||||
@@ -1055,9 +1178,19 @@ import { getApiUrl } from "@/common/config.js";
|
||||
} catch (error) {
|
||||
uni.hideLoading();
|
||||
console.error('删除标签失败:', error);
|
||||
// 根据错误类型提供更详细的错误信息
|
||||
let errorMessage = '删除失败,请重试';
|
||||
if (error.errMsg) {
|
||||
if (error.errMsg.includes('timeout')) {
|
||||
errorMessage = '请求超时,请检查网络连接后重试';
|
||||
} else if (error.errMsg.includes('fail')) {
|
||||
errorMessage = '网络请求失败,请检查网络连接';
|
||||
}
|
||||
}
|
||||
uni.showToast({
|
||||
title: '删除失败,请重试',
|
||||
icon: 'none'
|
||||
title: errorMessage,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1126,14 +1259,33 @@ import { getApiUrl } from "@/common/config.js";
|
||||
|
||||
const method = this.tagViewMode === 'edit' ? 'PUT' : 'POST';
|
||||
|
||||
// 获取认证信息
|
||||
let tenantId = '';
|
||||
let token = '';
|
||||
try {
|
||||
tenantId = uni.getStorageSync('backend-tenant-id') || '';
|
||||
token = uni.getStorageSync('backend-token') || '';
|
||||
} catch (e) {
|
||||
console.error('获取认证信息失败:', e);
|
||||
}
|
||||
|
||||
// 构建请求头
|
||||
const headers = {
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
if (tenantId) {
|
||||
headers['X-Tenant-Id'] = tenantId;
|
||||
}
|
||||
|
||||
const res = await uni.request({
|
||||
url: url,
|
||||
method: method,
|
||||
data: payload,
|
||||
header: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
timeout: 10000
|
||||
header: headers,
|
||||
timeout: 30000 // 增加超时时间到30秒
|
||||
});
|
||||
|
||||
const { statusCode, data } = res;
|
||||
@@ -1151,9 +1303,19 @@ import { getApiUrl } from "@/common/config.js";
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("保存标签失败:", error);
|
||||
// 根据错误类型提供更详细的错误信息
|
||||
let errorMessage = error?.message || (this.tagViewMode === 'edit' ? "更新失败,请重试" : "保存失败,请重试");
|
||||
if (error.errMsg) {
|
||||
if (error.errMsg.includes('timeout')) {
|
||||
errorMessage = '请求超时,请检查网络连接后重试';
|
||||
} else if (error.errMsg.includes('fail')) {
|
||||
errorMessage = '网络请求失败,请检查网络连接';
|
||||
}
|
||||
}
|
||||
uni.showToast({
|
||||
title: error?.message || (this.tagViewMode === 'edit' ? "更新失败,请重试" : "保存失败,请重试"),
|
||||
icon: "none"
|
||||
title: errorMessage,
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
});
|
||||
} finally {
|
||||
uni.hideLoading();
|
||||
|
||||
Reference in New Issue
Block a user