This commit is contained in:
张成
2025-12-22 16:26:59 +08:00
parent aa2d03ee30
commit e17d5610f5
54 changed files with 11735 additions and 3 deletions

76
app/api/apply_records.js Normal file
View File

@@ -0,0 +1,76 @@
/**
* 投递记录 API 服务
* 封装投递记录相关的API调用
*/
import apiClient from '../utils/api.js';
class ApplyRecordsAPI {
/**
* 获取投递记录列表
* @param {Object} params - 查询参数
* @param {Object} params.seachOption - 搜索条件
* @param {Object} params.pageOption - 分页选项
* @returns {Promise}
*/
async getList(params = {}) {
try {
const result = await apiClient.post('/apply/list', params);
return result;
} catch (error) {
console.error('获取投递记录列表失败:', error);
throw error;
}
}
/**
* 获取投递统计
* @param {String} snCode - 设备SN码可选
* @returns {Promise}
*/
async getStatistics(snCode = null) {
try {
const params = snCode ? { sn_code: snCode } : {};
const result = await apiClient.get('/apply/statistics', params);
return result;
} catch (error) {
console.error('获取投递统计失败:', error);
throw error;
}
}
/**
* 获取近7天投递趋势数据
* @param {String} snCode - 设备SN码可选
* @returns {Promise}
*/
async getTrendData(snCode = null) {
try {
const params = snCode ? { sn_code: snCode } : {};
const result = await apiClient.get('/apply/trend', params);
return result;
} catch (error) {
console.error('获取投递趋势数据失败:', error);
throw error;
}
}
/**
* 获取投递记录详情
* @param {String|Number} recordId - 投递记录ID可以是 id 或 applyId
* @returns {Promise}
*/
async getDetail(recordId) {
try {
// 使用 id 参数名(数据库主键字段)
const result = await apiClient.get('/apply/detail', { id: recordId });
return result;
} catch (error) {
console.error('获取投递记录详情失败:', error);
throw error;
}
}
}
export default new ApplyRecordsAPI();

102
app/api/config.js Normal file
View File

@@ -0,0 +1,102 @@
/**
* 系统配置 API 服务
* 封装配置相关的API调用
*/
import apiClient from '../utils/api.js';
// API 基础 URL用于拼接图片路径去掉 /api 后缀)
const getBaseURL = () => {
const apiUrl = 'http://localhost:9097/api';
// 如果包含 /api去掉它
return apiUrl.replace(/\/api$/, '');
};
class ConfigAPI {
/**
* 获取配置
* @param {String|Array} configKeys - 配置键(单个字符串或数组)
* @returns {Promise}
*/
async getConfig(configKeys) {
try {
let params = {};
// 支持单个字符串或数组
if (Array.isArray(configKeys)) {
params.configKeys = configKeys.join(',');
} else if (typeof configKeys === 'string') {
params.configKey = configKeys;
} else {
throw new Error('配置键格式错误');
}
const result = await apiClient.get('/config/get', params);
return result;
} catch (error) {
console.error('获取配置失败:', error);
throw error;
}
}
/**
* 获取微信相关配置
* @returns {Promise<Object>} { wechatNumber, wechatQRCode }
*/
async getWechatConfig() {
try {
const result = await this.getConfig(['wx_num', 'wx_img']);
if (result && result.code === 0) {
let qrcodeUrl = result.data.wx_img || '';
// 如果二维码是相对路径转换为完整URL
if (qrcodeUrl && !qrcodeUrl.startsWith('http://') && !qrcodeUrl.startsWith('https://') && !qrcodeUrl.startsWith('data:')) {
const baseURL = getBaseURL();
// 如果以 / 开头拼接服务器基础URL
if (qrcodeUrl.startsWith('/')) {
qrcodeUrl = baseURL + qrcodeUrl;
} else {
// 如果不是以 / 开头,可能是文件路径,需要拼接
qrcodeUrl = baseURL + '/' + qrcodeUrl;
}
}
return {
wechatNumber: result.data.wx_num || '',
wechatQRCode: qrcodeUrl
};
}
return {
wechatNumber: '',
wechatQRCode: ''
};
} catch (error) {
console.error('获取微信配置失败:', error);
return {
wechatNumber: '',
wechatQRCode: ''
};
}
}
/**
* 获取价格套餐列表
* @returns {Promise<Array>} 价格套餐列表
*/
async getPricingPlans() {
try {
const result = await apiClient.get('/config/pricing-plans');
if (result && result.code === 0) {
return result.data || [];
}
return [];
} catch (error) {
console.error('获取价格套餐失败:', error);
return [];
}
}
}
export default new ConfigAPI();

