{{ 'fb_in_app_browser_popup.desc' | translate }} {{ 'fb_in_app_browser_popup.copy_link' | translate }}
{{ 'in_app_browser_popup.desc' | translate }}
{{ childProduct.title_translations | translateModel }}
{{ getChildVariationShorthand(childProduct.child_variation) }}
{{ getSelectedItemDetail(selectedChildProduct, item).childProductName }} x {{ selectedChildProduct.quantity || 1 }}
{{ getSelectedItemDetail(selectedChildProduct, item).childVariationName }}
import React, { useState, useEffect } from 'react'; const TigerGodFortuneLottery = () => { const [isDrawing, setIsDrawing] = useState(false); const [result, setResult] = useState(null); const [showTemple, setShowTemple] = useState(true); // 財運等級 const fortuneLevels = [ { level: "大吉", description: "財源廣進,鴻運當頭" }, { level: "中吉", description: "財運亨通,順風順水" }, { level: "小吉", description: "小有所成,穩步向前" }, { level: "平", description: "財運平穩,守成為上" }, { level: "小凶", description: "小有阻礙,謹慎為宜" } ]; // 獎品清單 const prizes = [ // 頂級獎品 { name: "Gogoro VIVA MIX電動機車", value: 74800, weight: 1, image: "/api/placeholder/200/150" }, { name: "iPhone 16 Pro Max 1TB", value: 59900, weight: 1, image: "/api/placeholder/200/150" }, { name: "MacBook Pro 16吋 M3 Max", value: 109900, weight: 1, image: "/api/placeholder/200/150" }, { name: "ROG Strix G16電競筆電", value: 69900, weight: 1, image: "/api/placeholder/200/150" }, // 高價值獎品 { name: "Sony A7 IV 相機", value: 59980, weight: 2, image: "/api/placeholder/200/150" }, { name: "LG OLED C4 65吋電視", value: 69900, weight: 2, image: "/api/placeholder/200/150" }, { name: "Dyson V15 Detect", value: 28900, weight: 3, image: "/api/placeholder/200/150" }, { name: "Apple Watch Ultra 2", value: 27900, weight: 3, image: "/api/placeholder/200/150" }, { name: "iPad Pro 13吋 M2", value: 32900, weight: 3, image: "/api/placeholder/200/150" }, { name: "Bose QuietComfort Ultra耳機", value: 12900, weight: 5, image: "/api/placeholder/200/150" }, // 中價位獎品 { name: "Nintendo Switch OLED", value: 10480, weight: 8, image: "/api/placeholder/200/150" }, { name: "Samsung Galaxy Tab S9", value: 24900, weight: 8, image: "/api/placeholder/200/150" }, { name: "Philips Airfryer XXL", value: 12900, weight: 10, image: "/api/placeholder/200/150" }, { name: "GoPro HERO12 Black", value: 15990, weight: 10, image: "/api/placeholder/200/150" }, { name: "Garmin Fenix 7X", value: 28900, weight: 10, image: "/api/placeholder/200/150" }, // 其他熱門產品 (省略部分獎品以符合空間限制) { name: "RIMOWA Essential登機箱", value: 28500, weight: 15, image: "/api/placeholder/200/150" }, { name: "Theragun Pro按摩槍", value: 16000, weight: 15, image: "/api/placeholder/200/150" }, { name: "Nespresso Vertuo咖啡機", value: 10900, weight: 20, image: "/api/placeholder/200/150" }, { name: "Keychron Q1機械鍵盤", value: 10500, weight: 20, image: "/api/placeholder/200/150" }, { name: "Kindle Scribe電子書閱讀器", value: 12500, weight: 20, image: "/api/placeholder/200/150" } ]; // 抽取財運 const drawFortune = () => { setIsDrawing(true); setShowTemple(false); // 模擬抽籤動畫 setTimeout(() => { // 抽取財運等級 const fortuneIndex = Math.floor(Math.random() * fortuneLevels.length); const fortune = fortuneLevels[fortuneIndex]; // 根據財運等級決定獎品範圍和權重 let prizePool = []; let weightSum = 0; // 依財運等級調整獎品機率 if (fortune.level === "大吉") { // 大吉有機會抽到任何獎品,頂級獎品權重提高 prizePool = prizes.map(prize => { let adjustedWeight = prize.weight; if (prize.value > 50000) adjustedWeight *= 5; // 提高頂級獎品權重 weightSum += adjustedWeight; return { ...prize, adjustedWeight }; }); } else if (fortune.level === "中吉") { // 中吉主要是中高價位獎品 prizePool = prizes.map(prize => { let adjustedWeight = prize.weight; if (prize.value > 20000 && prize.value <= 50000) adjustedWeight *= 3; weightSum += adjustedWeight; return { ...prize, adjustedWeight }; }); } else { // 其他等級獎品基本權重不變 prizePool = prizes.map(prize => { weightSum += prize.weight; return { ...prize, adjustedWeight: prize.weight }; }); } // 加權隨機抽取獎品 let randomValue = Math.random() * weightSum; let selectedPrize = null; for (const prize of prizePool) { randomValue -= prize.adjustedWeight; if (randomValue <= 0) { selectedPrize = prize; break; } } // 設置結果 setResult({ fortune, prize: selectedPrize }); setIsDrawing(false); }, 3000); }; const resetDraw = () => { setResult(null); setShowTemple(true); }; return (
{showTemple && (
{/* 替換為機械虎人圖片 */}
今日一籤定財運,科技虎爺保平安
啟動抽籤系統
)} {isDrawing && (
虎爺AI正在計算您的今日財運...
)} {result && (
{result.fortune.description}
)}
); }; export default TigerGodFortuneLottery;