第一版

This commit is contained in:
2026-09-11 07:15:51 +08:00
parent e73c13657c
commit 14528eba64
226 changed files with 7942 additions and 0 deletions
+121
View File
@@ -0,0 +1,121 @@
<!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()">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold">套餐管理</h2>
<button class="btn btn-primary" @click="openCreate()">+ 新增套餐</button>
</div>
<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-4">
<div class="flex items-start justify-between">
<div>
<div class="font-bold" x-text="c.name"></div>
<span class="badge badge-accent mt-1" x-text="c.type"></span>
</div>
<span class="badge" :class="c.isActive ? 'badge-success' : 'badge-danger'" x-text="c.isActive ? '启用' : '停用'"></span>
</div>
<div class="text-sm text-[#9a9aa5] mt-2">折扣率:<span x-text="c.discountRate"></span></div>
<div class="flex gap-2 mt-3">
<button class="btn btn-ghost !py-1 !px-2 text-xs" @click="openItems(c)">组成项</button>
<button class="btn btn-ghost !py-1 !px-2 text-xs" @click="openEdit(c)">编辑</button>
<button class="btn btn-danger !py-1 !px-2 text-xs" @click="remove(c.id)">删除</button>
</div>
</div>
</template>
</div>
<!-- 套餐编辑 -->
<div x-show="modal" x-cloak class="modal-mask" @click.self="modal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-4" x-text="editing ? '编辑套餐' : '新增套餐'"></h3>
<div class="space-y-3">
<div><label class="label">名称</label><input x-model="form.name" class="input"></div>
<div><label class="label">类型</label>
<select x-model="form.type" class="select">
<option value="VIP">VIP</option><option value="DEVICE_GAME">设备游戏</option><option value="SNACK_DRINK">零食饮料</option>
</select>
</div>
<div><label class="label">折扣率(如 0.85)</label><input type="number" step="0.01" x-model="form.discountRate" class="input"></div>
<div class="flex items-center gap-2"><input type="checkbox" x-model="form.isActive" id="act"><label for="act">启用</label></div>
</div>
<div class="flex justify-end gap-2 mt-5">
<button class="btn btn-ghost" @click="modal=false">取消</button>
<button class="btn btn-primary" @click="save()">保存</button>
</div>
</div>
</div>
<!-- 组成项 -->
<div x-show="itemsModal" x-cloak class="modal-mask" @click.self="itemsModal=false">
<div class="modal" style="max-width:600px">
<h3 class="text-lg font-bold mb-2" x-text="'组成项:' + (curCombo ? curCombo.name : '')"></h3>
<div class="text-sm text-[#9a9aa5] mb-3">总价 = Σ(单价×数量) × 折扣率 = <span class="text-[#00d4ff]" x-text="'¥'+fmtMoney(curPrice)"></span></div>
<div class="space-y-2 mb-3">
<template x-for="it in items" :key="it.id">
<div class="flex items-center justify-between p-2 rounded-lg bg-[#16161a]">
<span class="text-sm" x-text="`${it.itemType} #${it.itemId} × ${it.quantity} (¥${fmtMoney(it.unitPriceAtCreation)})`"></span>
<button class="btn btn-danger !py-0.5 !px-2 text-xs" @click="removeItem(it.id)">移除</button>
</div>
</template>
<div x-show="items.length===0" class="text-center text-[#6b6b78] py-4 text-sm">暂无组成项</div>
</div>
<div class="border-t border-[#2a2a33] pt-3">
<div class="text-sm font-medium mb-2">添加组成项</div>
<div class="grid grid-cols-2 gap-2">
<select x-model="newItem.itemType" class="select">
<option value="GAME">游戏</option><option value="DEVICE">设备</option><option value="SNACK">零食</option><option value="TIMESLOT">时长</option>
</select>
<input type="number" placeholder="项目ID" x-model="newItem.itemId" class="input">
<input type="number" placeholder="数量" x-model="newItem.quantity" class="input">
<button class="btn btn-primary" @click="addItem()">添加</button>
</div>
</div>
<div class="flex justify-end mt-4"><button class="btn btn-ghost" @click="itemsModal=false">关闭</button></div>
</div>
</div>
<script src="/app.js"></script>
<script>
function combosApp() {
return {
list: [], modal: false, editing: null, itemsModal: false, curCombo: null, items: [], curPrice: 0,
form: { name: '', type: 'VIP', discountRate: 1, isActive: true },
newItem: { itemType: 'GAME', itemId: '', quantity: 1 },
async init() { await initLayout('combos'); this.load(); },
async load() { this.list = await api('/api/combos').catch(() => []); },
openCreate() { this.editing = null; this.form = { name: '', type: 'VIP', discountRate: 1, isActive: true }; this.modal = true; },
openEdit(c) { this.editing = c; this.form = { name: c.name, type: c.type, discountRate: c.discountRate, isActive: c.isActive }; this.modal = true; },
async save() {
const method = this.editing ? 'PUT' : 'POST';
const url = this.editing ? `/api/admin/combos/${this.editing.id}` : '/api/admin/combos';
await api(url, { method, body: JSON.stringify(this.form) });
toast(this.editing ? '已更新' : '已创建', 'success');
this.modal = false; this.load();
},
async remove(id) { if (!confirm('确认删除套餐?')) return; await api(`/api/admin/combos/${id}`, { method: 'DELETE' }); toast('已删除', 'success'); this.load(); },
async openItems(c) {
this.curCombo = c; this.itemsModal = true;
const d = await api(`/api/combos/${c.id}`).catch(() => ({ items: [], price: 0 }));
this.items = d.items || []; this.curPrice = d.price || 0;
},
async addItem() {
if (!this.newItem.itemId) { toast('请输入项目ID', 'error'); return; }
await api(`/api/admin/combos/${this.curCombo.id}/items`, { method: 'POST', body: JSON.stringify({ itemType: this.newItem.itemType, itemId: Number(this.newItem.itemId), quantity: Number(this.newItem.quantity) || 1 }) });
toast('已添加', 'success');
this.openItems(this.curCombo);
},
async removeItem(id) { await api(`/api/admin/combos/items/${id}`, { method: 'DELETE' }); toast('已移除', 'success'); this.openItems(this.curCombo); }
};
}
</script>
</body>
</html>
@@ -0,0 +1,47 @@
<!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="dashApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">管理概览</h2>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
<div class="card card-hover p-5">
<div class="text-sm text-[#9a9aa5]">用户总数</div>
<div class="text-3xl font-bold mt-2 text-[#00d4ff]" x-text="stats.userCount ?? 0"></div>
</div>
<div class="card card-hover p-5">
<div class="text-sm text-[#9a9aa5]">订单总数</div>
<div class="text-3xl font-bold mt-2 text-[#00d4ff]" x-text="stats.orderCount ?? 0"></div>
</div>
<div class="card card-hover p-5">
<div class="text-sm text-[#9a9aa5]">待审批充值</div>
<div class="text-3xl font-bold mt-2" :class="(stats.pendingRechargeCount||0)>0 ? 'text-[#fbbf24]' : 'text-[#34d399]'" x-text="stats.pendingRechargeCount ?? 0"></div>
</div>
</div>
<div class="card p-5 mt-6">
<h3 class="font-semibold mb-3">系统配置</h3>
<template x-for="(v,k) in config" :key="k">
<div class="flex items-center justify-between py-2 border-b border-[#2a2a33] last:border-0">
<span class="text-sm text-[#9a9aa5]" x-text="k"></span>
<input :value="v" class="input !w-40 text-right" @change="saveConfig(k, $event.target.value)">
</div>
</template>
</div>
<script src="/app.js"></script>
<script>
function dashApp() {
return {
stats: {}, config: {},
async init() { await initLayout('dashboard'); this.stats = await api('/api/admin/stats').catch(() => ({})); this.config = await api('/api/admin/config').catch(() => ({})); },
async saveConfig(k, v) { await api('/api/admin/config', { method: 'PUT', body: JSON.stringify({ [k]: v }) }); toast('配置已更新', 'success'); }
};
}
</script>
</body>
</html>
+97
View File
@@ -0,0 +1,97 @@
<!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="devicesApp()" x-init="init()">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold">设备管理</h2>
<button class="btn btn-primary" @click="openCreate()">+ 新增设备</button>
</div>
<div class="card overflow-x-auto">
<table class="table">
<thead>
<tr><th>ID</th><th>名称</th><th>描述</th><th>备注</th><th>创建时间</th><th>操作</th></tr>
</thead>
<tbody>
<template x-for="d in list" :key="d.id">
<tr>
<td x-text="d.id"></td>
<td x-text="d.name"></td>
<td class="text-[#9a9aa5]" x-text="d.description"></td>
<td class="remark" x-text="d.remark"></td>
<td class="text-[#9a9aa5]" x-text="fmtDateTime(d.createdAt)"></td>
<td>
<button class="btn btn-ghost !py-1 !px-2 text-xs" @click="openEdit(d)">编辑</button>
<button class="btn btn-danger !py-1 !px-2 text-xs" @click="remove(d.id)">删除</button>
</td>
</tr>
</template>
<tr x-show="list.length === 0"><td colspan="6" class="text-center text-[#6b6b78] py-8">暂无数据</td></tr>
</tbody>
</table>
</div>
<div class="flex justify-center gap-2 mt-4">
<button class="btn btn-ghost !py-1 text-xs" :disabled="page===0" @click="page--;load()">上一页</button>
<span class="text-sm text-[#9a9aa5] self-center" x-text="`${page+1} / ${totalPages}`"></span>
<button class="btn btn-ghost !py-1 text-xs" :disabled="page>=totalPages-1" @click="page++;load()">下一页</button>
</div>
<!-- 模态框 -->
<div x-show="modal" x-cloak class="modal-mask" @click.self="modal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-4" x-text="editing ? '编辑设备' : '新增设备'"></h3>
<div class="space-y-3">
<div><label class="label">名称</label><input x-model="form.name" class="input"></div>
<div><label class="label">描述</label><input x-model="form.description" class="input"></div>
<div><label class="label">备注</label><input x-model="form.remark" class="input"></div>
</div>
<div class="flex justify-end gap-2 mt-5">
<button class="btn btn-ghost" @click="modal=false">取消</button>
<button class="btn btn-primary" @click="save()">保存</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function devicesApp() {
return {
list: [], page: 0, totalPages: 1, modal: false, editing: null,
form: { name: '', description: '', remark: '' },
async init() {
await initLayout('devices');
this.load();
},
async load() {
const data = await api(`/api/admin/devices?page=${this.page}&size=10`).catch(() => ({ content: [], totalPages: 1 }));
this.list = data.content || [];
this.totalPages = data.totalPages || 1;
},
openCreate() { this.editing = null; this.form = { name: '', description: '', remark: '' }; this.modal = true; },
openEdit(d) { this.editing = d; this.form = { name: d.name, description: d.description || '', remark: d.remark || '' }; this.modal = true; },
async save() {
if (!this.form.name) { toast('请输入名称', 'error'); return; }
const method = this.editing ? 'PUT' : 'POST';
const url = this.editing ? `/api/admin/devices/${this.editing.id}` : '/api/admin/devices';
await api(url, { method, body: JSON.stringify(this.form) });
toast(this.editing ? '已更新' : '已创建', 'success');
this.modal = false; this.load();
},
async remove(id) {
if (!confirm('确认删除该设备?')) return;
await api(`/api/admin/devices/${id}`, { method: 'DELETE' });
toast('已删除', 'success'); this.load();
}
};
}
</script>
</body>
</html>
+113
View File
@@ -0,0 +1,113 @@
<!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="gamesApp()" x-init="init()">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold">游戏管理</h2>
<button class="btn btn-primary" @click="openCreate()">+ 新增游戏</button>
</div>
<div class="card overflow-x-auto">
<table class="table">
<thead>
<tr><th>ID</th><th>名称</th><th>通用</th><th>设备</th><th>会员单价</th><th>备注</th><th>操作</th></tr>
</thead>
<tbody>
<template x-for="g in list" :key="g.id">
<tr>
<td x-text="g.id"></td>
<td x-text="g.name"></td>
<td><span class="badge" :class="g.isUniversal ? 'badge-accent' : 'badge-success'" x-text="g.isUniversal ? '通用' : '绑定'"></span></td>
<td x-text="g.device ? g.device.name : '-'"></td>
<td x-text="'¥'+fmtMoney(g.memberPrice)"></td>
<td class="remark" x-text="g.remark"></td>
<td>
<button class="btn btn-ghost !py-1 !px-2 text-xs" @click="openEdit(g)">编辑</button>
<button class="btn btn-danger !py-1 !px-2 text-xs" @click="remove(g.id)">删除</button>
</td>
</tr>
</template>
<tr x-show="list.length === 0"><td colspan="7" class="text-center text-[#6b6b78] py-8">暂无数据</td></tr>
</tbody>
</table>
</div>
<div class="flex justify-center gap-2 mt-4">
<button class="btn btn-ghost !py-1 text-xs" :disabled="page===0" @click="page--;load()">上一页</button>
<span class="text-sm text-[#9a9aa5] self-center" x-text="`${page+1} / ${totalPages}`"></span>
<button class="btn btn-ghost !py-1 text-xs" :disabled="page>=totalPages-1" @click="page++;load()">下一页</button>
</div>
<div x-show="modal" x-cloak class="modal-mask" @click.self="modal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-4" x-text="editing ? '编辑游戏' : '新增游戏'"></h3>
<div class="space-y-3">
<div><label class="label">名称</label><input x-model="form.name" class="input"></div>
<div><label class="label">描述</label><input x-model="form.description" class="input"></div>
<div><label class="label">备注(小字灰色显示)</label><input x-model="form.remark" class="input"></div>
<div class="flex items-center gap-2">
<input type="checkbox" x-model="form.isUniversal" id="univ">
<label for="univ" class="text-sm">通用游戏(不绑定设备)</label>
</div>
<div x-show="!form.isUniversal">
<label class="label">绑定设备</label>
<select x-model="form.deviceId" class="select">
<option value="">请选择</option>
<template x-for="d in devices" :key="d.id">
<option :value="d.id" x-text="d.name"></option>
</template>
</select>
</div>
<div><label class="label">会员单价(用于拼套餐)</label><input type="number" step="0.01" x-model="form.memberPrice" class="input"></div>
</div>
<div class="flex justify-end gap-2 mt-5">
<button class="btn btn-ghost" @click="modal=false">取消</button>
<button class="btn btn-primary" @click="save()">保存</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function gamesApp() {
return {
list: [], devices: [], page: 0, totalPages: 1, modal: false, editing: null,
form: { name: '', description: '', remark: '', isUniversal: false, deviceId: '', memberPrice: 0 },
async init() { await initLayout('games'); this.devices = await api('/api/devices').catch(() => []); this.load(); },
async load() {
const data = await api(`/api/admin/games?page=${this.page}&size=10`).catch(() => ({ content: [], totalPages: 1 }));
this.list = data.content || []; this.totalPages = data.totalPages || 1;
},
openCreate() { this.editing = null; this.form = { name: '', description: '', remark: '', isUniversal: false, deviceId: '', memberPrice: 0 }; this.modal = true; },
openEdit(g) {
this.editing = g;
this.form = { name: g.name, description: g.description || '', remark: g.remark || '', isUniversal: !!g.isUniversal, deviceId: g.device ? g.device.id : '', memberPrice: g.memberPrice || 0 };
this.modal = true;
},
async save() {
if (!this.form.name) { toast('请输入名称', 'error'); return; }
const payload = { ...this.form, memberPrice: Number(this.form.memberPrice) || 0 };
if (!payload.isUniversal) payload.deviceId = Number(payload.deviceId) || null;
const method = this.editing ? 'PUT' : 'POST';
const url = this.editing ? `/api/admin/games/${this.editing.id}` : '/api/admin/games';
await api(url, { method, body: JSON.stringify(payload) });
toast(this.editing ? '已更新' : '已创建', 'success');
this.modal = false; this.load();
},
async remove(id) {
if (!confirm('确认删除?')) return;
await api(`/api/admin/games/${id}`, { method: 'DELETE' });
toast('已删除', 'success'); this.load();
}
};
}
</script>
</body>
</html>
+63
View File
@@ -0,0 +1,63 @@
<!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="rechargeApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">充值审批</h2>
<div class="card overflow-x-auto">
<table class="table">
<thead><tr><th>ID</th><th>用户ID</th><th>金额</th><th>授权码</th><th>状态</th><th>时间</th><th>操作</th></tr></thead>
<tbody>
<template x-for="r in list" :key="r.id">
<tr>
<td x-text="r.id"></td>
<td x-text="r.user ? r.user.id : r.userId"></td>
<td class="text-[#00d4ff]" x-text="'¥'+fmtMoney(r.amount)"></td>
<td class="mono" x-text="r.authCode"></td>
<td><span class="badge" :class="r.status==='PENDING'?'badge-warning':r.status==='APPROVED'?'badge-success':'badge-danger'" x-text="r.status"></span></td>
<td class="text-[#9a9aa5]" x-text="fmtDateTime(r.createdAt)"></td>
<td x-show="r.status==='PENDING'">
<button class="btn btn-primary !py-1 !px-2 text-xs" @click="approve(r)">批准</button>
<button class="btn btn-danger !py-1 !px-2 text-xs" @click="reject(r.id)">拒绝</button>
</td>
</tr>
</template>
<tr x-show="list.length === 0"><td colspan="7" class="text-center text-[#6b6b78] py-8">暂无待审批</td></tr>
</tbody>
</table>
</div>
<div x-show="approveModal" x-cloak class="modal-mask" @click.self="approveModal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-4">批准充值</h3>
<p class="text-sm text-[#9a9aa5] mb-3">金额:<span class="text-[#00d4ff]" x-text="'¥'+fmtMoney(cur && cur.amount)"></span></p>
<div><label class="label">请输入授权码</label><input x-model="authCode" class="input mono" placeholder="6位授权码"></div>
<div class="flex justify-end gap-2 mt-5">
<button class="btn btn-ghost" @click="approveModal=false">取消</button>
<button class="btn btn-primary" @click="doApprove()">确认批准</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function rechargeApp() {
return {
list: [], approveModal: false, cur: null, authCode: '',
async init() { await initLayout('recharge'); this.load(); },
async load() { this.list = await api('/api/admin/recharge/pending').catch(() => []); },
approve(r) { this.cur = r; this.authCode = ''; this.approveModal = true; },
async doApprove() {
await api(`/api/admin/recharge/${this.cur.id}/approve`, { method: 'POST', body: JSON.stringify({ authCode: this.authCode }) });
toast('已批准,余额已到账', 'success'); this.approveModal = false; this.load();
},
async reject(id) { if (!confirm('确认拒绝?')) return; await api(`/api/admin/recharge/${id}/reject`, { method: 'POST' }); toast('已拒绝', 'success'); this.load(); }
};
}
</script>
</body>
</html>
+89
View File
@@ -0,0 +1,89 @@
<!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="snacksApp()" x-init="init()">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold">零食/饮料管理</h2>
<button class="btn btn-primary" @click="openCreate()">+ 新增</button>
</div>
<div class="card overflow-x-auto">
<table class="table">
<thead><tr><th>ID</th><th>名称</th><th>类型</th><th>价格</th><th>会员单价</th><th>备注</th><th>操作</th></tr></thead>
<tbody>
<template x-for="s in list" :key="s.id">
<tr>
<td x-text="s.id"></td>
<td x-text="s.name"></td>
<td><span class="badge" :class="s.type==='DRINK' ? 'badge-accent' : 'badge-success'" x-text="s.type==='DRINK' ? '饮料' : '零食'"></span></td>
<td x-text="'¥'+fmtMoney(s.price)"></td>
<td x-text="'¥'+fmtMoney(s.memberPrice)"></td>
<td class="remark" x-text="s.remark"></td>
<td>
<button class="btn btn-ghost !py-1 !px-2 text-xs" @click="openEdit(s)">编辑</button>
<button class="btn btn-danger !py-1 !px-2 text-xs" @click="remove(s.id)">删除</button>
</td>
</tr>
</template>
<tr x-show="list.length === 0"><td colspan="7" class="text-center text-[#6b6b78] py-8">暂无数据</td></tr>
</tbody>
</table>
</div>
<div class="flex justify-center gap-2 mt-4">
<button class="btn btn-ghost !py-1 text-xs" :disabled="page===0" @click="page--;load()">上一页</button>
<span class="text-sm text-[#9a9aa5] self-center" x-text="`${page+1} / ${totalPages}`"></span>
<button class="btn btn-ghost !py-1 text-xs" :disabled="page>=totalPages-1" @click="page++;load()">下一页</button>
</div>
<div x-show="modal" x-cloak class="modal-mask" @click.self="modal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-4" x-text="editing ? '编辑' : '新增'"></h3>
<div class="space-y-3">
<div><label class="label">名称</label><input x-model="form.name" class="input"></div>
<div><label class="label">类型</label>
<select x-model="form.type" class="select">
<option value="SNACK">零食</option><option value="DRINK">饮料</option>
</select>
</div>
<div><label class="label">价格</label><input type="number" step="0.01" x-model="form.price" class="input"></div>
<div><label class="label">会员单价</label><input type="number" step="0.01" x-model="form.memberPrice" class="input"></div>
<div><label class="label">备注</label><input x-model="form.remark" class="input"></div>
</div>
<div class="flex justify-end gap-2 mt-5">
<button class="btn btn-ghost" @click="modal=false">取消</button>
<button class="btn btn-primary" @click="save()">保存</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function snacksApp() {
return {
list: [], page: 0, totalPages: 1, modal: false, editing: null,
form: { name: '', type: 'SNACK', price: 0, memberPrice: 0, remark: '' },
async init() { await initLayout('snacks'); this.load(); },
async load() {
const data = await api(`/api/admin/snacks?page=${this.page}&size=10`).catch(() => ({ content: [], totalPages: 1 }));
this.list = data.content || []; this.totalPages = data.totalPages || 1;
},
openCreate() { this.editing = null; this.form = { name: '', type: 'SNACK', price: 0, memberPrice: 0, remark: '' }; this.modal = true; },
openEdit(s) { this.editing = s; this.form = { name: s.name, type: s.type, price: s.price, memberPrice: s.memberPrice || 0, remark: s.remark || '' }; this.modal = true; },
async save() {
const payload = { ...this.form, price: Number(this.form.price), memberPrice: Number(this.form.memberPrice) || 0 };
const method = this.editing ? 'PUT' : 'POST';
const url = this.editing ? `/api/admin/snacks/${this.editing.id}` : '/api/admin/snacks';
await api(url, { method, body: JSON.stringify(payload) });
toast(this.editing ? '已更新' : '已创建', 'success');
this.modal = false; this.load();
},
async remove(id) { if (!confirm('确认删除?')) return; await api(`/api/admin/snacks/${id}`, { method: 'DELETE' }); toast('已删除', 'success'); this.load(); }
};
}
</script>
</body>
</html>
@@ -0,0 +1,81 @@
<!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="slotsApp()" x-init="init()">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold">时长管理</h2>
<button class="btn btn-primary" @click="openCreate()">+ 新增时长</button>
</div>
<div class="card overflow-x-auto">
<table class="table">
<thead><tr><th>ID</th><th>时长(分钟)</th><th>基础单价</th><th>会员单价</th><th>操作</th></tr></thead>
<tbody>
<template x-for="s in list" :key="s.id">
<tr>
<td x-text="s.id"></td>
<td><span class="badge badge-accent" x-text="s.durationMinutes + ' 分钟'"></span></td>
<td x-text="'¥'+fmtMoney(s.basePrice)"></td>
<td x-text="'¥'+fmtMoney(s.memberPrice)"></td>
<td>
<button class="btn btn-ghost !py-1 !px-2 text-xs" @click="openEdit(s)">编辑</button>
<button class="btn btn-danger !py-1 !px-2 text-xs" @click="remove(s.id)">删除</button>
</td>
</tr>
</template>
<tr x-show="list.length === 0"><td colspan="5" class="text-center text-[#6b6b78] py-8">暂无数据</td></tr>
</tbody>
</table>
</div>
<div class="flex justify-center gap-2 mt-4">
<button class="btn btn-ghost !py-1 text-xs" :disabled="page===0" @click="page--;load()">上一页</button>
<span class="text-sm text-[#9a9aa5] self-center" x-text="`${page+1} / ${totalPages}`"></span>
<button class="btn btn-ghost !py-1 text-xs" :disabled="page>=totalPages-1" @click="page++;load()">下一页</button>
</div>
<div x-show="modal" x-cloak class="modal-mask" @click.self="modal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-4" x-text="editing ? '编辑时长' : '新增时长'"></h3>
<div class="space-y-3">
<div><label class="label">时长(分钟)</label><input type="number" x-model="form.durationMinutes" class="input"></div>
<div><label class="label">基础单价</label><input type="number" step="0.01" x-model="form.basePrice" class="input"></div>
<div><label class="label">会员单价(拼套餐用)</label><input type="number" step="0.01" x-model="form.memberPrice" class="input"></div>
</div>
<div class="flex justify-end gap-2 mt-5">
<button class="btn btn-ghost" @click="modal=false">取消</button>
<button class="btn btn-primary" @click="save()">保存</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function slotsApp() {
return {
list: [], page: 0, totalPages: 1, modal: false, editing: null,
form: { durationMinutes: 30, basePrice: 0, memberPrice: 0 },
async init() { await initLayout('timeslots'); this.load(); },
async load() {
const data = await api(`/api/admin/timeslots?page=${this.page}&size=10`).catch(() => ({ content: [], totalPages: 1 }));
this.list = data.content || []; this.totalPages = data.totalPages || 1;
},
openCreate() { this.editing = null; this.form = { durationMinutes: 30, basePrice: 0, memberPrice: 0 }; this.modal = true; },
openEdit(s) { this.editing = s; this.form = { durationMinutes: s.durationMinutes, basePrice: s.basePrice, memberPrice: s.memberPrice || 0 }; this.modal = true; },
async save() {
const payload = { durationMinutes: Number(this.form.durationMinutes), basePrice: Number(this.form.basePrice), memberPrice: Number(this.form.memberPrice) || 0 };
const method = this.editing ? 'PUT' : 'POST';
const url = this.editing ? `/api/admin/timeslots/${this.editing.id}` : '/api/admin/timeslots';
await api(url, { method, body: JSON.stringify(payload) });
toast(this.editing ? '已更新' : '已创建', 'success');
this.modal = false; this.load();
},
async remove(id) { if (!confirm('确认删除?')) return; await api(`/api/admin/timeslots/${id}`, { method: 'DELETE' }); toast('已删除', 'success'); this.load(); }
};
}
</script>
</body>
</html>
+83
View File
@@ -0,0 +1,83 @@
<!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="usersApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">用户管理</h2>
<div class="card overflow-x-auto">
<table class="table">
<thead><tr><th>ID</th><th>用户名</th><th>角色</th><th>余额</th><th>积分</th><th>会员到期</th><th>操作</th></tr></thead>
<tbody>
<template x-for="u in list" :key="u.id">
<tr>
<td x-text="u.id"></td>
<td x-text="u.username"></td>
<td><span class="badge" :class="u.role==='ADMIN'?'badge-accent':u.role==='MEMBER'?'badge-success':'badge-warning'" x-text="u.role"></span></td>
<td x-text="'¥'+fmtMoney(u.balance)"></td>
<td x-text="u.points"></td>
<td class="text-[#9a9aa5]" x-text="fmtDate(u.memberExpireDate)"></td>
<td><button class="btn btn-ghost !py-1 !px-2 text-xs" @click="openEdit(u)">编辑</button>
<button class="btn btn-danger !py-1 !px-2 text-xs" @click="remove(u.id)">删除</button></td>
</tr>
</template>
<tr x-show="list.length===0"><td colspan="7" class="text-center text-[#6b6b78] py-8">暂无数据</td></tr>
</tbody>
</table>
</div>
<div class="flex justify-center gap-2 mt-4">
<button class="btn btn-ghost !py-1 text-xs" :disabled="page===0" @click="page--;load()">上一页</button>
<span class="text-sm text-[#9a9aa5] self-center" x-text="`${page+1} / ${totalPages}`"></span>
<button class="btn btn-ghost !py-1 text-xs" :disabled="page>=totalPages-1" @click="page++;load()">下一页</button>
</div>
<div x-show="modal" x-cloak class="modal-mask" @click.self="modal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-4">编辑用户</h3>
<div class="space-y-3">
<div><label class="label">用户名</label><input x-model="form.username" class="input"></div>
<div><label class="label">密码(留空不修改)</label><input x-model="form.password" class="input"></div>
<div><label class="label">角色</label>
<select x-model="form.role" class="select"><option value="PLAYER">PLAYER</option><option value="MEMBER">MEMBER</option><option value="ADMIN">ADMIN</option></select>
</div>
<div><label class="label">余额</label><input type="number" step="0.01" x-model="form.balance" class="input"></div>
<div><label class="label">积分(累计消费额)</label><input type="number" x-model="form.points" class="input"></div>
<div><label class="label">会员到期日</label><input type="date" x-model="form.memberExpireDate" class="input"></div>
</div>
<div class="flex justify-end gap-2 mt-5">
<button class="btn btn-ghost" @click="modal=false">取消</button>
<button class="btn btn-primary" @click="save()">保存</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function usersApp() {
return {
list: [], page: 0, totalPages: 1, modal: false, editing: null,
form: { username: '', password: '', role: 'PLAYER', balance: 0, points: 0, memberExpireDate: '' },
async init() { await initLayout('users'); this.load(); },
async load() {
const data = await api(`/api/admin/users?page=${this.page}&size=10`).catch(() => ({ content: [], totalPages: 1 }));
this.list = data.content || []; this.totalPages = data.totalPages || 1;
},
openEdit(u) {
this.editing = u;
this.form = { username: u.username, password: '', role: u.role, balance: u.balance, points: u.points, memberExpireDate: u.memberExpireDate ? String(u.memberExpireDate).slice(0,10) : '' };
this.modal = true;
},
async save() {
const payload = { ...this.form, balance: Number(this.form.balance), points: Number(this.form.points) };
await api(`/api/admin/users/${this.editing.id}`, { method: 'PUT', body: JSON.stringify(payload) });
toast('已更新', 'success'); this.modal = false; this.load();
},
async remove(id) { if (!confirm('确认删除该用户?')) return; await api(`/api/admin/users/${id}`, { method: 'DELETE' }); toast('已删除', 'success'); this.load(); }
};
}
</script>
</body>
</html>
+216
View File
@@ -0,0 +1,216 @@
/* GameParlor 全局样式 — 深色主题 + 霓虹蓝 */
/* 注:Tailwind 工具类由 tailwind.min.js (Play CDN) 运行时注入;本文件仅定义组件类与基础样式 */
:root {
--bg: #0f0f11;
--bg-soft: #16161a;
--bg-card: #1c1c22;
--border: #2a2a33;
--accent: #00d4ff;
--accent-dim: rgba(0, 212, 255, 0.15);
--text: #e8e8ed;
--text-dim: #9a9aa5;
--text-faint: #6b6b78;
--success: #34d399;
--danger: #f87171;
--warning: #fbbf24;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
padding: 0;
background: var(--bg);
color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a33; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a45; }
.card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 14px;
transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card-hover:hover {
transform: translateY(-3px);
box-shadow: 0 10px 30px rgba(0, 0, 0, .4), 0 0 0 1px rgba(0, 212, 255, .15);
border-color: rgba(0, 212, 255, .3);
}
.btn {
display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
padding: .55rem 1.1rem;
border-radius: 10px;
font-size: .875rem; font-weight: 500;
border: 1px solid transparent;
cursor: pointer;
transition: transform .1s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
user-select: none;
}
.btn:active { transform: scale(0.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #06242b; }
.btn-primary:hover:not(:disabled) { background: #33ddff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(248, 113, 113, .12); color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, .22); }
.input, .select, .textarea {
width: 100%;
background: var(--bg-soft);
border: 1px solid var(--border);
border-radius: 10px;
padding: .55rem .8rem;
color: var(--text);
font-size: .875rem;
transition: border-color .2s ease, box-shadow .2s ease;
}
.input:focus, .select:focus, .textarea:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.label { font-size: .8rem; color: var(--text-dim); margin-bottom: .35rem; display: block; }
.badge {
display: inline-flex; align-items: center;
padding: .15rem .55rem;
border-radius: 999px;
font-size: .72rem; font-weight: 600;
}
.badge-accent { background: var(--accent-dim); color: var(--accent); }
.badge-success { background: rgba(52, 211, 153, .12); color: var(--success); }
.badge-danger { background: rgba(248, 113, 113, .12); color: var(--danger); }
.badge-warning { background: rgba(251, 191, 36, .12); color: var(--warning); }
.remark { font-size: .75rem; color: var(--text-faint); }
.mono { font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace; }
/* 页面淡入(仅用 opacity:transform 会成为 position:fixed 后代的包含块,导致弹窗越界) */
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.page-fade { animation: fadeIn .35s ease both; }
/* Alpine 初始化前隐藏 x-cloak 元素(避免弹窗闪现) */
[x-cloak] { display: none !important; }
/* 顶部导航布局(纯 CSS,不依赖 Tailwind 运行时) */
.gp-header {
position: sticky; top: 0; z-index: 50;
background: rgba(15, 15, 17, .85);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border-bottom: 1px solid var(--border);
}
.gp-header-inner {
max-width: 80rem; margin: 0 auto; padding: 0 1rem;
min-height: 3.5rem;
display: flex; align-items: center; gap: 1.5rem;
}
.gp-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1rem; flex: none; }
.gp-logo {
width: 1.75rem; height: 1.75rem; border-radius: .5rem;
background: var(--accent); color: #06242b;
display: flex; align-items: center; justify-content: center; font-size: .875rem;
}
.gp-nav { display: flex; align-items: center; gap: .15rem; margin: 0; padding: 0; list-style: none; }
.gp-nav a {
display: inline-block; padding: .375rem .75rem; border-radius: .5rem;
font-size: .875rem; color: var(--text-dim);
white-space: nowrap; cursor: pointer;
transition: color .2s ease, background .2s ease;
}
.gp-nav a:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.gp-nav a.is-active { background: var(--accent-dim); color: var(--accent); }
.gp-nav-desktop { display: none; }
.gp-nav-mobile {
gap: .25rem; padding: .35rem .75rem .5rem;
max-width: 80rem; margin: 0 auto;
overflow-x: auto; flex-wrap: nowrap;
}
.gp-nav-mobile a { font-size: .75rem; padding: .3rem .6rem; flex: none; }
@media (min-width: 768px) {
.gp-nav-desktop { display: flex; }
.gp-nav-mobile { display: none; }
}
.gp-userbar { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .875rem; flex: none; }
.gp-user-meta { display: none; align-items: center; gap: .75rem; color: var(--text-dim); }
.gp-username { color: var(--accent); }
.gp-logout { padding: .25rem .6rem; font-size: .75rem; }
@media (min-width: 640px) {
.gp-user-meta { display: flex; }
}
/* 页面内容容器 */
.gp-page {
max-width: 80rem;
width: 100%;
margin: 0 auto;
padding: 1.5rem 1rem 2rem;
}
/* Toast */
@keyframes toastIn {
from { opacity: 0; transform: translateY(-10px) scale(.98); }
to { opacity: 1; transform: translateY(0) scale(1); }
}
.toast {
position: fixed; top: 1.2rem; left: 50%; transform: translateX(-50%);
z-index: 9999;
padding: .7rem 1.2rem;
border-radius: 10px;
font-size: .875rem;
box-shadow: 0 8px 30px rgba(0,0,0,.5);
animation: toastIn .25s ease both;
}
.toast-success { background: rgba(52, 211, 153, .15); color: var(--success); border: 1px solid rgba(52, 211, 153, .35); }
.toast-error { background: rgba(248, 113, 113, .15); color: var(--danger); border: 1px solid rgba(248, 113, 113, .35); }
/* 倒计时颜色渐变 */
.countdown { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
/* 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .85rem; }
.table th { color: var(--text-dim); font-weight: 500; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.table tr:hover td { background: rgba(255,255,255,.02); }
/* 模态遮罩(fixed 相对视口:祖先不得残留非 none 的 transform) */
.modal-mask {
position: fixed; inset: 0; background: rgba(0,0,0,.6);
backdrop-filter: blur(4px);
z-index: 1000;
display: flex; align-items: center; justify-content: center;
padding: 1rem;
overflow-y: auto;
animation: fadeIn .2s ease both;
}
.modal {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 16px;
padding: 1.4rem;
width: 100%; max-width: 480px;
max-height: calc(100vh - 2rem); overflow-y: auto;
margin: auto;
}
/* 移动端适配 */
@media (max-width: 640px) {
.btn { padding: .5rem .85rem; font-size: .8rem; }
}
+171
View File
@@ -0,0 +1,171 @@
// GameParlor 前端公共脚本
(function () {
const API_BASE = '';
// ---------- 存储 ----------
const TOKEN_KEY = 'gp_token';
const USER_KEY = 'gp_user';
window.GP = {
getToken() { return localStorage.getItem(TOKEN_KEY); },
setToken(t) { localStorage.setItem(TOKEN_KEY, t); },
clearAuth() { localStorage.removeItem(TOKEN_KEY); localStorage.removeItem(USER_KEY); },
getUser() {
try { return JSON.parse(localStorage.getItem(USER_KEY) || 'null'); }
catch { return null; }
},
setUser(u) { localStorage.setItem(USER_KEY, JSON.stringify(u)); },
isAdmin() { const u = this.getUser(); return u && u.role === 'ADMIN'; },
isMember() { const u = this.getUser(); return u && (u.role === 'MEMBER' || u.role === 'ADMIN'); },
redirectLogin() { window.location.href = '/index.html'; },
};
// ---------- API ----------
async function api(path, options = {}) {
const headers = Object.assign({ 'Content-Type': 'application/json' }, options.headers || {});
const token = GP.getToken();
if (token) headers['Authorization'] = 'Bearer ' + token;
const res = await fetch(API_BASE + path, Object.assign({ headers }, options));
let body;
try { body = await res.json(); } catch { body = { code: 500, message: '网络错误' }; }
if (body.code === 401) {
GP.clearAuth();
GP.redirectLogin();
throw new Error(body.message || '未登录');
}
if (body.code !== 200) {
toast(body.message || '操作失败', 'error');
throw new Error(body.message);
}
return body.data;
}
window.api = api;
// ---------- Toast ----------
let toastTimer = null;
function toast(message, type = 'success') {
const existing = document.querySelector('.toast');
if (existing) existing.remove();
const el = document.createElement('div');
el.className = 'toast toast-' + type;
el.textContent = message;
document.body.appendChild(el);
clearTimeout(toastTimer);
toastTimer = setTimeout(() => el.remove(), 2200);
}
window.toast = toast;
// ---------- 登出 ----------
window.logout = async function () {
try { await api('/api/auth/logout', { method: 'POST' }); } catch {}
GP.clearAuth();
GP.redirectLogin();
};
// ---------- 工具 ----------
window.fmtMoney = function (n) {
if (n == null) return '0.00';
return Number(n).toFixed(2);
};
window.fmtDateTime = function (s) {
if (!s) return '-';
return s.replace('T', ' ').slice(0, 16);
};
window.fmtDate = function (s) {
if (!s) return '-';
return String(s).slice(0, 10);
};
window.fmtDuration = function (seconds) {
if (seconds == null) return '00:00';
const m = Math.floor(seconds / 60);
const s = seconds % 60;
return String(m).padStart(2, '0') + ':' + String(s).padStart(2, '0');
};
// ---------- 布局骨架 ----------
// 本脚本在 body 末尾以经典脚本方式加载,执行时 Alpine(defer) 尚未启动。
// 在此同步完成 header/main 的 DOM 搭建,可避免 Alpine 启动后再移动节点
// 触发 MutationObserver 而导致 x-init / initLayout 二次执行(顶部菜单重复的根因)。
if (!document.body.classList.contains('gp-auth')) {
const header = document.createElement('header');
header.className = 'gp-header';
header.innerHTML =
'<div class="gp-header-inner">' +
'<div class="gp-brand"><span class="gp-logo">G</span><span>GameParlor</span></div>' +
'<nav class="gp-nav gp-nav-desktop" data-gp-nav="desktop"></nav>' +
'<div class="gp-userbar" data-gp-userbar></div>' +
'</div>' +
'<nav class="gp-nav gp-nav-mobile" data-gp-nav="mobile"></nav>';
const main = document.createElement('main');
main.className = 'gp-page page-fade';
Array.from(document.body.children).forEach(c => main.appendChild(c));
document.body.appendChild(header);
document.body.appendChild(main);
}
// ---------- 顶部导航数据填充(Alpine 启动后调用,仅填充,不再移动 DOM) ----------
window.initLayout = async function (active) {
if (window.__gpLayoutMe) return window.__gpLayoutMe; // 幂等,防止重复注入
const me = await api('/api/user/me').catch(() => null);
if (!me) { GP.clearAuth(); GP.redirectLogin(); throw new Error('未登录'); }
GP.setUser(me);
window.__gpLayoutMe = me;
const isAdmin = me.role === 'ADMIN';
const isMember = me.role === 'MEMBER' || isAdmin;
const navItems = isAdmin ? [
{ key: 'dashboard', label: '概览', href: '/admin/dashboard.html' },
{ key: 'devices', label: '设备', href: '/admin/devices.html' },
{ key: 'games', label: '游戏', href: '/admin/games.html' },
{ key: 'timeslots', label: '时长', href: '/admin/timeslots.html' },
{ key: 'snacks', label: '零食', href: '/admin/snacks.html' },
{ key: 'combos', label: '套餐', href: '/admin/combos.html' },
{ key: 'users', label: '用户', href: '/admin/users.html' },
{ key: 'recharge', label: '充值审批', href: '/admin/recharge.html' },
] : [
{ key: 'dashboard', label: '首页', href: '/player/dashboard.html' },
{ key: 'browse', label: '玩游戏', href: '/player/browse.html' },
{ key: 'combos', label: '套餐', href: '/player/combos.html' },
...(isMember ? [{ key: 'custom', label: '拼套餐', href: '/player/custom-combo.html' }] : []),
{ key: 'snacks', label: '零食', href: '/player/snacks.html' },
{ key: 'recharge', label: '充值', href: '/player/recharge.html' },
...(isMember ? [{ key: 'points', label: '积分兑换', href: '/player/points.html' }] : []),
{ key: 'history', label: '记录', href: '/player/history.html' },
];
const navHtml = navItems.map(n =>
`<a href="${n.href}"${active === n.key ? ' class="is-active"' : ''}>${n.label}</a>`).join('');
document.querySelectorAll('[data-gp-nav]').forEach(el => { el.innerHTML = navHtml; });
const userbar = document.querySelector('[data-gp-userbar]');
if (userbar) {
userbar.innerHTML =
'<span class="gp-user-meta">' +
'<span>余额 ¥' + fmtMoney(me.balance) + '</span>' +
(isMember ? '<span class="badge badge-accent">会员</span>' : '') +
'<span title="累计消费额(积分)">★ ' + (me.points || 0) + '</span>' +
'</span>' +
'<span class="gp-username"></span>' +
'<button type="button" onclick="logout()" class="btn btn-ghost gp-logout">退出</button>';
userbar.querySelector('.gp-username').textContent = me.username;
}
return me;
};
// ---------- 内联 SVG 图标 ----------
const iconHome = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>';
const iconDevice = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="inline"><rect x="2" y="6" width="20" height="12" rx="2"/><path d="M6 12h.01M10 12h.01"/></svg>';
const iconGame = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><line x1="6" y1="11" x2="10" y2="11"/><line x1="8" y1="9" x2="8" y2="13"/><line x1="15" y1="12" x2="15.01" y2="12"/><line x1="18" y1="10" x2="18.01" y2="10"/><rect x="2" y="6" width="20" height="12" rx="6"/></svg>';
const iconClock = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>';
const iconSnack = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><path d="M5 3h14l-2 18H7z"/><line x1="9" y1="8" x2="9" y2="13"/><line x1="15" y1="8" x2="15" y2="13"/></svg>';
const iconCombo = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>';
const iconUser = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>';
const iconWallet = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><path d="M21 12V7H5a2 2 0 0 1 0-4h14v4"/><path d="M3 5v14a2 2 0 0 0 2 2h16v-5"/><path d="M18 12a2 2 0 0 0 0 4h4v-4z"/></svg>';
const iconStar = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>';
const iconList = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>';
})();
+79
View File
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-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 class="gp-auth min-h-screen flex items-center justify-center p-4"
style="background: radial-gradient(1200px 600px at 50% -10%, rgba(0,212,255,.12), transparent 60%), #0f0f11;">
<div x-data="authApp()" class="w-full max-w-md">
<div class="card p-8 page-fade">
<div class="flex items-center gap-3 mb-8">
<div class="w-11 h-11 rounded-xl bg-[#00d4ff] text-[#06242b] flex items-center justify-center text-xl font-bold">G</div>
<div>
<h1 class="text-xl font-bold">GameParlor</h1>
<p class="text-xs text-[#6b6b78]">电玩店自助管理与消费系统</p>
</div>
</div>
<div class="flex gap-1 p-1 rounded-xl bg-[#16161a] mb-6">
<button @click="mode='login'" :class="mode==='login' ? 'bg-[#00d4ff] text-[#06242b]' : 'text-[#9a9aa5]'"
class="flex-1 py-2 rounded-lg text-sm font-medium transition-colors">登录</button>
<button @click="mode='register'" :class="mode==='register' ? 'bg-[#00d4ff] text-[#06242b]' : 'text-[#9a9aa5]'"
class="flex-1 py-2 rounded-lg text-sm font-medium transition-colors">注册</button>
</div>
<form @submit.prevent="submit" class="space-y-4">
<div>
<label class="label">用户名</label>
<input x-model="form.username" class="input" placeholder="请输入用户名" autocomplete="username" required>
</div>
<div>
<label class="label">密码</label>
<input x-model="form.password" type="password" class="input" placeholder="请输入密码"
autocomplete="current-password" required>
</div>
<button type="submit" class="btn btn-primary w-full" :disabled="loading">
<span x-show="!loading" x-text="mode==='login' ? '登 录' : '注 册'"></span>
<span x-show="loading">处理中...</span>
</button>
</form>
<p class="remark mt-6 text-center">默认管理员:admin / admin123</p>
</div>
</div>
<script src="/app.js"></script>
<script>
function authApp() {
return {
mode: 'login',
loading: false,
form: { username: '', password: '' },
async submit() {
this.loading = true;
try {
const path = this.mode === 'login' ? '/api/auth/login' : '/api/auth/register';
const data = await api(path, { method: 'POST', body: JSON.stringify(this.form) });
GP.setToken(data.token);
GP.setUser({ userId: data.userId, username: data.username, role: data.role });
toast(this.mode === 'login' ? '登录成功' : '注册成功', 'success');
const isAdmin = data.role === 'ADMIN';
setTimeout(() => {
window.location.href = isAdmin ? '/admin/dashboard.html' : '/player/dashboard.html';
}, 400);
} catch (e) {
// toast already shown
} finally {
this.loading = false;
}
}
};
}
</script>
</body>
</html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+96
View File
@@ -0,0 +1,96 @@
<!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="browseApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">玩游戏</h2>
<div class="flex gap-2 mb-5">
<button class="btn" :class="mode==='device' ? 'btn-primary' : 'btn-ghost'" @click="mode='device';loadGames()">按设备浏览</button>
<button class="btn" :class="mode==='game' ? 'btn-primary' : 'btn-ghost'" @click="mode='game';loadGames()">按游戏浏览</button>
<button class="btn" :class="mode==='universal' ? 'btn-primary' : 'btn-ghost'" @click="mode='universal';loadGames()">通用游戏</button>
</div>
<!-- 按设备 -->
<div x-show="mode==='device'" class="mb-4">
<select x-model="selectedDevice" @change="loadGames()" class="select max-w-xs">
<option value="">选择设备</option>
<template x-for="d in devices" :key="d.id"><option :value="d.id" x-text="d.name"></option></template>
</select>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
<template x-for="g in games" :key="g.id">
<div class="card card-hover p-4 cursor-pointer" @click="pickGame(g)">
<div class="font-bold" x-text="g.name"></div>
<div class="text-xs text-[#9a9aa5] mt-1" x-text="g.description"></div>
<div class="remark mt-2" x-text="g.remark"></div>
</div>
</template>
<div x-show="games.length===0" class="text-center text-[#6b6b78] py-12 col-span-full">暂无游戏</div>
</div>
<!-- 选时长弹窗 -->
<div x-show="pickModal" x-cloak class="modal-mask" @click.self="pickModal=false">
<div class="modal">
<h3 class="text-lg font-bold mb-1" x-text="curGame && curGame.name"></h3>
<div class="remark mb-4" x-text="curGame && curGame.remark"></div>
<div class="space-y-2 mb-4">
<template x-for="s in slots" :key="s.id">
<div class="flex items-center justify-between p-3 rounded-lg bg-[#16161a] cursor-pointer hover:bg-[#1c1c22]"
@click="curSlot = s" :class="curSlot && curSlot.id===s.id ? 'ring-1 ring-[#00d4ff]' : ''">
<div>
<div class="font-medium" x-text="s.durationMinutes + ' 分钟'"></div>
<div class="text-xs text-[#9a9aa5]">基础价 ¥<span x-text="fmtMoney(s.basePrice)"></span></div>
</div>
<div class="text-[#00d4ff] font-bold" x-text="'¥'+fmtMoney(s.basePrice)"></div>
</div>
</template>
</div>
<div class="flex justify-between items-center">
<div class="text-sm text-[#9a9aa5]">余额 ¥<span x-text="fmtMoney(me.balance)"></span></div>
<div class="flex gap-2">
<button class="btn btn-ghost" @click="pickModal=false">取消</button>
<button class="btn btn-primary" :disabled="!curSlot" @click="startGame()">开始游玩</button>
</div>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function browseApp() {
return {
me: {}, mode: 'device', devices: [], games: [], slots: [], selectedDevice: '',
pickModal: false, curGame: null, curSlot: null,
async init() {
await initLayout('browse');
this.me = await api('/api/user/me').catch(() => ({}));
this.devices = await api('/api/devices').catch(() => []);
this.slots = await api('/api/timeslots').catch(() => []);
this.loadGames();
},
async loadGames() {
let url = '/api/games';
if (this.mode === 'device' && this.selectedDevice) url = '/api/games?deviceId=' + this.selectedDevice;
else if (this.mode === 'universal') url = '/api/games?universal=true';
this.games = await api(url).catch(() => []);
},
pickGame(g) { this.curGame = g; this.curSlot = null; this.pickModal = true; },
async startGame() {
await api('/api/orders', { method: 'POST', body: JSON.stringify({ gameId: this.curGame.id, timeSlotId: this.curSlot.id }) });
toast('开始游玩,祝玩得开心!', 'success');
this.pickModal = false;
setTimeout(() => window.location.href = '/player/dashboard.html', 500);
}
};
}
</script>
</body>
</html>
+63
View File
@@ -0,0 +1,63 @@
<!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>
@@ -0,0 +1,105 @@
<!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="customApp()" x-init="init()">
<h2 class="text-xl font-bold mb-2">自定义拼套餐</h2>
<p class="text-sm text-[#9a9aa5] mb-6">仅会员可用。自由勾选项目,享会员专属折扣。</p>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="lg:col-span-2 space-y-6">
<!-- 游戏 -->
<div class="card p-4">
<h3 class="font-semibold mb-3">游戏</h3>
<div class="grid grid-cols-2 gap-2">
<template x-for="g in games" :key="'g'+g.id">
<label class="flex items-center gap-2 p-2 rounded-lg bg-[#16161a] cursor-pointer">
<input type="checkbox" :value="g.id" @change="toggle('GAME', g.id, g.memberPrice, $event.target.checked)">
<span class="text-sm" x-text="g.name"></span>
<span class="text-xs text-[#9a9aa5] ml-auto">¥<span x-text="fmtMoney(g.memberPrice)"></span></span>
</label>
</template>
</div>
</div>
<!-- 时长 -->
<div class="card p-4">
<h3 class="font-semibold mb-3">时长</h3>
<div class="grid grid-cols-2 gap-2">
<template x-for="s in slots" :key="'s'+s.id">
<label class="flex items-center gap-2 p-2 rounded-lg bg-[#16161a] cursor-pointer">
<input type="checkbox" :value="s.id" @change="toggle('TIMESLOT', s.id, s.memberPrice, $event.target.checked)">
<span class="text-sm" x-text="s.durationMinutes + ' 分钟'"></span>
<span class="text-xs text-[#9a9aa5] ml-auto">¥<span x-text="fmtMoney(s.memberPrice)"></span></span>
</label>
</template>
</div>
</div>
<!-- 零食 -->
<div class="card p-4">
<h3 class="font-semibold mb-3">零食饮料</h3>
<div class="grid grid-cols-2 gap-2">
<template x-for="sn in snacks" :key="'sn'+sn.id">
<label class="flex items-center gap-2 p-2 rounded-lg bg-[#16161a] cursor-pointer">
<input type="checkbox" :value="sn.id" @change="toggle('SNACK', sn.id, sn.memberPrice, $event.target.checked)">
<span class="text-sm" x-text="sn.name"></span>
<span class="text-xs text-[#9a9aa5] ml-auto">¥<span x-text="fmtMoney(sn.memberPrice)"></span></span>
</label>
</template>
</div>
</div>
</div>
<!-- 结算栏 -->
<div class="lg:col-span-1">
<div class="card p-5 sticky top-20">
<h3 class="font-semibold mb-3">结算</h3>
<div class="text-sm text-[#9a9aa5] mb-2">已选 <span x-text="selected.length"></span> 项</div>
<div class="text-sm text-[#9a9aa5] mb-1">会员折扣率:<span x-text="discountRate"></span></div>
<div class="text-3xl font-bold text-[#00d4ff] my-3" x-text="'¥'+fmtMoney(total)"></div>
<button class="btn btn-primary w-full" :disabled="selected.length===0" @click="purchase()">确认下单</button>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function customApp() {
return {
games: [], slots: [], snacks: [], selected: [], total: 0, discountRate: '0.85',
async init() {
await initLayout('custom');
this.games = await api('/api/games').catch(() => []);
this.slots = await api('/api/timeslots').catch(() => []);
this.snacks = await api('/api/snacks').catch(() => []);
const cfg = await api('/api/config').catch(() => ({}));
this.discountRate = cfg.member_discount_rate || '0.85';
},
toggle(type, id, price, checked) {
const key = type + '-' + id;
if (checked) this.selected.push({ itemType: type, itemId: id, quantity: 1, unitPrice: Number(price) || 0 });
else this.selected = this.selected.filter(i => !(i.itemType === type && i.itemId === id));
this.calc();
},
async calc() {
if (this.selected.length === 0) { this.total = 0; return; }
const items = this.selected.map(i => ({ itemType: i.itemType, itemId: i.itemId, quantity: i.quantity }));
this.total = await api('/api/member/custom-combo/price', { method: 'POST', body: JSON.stringify({ items }) }).catch(() => 0);
},
async purchase() {
const items = this.selected.map(i => ({ itemType: i.itemType, itemId: i.itemId, quantity: i.quantity }));
await api('/api/member/custom-combo/purchase', { method: 'POST', body: JSON.stringify({ items }) });
toast('下单成功', 'success');
this.selected = []; this.total = 0;
document.querySelectorAll('input[type=checkbox]').forEach(c => c.checked = false);
}
};
}
</script>
</body>
</html>
+101
View File
@@ -0,0 +1,101 @@
<!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="dashApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">欢迎回来</h2>
<!-- 进行中倒计时 -->
<div class="card p-6 mb-6" x-show="active">
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<div>
<div class="text-sm text-[#9a9aa5]">正在游玩</div>
<div class="text-2xl font-bold mt-1" x-text="(active && active.gameName) || '游戏中'"></div>
</div>
<div class="text-right">
<div class="text-xs text-[#9a9aa5] mb-1">剩余时间</div>
<div class="countdown mono text-5xl font-bold tabular-nums"
:style="remaining < 300 ? 'color:#f87171' : 'color:#34d399'"
x-text="fmtDuration(remaining)"></div>
</div>
</div>
<div class="mt-4 flex gap-2">
<button class="btn btn-primary" :disabled="!active" @click="renew(30)">续费 30 分钟</button>
<button class="btn btn-ghost" :disabled="!active" @click="renew(60)">续费 60 分钟</button>
</div>
</div>
<!-- 信息卡片 -->
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
<div class="card p-4">
<div class="text-xs text-[#9a9aa5]">钱包余额</div>
<div class="text-2xl font-bold mt-1 text-[#00d4ff]" x-text="'¥'+fmtMoney(me.balance)"></div>
</div>
<div class="card p-4">
<div class="text-xs text-[#9a9aa5]">积分(累计消费)</div>
<div class="text-2xl font-bold mt-1 text-[#fbbf24]" x-text="me.points || 0"></div>
</div>
<div class="card p-4">
<div class="text-xs text-[#9a9aa5]">会员到期</div>
<div class="text-lg font-bold mt-1" x-text="fmtDate(me.memberExpireDate)"></div>
</div>
<div class="card p-4">
<div class="text-xs text-[#9a9aa5]">角色</div>
<div class="text-lg font-bold mt-1" x-text="me.role"></div>
</div>
</div>
<!-- 最近订单 -->
<div class="card p-5">
<h3 class="font-semibold mb-3">最近订单</h3>
<div class="space-y-2">
<template x-for="o in recent" :key="o.id">
<div class="flex items-center justify-between py-2 border-b border-[#2a2a33] last:border-0">
<div>
<div class="text-sm" x-text="'订单 #' + o.id"></div>
<div class="text-xs text-[#6b6b78]" x-text="fmtDateTime(o.createdAt)"></div>
</div>
<div class="flex items-center gap-3">
<span class="badge" :class="o.status==='PAID'?'badge-success':'badge-danger'" x-text="o.status"></span>
<span class="text-[#00d4ff]" x-text="'¥'+fmtMoney(o.totalAmount)"></span>
</div>
</div>
</template>
<div x-show="recent.length===0" class="text-center text-[#6b6b78] py-4 text-sm">暂无订单</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function dashApp() {
return {
me: {}, active: null, remaining: 0, recent: [], timer: null,
async init() {
await initLayout('dashboard');
this.me = await api('/api/user/me').catch(() => ({}));
const orders = await api('/api/history/orders?page=0&size=5').catch(() => ({ content: [] }));
this.recent = orders.content || [];
await this.poll();
setInterval(() => { if (this.remaining > 0) this.remaining--; }, 1000);
this.timer = setInterval(() => this.poll(), 10000);
},
async poll() {
this.active = await api('/api/orders/active').catch(() => null);
if (this.active) this.remaining = this.active.remainingSeconds;
else this.remaining = 0;
},
async renew(min) {
await api('/api/orders/renew', { method: 'POST', body: JSON.stringify({ orderId: this.active.orderId, additionalMinutes: min }) });
toast('续费成功', 'success'); this.poll();
}
};
}
</script>
</body>
</html>
+92
View File
@@ -0,0 +1,92 @@
<!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="historyApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">历史记录</h2>
<div class="flex gap-2 mb-4">
<button class="btn" :class="tab==='orders'?'btn-primary':'btn-ghost'" @click="tab='orders';load()">订单</button>
<button class="btn" :class="tab==='tx'?'btn-primary':'btn-ghost'" @click="tab='tx';load()">消费明细</button>
<button class="btn" :class="tab==='recharge'?'btn-primary':'btn-ghost'" @click="tab='recharge';load()">充值记录</button>
</div>
<div class="card overflow-x-auto" x-show="tab==='orders'">
<table class="table">
<thead><tr><th>订单号</th><th>金额</th><th>状态</th><th>时间</th></tr></thead>
<tbody>
<template x-for="o in orders" :key="o.id">
<tr>
<td x-text="'#'+o.id"></td>
<td class="text-[#00d4ff]" x-text="'¥'+fmtMoney(o.totalAmount)"></td>
<td><span class="badge" :class="o.status==='PAID'?'badge-success':'badge-danger'" x-text="o.status"></span></td>
<td class="text-[#9a9aa5]" x-text="fmtDateTime(o.createdAt)"></td>
</tr>
</template>
<tr x-show="orders.length===0"><td colspan="4" class="text-center text-[#6b6b78] py-8">暂无订单</td></tr>
</tbody>
</table>
</div>
<div class="card overflow-x-auto" x-show="tab==='tx'">
<table class="table">
<thead><tr><th>类型</th><th>金额</th><th>备注</th><th>时间</th></tr></thead>
<tbody>
<template x-for="t in txs" :key="t.id">
<tr>
<td><span class="badge" :class="t.type==='RECHARGE'?'badge-success':t.type==='CONSUME'?'badge-danger':'badge-warning'" x-text="t.type"></span></td>
<td :class="t.amount > 0 ? 'text-[#34d399]' : 'text-[#f87171]'" x-text="(t.amount>0?'+':'') + fmtMoney(t.amount)"></td>
<td class="text-[#9a9aa5]" x-text="t.remark"></td>
<td class="text-[#9a9aa5]" x-text="fmtDateTime(t.createdAt)"></td>
</tr>
</template>
<tr x-show="txs.length===0"><td colspan="4" class="text-center text-[#6b6b78] py-8">暂无记录</td></tr>
</tbody>
</table>
</div>
<div class="card overflow-x-auto" x-show="tab==='recharge'">
<table class="table">
<thead><tr><th>金额</th><th>授权码</th><th>状态</th><th>时间</th></tr></thead>
<tbody>
<template x-for="r in recharges" :key="r.id">
<tr>
<td class="text-[#00d4ff]" x-text="'¥'+fmtMoney(r.amount)"></td>
<td class="mono" x-text="r.authCode"></td>
<td><span class="badge" :class="r.status==='APPROVED'?'badge-success':r.status==='REJECTED'?'badge-danger':'badge-warning'" x-text="r.status"></span></td>
<td class="text-[#9a9aa5]" x-text="fmtDateTime(r.createdAt)"></td>
</tr>
</template>
<tr x-show="recharges.length===0"><td colspan="4" class="text-center text-[#6b6b78] py-8">暂无记录</td></tr>
</tbody>
</table>
</div>
<script src="/app.js"></script>
<script>
function historyApp() {
return {
tab: 'orders', orders: [], txs: [], recharges: [],
async init() { await initLayout('history'); this.load(); },
async load() {
if (this.tab === 'orders') {
const d = await api('/api/history/orders?page=0&size=20').catch(() => ({ content: [] }));
this.orders = d.content || [];
} else if (this.tab === 'tx') {
const d = await api('/api/history/transactions?page=0&size=20').catch(() => ({ content: [] }));
this.txs = d.content || [];
} else {
const d = await api('/api/recharge/my?page=0&size=20').catch(() => ({ content: [] }));
this.recharges = d.content || [];
}
}
};
}
</script>
</body>
</html>
+63
View File
@@ -0,0 +1,63 @@
<!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="pointsApp()" x-init="init()">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold">积分兑换</h2>
<div class="text-sm">我的积分:<span class="text-[#fbbf24] font-bold" x-text="me.points || 0"></span></div>
</div>
<p class="text-sm text-[#9a9aa5] mb-4">兑换比例:<span x-text="rate"></span> 积分 = 1 元(按商品原价换算)</p>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<template x-for="it in items" :key="it.type+it.id">
<div class="card card-hover p-4">
<div class="font-bold" x-text="it.name"></div>
<div class="text-xs text-[#9a9aa5] mt-1" x-text="it.type"></div>
<div class="text-[#00d4ff] font-bold mt-2" x-text="it.points + ' 积分'"></div>
<button class="btn btn-primary w-full mt-3 !py-1 text-xs" @click="exchange(it)" :disabled="(me.points||0) < it.points">兑换</button>
</div>
</template>
</div>
<script src="/app.js"></script>
<script>
function pointsApp() {
return {
me: {}, rate: 100, items: [],
async init() {
await initLayout('points');
this.me = await api('/api/user/me').catch(() => ({}));
const cfg = await api('/api/config').catch(() => ({}));
this.rate = Number(cfg.points_exchange_rate) || 100;
const slots = await api('/api/timeslots').catch(() => []);
const snacks = await api('/api/snacks').catch(() => []);
const combos = await api('/api/combos').catch(() => []);
slots.forEach(s => this.items.push({ type: 'TIMESLOT', id: s.id, name: s.durationMinutes + ' 分钟时长', price: s.basePrice, points: Math.ceil(s.basePrice * this.rate) }));
snacks.forEach(s => this.items.push({ type: 'SNACK', id: s.id, name: s.name, price: s.price, points: Math.ceil(s.price * this.rate) }));
combos.forEach(c => this.items.push({ type: 'COMBO', id: c.id, name: c.name, price: 0, points: 0 }));
// 套餐价格需单独取
for (const c of combos) {
const d = await api('/api/combos/' + c.id).catch(() => null);
if (d) {
const it = this.items.find(i => i.type === 'COMBO' && i.id === c.id);
if (it) { it.price = d.price; it.points = Math.ceil(d.price * this.rate); }
}
}
},
async exchange(it) {
await api('/api/member/points/exchange', { method: 'POST', body: JSON.stringify({ itemType: it.type, itemId: it.id }) });
toast('兑换成功', 'success');
this.me = await api('/api/user/me').catch(() => ({}));
}
};
}
</script>
</body>
</html>
@@ -0,0 +1,65 @@
<!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="rechargeApp()" x-init="init()">
<h2 class="text-xl font-bold mb-6">自助充值</h2>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="card p-6">
<h3 class="font-semibold mb-4">提交充值申请</h3>
<div class="space-y-3">
<div>
<label class="label">充值金额</label>
<input type="number" step="0.01" x-model="amount" class="input" placeholder="请输入金额">
</div>
<button class="btn btn-primary w-full" @click="submit()">提交申请</button>
</div>
<div x-show="lastCode" class="mt-5 p-4 rounded-lg bg-[#16161a] text-center">
<div class="text-xs text-[#9a9aa5] mb-1">请向管理员出示授权码</div>
<div class="mono text-3xl font-bold text-[#00d4ff] tracking-widest" x-text="lastCode"></div>
<div class="remark mt-2">管理员审批通过后余额自动到账</div>
</div>
</div>
<div class="card p-6">
<h3 class="font-semibold mb-4">我的充值记录</h3>
<div class="space-y-2">
<template x-for="r in list" :key="r.id">
<div class="flex items-center justify-between py-2 border-b border-[#2a2a33] last:border-0">
<div>
<div class="text-sm" x-text="'¥'+fmtMoney(r.amount)"></div>
<div class="text-xs text-[#6b6b78]" x-text="fmtDateTime(r.createdAt)"></div>
</div>
<span class="badge" :class="r.status==='APPROVED'?'badge-success':r.status==='REJECTED'?'badge-danger':'badge-warning'" x-text="r.status"></span>
</div>
</template>
<div x-show="list.length===0" class="text-center text-[#6b6b78] py-4 text-sm">暂无记录</div>
</div>
</div>
</div>
<script src="/app.js"></script>
<script>
function rechargeApp() {
return {
amount: 100, lastCode: '', list: [],
async init() { await initLayout('recharge'); this.load(); },
async load() {
const d = await api('/api/recharge/my?page=0&size=10').catch(() => ({ content: [] }));
this.list = d.content || [];
},
async submit() {
if (!this.amount || this.amount <= 0) { toast('请输入有效金额', 'error'); return; }
const r = await api('/api/recharge/request', { method: 'POST', body: JSON.stringify({ amount: Number(this.amount) }) });
this.lastCode = r.authCode;
toast('申请已提交', 'success'); this.load();
}
};
}
</script>
</body>
</html>
+70
View File
@@ -0,0 +1,70 @@
<!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="snacksApp()" x-init="init()">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold">零食饮料</h2>
<button class="btn btn-primary" @click="checkout()" :disabled="cart.length===0">
结算 (<span x-text="cartCount"></span>) ¥<span x-text="fmtMoney(cartTotal)"></span>
</button>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
<template x-for="s in list" :key="s.id">
<div class="card card-hover p-4">
<div class="flex items-start justify-between">
<div>
<div class="font-bold" x-text="s.name"></div>
<span class="badge mt-1" :class="s.type==='DRINK'?'badge-accent':'badge-success'" x-text="s.type==='DRINK'?'饮料':'零食'"></span>
</div>
<div class="text-[#00d4ff] font-bold" x-text="'¥'+fmtMoney(s.price)"></div>
</div>
<div class="remark mt-2" x-text="s.remark"></div>
<div class="flex items-center gap-2 mt-3">
<button class="btn btn-ghost !py-1 !px-2 text-xs" @click="dec(s)">-</button>
<span class="w-6 text-center" x-text="qty(s.id)"></span>
<button class="btn btn-primary !py-1 !px-2 text-xs" @click="inc(s)">+</button>
</div>
</div>
</template>
</div>
<script src="/app.js"></script>
<script>
function snacksApp() {
return {
list: [], cart: [],
async init() { await initLayout('snacks'); this.list = await api('/api/snacks').catch(() => []); },
qty(id) { const it = this.cart.find(c => c.snackId === id); return it ? it.quantity : 0; },
inc(s) {
const it = this.cart.find(c => c.snackId === s.id);
if (it) it.quantity++; else this.cart.push({ snackId: s.id, quantity: 1 });
},
dec(s) {
const idx = this.cart.findIndex(c => c.snackId === s.id);
if (idx < 0) return;
this.cart[idx].quantity--;
if (this.cart[idx].quantity <= 0) this.cart.splice(idx, 1);
},
get cartCount() { return this.cart.reduce((a, c) => a + c.quantity, 0); },
get cartTotal() {
return this.cart.reduce((a, c) => {
const s = this.list.find(x => x.id === c.snackId);
return a + (s ? s.price * c.quantity : 0);
}, 0);
},
async checkout() {
await api('/api/orders/snacks', { method: 'POST', body: JSON.stringify({ items: this.cart }) });
toast('购买成功', 'success'); this.cart = [];
}
};
}
</script>
</body>
</html>