369 lines
11 KiB
JavaScript
369 lines
11 KiB
JavaScript
/**
|
||
* 客户相关 API
|
||
*/
|
||
|
||
/**
|
||
* 获取客户列表
|
||
* @param {Object} params 请求参数(可选)
|
||
* @param {number} params.pageNum 页码(从1开始)
|
||
* @param {number} params.pageSize 每页数量
|
||
* @param {string[]} params.statusList 客户状态列表:["1"] 正在跟进, ["2"] 待跟进
|
||
* @param {string} params.excludeld 排除id
|
||
* @param {string[]} params.ids id列表
|
||
* @param {string} params.intent 意向
|
||
* @param {string} params.createDate 创建日期 (yyyy-MM-dd)
|
||
* @param {string} params.joinUserld 参与人id
|
||
* @param {string} params.lastFollowDate 上次跟进日期 (yyyy-MM-dd)
|
||
* @param {string} params.nextFollowDate 下次跟进日期 (yyyy-MM-dd)
|
||
* @param {string} params.nextFollowDateStart 下次跟进日期开始 (yyyy-MM-dd)
|
||
* @param {string} params.nextFollowDateEnd 下次跟进日期结束 (yyyy-MM-dd)
|
||
* @param {string[]} params.createDateRange 创建日期范围 (yyyy-MM-dd)
|
||
* @param {string[]} params.saleList 销售列表
|
||
* @returns {Promise} 返回客户列表 { total: number, rows: array }
|
||
*/
|
||
export const getCustomerList = (params = {}) => {
|
||
const queryParams = [];
|
||
|
||
// 处理分页参数
|
||
if (params.pageNum !== undefined && params.pageNum !== null) {
|
||
queryParams.push(`pageNum=${encodeURIComponent(params.pageNum)}`);
|
||
}
|
||
|
||
if (params.pageSize !== undefined && params.pageSize !== null) {
|
||
queryParams.push(`pageSize=${encodeURIComponent(params.pageSize)}`);
|
||
}
|
||
|
||
// 处理数组参数
|
||
if (params.statusList && Array.isArray(params.statusList) && params.statusList.length > 0) {
|
||
params.statusList.forEach(status => {
|
||
queryParams.push(`statusList=${encodeURIComponent(status)}`);
|
||
});
|
||
}
|
||
|
||
if (params.ids && Array.isArray(params.ids) && params.ids.length > 0) {
|
||
params.ids.forEach(id => {
|
||
queryParams.push(`ids=${encodeURIComponent(id)}`);
|
||
});
|
||
}
|
||
|
||
if (params.createDateRange && Array.isArray(params.createDateRange) && params.createDateRange.length > 0) {
|
||
params.createDateRange.forEach(date => {
|
||
queryParams.push(`createDateRange=${encodeURIComponent(date)}`);
|
||
});
|
||
}
|
||
|
||
if (params.saleList && Array.isArray(params.saleList) && params.saleList.length > 0) {
|
||
params.saleList.forEach(sale => {
|
||
queryParams.push(`saleList=${encodeURIComponent(sale)}`);
|
||
});
|
||
}
|
||
|
||
// 处理字符串参数
|
||
if (params.excludeld) {
|
||
queryParams.push(`excludeld=${encodeURIComponent(params.excludeld)}`);
|
||
}
|
||
|
||
if (params.intent) {
|
||
queryParams.push(`intent=${encodeURIComponent(params.intent)}`);
|
||
}
|
||
|
||
if (params.createDate) {
|
||
queryParams.push(`createDate=${encodeURIComponent(params.createDate)}`);
|
||
}
|
||
|
||
if (params.joinUserld) {
|
||
queryParams.push(`joinUserld=${encodeURIComponent(params.joinUserld)}`);
|
||
}
|
||
|
||
if (params.lastFollowDate) {
|
||
queryParams.push(`lastFollowDate=${encodeURIComponent(params.lastFollowDate)}`);
|
||
}
|
||
|
||
if (params.nextFollowDate) {
|
||
queryParams.push(`nextFollowDate=${encodeURIComponent(params.nextFollowDate)}`);
|
||
}
|
||
|
||
if (params.nextFollowDateStart) {
|
||
queryParams.push(`nextFollowDateStart=${encodeURIComponent(params.nextFollowDateStart)}`);
|
||
}
|
||
|
||
if (params.nextFollowDateEnd) {
|
||
queryParams.push(`nextFollowDateEnd=${encodeURIComponent(params.nextFollowDateEnd)}`);
|
||
}
|
||
|
||
const queryString = queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
|
||
|
||
return uni.$uv.http.get(`bst/customer/list${queryString}`, {
|
||
custom: {
|
||
auth: true // 启用 token 认证
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户详情
|
||
* @param {string} id 客户ID
|
||
* @returns {Promise} 返回客户详情
|
||
*/
|
||
export const getCustomerDetail = (id) => {
|
||
return uni.$uv.http.get(`bst/customer/${id}`, {
|
||
custom: {
|
||
auth: true // 启用 token 认证
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户跟进动态列表
|
||
* @param {string} customerId 客户ID
|
||
* @returns {Promise} 返回跟进动态列表 { total: number, rows: array }
|
||
*/
|
||
export const getCustomerFollowupList = (customerId) => {
|
||
return uni.$uv.http.get(`bst/customerFollow/list`, {
|
||
params: {
|
||
customerId: customerId
|
||
},
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取跟进详情
|
||
* @param {string} followId 跟进ID
|
||
* @returns {Promise} 返回跟进详情
|
||
*/
|
||
export const getFollowupDetail = (followId) => {
|
||
return uni.$uv.http.get(`bst/customerFollow/${followId}`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 创建跟进记录
|
||
* @param {Object} data 跟进记录数据
|
||
* @param {string} data.customerId 客户ID
|
||
* @param {string} data.type 跟进方式
|
||
* @param {string} data.content 跟进内容
|
||
* @param {string} data.picture 图片URL(多个用逗号分隔)
|
||
* @param {string} data.attaches 附件URL(多个用逗号分隔)
|
||
* @param {string} data.followTime 跟进时间 (yyyy-MM-dd HH:mm:ss)
|
||
* @param {string} data.nextFollowTime 下次跟进时间 (yyyy-MM-dd HH:mm:ss)
|
||
* @param {string} data.customerStatus 客户状态
|
||
* @param {string} data.customerIntentLevel 客户意向强度
|
||
* @returns {Promise} 返回创建结果
|
||
*/
|
||
export const createFollowup = (data) => {
|
||
return uni.$uv.http.post(`bst/customerFollow`, data, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 更新跟进记录
|
||
* @param {Object} data 跟进记录数据(必须包含 followId)
|
||
* @param {string} data.followId 跟进ID
|
||
* @param {string} data.customerId 客户ID
|
||
* @param {string} data.type 跟进方式
|
||
* @param {string} data.content 跟进内容
|
||
* @param {string} data.picture 图片URL(多个用逗号分隔)
|
||
* @param {string} data.attaches 附件URL(多个用逗号分隔)
|
||
* @param {string} data.followTime 跟进时间 (yyyy-MM-dd HH:mm:ss)
|
||
* @param {string} data.nextFollowTime 下次跟进时间 (yyyy-MM-dd HH:mm:ss)
|
||
* @param {string} data.customerStatus 客户状态
|
||
* @param {string} data.customerIntentLevel 客户意向强度
|
||
* @returns {Promise} 返回更新结果
|
||
*/
|
||
export const updateFollowup = (data) => {
|
||
return uni.$uv.http.put(`bst/customerFollow`, data, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户项目列表
|
||
* @param {string} customerId 客户ID
|
||
* @returns {Promise} 返回项目列表
|
||
*/
|
||
export const getCustomerProjects = (customerId) => {
|
||
return uni.$uv.http.get(`bst/project/list`, {
|
||
params: {
|
||
customerId: customerId,
|
||
pageNum: 1,
|
||
pageSize: 30
|
||
},
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 创建客户
|
||
* @param {Object} data 客户数据
|
||
* @param {string} data.type 类型(固定为2)
|
||
* @param {string} data.name 客户名
|
||
* @param {string} data.mobile 手机号
|
||
* @param {string} data.wechat 微信号
|
||
* @param {string} data.source 来源
|
||
* @param {string} data.intents 意向的设备,逗号分离
|
||
* @param {string} data.status 状态(1潜在2意向3成交4失效)
|
||
* @param {string} data.intentLevel 意向强度
|
||
* @param {string} data.customerStatus 客户状态
|
||
* @param {string} data.customerIntentLevel 客户意向强度
|
||
* @param {string} data.nextFollowTime 下次跟进时间
|
||
* @param {string} data.followId 跟进人id
|
||
* @param {string} data.remark 备注
|
||
* @param {string} data.concern 顾虑点
|
||
* @param {string} data.pain 痛点
|
||
* @param {string} data.attention 关注点
|
||
* @param {string} data.demand 需求点
|
||
* @returns {Promise} 返回创建结果
|
||
*/
|
||
export const createCustomer = (data) => {
|
||
return uni.$uv.http.post(`bst/customer`, data, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 更新客户
|
||
* @param {Object} data 客户数据(必须包含id)
|
||
* @param {string} data.id 客户ID
|
||
* @param {string} data.type 类型
|
||
* @param {string} data.name 客户名
|
||
* @param {string} data.mobile 手机号
|
||
* @param {string} data.wechat 微信号
|
||
* @param {string} data.source 来源
|
||
* @param {string} data.intents 意向的设备,逗号分离
|
||
* @param {string} data.status 状态(1潜在2意向3成交4失效)
|
||
* @param {string} data.intentLevel 意向强度
|
||
* @param {string} data.customerStatus 客户状态
|
||
* @param {string} data.customerIntentLevel 客户意向强度
|
||
* @param {string} data.nextFollowTime 下次跟进时间
|
||
* @param {string} data.followId 跟进人id
|
||
* @param {string} data.remark 备注
|
||
* @param {string} data.concern 顾虑点
|
||
* @param {string} data.pain 痛点
|
||
* @param {string} data.attention 关注点
|
||
* @param {string} data.demand 需求点
|
||
* @returns {Promise} 返回更新结果
|
||
*/
|
||
export const updateCustomer = (data) => {
|
||
return uni.$uv.http.put(`bst/customer`, data, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户意向字典数据
|
||
* @returns {Promise} 返回字典数据数组,包含 dictLabel 和 dictValue
|
||
*/
|
||
export const getCustomerIntentDict = () => {
|
||
return uni.$uv.http.get(`system/dict/data/type/customer_intent`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户意向强度字典数据
|
||
* @returns {Promise} 返回字典数据数组,包含 dictLabel 和 dictValue
|
||
*/
|
||
export const getCustomerIntentLevelDict = () => {
|
||
return uni.$uv.http.get(`system/dict/data/type/customer_intent_level`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户来源字典数据
|
||
* @returns {Promise} 返回字典数据数组,包含 dictLabel 和 dictValue
|
||
*/
|
||
export const getCustomerSourceDict = () => {
|
||
return uni.$uv.http.get(`system/dict/data/type/customer_source`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户类型字典数据
|
||
* @returns {Promise} 返回字典数据数组,包含 dictLabel 和 dictValue
|
||
*/
|
||
export const getCustomerTypeDict = () => {
|
||
return uni.$uv.http.get(`system/dict/data/type/customer_type`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户状态字典数据
|
||
* @returns {Promise} 返回字典数据数组,包含 dictLabel 和 dictValue
|
||
*/
|
||
export const getCustomerStatusDict = () => {
|
||
return uni.$uv.http.get(`system/dict/data/type/customer_status`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取客户跟进方式字典数据
|
||
* @returns {Promise} 返回字典数据数组,包含 dictLabel 和 dictValue
|
||
*/
|
||
export const getCustomerFollowTypeDict = () => {
|
||
return uni.$uv.http.get(`system/dict/data/type/customer_follow_type`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取微信列表
|
||
* @returns {Promise} 返回微信列表 { total: number, rows: array }
|
||
*/
|
||
export const getWechatList = () => {
|
||
return uni.$uv.http.get(`bst/wechat/list`, {
|
||
custom: {
|
||
auth: true
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 删除客户
|
||
* @param {string|string[]} ids 客户ID或ID数组(多个ID用逗号分隔或传入数组)
|
||
* @returns {Promise} 返回删除结果
|
||
*/
|
||
export const deleteCustomer = (ids) => {
|
||
// 如果传入的是数组,转换为逗号分隔的字符串
|
||
const idsParam = Array.isArray(ids) ? ids.join(',') : ids;
|
||
|
||
return uni.$uv.http.delete(`bst/customer/${idsParam}`,{}, {
|
||
custom: {
|
||
auth: true // 启用 token 认证
|
||
}
|
||
});
|
||
};
|
||
|