hotProducts.js 9.77 KB
/**
 * 热卖产品 Mock 数据
 *
 * @description 包含项目所有保险类型的产品 mock 数据,用于测试计划书模板显示
 *              涵盖人寿保险、重疾保险、储蓄型产品三大类
 * @module mock/hotProducts
 * @author Claude Code
 * @created 2026-02-09
 */

/**
 * 热卖产品 Mock 数据列表
 *
 * @description 包含 10 种产品,覆盖所有计划书模板类型:
 * - 人寿保险 (2 种): WIOP3E、WIOP3
 * - 重疾保险 (3 种): MPC、MBC PRO、MBC2
 * - 储蓄型产品 (5 种): GS、GC、FA、LV2、GS(多阶段)
 */
export const hotProductsMockData = [
  // ====== 人寿保险 (LifeInsuranceTemplate) ======

  {
    id: 1,
    product_name: 'WIOP3E 盈传创富保障计划 3 - 优选版',
    recommend: 'hot',
    form_sn: 'life-insurance-wiop3e', // 对应 LifeInsuranceTemplate
    categories: [
      { id: 'life', name: '人寿保险' }
    ],
    tags: [
      { id: 't1', name: '终身寿险', bg_color: '#DBEAFE', text_color: '#1E40AF' },
      { id: 't2', name: '美元产品', bg_color: '#DCFCE7', text_color: '#166534' }
    ],
    cover_image: 'https://picsum.photos/seed/wiop3e/400/300',
    created_time: '2026-01-01 00:00:00'
  },

  {
    id: 2,
    product_name: 'WIOP3 盈传创富保障计划 3',
    recommend: 'hot',
    form_sn: 'life-insurance-wiop3', // 对应 LifeInsuranceTemplate
    categories: [
      { id: 'life', name: '人寿保险' }
    ],
    tags: [
      { id: 't1', name: '终身寿险', bg_color: '#DBEAFE', text_color: '#1E40AF' },
      { id: 't2', name: '美元产品', bg_color: '#DCFCE7', text_color: '#166534' }
    ],
    cover_image: 'https://picsum.photos/seed/wiop3/400/300',
    created_time: '2026-01-02 00:00:00'
  },

  // ====== 重疾保险 (CriticalIllnessTemplate) ======

  {
    id: 3,
    product_name: 'MPC 守护无间重疾',
    recommend: 'hot',
    form_sn: 'critical-illness-mpc', // 对应 CriticalIllnessTemplate
    categories: [
      { id: 'critical', name: '重疾保险' }
    ],
    tags: [
      { id: 't1', name: '重疾保障', bg_color: '#FEF3C7', text_color: '#92400E' },
      { id: 't2', name: '终身保障', bg_color: '#E0E7FF', text_color: '#3730A3' }
    ],
    cover_image: 'https://picsum.photos/seed/mpc/400/300',
    created_time: '2026-01-03 00:00:00'
  },

  {
    id: 4,
    product_name: 'MBC PRO 活跃人生重疾保 PRO',
    recommend: 'hot',
    form_sn: 'critical-illness-mbc-pro', // 对应 CriticalIllnessTemplate
    categories: [
      { id: 'critical', name: '重疾保险' }
    ],
    tags: [
      { id: 't1', name: '重疾保障', bg_color: '#FEF3C7', text_color: '#92400E' },
      { id: 't2', name: 'PRO 版本', bg_color: '#FEE2E2', text_color: '#991B1B' }
    ],
    cover_image: 'https://picsum.photos/seed/mbc-pro/400/300',
    created_time: '2026-01-04 00:00:00'
  },

  {
    id: 5,
    product_name: 'MBC2 活跃人生重疾保 2',
    recommend: 'hot',
    form_sn: 'critical-illness-mbc2', // 对应 CriticalIllnessTemplate
    categories: [
      { id: 'critical', name: '重疾保险' }
    ],
    tags: [
      { id: 't1', name: '重疾保障', bg_color: '#FEF3C7', text_color: '#92400E' },
      { id: 't2', name: '升级版', bg_color: '#DCFCE7', text_color: '#166534' }
    ],
    cover_image: 'https://picsum.photos/seed/mbc2/400/300',
    created_time: '2026-01-05 00:00:00'
  },

  // ====== 储蓄型产品 (SavingsTemplate) ======

  {
    id: 6,
    product_name: 'GS 宏挚传承保障计划',
    recommend: 'hot',
    form_sn: 'savings-gs', // 对应 SavingsTemplate
    categories: [
      { id: 'savings', name: '储蓄保险' }
    ],
    tags: [
      { id: 't1', name: '储蓄型', bg_color: '#E0E7FF', text_color: '#3730A3' },
      { id: 't2', name: '传承规划', bg_color: '#F3E8FF', text_color: '#6B21A8' }
    ],
    cover_image: 'https://picsum.photos/seed/gs/400/300',
    created_time: '2026-01-06 00:00:00'
  },

  {
    id: 7,
    product_name: 'GC 宏挚家传保险计划',
    recommend: 'hot',
    form_sn: 'savings-gc', // 对应 SavingsTemplate
    categories: [
      { id: 'savings', name: '储蓄保险' }
    ],
    tags: [
      { id: 't1', name: '储蓄型', bg_color: '#E0E7FF', text_color: '#3730A3' },
      { id: 't2', name: '家庭保障', bg_color: '#FEE2E2', text_color: '#991B1B' }
    ],
    cover_image: 'https://picsum.photos/seed/gc/400/300',
    created_time: '2026-01-07 00:00:00'
  },

  {
    id: 8,
    product_name: 'FA 宏浚传承保障计划',
    recommend: 'hot',
    form_sn: 'savings-fa', // 对应 SavingsTemplate
    categories: [
      { id: 'savings', name: '储蓄保险' }
    ],
    tags: [
      { id: 't1', name: '储蓄型', bg_color: '#E0E7FF', text_color: '#3730A3' },
      { id: 't2', name: '财富传承', bg_color: '#FEF3C7', text_color: '#92400E' }
    ],
    cover_image: 'https://picsum.photos/seed/fa/400/300',
    created_time: '2026-01-08 00:00:00'
  },

  {
    id: 9,
    product_name: 'LV2 赤霞珠终身寿险计划2',
    recommend: 'hot',
    form_sn: 'savings-lv2', // 对应 SavingsTemplate
    categories: [
      { id: 'savings', name: '储蓄保险' }
    ],
    tags: [
      { id: 't1', name: '储蓄型', bg_color: '#E0E7FF', text_color: '#3730A3' },
      { id: 't2', name: '终身寿险', bg_color: '#DBEAFE', text_color: '#1E40AF' }
    ],
    cover_image: 'https://picsum.photos/seed/lv2/400/300',
    created_time: '2026-01-09 00:00:00'
  },

  // ====== 储蓄型产品 - 多阶段提取(新增 2026-02-25) ======

  {
    id: 10,
    product_name: 'GS 宏挚传承保障计划(多阶段)',
    recommend: 'hot',
    form_sn: 'savings-gs-multistage', // 对应 SavingsTemplate 多阶段模式
    categories: [
      { id: 'savings', name: '储蓄保险' }
    ],
    tags: [
      { id: 't1', name: '多阶段提取', bg_color: '#F3E8FF', text_color: '#6B21A8' },
      { id: 't2', name: '新品', bg_color: '#DCFCE7', text_color: '#166534' },
      { id: 't3', name: '灵活规划', bg_color: '#FEF3C7', text_color: '#92400E' }
    ],
    cover_image: 'https://picsum.photos/seed/gs-multistage/400/300',
    created_time: '2026-02-25 00:00:00'
  }
]

