乐于分享
好东西不私藏

【星辰电竞】免单抽奖开源代码

【星辰电竞】免单抽奖开源代码

尊敬的客户您好,以下为星辰电竞抽奖的开源代码,供您参考!
<!DOCTYPE html><htmllang="zh-CN"><head>    <metacharset="UTF-8">    <metaname="viewport"content="width=device-width, initial-scale=1.0">    <title>幸运抽奖系统 · 完美转盘版</title>    <linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">    <style>        * {            margin0;            padding0;            box-sizing: border-box;            font-family'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;        }        body {            backgroundlinear-gradient(135deg#1a2a6c#b21f1f#1a2a6c);            min-height100vh;            display: flex;            flex-direction: column;            align-items: center;            padding20px;            color: white;            overflow-x: hidden;        }        .header {            text-align: center;            margin-bottom30px;            padding20px;            width100%;        }        h1 {            font-size3.2rem;            margin-bottom15px;            text-shadow0 0 15px rgba(2552552550.7);            backgroundlinear-gradient(to right, #ff9966#ff5e62);            -webkit-background-clip: text;            -webkit-text-fill-color: transparent;            letter-spacing2px;        }        .subtitle {            font-size1.3rem;            color#ffcc00;            margin-bottom10px;            text-shadow0 0 5px rgba(0,0,0,0.5);        }        .tabs {            display: flex;            justify-content: center;            margin-bottom30px;            backgroundrgba(0000.3);            border-radius50px;            padding8px;            max-width500px;            width100%;            box-shadow0 5px 15px rgba(0,0,0,0.3);        }        .tab-btn {            background: none;            border: none;            color: white;            padding14px 35px;            font-size1.2rem;            cursor: pointer;            border-radius30px;            transition: all 0.3s ease;            margin0 5px;            display: flex;            align-items: center;            gap8px;        }        .tab-btn.active {            backgroundlinear-gradient(to right, #ff9966#ff5e62);            box-shadow0 0 15px rgba(25594980.5);        }        .tab-btn i {            font-size1.3rem;        }        .container {            display: flex;            flex-direction: column;            align-items: center;            width100%;            max-width1200px;        }        .tab-content {            display: none;            width100%;            backgroundrgba(2552552550.1);            backdrop-filterblur(10px);            border-radius20px;            padding35px;            box-shadow0 15px 35px rgba(0000.4);            margin-bottom30px;            border1px solid rgba(255,255,255,0.2);        }        .tab-content.active {            display: block;            animation: fadeIn 0.6s ease;        }        @keyframes fadeIn {            from { opacity0transformtranslateY(20px); }            to { opacity1transformtranslateY(0); }        }        /* 转盘抽奖样式 (Canvas版) */        .wheel-container {            display: flex;            flex-direction: column;            align-items: center;        }        .wheel-wrapper {            position: relative;            width420px;            height420px;            margin0 auto 40px;        }        #wheelCanvas {            width100%;            height100%;            display: block;            border-radius50%;            box-shadow0 0 0 15px rgba(25521500.5),                        0 0 40px rgba(25521500.8);            transition: transform 4s cubic-bezier(0.170.670.120.99);            background#2c3e50/* 底色, 实际被canvas覆盖 */        }        .wheel-center {            position: absolute;            top50%;            left50%;            transformtranslate(-50%, -50%);            width70px;            height70px;            background#fff;            border-radius50%;            box-shadow0 0 15px rgba(0,0,0,0.5);            z-index10;            display: flex;            align-items: center;            justify-content: center;            font-weight: bold;            color#ff5e62;            font-size1.4rem;            cursor: pointer;            transition: transform 0.3s ease;        }        .wheel-center:hover {            transformtranslate(-50%, -50%scale(1.1);        }        .pointer {            position: absolute;            top: -25px;            left50%;            transformtranslateX(-50%);            width50px;            height70px;            z-index9;        }        .pointer::before {            content"";            position: absolute;            top0;            left0;            width0;            height0;            border-left25px solid transparent;            border-right25px solid transparent;            border-top50px solid #ff5e62;            filterdrop-shadow(0 0 5px rgba(0,0,0,0.5));        }        .controls {            display: flex;            flex-direction: column;            align-items: center;            width100%;            max-width500px;        }        .prize-result {            margin25px 0;            font-size1.8rem;            min-height50px;            text-align: center;            font-weight: bold;            color: gold;            text-shadow0 0 8px rgba(0,0,0,0.8);            padding15px 30px;            border-radius15px;            backgroundrgba(0,0,0,0.3);            width100%;            transition: all 0.3s ease;        }        .prize-result.win {            backgroundrgba(010000.4);            animation: pulse 1s infinite;        }        @keyframes pulse {            0% { box-shadow0 0 5px gold; }            50% { box-shadow0 0 20px gold; }            100% { box-shadow0 0 5px gold; }        }        .btn {            backgroundlinear-gradient(to right, #ff9966#ff5e62);            border: none;            color: white;            padding18px 45px;            font-size1.3rem;            border-radius50px;            cursor: pointer;            transition: all 0.3s ease;            box-shadow0 5px 20px rgba(25594980.4);            margin15px 0;            display: flex;            align-items: center;            gap10px;            font-weight: bold;            letter-spacing1px;        }        .btn:hover {            transformtranslateY(-5px);            box-shadow0 10px 25px rgba(25594980.6);        }        .btn:active {            transformtranslateY(2px);        }        .prize-info {            display: grid;            grid-template-columnsrepeat(31fr);            gap20px;            width100%;            max-width700px;            margin-top30px;        }        .prize-card {            backgroundrgba(2552552550.15);            border-radius15px;            padding20px;            text-align: center;            border2px solid rgba(255,255,255,0.2);            transition: all 0.3s ease;        }        .prize-card:hover {            transformtranslateY(-5px);            box-shadow0 10px 20px rgba(0,0,0,0.2);        }        .prize-card h3 {            font-size1.4rem;            margin-bottom10px;            color#ffcc00;        }        .prize-card p {            font-size1.2rem;            font-weight: bold;        }        /* 名字抽取样式 */        .draw-container {            display: flex;            flex-direction: column;            align-items: center;            width100%;        }        .input-area {            width100%;            max-width700px;            margin-bottom30px;        }        textarea {            width100%;            height180px;            padding20px;            border-radius15px;            border3px solid #ff5e62;            backgroundrgba(2552552550.1);            color: white;            font-size18px;            resize: vertical;            margin-bottom20px;            transition: all 0.3s ease;        }        textarea:focus {            outline: none;            border-color#ffcc00;            box-shadow0 0 15px rgba(25520400.5);        }        textarea::placeholder {            colorrgba(2552552550.6);        }        .draw-controls {            display: flex;            flex-wrap: wrap;            gap20px;            justify-content: center;            margin-bottom30px;            width100%;        }        .draw-controls input {            padding15px 25px;            border-radius30px;            border3px solid #ff5e62;            backgroundrgba(2552552550.1);            color: white;            font-size18px;            width150px;            text-align: center;            font-weight: bold;        }        .result-area {            display: flex;            flex-wrap: wrap;            justify-content: center;            gap25px;            width100%;            max-width900px;            min-height200px;            margin-bottom30px;        }        .result-card {            backgroundlinear-gradient(135deg#ff9966#ff5e62);            border-radius18px;            padding30px 45px;            font-size2.2rem;            font-weight: bold;            text-align: center;            box-shadow0 8px 25px rgba(0000.4);            animation: popIn 0.5s ease;            min-width220px;            display: flex;            align-items: center;            justify-content: center;            position: relative;            overflow: hidden;        }        .result-card::after {            content"";            position: absolute;            top: -50%;            left: -50%;            width200%;            height200%;            backgroundlinear-gradient(rgba(255,255,255,0.1), rgba(255,255,255,0));            transformrotate(30deg);        }        @keyframes popIn {            0% { transformscale(0.5rotate(-10deg); opacity0; }            100% { transformscale(1rotate(0); opacity1; }        }        .history {            width100%;            max-width800px;            margin-top20px;            backgroundrgba(0000.2);            border-radius20px;            padding25px;            border1px solid rgba(255,255,255,0.1);        }        .history h3 {            text-align: center;            margin-bottom20px;            color#ffcc00;            font-size1.8rem;            display: flex;            align-items: center;            justify-content: center;            gap15px;        }        .history-list {            max-height220px;            overflow-y: auto;            padding10px;            backgroundrgba(0,0,0,0.2);            border-radius10px;        }        .history-item {            padding15px;            border-bottom1px solid rgba(2552552550.1);            font-size1.2rem;            display: flex;            align-items: center;            gap15px;        }        .history-item::before {            content"•";            color#ff5e62;            font-size1.8rem;        }        /* 响应式 */        @media (max-width900px) {            .prize-info {                grid-template-columnsrepeat(21fr);            }        }        @media (max-width768px) {            .wheel-wrapper {                width350px;                height350px;            }            h1 {                font-size2.5rem;            }            .result-card {                font-size1.8rem;                padding25px 35px;            }            .prize-info {                grid-template-columns1fr;            }        }        @media (max-width480px) {            .wheel-wrapper {                width280px;                height280px;            }            .btn {                padding15px 35px;                font-size1.1rem;            }            .draw-controls {                flex-direction: column;                align-items: center;            }            .tab-btn {                padding12px 25px;                font-size1.1rem;            }            h1 {                font-size2rem;            }            .result-card {                font-size1.5rem;                padding20px 30px;                min-width180px;            }        }        .firework {            position: absolute;            width10px;            height10px;            border-radius50%;            pointer-events: none;            animation: firework 1s ease-out;            z-index100;        }        @keyframes firework {            0% { transformtranslate(00); opacity1; }            100% { transformtranslate(var(--tx), var(--ty)); opacity0; }        }        .confetti {            position: absolute;            width15px;            height15px;            background-color#f00;            border-radius50%;            animation: confetti-fall 3s linear forwards;            z-index1000;        }        @keyframes confetti-fall {            0% {                transformtranslateY(-20vhrotate(0deg);                opacity1;            }            100% {                transformtranslateY(100vhrotate(720deg);                opacity0;            }        }    </style></head><body>    <divclass="header">        <h1><iclass="fas fa-star"></i> 幸运抽奖系统 <iclass="fas fa-star"></i></h1>        <pclass="subtitle">优化版 · 完美转盘 + 名字抽取</p>    </div>    <divclass="tabs">        <buttonclass="tab-btn active"data-tab="wheel">            <iclass="fas fa-sync-alt"></i> 转盘抽奖        </button>        <buttonclass="tab-btn"data-tab="draw">            <iclass="fas fa-users"></i> 名字抽取        </button>    </div>    <divclass="container">        <!-- 转盘抽奖页面 (Canvas重制) -->        <divid="wheel-tab"class="tab-content active">            <divclass="wheel-container">                <divclass="wheel-wrapper">                    <canvasid="wheelCanvas"width="400"height="400"></canvas>                    <divclass="wheel-center"id="spin-center">GO!</div>                    <divclass="pointer"></div>                </div>                <divclass="prize-result"id="prize-result">点击GO!开始抽奖...</div>                <divclass="controls">                    <buttonclass="btn"id="spin-btn">                        <iclass="fas fa-play"></i> 开始抽奖                    </button>                </div>                <divclass="prize-info">                    <divclass="prize-card"><h3><iclass="fas fa-trophy"></i> 一等奖</h3><p>概率 2%</p></div>                    <divclass="prize-card"><h3><iclass="fas fa-medal"></i> 二等奖</h3><p>概率 5%</p></div>                    <divclass="prize-card"><h3><iclass="fas fa-award"></i> 三等奖</h3><p>概率 10%</p></div>                    <divclass="prize-card"><h3><iclass="fas fa-gem"></i> 四等奖</h3><p>概率 20%</p></div>                    <divclass="prize-card"><h3><iclass="fas fa-certificate"></i> 五等奖</h3><p>概率 30%</p></div>                    <divclass="prize-card"><h3><iclass="fas fa-heart"></i> 参与奖</h3><p>概率 33%</p></div>                </div>            </div>        </div>        <!-- 名字抽取页面 (保持不变) -->        <divid="draw-tab"class="tab-content">            <divclass="draw-container">                <divclass="input-area">                    <textareaid="name-input"placeholder="请输入名字,每行一个名字&#10;例如:&#10;张三&#10;李四&#10;王五&#10;赵六&#10;钱七"></textarea>                </div>                <divclass="draw-controls">                    <inputtype="number"id="draw-count"min="1"max="20"value="3"placeholder="抽取数量">                    <buttonclass="btn"id="draw-btn"><iclass="fas fa-random"></i> 随机抽取</button>                    <buttonclass="btn"id="reset-btn"><iclass="fas fa-redo"></i> 重置结果</button>                </div>                <divclass="result-area"id="result-area"></div>                <divclass="history">                    <h3><iclass="fas fa-history"></i> 抽取历史</h3>                    <divclass="history-list"id="history-list"></div>                </div>            </div>        </div>    </div>    <script>        // ================== 标签切换 ==================        const tabBtns = document.querySelectorAll('.tab-btn');        const tabContents = document.querySelectorAll('.tab-content');        tabBtns.forEach(btn => {            btn.addEventListener('click'() => {                tabBtns.forEach(b => b.classList.remove('active'));                tabContents.forEach(c => c.classList.remove('active'));                btn.classList.add('active');                const tabId = btn.getAttribute('data-tab');                document.getElementById(`${tabId}-tab`).classList.add('active');            });        });        // ================== 转盘抽奖 (Canvas绘制) ==================        const canvas = document.getElementById('wheelCanvas');        const ctx = canvas.getContext('2d');        const spinBtn = document.getElementById('spin-btn');        const spinCenter = document.getElementById('spin-center');        const prizeResult = document.getElementById('prize-result');        // 奖项配置 (名称, 概率, 颜色)        const prizes = [            { name"一等奖"probability2color"#FF6384" },            { name"二等奖"probability5color"#36A2EB" },            { name"三等奖"probability10color"#FFCE56" },            { name"四等奖"probability20color"#4BC0C0" },            { name"五等奖"probability30color"#9966FF" },            { name"参与奖"probability33color"#C9CBCF" }        ];        // 计算总概率 & 存储每个奖项的角度范围 (弧度, 绝对角度从0°开始)        const totalProb = prizes.reduce((sum, p) => sum + p.probability0);        let prizeRanges = []; // 每个奖项: { start, end, mid, name, color }        function calcRanges() {            let start = 0// 弧度, 从0开始 (右侧水平)            prizeRanges = prizes.map(p => {                const angle = (p.probability / totalProb) * 2 * Math.PI;                const end = start + angle;                const mid = start + angle / 2;                const range = {                     start, end, mid,                     name: p.name                    color: p.color,                    probability: p.probability                 };                start = end;                return range;            });        }        calcRanges();        // 绘制转盘        function drawWheel() {            const w = canvas.width;            const h = canvas.height;            const radius = w * 0.4// 留出边距            const centerX = w / 2;            const centerY = h / 2;            ctx.clearRect(00, w, h);            // 绘制每个扇形            prizeRanges.forEach(range => {                ctx.beginPath();                ctx.moveTo(centerX, centerY);                ctx.arc(centerX, centerY, radius, range.start, range.end);                ctx.closePath();                ctx.fillStyle = range.color;                ctx.fill();                // 描边分割线                ctx.strokeStyle = 'rgba(255,255,255,0.3)';                ctx.lineWidth = 2;                ctx.beginPath();                ctx.moveTo(centerX, centerY);                ctx.arc(centerX, centerY, radius, range.start, range.end);                ctx.lineTo(centerX, centerY);                ctx.stroke();            });            // 绘制文字            ctx.fillStyle = '#1e2a3a';            ctx.font = 'bold 18px "Segoe UI", "Microsoft YaHei", sans-serif';            ctx.textAlign = 'center';            ctx.textBaseline = 'middle';            prizeRanges.forEach(range => {                const textRadius = radius * 0.7;                const x = centerX + Math.cos(range.mid) * textRadius;                const y = centerY + Math.sin(range.mid) * textRadius;                // 白色背景衬底                ctx.fillStyle = '#ffffff';                ctx.fillText(range.name, x, y);                ctx.fillStyle = '#1e2a3a';                ctx.fillText(range.name, x, y);            });            // 中心小圆装饰            ctx.beginPath();            ctx.arc(centerX, centerY, 1202 * Math.PI);            ctx.fillStyle = '#ffdd99';            ctx.shadowColor = 'gold';            ctx.shadowBlur = 10;            ctx.fill();            ctx.shadowBlur = 0;        }        // 旋转转盘        let isSpinning = false;        const wheelCanvasEl = document.getElementById('wheelCanvas');        function spinWheel() {            if (isSpinning) return;            isSpinning = true;            // 重置旋转 (瞬间回到0°, 取消过渡)            wheelCanvasEl.style.transition = 'none';            wheelCanvasEl.style.transform = 'rotate(0deg)';            prizeResult.textContent = "抽奖中...";            prizeResult.classList.remove('win');            // 根据概率随机选择奖项            let rand = Math.random() * totalProb;            let accumulated = 0;            let selectedRange = null;            for (let i = 0; i < prizes.length; i++) {                accumulated += prizes[i].probability;                if (rand <= accumulated) {                    selectedRange = prizeRanges[i];                    break;                }            }            // 计算目标角度: 使选中扇形的中间(mid)对准指针方向(指针在正上方 = -90° 或 270°)            // 指针方向(绝对): -PI/2 (270°)            // 旋转公式: 需要将mid转到 -PI/2 方向, 因此旋转角度 = mid - (-PI/2) = mid + PI/2 (弧度)            // 转换为度: rotation = (mid + PI/2) * 180/PI            const mid = selectedRange.mid// 弧度            let targetDeg = (mid + Math.PI/2) * 180 / Math.PI// 转换为度            // 多转几圈增加真实感            targetDeg += 360 * 5// 5圈            // 应用旋转            setTimeout(() => {                wheelCanvasEl.style.transition = 'transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99)';                wheelCanvasEl.style.transform = `rotate(${targetDeg}deg)`;                // 烟花 & 结果                createFireworks(20);                setTimeout(() => {                    prizeResult.textContent = `恭喜您获得:${selectedRange.name}!`;                    prizeResult.classList.add('win');                    createConfetti();                    isSpinning = false;                }, 4000);            }, 20);        }        spinBtn.addEventListener('click', spinWheel);        spinCenter.addEventListener('click', spinWheel);        // 烟花效果        function createFireworks(count) {            for (let i = 0; i < count; i++) {                const f = document.createElement('div');                f.className = 'firework';                f.style.left = `${Math.random() * 100}%`;                f.style.top = `${Math.random() * 100}%`;                f.style.backgroundColor = `hsl(${Math.random() * 360}, 100%, 60%)`;                f.style.setProperty('--tx'`${Math.random() * 200 - 100}px`);                f.style.setProperty('--ty'`${Math.random() * 200 - 100}px`);                document.body.appendChild(f);                setTimeout(() => f.remove(), 1000);            }        }        // 彩色纸屑        function createConfetti() {            const colors = ['#ff0000''#00ff00''#0000ff''#ffff00''#ff00ff''#00ffff'];            for (let i = 0; i < 150; i++) {                const c = document.createElement('div');                c.className = 'confetti';                c.style.left = `${Math.random() * 100}%`;                c.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];                c.style.animationDuration = `${Math.random() * 3 + 2}s`;                document.body.appendChild(c);                setTimeout(() => c.remove(), 5000);            }        }        // ================== 名字抽取逻辑 (不变) ==================        const nameInput = document.getElementById('name-input');        const drawCountInput = document.getElementById('draw-count');        const drawBtn = document.getElementById('draw-btn');        const resetBtn = document.getElementById('reset-btn');        const resultArea = document.getElementById('result-area');        const historyList = document.getElementById('history-list');        drawBtn.addEventListener('click'() => {            const names = nameInput.value.split('\n').filter(name => name.trim() !== '');            if (names.length === 0) {                alert('请输入至少一个名字');                return;            }            let drawCount = parseInt(drawCountInput.value);            if (isNaN(drawCount)) drawCount = 3;            drawCount = Math.max(1Math.min(drawCount, names.length));            const selected = [];            const temp = [...names];            for (let i = 0; i < drawCount; i++) {                if (temp.length === 0break;                const idx = Math.floor(Math.random() * temp.length);                selected.push(temp[idx]);                temp.splice(idx, 1);            }            // 显示结果            resultArea.innerHTML = '';            selected.forEach(name => {                const card = document.createElement('div');                card.className = 'result-card';                card.textContent = name;                resultArea.appendChild(card);            });            // 历史记录            const item = document.createElement('div');            item.className = 'history-item';            const time = new Date().toLocaleTimeString();            item.textContent = `${time} - 抽取: ${selected.join(', ')}`;            historyList.appendChild(item);            historyList.scrollTop = historyList.scrollHeight;            if (historyList.children.length > 10) {                historyList.removeChild(historyList.firstChild);            }        });        resetBtn.addEventListener('click'() => {            resultArea.innerHTML = '';        });        // 初始化        window.onload = function() {            drawWheel();          // 绘制转盘            nameInput.value = "张三\n李四\n王五\n赵六\n钱七\n孙八\n周九\n吴十\n郑十一\n王十二";        };    </script></body></html>
若该代码中包含任何错误,请联系审核员
审核员邮箱:hpgzs0713@qq.com
我们会给予相对应的奖励!
本站文章均为手工撰写未经允许谢绝转载:夜雨聆风 » 【星辰电竞】免单抽奖开源代码

评论 抢沙发

2 + 5 =
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
×
订阅图标按钮