import React, { useState, useEffect } from 'react';
import { Calculator, TrendingUp, ShieldCheck, FileText, ArrowRight, UserCheck, Building2, Crown, Sparkles, CheckCircle2, MessageCircle, PiggyBank, Smile, Coins, Undo2, Home, Wallet, ArrowDown, Percent, Repeat, BadgeCheck, Lock, Zap } from 'lucide-react';
const Card = ({ children, className = "" }) => (
{children}
);
// 跳動的減壓勳章
const JumpingBadge = ({ percent }) => (
減壓
{(percent || 0).toFixed(0)}%
);
// --- 主程式 ---
export default function AssetOptimizationSystem_Lite() {
const [mode, setMode] = useState('landing'); // landing, buyer, owner
return (
{/* 背景裝飾 */}
{mode === 'landing' && }
{mode === 'buyer' && setMode('landing')} />}
{mode === 'owner' && setMode('landing')} />}
);
}
// --- 1. 首頁選擇 (Landing) - 輕鬆成家版 ---
function LandingView({ onSelect }) {
return (
房貸減壓.輕鬆成家
透過財務優化,讓買房不再是重擔。
請選擇您的身分:
{/* Buyer Option */}
onSelect('buyer')}>
準備買房看這裡
我是首購族
頭期款已準備好?想減輕房貸壓力?
👉 立即查看輕鬆成家方案
{/* Owner Option */}
onSelect('owner')}>
已有房貸看這裡
我是有房族
覺得每個月繳得很辛苦?
👉 立即查看減壓潛力
安全匿名試算,不留存個人紀錄
);
}
// --- 2. 首購族流程 (Buyer Flow) ---
function BuyerFlow({ onBack }) {
const [step, setStep] = useState(1);
const [price, setPrice] = useState(2000); // 萬
const [fundType, setFundType] = useState('standard');
const [loading, setLoading] = useState(false);
// 試算邏輯
const isRich = fundType === 'rich';
// 參數設定 (固定)
const mRate = 2.3 / 100 / 12;
const periods = 360;
// A. 一般規劃 (傳統)
const tradDownPct = isRich ? 0.5 : 0.2;
const tradLoanAmt = price * 10000 * (1 - tradDownPct);
// 傳統月付
const tradFullPay = Math.round((tradLoanAmt * mRate * Math.pow(1 + mRate, periods)) / (Math.pow(1 + mRate, periods) - 1)) || 0;
const tradGracePay = Math.round(tradLoanAmt * mRate) || 0;
// B. 優化規劃
const optLoanAmt = price * 10000 * 0.8;
const optDownAmt = price * 10000 * 0.2;
// 投資本金
const investRatio = isRich ? 0.3 : 0.2;
const investedCapital = price * 10000 * investRatio;
// 每月配息效益 (8%)
const monthlyYield = Math.round((investedCapital * 0.08) / 12);
// 優化後月付
const optLoanFullPayRaw = Math.round((optLoanAmt * mRate * Math.pow(1 + mRate, periods)) / (Math.pow(1 + mRate, periods) - 1));
const optFullPay = Math.max(0, optLoanFullPayRaw - monthlyYield);
const optLoanGracePayRaw = Math.round(optLoanAmt * mRate);
const optGracePay = Math.max(0, optLoanGracePayRaw - monthlyYield);
// 總購屋成本
const totalTradCost = (price * 10000 * tradDownPct) + (tradFullPay * 360);
const totalOptCost = optDownAmt + (optFullPay * 360);
// 減壓百分比
const reliefPercent = tradFullPay > 0 ? ((tradFullPay - optFullPay) / tradFullPay) * 100 : 0;
// 退休後續領金額
const passiveIncomeAfterLoan = monthlyYield;
// 省下金額 (顯示用)
const savedMonthly = tradFullPay - optFullPay;
const handleCalc = () => {
setStep(2);
setLoading(true);
setTimeout(() => { setLoading(false); setStep(3); }, 1500);
};
return (
{step === 1 && (
{fundType === 'rich' ? '* 已切換為:高資產優化模式' : '* 已切換為:首購減壓模式'}
)}
{step === 2 &&
}
{step === 3 && (
setStep(1)}
reliefPercent={reliefPercent}
isBuyer={true}
futurePassive={passiveIncomeAfterLoan}
totalTrad={totalTradCost}
totalOpt={totalOptCost}
diff={savedMonthly}
/>
)}
);
}
// --- 3. 有房族流程 (Owner Flow) ---
function OwnerFlow({ onBack }) {
const [step, setStep] = useState(1);
const [monthlyPay, setMonthlyPay] = useState(45000);
const [loading, setLoading] = useState(false);
// 試算邏輯 (保守估計降 40%)
const optimizedPay = Math.round(monthlyPay * 0.6);
const savedMonthly = monthlyPay - optimizedPay;
// 繳清後月領 (願景:原本拿去繳房貸的錢,現在變成月領配息)
const futurePassive = savedMonthly;
// 30年多存
const saved30Years = savedMonthly * 12 * 30;
// 減壓百分比
const reliefPercent = monthlyPay > 0 ? ((monthlyPay - optimizedPay) / monthlyPay) * 100 : 0;
const handleCalc = () => {
setStep(2);
setLoading(true);
setTimeout(() => { setLoading(false); setStep(3); }, 1500);
};
return (
{step === 1 && (
)}
{step === 2 &&
}
{step === 3 && (
setStep(1)}
reliefPercent={reliefPercent}
isOwner={true}
futurePassive={futurePassive}
saved30Years={saved30Years}
diff={savedMonthly}
/>
)}
);
}
// --- Loading Component ---
function LoadingScreen() {
return (
);
}
// --- Result Component ---
function ResultScreen({
tradGrace, optGrace,
tradFull, optFull,
onReset, reliefPercent, isBuyer, isOwner, futurePassive, totalTrad, totalOpt, saved30Years, diff
}) {
const formatCurrency = (val) => new Intl.NumberFormat('zh-TW', { style: 'currency', currency: 'TWD', maximumFractionDigits: 0 }).format(val);
const formatWan = (val) => (val / 10000).toFixed(0);
return (
{/* 核心結果:上下對照 */}
{/* 跳動勳章 */}
{/* 1. 寬限期比較 (首購族顯示) */}
{isBuyer && (
第一階段 (寬限期)
{formatCurrency(tradGrace)} 元
{optGrace <= 0 ? "0" : formatCurrency(optGrace)} 元
{optGrace < 0 &&
每個月還倒賺 {formatCurrency(Math.abs(optGrace))}
}
)}
{/* 2. 本利攤比較 / 有房族月付比較 */}
{isBuyer ? '第二階段 (本利攤)' : '每月房貸負擔'}
{formatCurrency(tradFull)} 元
{formatCurrency(optFull)} 元
每月幫您省下 {formatCurrency(diff)}
{/* 願景卡片 (Vision Cards) */}
{/* Left Card: 總購屋成本 (Buyer) / 累積多存 (Owner) */}
{isBuyer ? (
總購屋成本
{formatWan(totalTrad)} 萬
{formatWan(totalOpt)} 萬
省下 {formatWan(totalTrad - totalOpt)} 萬
) : (
30年累積多存
{formatWan(saved30Years)} 萬
)}
{/* Right Card: 繳清後月領 */}
繳清房貸後
每月配息
{formatCurrency(futurePassive)}
{/* CTA */}
想了解如何落實這套規劃?
);
}