/**
 * 获取热卖产品 Mock 数据
 *
 * @description 模拟 API 返回格式,包含完整的产品列表数据
 * @returns {Object} 模拟的 API 响应对象
 * @example
 * const mockResponse = getHotProductsMock()
 * // 返回: { code: 1, data: { list: [...], total: 9 }, msg: 'success' }
 */
export function getHotProductsMock() {
  return {
    code: 1,
    msg: 'success',
    data: {
      list: hotProductsMockData,
      total: hotProductsMockData.length,
      // 分类统计(可选,用于筛选)
      categories: [
        { id: 'life', name: '人寿保险' },
        { id: 'critical', name: '重疾保险' },
        { id: 'savings', name: '储蓄保险' }
      ]
    }
  }
}

/**
 * 根据 form_sn 获取产品 Mock 数据
 *
 * @description 用于测试特定计划书模板
 * @param {string} formSn - 表单模板标识
 * @returns {Object|null} 产品对象,未找到返回 null
 * @example
 * const product = getProductByFormSn('life-insurance-wiop3e')
 * // 返回: { id: 1, product_name: 'WIOP3E...', form_sn: 'life-insurance-wiop3e', ... }
 */
export function getProductByFormSn(formSn) {
  return hotProductsMockData.find(p => p.form_sn === formSn) || null
}

