/**
 * @file 路由配置文件
 * @description 定义所有电商页面的路由配置
 */

// 认证相关路由（独立布局，无Header）
export const authRoutes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/auth/login.vue'),
    meta: {
      title: '用户登录',
      description: '登录到您的账户',
      requiresAuth: false // 不需要登录即可访问
    }
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/auth/register.vue'),
    meta: {
      title: '用户注册',
      description: '创建新账户',
      requiresAuth: false
    }
  },
  {
    path: '/reset-password',
    name: 'ResetPassword',
    component: () => import('../views/auth/reset-password.vue'),
    meta: {
      title: '重置密码',
      description: '重置您的账户密码',
      requiresAuth: false
    }
  }
]

// 商品相关路由
export const productRoutes = [
  {
    path: '/productList',
    name: 'productList',
   
    component: () => import('../views/productList/index.vue'),
    meta: {
      title: '商品列表',
      description: '浏览所有可用商品',
      allAuthority: ['all']
    }
  },
  {
    path: '/product/:id',
    name: 'productDetail',
    component: () => import('../views/productDetail/index.vue'),
    meta: {
      title: '商品详情',
      description: '查看商品详细信息',
      allAuthority: ['all']
    }
  }
]

// 购物车相关路由
export const cartRoutes = [
  {
    path: '/cart',
    name: 'cart',
    component: () => import('../views/cart/index.vue'),
    meta: {
      title: '购物车',
      description: '管理购物车商品',
      allAuthority: ['all']
    }
  }
]

// 结算相关路由
export const checkoutRoutes = [
  {
    path: '/checkout',
    name: 'checkout',
    component: () => import('../views/checkout/index.vue'),
    meta: {
      title: '订单结算',
      description: '完成订单结算',
      allAuthority: ['all']
    }
  }
]

// 个人中心相关路由
export const accountRoutes = [
  {
    path: '/account',
    name: 'account',
    component: () => import('../views/account/index.vue'),
    redirect: '/account/shops',
    meta: {
      title: '个人中心',
      description: '管理个人资料和店铺',
      allAuthority: ['all']
    },
    children: [
      {
        path: 'wallet',
        name: 'Wallet',
        component: () => import('../views/account/wallet.vue'),
        meta: {
          title: '我的钱包',
          description: '查看钱包余额、充值和提现',
          allAuthority: ['all']
        }
      },
      {//充值记录
        path: 'rechargeRecord',
        name: 'RechargeRecord',
        component: () => import('../views/account/rechargeRecord.vue'),
        meta: {
          title: '充值记录',
          description: '查看充值记录',
          allAuthority: ['all']
        }
      },
      {//提现记录
        path: 'withdrawalHistory',
        name: 'WithdrawalHistory',
        component: () => import('../views/account/withdrawalHistory.vue'),
        meta: {
          title: '提现记录',
          description: '查看提现记录',
          allAuthority: ['all']
        }
      },
      {
        path: 'receipt-record',
        name: 'accountReceiptRecord',
        component: () => import('../views/account/receiptRecord.vue'),
        meta: {
          title: '收款记录',
          description: '卖家收款流水记录',
          allAuthority: ['all']
        }
      },
      {
        path: 'withdraw-record',
        name: 'accountWithdrawRecord',
        component: () => import('../views/account/withdrawRecord.vue'),
        meta: {
          title: '提现记录',
          description: '卖家提现流水记录',
          allAuthority: ['all']
        }
      },
      {
        path: 'shop-new',
        name: 'accountShopNew',
        component: () => import('../views/account/shopNew.vue'),
        meta: {
          title: '新增店铺',
          description: '创建新的店铺',
          allAuthority: ['all']
        }
      },
      {
        path: 'shop-config',
        name: 'accountShopConfig',
        component: () => import('../views/account/shopConfig.vue'),
        meta: {
          title: '钱包绑定',
          description: '绑定店铺收款钱包',
          allAuthority: ['all']
        }
      },
      {
        path: 'shops',
        name: 'accountMyShops',
        component: () => import('../views/account/myShops.vue'),
        meta: {
          title: '我的店铺',
          description: '查看我的店铺信息',
          allAuthority: ['all']
        }
      },
      {
        path: 'product-new',
        name: 'accountProductNew',
        component: () => import('../views/account/productNew.vue'),
        meta: {
          title: '新增商品',
          description: '创建新的商品',
          allAuthority: ['all']
        }
      },
      {
        path: 'products',
        name: 'accountProducts',
        component: () => import('../views/account/products.vue'),
        meta: {
          title: '商品列表',
          description: '管理店铺下的商品列表',
          allAuthority: ['all']
        }
      },
      {
        path: 'purchased-machine-config',
        name: 'accountPurchasedMachineConfig',
        component: () => import('../views/account/purchasedMachineConfig.vue'),
        meta: {
          title: '已购商品',
          description: '查看已购买商品的配置信息',
          allAuthority: ['all']
        }
      },
      {
        path: 'funds-flow',
        name: 'accountFundsFlow',
        component: () => import('../views/account/fundsFlow.vue'),
        meta: {
          title: '资金流水',
          description: '充值/提现/消费记录切换查看',
          allAuthority: ['all']
        }
      },
      {
        path: 'orders',
        name: 'accountOrders',
        component: () => import('../views/account/orders.vue'),
        meta: {
          title: '订单列表',
          description: '查看与管理订单（按状态筛选）',
          allAuthority: ['all']
        }
      },
      {
        path: 'seller-orders',
        name: 'accountSellerOrders',
        component: () => import('../views/account/SellerOrders.vue'),
        meta: {
          title: '已售出订单',
          description: '卖家侧订单列表',
          allAuthority: ['all']
        }
      },
      {
        path: 'order-detail/:id',
        name: 'accountOrderDetail',
        component: () => import('../views/account/orderDetail.vue'),
        meta: {
          title: '订单详情',
          description: '查看订单详细信息',
          allAuthority: ['all']
        }
      },
      {
        path: 'product-detail/:id',
        name: 'accountProductDetail',
        component: () => import('../views/account/productDetail.vue'),
        meta: {
          title: '商品详情',
          description: '个人中心 - 商品详情',
          allAuthority: ['all']
        }
      },
      {
        path: 'product-machine-add',
        name: 'accountProductMachineAdd',
        component: () => import('../views/account/productMachineAdd.vue'),
        meta: {
          title: '添加出售机器',
          description: '为商品添加出售机器',
          allAuthority: ['all']
        }
      }
    ]
  }
]

// 所有子路由
export const childrenRoutes = [
  ...productRoutes,
  ...cartRoutes,
  ...checkoutRoutes,
  ...accountRoutes
]

// 主路由配置
export const mainRoutes = [
  // 认证路由（独立布局，无Header）
  ...authRoutes,
  
  // 主应用路由（带Layout）
  {
    path: '/',
    name: 'Home',
    component: () => import('../Layout/idnex.vue'),
    redirect: '/productList',
    children: childrenRoutes
  },
  
  // 404页面重定向到商品列表
  {
    path: '*',
    redirect: '/productList'
  }
]

export default mainRoutes 