View File

@@ -0,0 +1,45 @@
/**
* 投递配置 API 服务
* 封装投递配置相关的API调用
*/
import apiClient from '../utils/api.js';
class DeliveryConfigAPI {
/**
* 获取投递配置
* @param {String} snCode - 设备SN码
* @returns {Promise}
*/
async getConfig(snCode) {
try {
const result = await apiClient.post('/user/delivery-config/get', { sn_code: snCode });
return result;
} catch (error) {
console.error('获取投递配置失败:', error);
throw error;
}
}
/**
* 保存投递配置
* @param {String} snCode - 设备SN码
* @param {Object} deliverConfig - 投递配置对象
* @returns {Promise}
*/
async saveConfig(snCode, deliverConfig) {
try {
const result = await apiClient.post('/user/delivery-config/save', {
sn_code: snCode,
deliver_config: deliverConfig
});
return result;
} catch (error) {
console.error('保存投递配置失败:', error);
throw error;
}
}
}
export default new DeliveryConfigAPI();

64
app/api/feedback.js Normal file
View File

@@ -0,0 +1,64 @@
/**
* 意见反馈 API 服务
* 封装意见反馈相关的API调用
*/
import apiClient from '../utils/api.js';
import { mapState } from 'vuex';
class FeedbackAPI {
/**
* 提交反馈
* @param {Object} data - 反馈数据
* @param {String} data.type - 反馈类型
* @param {String} data.content - 反馈内容
* @param {String} data.contact - 联系方式(可选)
* @param {String} data.sn_code - 设备SN码可选从 store 获取)
* @returns {Promise}
*/
async submit(data) {
try {
const result = await apiClient.post('/feedback/submit', data);
return result;
} catch (error) {
console.error('提交反馈失败:', error);
throw error;
}
}
/**
* 获取反馈列表
* @param {Object} params - 查询参数
* @param {Number} params.page - 页码
* @param {Number} params.pageSize - 每页数量
* @param {String} params.sn_code - 设备SN码可选从 store 获取)
* @returns {Promise}
*/
async getList(params = {}) {
try {
const result = await apiClient.post('/feedback/list', params);
return result;
} catch (error) {
console.error('获取反馈列表失败:', error);
throw error;
}
}
/**
* 获取反馈详情
* @param {String|Number} feedbackId - 反馈ID
* @returns {Promise}
*/
async getDetail(feedbackId) {
try {
const result = await apiClient.get('/feedback/detail', { id: feedbackId });
return result;
} catch (error) {
console.error('获取反馈详情失败:', error);
throw error;
}
}
}
export default new FeedbackAPI();

83
app/api/invite.js Normal file
View File

@@ -0,0 +1,83 @@
/**
* 推广邀请 API 服务
* 封装推广邀请相关的API调用
*/
import apiClient from '../utils/api.js';
class InviteAPI {
/**
* 获取邀请信息
* @param {string} snCode 设备SN码
* @returns {Promise}
*/
async getInviteInfo(snCode) {
try {
const result = await apiClient.post('/invite/info', {
sn_code: snCode
});
return result;
} catch (error) {
console.error('获取邀请信息失败:', error);
throw error;
}
}
/**
* 获取邀请统计
* @param {string} snCode 设备SN码
* @returns {Promise}
*/
async getStatistics(snCode) {
try {
const result = await apiClient.post('/invite/statistics', {
sn_code: snCode
});
return result;
} catch (error) {
console.error('获取邀请统计失败:', error);
throw error;
}
}
/**
* 生成邀请码
* @param {string} snCode 设备SN码
* @returns {Promise}
*/
async generateInviteCode(snCode) {
try {
const result = await apiClient.post('/invite/generate', {
sn_code: snCode
});
return result;
} catch (error) {
console.error('生成邀请码失败:', error);
throw error;
}
}
/**
* 获取邀请记录列表
* @param {string} snCode 设备SN码
* @param {Object} params 分页参数
* @param {number} params.page 页码
* @param {number} params.pageSize 每页数量
* @returns {Promise}
*/
async getRecords(snCode, params = {}) {
try {
const result = await apiClient.post('/invite/records', {
sn_code: snCode,
page: params.page || 1,
pageSize: params.pageSize || 20
});
return result;
} catch (error) {
console.error('获取邀请记录列表失败:', error);
throw error;
}
}
}
export default new InviteAPI();