fix: 修复API模式配置和GET请求参数问题

🐛 修复的问题:
1. 切换 dataMode 从 'mock' 改为 'api'
2. 修复所有GET请求使用 params 而不是 data
   - api/athlete.js: getMyAthletes, getAthletesForAdmin, getVenues, getProjects
   - api/score.js: getDeductions
3. 修复 utils/request.js 支持 params 参数
   - GET 请求使用 params 作为查询参数
   - POST/PUT/DELETE 请求使用 data 作为请求体

 现在可以正确调用后端API接口

📋 测试步骤:
1. 确保后端服务运行在 http://localhost:8080
2. 刷新小程序页面
3. 查看控制台调试信息
4. 验证接口调用

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-11 18:58:30 +08:00
parent c25ecc9f1f
commit 6d42c4a5ed
4 changed files with 14 additions and 9 deletions

View File

@@ -33,7 +33,8 @@ function getHeaders(customHeader = {}) {
* @param {Object} options 请求配置
* @param {String} options.url 请求路径不含baseURL
* @param {String} options.method 请求方法GET/POST/PUT/DELETE
* @param {Object} options.data 请求数据
* @param {Object} options.data 请求数据POST/PUT使用
* @param {Object} options.params 查询参数GET使用
* @param {Object} options.header 自定义请求头
* @param {Boolean} options.showLoading 是否显示Loading
* @param {String} options.loadingText Loading文本
@@ -44,6 +45,7 @@ function request(options = {}) {
url = '',
method = 'GET',
data = {},
params = {},
header = {},
showLoading = false,
loadingText = '加载中...'
@@ -59,14 +61,17 @@ function request(options = {}) {
// 打印调试信息
if (config.debug) {
console.log(`[API请求] ${method} ${url}`, data)
console.log(`[API请求] ${method} ${url}`, method === 'GET' ? params : data)
}
// 对于 GET 请求,使用 params 作为查询参数
const requestData = method === 'GET' ? params : data
return new Promise((resolve, reject) => {
uni.request({
url: config.apiBaseURL + url,
method,
data,
data: requestData,
header: getHeaders(header),
timeout: config.timeout,
success: (res) => {