/**
 * 获取所有计划书模板类型
 *
 * @description 返回项目中所有支持的计划书模板类型
 * @returns {Array} 模板类型列表
 * @example
 * const templates = getAllTemplateTypes()
 * // 返回: ['life-insurance-wiop3e', 'life-insurance-wiop3', 'critical-illness-mpc', ...]
 */
export function getAllTemplateTypes() {
  return hotProductsMockData.map(p => ({
    form_sn: p.form_sn,
    product_name: p.product_name,
    category: p.categories[0]?.name
  }))
}

/**
 * Mock 数据使用说明
 *
 * @description 在开发环境中使用 mock 数据测试计划书功能
 *
 * ## 使用方式
 *
 * ### 方式 1: 直接替换 API 调用(推荐)
 * ```javascript
 * // src/pages/index/index.vue
 * import { getHotProductsMock } from '@/mock/hotProducts'
 *
 * const fetchHotProducts = async () => {
 *   // 开发环境使用 mock 数据
 *   if (process.env.NODE_ENV === 'development') {
 *     const res = getHotProductsMock()
 *     if (res.code === 1 && res.data) {
 *       hotProducts.value = res.data.list
 *     }
 *     return
 *   }
 *
 *   // 生产环境调用真实 API
 *   const res = await listAPI({ recommend: 'hot' })
 *   // ...
 * }
 * ```
 *
 * ### 方式 2: 使用环境变量控制
 * ```javascript
 * // config/index.js
 * const config = {
 *   useMock: process.env.USE_MOCK === 'true' // 环境变量控制
 * }
 *
 * // src/pages/index/index.vue
 * const fetchHotProducts = async () => {
 *   if (config.useMock) {
 *     const res = getHotProductsMock()
 *     // ...
 *   }
 *   // ...
 * }
 * ```
 *
 * ## 测试覆盖
 *
 * Mock 数据覆盖以下计划书模板:
 *
 * ### 人寿保险 (LifeInsuranceTemplate)
 * - ✅ life-insurance-wiop3e - WIOP3E 盈传创富保障计划 3 - 优选版
 * - ✅ life-insurance-wiop3 - WIOP3 盈传创富保障计划 3
 *
 * ### 重疾保险 (CriticalIllnessTemplate)
 * - ✅ critical-illness-mpc - MPC 守护无间重疾
 * - ✅ critical-illness-mbc-pro - MBC PRO 活跃人生重疾保 PRO
 * - ✅ critical-illness-mbc2 - MBC2 活跃人生重疾保 2
 *
 * ### 储蓄型产品 (SavingsTemplate)
 * - ✅ savings-gs - GS 宏挚传承保障计划
 * - ✅ savings-gc - GC 宏挚家传保险计划
 * - ✅ savings-fa - FA 宏浚传承保障计划
 * - ✅ savings-lv2 - LV2 赤霞珠终身寿险计划2
 * - ✅ savings-gs-multistage - GS 宏挚传承保障计划(多阶段) - 支持多阶段提取
 *
 * ## 测试步骤
 *
 * 1. 在首页点击任意产品的"计划书"按钮
 * 2. 验证弹窗标题是否正确显示产品名称
 * 3. 验证表单字段是否与产品类型匹配
 * 4. 测试表单提交功能
 * 5. 验证错误提示和校验规则
 */