Files
2026-09-11 07:15:51 +08:00

64 lines
2.8 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>套餐 · GameParlor</title>
<link rel="stylesheet" href="/app.css">
<script src="/js/vendor/tailwind.min.js"></script>
<script defer src="/js/vendor/alpine.min.js"></script>
</head>
<body x-data="combosApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">套餐</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<template x-for="c in list" :key="c.id">
<div class="card card-hover p-5">
<div class="flex items-start justify-between">
<div class="font-bold text-lg" x-text="c.name"></div>
<span class="badge badge-accent" x-text="c.type"></span>
</div>
<div class="text-sm text-[#9a9aa5] mt-2">折扣率 <span x-text="c.discountRate"></span></div>
<button class="btn btn-ghost !py-1 text-xs mt-3" @click="showDetail(c)">查看详情</button>
</div>
</template>
</div>
<div x-show="detailModal" x-cloak class="modal-mask" @click.self="detailModal=false">
<div class="modal" style="max-width:560px">
<h3 class="text-lg font-bold mb-2" x-text="detail && detail.combo && detail.combo.name"></h3>
<div class="text-sm text-[#9a9aa5] mb-3">
类型 <span x-text="detail && detail.combo && detail.combo.type"></span> · 折扣率 <span x-text="detail && detail.combo && detail.combo.discountRate"></span>
</div>
<div class="text-sm mb-2 text-[#9a9aa5]">包含项目:</div>
<div class="space-y-2 mb-4">
<template x-for="it in ((detail && detail.items) || [])" :key="it.id">
<div class="flex justify-between text-sm p-2 rounded bg-[#16161a]">
<span x-text="`${it.itemType} #${it.itemId} × ${it.quantity}`"></span>
<span class="text-[#9a9aa5]" x-text="'¥'+fmtMoney(it.unitPriceAtCreation)"></span>
</div>
</template>
</div>
<div class="flex justify-between items-center">
<div class="text-xl font-bold text-[#00d4ff]" x-text="'¥'+fmtMoney(detail && detail.price)"></div>
<button class="btn btn-primary" :disabled="!detail" @click="buy()">立即购买</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function combosApp() {
return {
list: [], detailModal: false, detail: null,
async init() { await initLayout('combos'); this.list = await api('/api/combos').catch(() => []); },
async showDetail(c) { this.detail = await api('/api/combos/' + c.id).catch(() => null); this.detailModal = true; },
async buy() {
await api('/api/orders/combos/' + this.detail.combo.id, { method: 'POST' });
toast('购买成功', 'success'); this.detailModal = false;
}
};
}
</script>
</body>
</html>