108 lines
6.4 KiB
PHP
108 lines
6.4 KiB
PHP
<div class="p-6">
|
|
<h2 class="text-2xl font-bold mb-4">🏎️ PK10 期号管理</h2>
|
|
|
|
<!-- 统计 -->
|
|
<div class="grid grid-cols-4 gap-4 mb-6">
|
|
<div class="bg-white rounded-xl p-4 shadow"><div class="text-gray-400 text-sm">总计</div><div class="text-2xl font-bold"><?=$stats['total']??0?></div></div>
|
|
<div class="bg-white rounded-xl p-4 shadow"><div class="text-gray-400 text-sm">待开奖</div><div class="text-2xl font-bold text-yellow-500"><?=$stats['pending']??0?></div></div>
|
|
<div class="bg-white rounded-xl p-4 shadow"><div class="text-gray-400 text-sm">已开奖</div><div class="text-2xl font-bold text-blue-500"><?=$stats['drawn']??0?></div></div>
|
|
<div class="bg-white rounded-xl p-4 shadow"><div class="text-gray-400 text-sm">已结算</div><div class="text-2xl font-bold text-green-500"><?=$stats['settled']??0?></div></div>
|
|
</div>
|
|
|
|
<!-- 当前期号 -->
|
|
<div class="bg-white rounded-xl p-6 shadow mb-6">
|
|
<h3 class="font-bold mb-3">当前期号</h3>
|
|
<?php if($current): ?>
|
|
<div class="flex items-center justify-between flex-wrap gap-3">
|
|
<div>
|
|
<span class="text-gray-400">期号:</span> <span class="font-mono font-bold"><?=$current['period_number']?></span>
|
|
<span class="ml-4 px-2 py-1 rounded text-xs <?=$current['status']==='pending'?'bg-yellow-100 text-yellow-700':($current['status']==='drawn'?'bg-blue-100 text-blue-700':'bg-green-100 text-green-700')?>"><?=$current['status']==='pending'?'待开奖':($current['status']==='locked'?'已封盘':($current['status']==='drawn'?'已开奖':'已结算'))?></span>
|
|
</div>
|
|
<div class="flex gap-2">
|
|
<?php if($current['status']==='pending'): ?>
|
|
<button onclick="doAction('lock',<?=$current['id']?>)" class="px-4 py-2 bg-orange-500 text-white rounded hover:bg-orange-600 text-sm">🔒 封盘</button>
|
|
<button onclick="doAction('draw',<?=$current['id']?>)" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 text-sm">🎲 自动开奖</button>
|
|
<button onclick="showManualDraw(<?=$current['id']?>)" class="px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600 text-sm">✏️ 手动开奖</button>
|
|
<?php elseif($current['status']==='locked'): ?>
|
|
<button onclick="doAction('draw',<?=$current['id']?>)" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 text-sm">🎲 自动开奖</button>
|
|
<button onclick="showManualDraw(<?=$current['id']?>)" class="px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600 text-sm">✏️ 手动开奖</button>
|
|
<?php elseif($current['status']==='drawn'): ?>
|
|
<div class="flex gap-1 items-center mr-4">
|
|
<?php if($current['pk10']): for($i=1;$i<=10;$i++): $v=$current['pk10']['rank_'.$i]??0; ?>
|
|
<span class="w-7 h-7 rounded-full bg-gray-200 flex items-center justify-center text-xs font-bold"><?=$v?></span>
|
|
<?php endfor; endif; ?>
|
|
</div>
|
|
<button onclick="doAction('settle',<?=$current['id']?>)" class="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600 text-sm">💰 结算</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="flex items-center justify-between">
|
|
<span class="text-gray-400">暂无进行中的期号</span>
|
|
<button onclick="doAction('start',0)" class="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600 text-sm">▶ 开始新期</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- 手动开奖弹窗 -->
|
|
<div id="manualModal" class="fixed inset-0 bg-black/50 z-50 hidden flex items-center justify-center">
|
|
<div class="bg-white rounded-xl p-6 w-full max-w-md">
|
|
<h3 class="font-bold mb-4">手动开奖 - 输入结果 (1-10)</h3>
|
|
<div class="grid grid-cols-5 gap-2 mb-4">
|
|
<?php for($i=1;$i<=10;$i++): ?>
|
|
<div>
|
|
<label class="text-xs text-gray-400">第<?=$i?>名</label>
|
|
<input type="number" min="1" max="10" id="mr<?=$i?>" class="w-full border rounded px-2 py-1 text-center" placeholder="<?=$i?>">
|
|
</div>
|
|
<?php endfor; ?>
|
|
</div>
|
|
<div class="flex gap-2">
|
|
<button onclick="submitManualDraw()" class="flex-1 py-2 bg-purple-500 text-white rounded hover:bg-purple-600">确认开奖</button>
|
|
<button onclick="document.getElementById('manualModal').classList.add('hidden')" class="flex-1 py-2 bg-gray-200 rounded hover:bg-gray-300">取消</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 历史列表 -->
|
|
<div class="bg-white rounded-xl shadow overflow-hidden">
|
|
<table class="w-full text-sm">
|
|
<thead class="bg-gray-50"><tr>
|
|
<th class="px-4 py-3 text-left">期号</th><th class="px-4 py-3 text-left">状态</th><th class="px-4 py-3 text-left">结果</th><th class="px-4 py-3 text-left">冠亚和</th><th class="px-4 py-3 text-left">时间</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
<?php foreach($periods??[] as $p): ?>
|
|
<tr class="border-t hover:bg-gray-50">
|
|
<td class="px-4 py-2 font-mono text-xs"><?=$p['period_number']?></td>
|
|
<td class="px-4 py-2"><span class="px-2 py-1 rounded text-xs <?=$p['status']==='settled'?'bg-green-100 text-green-700':($p['status']==='drawn'?'bg-blue-100 text-blue-700':'bg-yellow-100 text-yellow-700')?>"><?=$p['status']==='settled'?'已结算':($p['status']==='drawn'?'已开奖':'待开奖')?></span></td>
|
|
<td class="px-4 py-2">
|
|
<?php if($p['pk10']): ?>
|
|
<div class="flex gap-1"><?php for($i=1;$i<=10;$i++): $v=$p['pk10']['rank_'.$i]??0; ?><span class="w-5 h-5 rounded-full bg-gray-200 flex items-center justify-center text-xs"><?=$v?></span><?php endfor; ?></div>
|
|
<?php else: ?>---<?php endif; ?>
|
|
</td>
|
|
<td class="px-4 py-2"><?=$p['pk10']['champion_sum']??'-'?></td>
|
|
<td class="px-4 py-2 text-gray-400 text-xs"><?=$p['created_at']??''?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
let manualPeriodId=0;
|
|
function showManualDraw(id){manualPeriodId=id;document.getElementById('manualModal').classList.remove('hidden');}
|
|
async function submitManualDraw(){
|
|
const result=[];for(let i=1;i<=10;i++){const v=parseInt(document.getElementById('mr'+i).value);if(!v||v<1||v>10){alert('每个名次请输入1-10的数字');return;}result.push(v);}
|
|
if(new Set(result).size!==10){alert('10个名次的车号不能重复');return;}
|
|
await doAction('draw',manualPeriodId,{manual:true,result});
|
|
document.getElementById('manualModal').classList.add('hidden');
|
|
}
|
|
async function doAction(action,periodId,extra={}){
|
|
const body={period_id:periodId,...extra};
|
|
const url='/admin/pk10-periods/'+action;
|
|
const r=await fetch(url,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)});
|
|
const d=await r.json();
|
|
if(d.status==='success'){location.reload();}else{alert(d.message||'操作失败');}
|
|
}
|
|
</script>
|