OfficeSystem/common/api.js
2025-11-06 09:46:14 +08:00

42 lines
968 B
JavaScript

/**
* API 接口封装
* 统一管理所有 API 请求
*/
/**
* 获取用户信息
* @returns {Promise} 返回用户信息
*/
export const getUserInfo = () => {
return uni.$uv.http.get('/getInfo', {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 获取仪表板简要信息
* @param {Object} params 请求参数
* @param {string} params.joinUserId 用户ID
* @param {string[]} params.keys 需要获取的数据键名数组
* @returns {Promise} 返回仪表板简要信息
*/
export const getDashboardBrief = ({ joinUserId, keys }) => {
// 构建查询参数字符串
const params = [`joinUserId=${joinUserId}`];
if (keys && Array.isArray(keys)) {
keys.forEach((key) => {
params.push(`keys=${encodeURIComponent(key)}`);
});
}
const queryString = params.join('&');
return uni.$uv.http.get(`dashboard/brief?${queryString}`, {
custom: {
auth: true // 启用 token 认证
}
});
};