import Mock from 'mockjs'

/**
 * 全局 mock 数据
 * 集中管理所有页面所需的假数据，便于查看效果
 */

// 商品分类（树形）
export const mockCategories = [
  { id: 1, name: '休闲零食', parentId: 0, level: 1, sort: 1 },
  { id: 2, name: '坚果炒货', parentId: 1, level: 2, sort: 1, icon: '' },
  { id: 3, name: '糖果巧克力', parentId: 1, level: 2, sort: 2 },
  { id: 4, name: '肉脯卤味', parentId: 1, level: 2, sort: 3 },
  { id: 5, name: '膨化食品', parentId: 1, level: 2, sort: 4 },
  { id: 6, name: '蜜饯果干', parentId: 1, level: 2, sort: 5 },
  { id: 7, name: '饮料饮品', parentId: 0, level: 1, sort: 2 }
]

// 商品列表
export const mockProducts = Mock.mock({
  'list|30': [
    {
      'id|+1': 1,
      name: '@ctitle(4, 8)',
      categoryId: '@integer(2, 7)',
      mainImage: Mock.Random.image('120x120', Mock.Random.color(), '#fff', 'png', '商品'),
      price: '@float(10, 200, 2, 2)',
      stock: '@integer(0, 999)',
      sales: '@integer(0, 5000)',
      status: '@integer(0, 1)',
      createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
    }
  ]
}).list

// 用户列表
export const mockUsers = Mock.mock({
  'list|25': [
    {
      'id|+1': 1001,
      username: '@cname',
      phone: /^1[3-9]\d{9}$/,
      avatar: Mock.Random.image('80x80', Mock.Random.color(), '#fff', 'png', 'U'),
      status: '@integer(0, 1)',
      createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
    }
  ]
}).list

// 订单列表
export const mockOrders = Mock.mock({
  'list|20': [
    {
      'id|+1': 1,
      orderNo: 'SN@date("yyyyMMdd")@string("number", 6)',
      userId: '@integer(1001, 1050)',
      username: '@cname',
      totalAmount: '@float(50, 800, 2, 2)',
      payAmount: '@float(50, 800, 2, 2)',
      status: '@integer(0, 4)',
      receiverName: '@cname',
      receiverPhone: /^1[3-9]\d{9}$/,
      createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
    }
  ]
}).list

// 优惠券列表
export const mockCoupons = Mock.mock({
  'list|12': [
    {
      'id|+1': 1,
      name: '@ctitle(6, 12)券',
      type: '@integer(0, 2)',
      amount: '@float(5, 100, 0, 2)',
      minAmount: '@float(0, 200, 0, 2)',
      maxDiscount: '@float(0, 80, 0, 2)',
      total: '@integer(100, 1000)',
      remain: '@integer(0, 500)',
      received: '@integer(0, 500)',
      perLimit: '@integer(1, 3)',
      status: '@integer(0, 2)',
      description: '@csentence(10, 28)',
      validDays: '@integer(7, 60)',
      startTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      endTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      updateTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
    }
  ]
}).list

// 公告列表
export const mockNotices = Mock.mock({
  'list|10': [
    {
      'id|+1': 1,
      title: '@ctitle(8, 18)',
      type: '@integer(0, 2)',
      isTop: '@integer(0, 1)',
      status: '@integer(0, 1)',
      startTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      endTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
    }
  ]
}).list

// 抢购活动
export const mockSeckillActivities = Mock.mock({
  'list|6': [
    {
      'id|+1': 1,
      name: '@ctitle(6, 10) 限时抢购',
      startTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      endTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      status: '@integer(0, 2)',
      createTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
    }
  ]
}).list

// 客服会话
export const mockChatSessions = Mock.mock({
  'list|8': [
    {
      'id|+1': 1,
      sessionNo: 'CS@date("yyyyMMdd")@string("number", 4)',
      userId: '@integer(1001, 1100)',
      username: '@cname',
      adminId: null,
      status: '@integer(0, 2)',
      lastMessage: '@csentence(5, 12)',
      unreadCount: '@integer(0, 5)',
      updateTime: '@datetime("yyyy-MM-dd HH:mm:ss")'
    }
  ]
}).list

// 仪表盘数据（已由真实后端提供，mock 直通）
