index.ts 5.29 KB
export type PageId = 'home' | 'prelearning' | 'sop-material-preview';

export type EntrySource = 'home_popup' | 'package_detail';
export type ProductType = 0 | 1;
export type PrelearningStepKind = 'normal' | 'highlight';
export type PrelearningBuriedPointEventType = 'page_view' | 'intercept_back' | 'task_completed' | 'reroll_case';

export interface PrelearningInitPayload {
  entrySource: EntrySource;
  activityId: string;
  activityProductId: string;
  staffName?: string;
  staffUuid: string;
  merchantId: string;
  caseId?: string;
}

export interface PrelearningInitRequest {
  payload: PrelearningInitPayload;
}

export type PrelearningActionType = 'learn_next' | 'complete' | 'view_other';

export interface PrelearningActionState {
  actionType: PrelearningActionType;
  buttonLabel: string;
  disabled: boolean;
  disabledReason?: string;
  toastMessage?: string;
}

export interface PrelearningActionPayload extends PrelearningInitPayload {
  sessionId?: string;
}

export interface PrelearningActionRequest {
  actionType: PrelearningActionType;
  payload: PrelearningActionPayload;
}

export interface PrelearningBuriedPointPayload {
  entrySource: EntrySource;
  eventType: PrelearningBuriedPointEventType;
  staffName?: string;
  staffUuid: string;
  merchantId: string;
  activityId: string;
  activityProductId: string;
  caseId: string;
  sessionId: string;
  durationSeconds: number;
  eventTime: string;
}

export interface PrelearningBuriedPointRequest {
  payload: PrelearningBuriedPointPayload;
}

export interface PrelearningBuriedPointResponse {
  stored: boolean;
  duplicate: boolean;
}

export interface PrelearningCompleteActivityPayload {
  entrySource: EntrySource;
  staffUuid: string;
  merchantId: string;
  activityId: string;
  activityProductId: string;
  caseId: string;
  sessionId: string;
}

export interface PrelearningPackageInfo {
  name: string;
  oldPrice: string;
  newPrice: string;
  includes: string[];
  imageUrl: string;
}

export interface PrelearningProfile {
  name: string;
  type: string;
  car: string;
  job: string;
  family: string;
  behavior: string;
  objections: string[];
  needs: string[];
  includes: string[];
}

export interface PrelearningGameStepBase {
  stageName: string;
  stageSummary: string;
  audioStartTime: string;
  audioEndTime: string;
}

export interface PrelearningNormalGameStep extends PrelearningGameStepBase {
  kind: 'normal';
}

export interface PrelearningHighlightGameStep extends PrelearningGameStepBase {
  kind: 'highlight';
  highlightTitle: string;
  prompt: string;
  dialogue: string;
  salesPitch: string;
  analysis: string;
}

export type PrelearningGameStep = PrelearningNormalGameStep | PrelearningHighlightGameStep;

export interface PrelearningScriptViewModel {
  caseId: string;
  title: string;
  packageInfo: PrelearningPackageInfo;
  profile: PrelearningProfile;
  gameSteps: PrelearningGameStep[];
}

export interface PrelearningInitResponse {
  sessionId: string;
  productType: ProductType;
  actionState: PrelearningActionState;
  activityProduct: {
    activityId: number;
    activityProductId: string;
    productType: ProductType;
    tabName: string;
    tabDescription: string;
    goodsCode: string;
    packageCode: string;
    goodsType: number | null;
    goodsTypeName: string | null;
    mainImageUrl: string;
    thumbImageUrl: string;
    detailImageUrl: string;
    currentPrice: string;
    minimumPrice: string;
    discountPrice: string;
    salesIncentive: string;
    isMainPush: boolean;
  };
  script: PrelearningScriptViewModel;
}

export interface PrelearningActionResponse extends PrelearningInitResponse {
  notice?: string;
}

export interface PrelearningApiError {
  error: {
    code: string;
    message: string;
    details?: unknown;
    requestId?: string;
  };
}

export type MaterialType = 'image' | 'video';
export type SopMaterialPreviewMessageType = 'SOP_MATERIAL_PREVIEW_READY' | 'SOP_MATERIAL_PREVIEW_INIT';

export interface ErrorResponse {
  error: {
    code: string;
    message: string;
    details?: unknown;
    requestId?: string;
  };
}

export interface MaterialItem {
  type: string;
  url: string;
}

export interface SopMaterialPreviewModel {
  id?: number;
  content: string;
  bgColor: string;
  intervalPx: number;
  materials: MaterialItem[];
}

export interface SopMaterialPreviewInitPayload extends SopMaterialPreviewModel {}

export interface SopMaterialPreviewInitMessage {
  type: 'SOP_MATERIAL_PREVIEW_INIT';
  payload: SopMaterialPreviewInitPayload;
}

export interface SopMaterialPreviewReadyMessage {
  type: 'SOP_MATERIAL_PREVIEW_READY';
}

export interface SopMaterialPreviewApiResponse extends SopMaterialPreviewModel {
  id: number;
}

export type SopMaterialPreviewApiError = ErrorResponse;

export interface PageManifest {
  id: PageId;
  title: string;
  description: string;
  path: string;
}

export const PAGE_MANIFESTS: readonly PageManifest[] = [
  {
    id: 'home',
    title: 'single-pages',
    description: '项目基座与独立页面入口',
    path: '/index.html',
  },
  {
    id: 'prelearning',
    title: '套餐话术预学习',
    description: 'APP WebView / 浏览器调试统一入口',
    path: '/prelearning.html',
  },
  {
    id: 'sop-material-preview',
    title: 'SOP 素材展示/预览',
    description: 'ID 渲染与 iframe 预览入口',
    path: '/sop-material-preview.html',
  },
] as const;