OfficeSystem/api/common.js
2025-11-14 16:03:10 +08:00

66 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 通用 API工具类接口
*/
/**
* 获取七牛云上传token
* @returns {Promise} 返回七牛云上传token
*/
export const getQiniuUploadToken = () => {
return uni.$uv.http.get('/common/qiniuToken', {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 获取地区树
* @returns {Promise} 返回地区树数据
*/
export const getRegionTree = () => {
return uni.$uv.http.get(`/bst/region/treaDity`, {
custom: {
auth: true
}
});
};
/**
* 获取数据字典列表
* @param {Object} params 请求参数(可选)
* @param {string} params.dictType 字典类型(可选,用于筛选特定类型的字典)
* @param {number} params.pageNum 页码可选默认1
* @param {number} params.pageSize 每页大小可选默认200
* @returns {Promise} 返回字典数据列表
*/
export const getDictDataList = (params = {}) => {
// 设置默认参数
const defaultParams = {
pageNum: 1,
pageSize: 200
};
// 合并参数
const requestParams = { ...defaultParams, ...params };
// 构建查询参数数组兼容uniapp
const queryParams = [];
Object.entries(requestParams).forEach(([key, value]) => {
if (value !== undefined && value !== null && value !== '') {
queryParams.push(`${key}=${encodeURIComponent(value.toString())}`);
}
});
const queryString = queryParams.join('&');
const url = `/system/dict/data/list${queryString ? `?${queryString}` : ''}`;
console.log('请求URL:', url); // 调试用
return uni.$uv.http.get(url, {
custom: {
auth: true
}
});
};