// 路由系统 - 支持多订单班结果展示 class OrderClassRouter { constructor() { this.routes = { 'wenlu': { name: '文旅订单班', path: '/result/wenlu', template: 'wenlu-result.html', title: '2024长三角国际新能源汽车与智能交通产业博览会', agents: ['项目策划专家', '展会设计师', '市场营销专家', '运营管理专家', '财务分析师', '风险控制专家'] }, 'food': { name: '食品订单班', path: '/result/food', template: 'food-result.html', title: '中高端个性化轻食店铺经营方案', agents: ['轻食店经营管理专家', '餐饮市场调研专家', '餐饮品牌设计专家', '菜品研发专家', '餐厅选址装修专家', '餐饮团队人员管理专家', '财务预算专家'] } }; this.currentRoute = null; this.init(); } init() { // 监听URL变化 window.addEventListener('popstate', () => this.handleRoute()); // 处理初始路由 this.handleRoute(); } handleRoute() { const path = window.location.pathname; const urlParams = new URLSearchParams(window.location.search); const orderClass = urlParams.get('class') || this.getClassFromPath(path); if (orderClass && this.routes[orderClass]) { this.loadRoute(orderClass); } else { // 默认加载文旅订单班 this.loadRoute('wenlu'); } } getClassFromPath(path) { // 从路径中提取订单班类型 const match = path.match(/\/result\/(\w+)/); return match ? match[1] : null; } loadRoute(orderClass) { const route = this.routes[orderClass]; if (!route) return; this.currentRoute = orderClass; // 更新页面标题 document.title = route.title; // 更新URL(不刷新页面) const newUrl = `${window.location.origin}${route.path}`; if (window.location.href !== newUrl) { window.history.pushState({ orderClass }, '', newUrl); } // 加载对应的内容 this.loadContent(route); } loadContent(route) { // 检查是否有特定的内容容器 const contentContainer = document.getElementById('order-class-content'); if (!contentContainer) { console.warn('未找到内容容器 #order-class-content'); return; } // 根据订单班类型加载不同的内容 if (route.template) { this.loadTemplate(route.template, contentContainer); } else { // 动态生成内容 this.generateContent(route, contentContainer); } } async loadTemplate(templatePath, container) { try { const response = await fetch(`/pages/${templatePath}`); if (response.ok) { const html = await response.text(); container.innerHTML = html; this.initializePageScripts(); } else { this.generateContent(this.routes[this.currentRoute], container); } } catch (error) { console.error('加载模板失败:', error); this.generateContent(this.routes[this.currentRoute], container); } } generateContent(route, container) { // 动态生成页面内容 const html = `
基于AI Agent多角色协作生成的完整方案