253 行
7.3 KiB
Plaintext
253 行
7.3 KiB
Plaintext
/**
|
|
* OmniCard AI (CRMmp) - 用户端面向微官网与名片的核心 API 客户端
|
|
* 严格遵循 AGENTS.md 规范与 uts 强类型约束
|
|
*/
|
|
|
|
import {
|
|
AiChatReply,
|
|
AiChatRequest,
|
|
CardContact,
|
|
CardEvent,
|
|
CardEventJoinResult,
|
|
CardProfile,
|
|
CardPortalDetail,
|
|
LeadEntity,
|
|
LeadStatus,
|
|
NFCRecord,
|
|
NfcBindParams,
|
|
NfcUidParams,
|
|
OwnerPageData,
|
|
OwnerPageQuery,
|
|
QuotaCheckResult,
|
|
RadarHotInbox,
|
|
RadarTrack,
|
|
TeamRankItem,
|
|
SubmitLeadParams,
|
|
RecordRadarTrackParams,
|
|
} from './types.uts';
|
|
import { httpGet, httpPost } from './request.uts';
|
|
|
|
/**
|
|
* 获取微官网与名片公开聚合详情 (包含 Hero、Bento 块、多语言与品牌 VI)
|
|
* 对齐后端 GET /open/card/portal/detail?id= | ?slug= | ?slugOrId=
|
|
*
|
|
* @param slugOrId 名片主键 ID 或自定义短链标识
|
|
*/
|
|
export function fetchPortalCard(slugOrId: string): Promise<CardPortalDetail> {
|
|
if (/^\d+$/.test(slugOrId)) {
|
|
return httpGet<CardPortalDetail>('/open/card/portal/detail', {
|
|
slugOrId: slugOrId,
|
|
id: slugOrId,
|
|
});
|
|
}
|
|
return httpGet<CardPortalDetail>('/open/card/portal/detail', {
|
|
slugOrId: slugOrId,
|
|
slug: slugOrId,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 提交无摩擦潜客留资 / 互换名片数据
|
|
* 对齐后端 POST /open/crm/lead/exchange
|
|
*
|
|
* @param leadData 潜客留资信息
|
|
*/
|
|
export function submitLead(leadData: SubmitLeadParams): Promise<LeadEntity> {
|
|
return httpPost<LeadEntity>('/open/crm/lead/exchange', leadData);
|
|
}
|
|
|
|
/**
|
|
* 记录访客实时雷达轨迹足迹 (停留时长、滚动深度、浏览块等)
|
|
* 对齐后端 POST /open/crm/radar/track
|
|
*
|
|
* @param trackData 轨迹行为数据
|
|
*/
|
|
export function recordRadarTrack(trackData: RecordRadarTrackParams): Promise<RadarTrack> {
|
|
return httpPost<RadarTrack>('/open/crm/radar/track', trackData);
|
|
}
|
|
|
|
/**
|
|
* 查询名片最近访客足迹流水
|
|
* 对齐后端 GET /open/crm/radar/recent?cardId=
|
|
*
|
|
* @param cardId 名片主键
|
|
* @param limit 返回条数上限
|
|
*/
|
|
export function getRecentTracks(cardId: string | number, limit?: number): Promise<RadarTrack[]> {
|
|
const query: Record<string, string | number> = { cardId };
|
|
if (limit != null) {
|
|
query.limit = limit;
|
|
}
|
|
return httpGet<RadarTrack[]>('/open/crm/radar/recent', query);
|
|
}
|
|
|
|
export function bindNfcDevice(params: NfcBindParams): Promise<NFCRecord> {
|
|
return httpPost<NFCRecord>('/admin/nfc/bind/bind', params);
|
|
}
|
|
|
|
export function activateNfcDevice(params: NfcUidParams): Promise<NFCRecord> {
|
|
return httpPost<NFCRecord>('/admin/nfc/bind/activate', params);
|
|
}
|
|
|
|
export function switchNfcCard(params: NfcBindParams): Promise<NFCRecord> {
|
|
return httpPost<NFCRecord>('/admin/nfc/bind/switchCard', params);
|
|
}
|
|
|
|
export function unbindNfcDevice(params: NfcUidParams): Promise<NFCRecord> {
|
|
return httpPost<NFCRecord>('/admin/nfc/bind/unbind', params);
|
|
}
|
|
|
|
export function updateNfcDevice(
|
|
payload: NFCRecord & { id: string | number }
|
|
): Promise<NFCRecord> {
|
|
return httpPost<NFCRecord>('/admin/nfc/device/update', payload);
|
|
}
|
|
|
|
export function freezeNfcDevice(
|
|
params: { id?: number | string; uid?: string }
|
|
): Promise<NFCRecord> {
|
|
return httpPost<NFCRecord>('/admin/nfc/security/freeze', params);
|
|
}
|
|
|
|
export function unfreezeNfcDevice(
|
|
params: { id?: number | string; uid?: string }
|
|
): Promise<NFCRecord> {
|
|
return httpPost<NFCRecord>('/admin/nfc/security/unfreeze', params);
|
|
}
|
|
|
|
export function fetchOwnerLeadPage(
|
|
query: OwnerPageQuery
|
|
): Promise<OwnerPageData<LeadEntity>> {
|
|
return httpPost<OwnerPageData<LeadEntity>>('/admin/crm/lead/page', query);
|
|
}
|
|
|
|
export function fetchOwnerLeadInfo(id: string | number): Promise<LeadEntity> {
|
|
return httpGet<LeadEntity>('/admin/crm/lead/info', { id });
|
|
}
|
|
|
|
export function updateOwnerLeadStatus(
|
|
id: string | number,
|
|
status: LeadStatus
|
|
): Promise<LeadEntity> {
|
|
return httpPost<LeadEntity>('/admin/crm/lead/updateStatus', { id, status });
|
|
}
|
|
|
|
export function fetchOwnerRadarPage(
|
|
query: OwnerPageQuery
|
|
): Promise<OwnerPageData<RadarTrack>> {
|
|
return httpPost<OwnerPageData<RadarTrack>>('/admin/crm/radar/page', query);
|
|
}
|
|
|
|
export function askAiChat(req: AiChatRequest): Promise<AiChatReply> {
|
|
return httpPost<AiChatReply>('/open/ai/chat/ask', req);
|
|
}
|
|
|
|
export function fetchOwnerCardPage(
|
|
query: OwnerPageQuery
|
|
): Promise<OwnerPageData<CardProfile>> {
|
|
return httpPost<OwnerPageData<CardProfile>>('/admin/card/info/page', query);
|
|
}
|
|
|
|
export function fetchOwnerCardInfo(id: string | number): Promise<CardProfile> {
|
|
return httpGet<CardProfile>('/admin/card/info/info', { id });
|
|
}
|
|
|
|
export function updateOwnerCard(
|
|
payload: CardProfile & { id: string | number }
|
|
): Promise<CardProfile> {
|
|
return httpPost<CardProfile>('/admin/card/info/update', payload);
|
|
}
|
|
|
|
export function fetchCardQrcodeSvg(
|
|
slugOrId: string
|
|
): Promise<{ svg: string; url: string }> {
|
|
return httpGet<{ svg: string; url: string }>('/open/card/qrcode/svg', {
|
|
slugOrId,
|
|
});
|
|
}
|
|
|
|
export function fetchHallContactPage(
|
|
query: OwnerPageQuery
|
|
): Promise<OwnerPageData<CardContact>> {
|
|
return httpPost<OwnerPageData<CardContact>>('/admin/card/contact/hallPage', query);
|
|
}
|
|
|
|
export function collectHallContact(
|
|
peerCardId: string | number,
|
|
ownerCardId?: string | number
|
|
): Promise<CardContact> {
|
|
const payload: Record<string, string | number> = { peerCardId };
|
|
if (ownerCardId != null) {
|
|
payload.ownerCardId = ownerCardId;
|
|
}
|
|
return httpPost<CardContact>('/admin/card/contact/collect', payload);
|
|
}
|
|
|
|
export function fetchTeamWallPage(
|
|
query: OwnerPageQuery
|
|
): Promise<OwnerPageData<CardContact>> {
|
|
return httpPost<OwnerPageData<CardContact>>('/admin/card/contact/teamWall', query);
|
|
}
|
|
|
|
export function fetchEventFloorPage(
|
|
query: OwnerPageQuery
|
|
): Promise<OwnerPageData<CardContact>> {
|
|
return httpPost<OwnerPageData<CardContact>>('/admin/card/event/floorPage', query);
|
|
}
|
|
|
|
export function joinHallEvent(
|
|
code: string,
|
|
cardId?: string | number
|
|
): Promise<CardEventJoinResult> {
|
|
const payload: Record<string, string | number> = { code };
|
|
if (cardId != null) {
|
|
payload.cardId = cardId;
|
|
}
|
|
return httpPost<CardEventJoinResult>('/admin/card/event/join', payload);
|
|
}
|
|
|
|
export function fetchCurrentEvent(): Promise<CardEvent | null> {
|
|
return httpPost<CardEvent | null>('/admin/card/event/current', {});
|
|
}
|
|
|
|
export function fetchRadarHotInbox(): Promise<RadarHotInbox> {
|
|
return httpPost<RadarHotInbox>('/admin/crm/radar/hotInbox', {});
|
|
}
|
|
|
|
export function fetchTeamLiveRank(
|
|
eventId?: string
|
|
): Promise<TeamRankItem[]> {
|
|
const payload: Record<string, string> = {};
|
|
if (eventId != null && eventId !== '') {
|
|
payload.eventId = eventId;
|
|
}
|
|
return httpPost<TeamRankItem[]>('/admin/team/members/live-rank', payload);
|
|
}
|
|
|
|
export function fetchCardQuota(
|
|
tenantId?: string | number
|
|
): Promise<QuotaCheckResult> {
|
|
const payload: Record<string, string | number> = { resourceType: 'cards' };
|
|
if (tenantId != null && String(tenantId) !== '') {
|
|
payload.tenantId = tenantId;
|
|
}
|
|
return httpPost<QuotaCheckResult>('/admin/team/billing/quota', payload);
|
|
}
|
|
|
|
export function confirmHallExchange(
|
|
exchangeCode: string,
|
|
actingCardId?: string | number
|
|
): Promise<{ status: string; isDualSynced: boolean }> {
|
|
const payload: Record<string, string | number> = { exchangeCode };
|
|
if (actingCardId != null) {
|
|
payload.actingCardId = actingCardId;
|
|
}
|
|
return httpPost<{ status: string; isDualSynced: boolean }>(
|
|
'/admin/card/exchange/confirm',
|
|
payload
|
|
);
|
|
}
|
|
|
|
export * from './types.uts';
|
|
export * from './request.uts';
|