function showPage(pageName, btnElement) { document.querySelectorAll('.page').forEach(p => p.classList.remove('active')); document.getElementById('page-' + pageName).classList.add('active'); document.querySelectorAll('.nav-item').forEach(b => b.classList.remove('active')); if (btnElement) { btnElement.classList.add('active'); } } function scrollToThermometer() { document.querySelectorAll('.nav-item').forEach(b => b.classList.remove('active')); document.querySelectorAll('.page').forEach(p => p.classList.remove('active')); document.getElementById('page-index').classList.add('active'); setTimeout(() => { const section = document.getElementById('thermometer-section'); if (section) { section.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }, 100); } const fastData = generateFastData(); function generateFastData() { const data = []; let baseIndex = 50; const today = new Date('2026-03-23'); for (let i = 30; i >= 0; i--) { const date = new Date(today); date.setDate(date.getDate() - i); const dateStr = date.toISOString().split('T')[0]; baseIndex += (Math.random() - 0.5) * 10; baseIndex = Math.max(15, Math.min(85, baseIndex)); let alert = "😐 情绪正常"; if (baseIndex > 80) alert = "🔥 市场极度亢奋!"; else if (baseIndex > 60) alert = "📈 情绪偏热,谨慎"; else if (baseIndex < 20) alert = "✅ 市场极度低迷"; else if (baseIndex < 40) alert = "📉 情绪偏冷,观望"; data.push({ date: dateStr, sentiment_index: baseIndex, alert: alert }); } return data; } function runFastAnalysis() { const loading = document.getElementById('loading'); const result = document.getElementById('result'); loading.style.display = "block"; result.style.display = "none"; setTimeout(() => { const startDate = document.getElementById('startDate').value; const endDate = document.getElementById('endDate').value; const filteredData = fastData.filter(d => d.date >= startDate && d.date <= endDate); if (filteredData.length === 0) { renderFastResult(fastData.slice(-10)); } else { renderFastResult(filteredData); } loading.style.display = "none"; result.style.display = "block"; result.scrollIntoView({behavior: 'smooth'}); }, 300); } function renderFastResult(data) { const container = document.getElementById('tableContainer'); let html = ``; data.slice(-5).forEach(item => { html += ``; }); html += `
日期情绪指数状态
${item.date} ${item.sentiment_index.toFixed(1)} ${item.alert}
`; container.innerHTML = html; renderFastChart(data); } function renderFastChart(data) { const ctx = document.getElementById('sentimentChart').getContext('2d'); if (window.myChart) window.myChart.destroy(); window.myChart = new Chart(ctx, { type: 'line', data: { labels: data.map(d => d.date.slice(5)), datasets: [{ label: '情绪指数', data: data.map(d => d.sentiment_index), borderColor: '#ff4500', backgroundColor: 'rgba(255, 69, 0, 0.1)', borderWidth: 2, fill: true, tension: 0.3 }, { label: '亢奋线 (80)', data: Array(data.length).fill(80), borderColor: 'red', borderDash: [5, 5], pointRadius: 0 }, { label: '低迷线 (20)', data: Array(data.length).fill(20), borderColor: 'green', borderDash: [5, 5], pointRadius: 0 }] }, options: { responsive: true, maintainAspectRatio: false, scales: { y: {beginAtZero: true, max: 100}, x: {ticks: {maxRotation: 45}} } } }); } let currentQ = 1; const totalQ = 8; let answers = {}; function updateProgress() { const percent = (currentQ / totalQ) * 100; document.getElementById('progress').style.width = percent + '%'; } document.addEventListener('DOMContentLoaded', function() { document.querySelectorAll('.option').forEach(option => { option.addEventListener('click', function () { const card = this.closest('.question-card'); card.querySelectorAll('.option').forEach(o => o.classList.remove('selected')); this.classList.add('selected'); const qNum = card.dataset.q; answers[qNum] = { value: this.dataset.value, score: parseInt(this.dataset.score) }; document.getElementById('nextBtn').disabled = false; }); }); }); function nextQuestion() { if (currentQ < totalQ) { document.querySelector(`[data-q="${currentQ}"]`).classList.remove('active'); currentQ++; document.querySelector(`[data-q="${currentQ}"]`).classList.add('active'); document.getElementById('prevBtn').disabled = false; document.getElementById('nextBtn').disabled = !answers[currentQ]; document.getElementById('nextBtn').textContent = currentQ === totalQ ? '查看结果' : '下一题'; } else { showResult(); } updateProgress(); } function prevQuestion() { if (currentQ > 1) { document.querySelector(`[data-q="${currentQ}"]`).classList.remove('active'); currentQ--; document.querySelector(`[data-q="${currentQ}"]`).classList.add('active'); document.getElementById('prevBtn').disabled = currentQ === 1; document.getElementById('nextBtn').disabled = false; document.getElementById('nextBtn').textContent = '下一题'; } updateProgress(); } function showResult() { const totalScore = Object.values(answers).reduce((sum, a) => sum + a.score, 0); const maxScore = totalQ * 3; const percent = (totalScore / maxScore * 100).toFixed(0); let type, icon, title, desc, suggestions; if (percent >= 75) { type = 'type-aggressive'; icon = '🔥'; title = '进取型投资者'; desc = '您对新能源投资有较高认知和风险承受能力,但请警惕过度自信。河北调研显示,高认知群体也可能因轻信"熟人推荐"而受骗。'; suggestions = [ '优先选择国家电网、大型国企背景的正规项目', '对"保本高收益"承诺保持警惕,核实企业资质', '建议将新能源投资控制在家庭资产的30%以内', '定期关注情绪指数,避免在市场过热时追高' ]; } else if (percent >= 50) { type = 'type-moderate'; icon = '⚖️'; title = '稳健型投资者'; desc = '您具备一定的投资基础,但部分认知仍有提升空间。这是河北居民中最常见的类型,建议加强防骗学习。'; suggestions = [ '从政府补贴的户用光伏等低风险项目入手', '投资前务必通过发改委、电网公司核实项目备案', '拒绝任何形式的"拉人头返利"模式', '建议先完成"防骗学堂"课程再决策' ]; } else { type = 'type-conservative'; icon = '🛡️'; title = '谨慎型投资者'; desc = '当前您对新能源投资了解有限或风险承受能力较弱。河北调研显示,这一群体最易成为诈骗目标,建议先学习后决策。'; suggestions = [ '强烈建议先完成"防骗学堂"课程', '切勿相信"零风险、高回报"宣传,这100%是骗局', '如有投资意向,只选择村委会/政府统一组织的项目', '建议从免费的政策补贴申请开始,而非直接资金投入' ]; } document.getElementById('result-content').innerHTML = `
${icon}
${title}
匹配度评分:${percent}%
${desc}

💡 针对您的建议

`; document.getElementById('quiz-container').style.display = 'none'; document.getElementById('btn-group').style.display = 'none'; document.getElementById('progress').parentElement.style.display = 'none'; document.getElementById('result-card').style.display = 'block'; } function restartTest() { currentQ = 1; answers = {}; document.querySelectorAll('.question-card').forEach((card, i) => { card.classList.toggle('active', i === 0); }); document.querySelectorAll('.option').forEach(o => o.classList.remove('selected')); document.getElementById('quiz-container').style.display = 'block'; document.getElementById('btn-group').style.display = 'flex'; document.getElementById('progress').parentElement.style.display = 'block'; document.getElementById('result-card').style.display = 'none'; document.getElementById('prevBtn').disabled = true; document.getElementById('nextBtn').disabled = true; document.getElementById('nextBtn').textContent = '下一题'; updateProgress(); } function toggleCourse(header) { const content = header.nextElementSibling; const isActive = content.classList.contains('active'); document.querySelectorAll('.course-content').forEach(c => c.classList.remove('active')); document.querySelectorAll('.course-header').forEach(h => h.classList.remove('expanded')); if (!isActive) { content.classList.add('active'); header.classList.add('expanded'); } } updateProgress();