OfficeSystem/api/dashboard.js

52 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-11-07 11:18:43 +08:00
/**
* 仪表板相关 API
*/
/**
* 获取仪表板简要信息
* @param {Object} params 请求参数
* @param {string} params.joinUserId 用户ID
* @param {string[]} params.keys 需要获取的数据键名数组
* @returns {Promise} 返回仪表板简要信息
*/
export const getDashboardBrief = ({ joinUserId, keys }) => {
// 构建查询参数字符串
let params=[]
if (joinUserId) {
params = [`joinUserId=${joinUserId}`];
}
2025-11-07 11:18:43 +08:00
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 认证
}
});
};
2025-11-13 10:21:17 +08:00
/**
* 获取客户统计排行榜
* @returns {Promise} 返回排行榜数据包含 todayweekmonth 三个时间段的数据
*/
2025-11-13 18:00:07 +08:00
export const getCustomerStatistics = (params = {}) => {
// 期望传入为数组: [start, end] 或 [day, day]
const dateRange = Array.isArray(params) ? params : [];
const query =
dateRange.length > 0
? `?${dateRange.map(d => `queryDateRange=${encodeURIComponent(d)}`).join('&')}`
: '';
return uni.$uv.http.get(`/dashboard/customer/statistics${query}`, {
2025-11-13 10:21:17 +08:00
custom: {
auth: true // 启用 token 认证
}
});
};