Files
coolcoth.com/app/Views/admin/products.php
T
2026-08-08 15:53:53 +08:00

37 lines
2.3 KiB
PHP

<?php
$cm = new \App\Models\Category();
$cmap = []; foreach ($cm->all() as $c) $cmap[$c['id']] = $c['name'];
?>
<div class="page-head">
<div><h1>产品管理</h1><div class="desc">管理降温服产品与上下架</div></div>
<a class="btn-primary" href="<?php echo site_url('admin/products/create'); ?>">+ 新增产品</a>
</div>
<div class="admin-card">
<table class="admin-table">
<tr><th>封面</th><th>名称</th><th>分类</th><th>价格</th><th>模式</th><th>状态</th><th>操作</th></tr>
<?php foreach ($products as $p): ?>
<?php $pm = empty($p['mode']) ? 'fixed' : $p['mode']; ?>
<tr>
<td><?php if (!empty($p['cover'])): ?><div class="thum" style="background:#fff"><img src="<?php echo e(site_url($p['cover'])); ?>" alt="" style="width:100%;height:100%;object-fit:cover;border-radius:10px"></div><?php else: ?><div class="thum" style="background:<?php echo gradient($p['id']); ?>">❄</div><?php endif; ?></td>
<td><b><?php echo e($p['name']); ?></b><br><span class="muted" style="font-size:12px"><?php echo e($p['slug']); ?></span></td>
<td><?php echo e($cmap[$p['category_id']] ?? '—'); ?></td>
<td>¥<?php echo e($p['price']); ?></td>
<td><span class="mode-badge <?php echo $pm === 'builder' ? 'builder' : 'fixed'; ?>"><?php echo $pm === 'builder' ? '可视化编辑' : '固定版面'; ?></span></td>
<td><?php echo ($p['status'] ?? 1) ? '<span class="tag-mini">已上线</span>' : '<span class="muted">草稿</span>'; ?></td>
<td>
<div class="row-actions">
<a class="btn-soft btn-sm" href="<?php echo site_url('admin/products/edit/' . $p['id']); ?>">编辑</a>
<form class="del-form" method="post" action="<?php echo site_url('admin/products/delete/' . $p['id']); ?>"><?php echo csrf_field(); ?><button class="btn-danger btn-sm" type="submit">删除</button></form>
</div>
</td>
</tr>
<?php endforeach; ?>
</table>
<style>
.mode-badge{display:inline-block;padding:3px 10px;border-radius:999px;font-size:12px;font-weight:600}
.mode-badge.fixed{background:#f1f5f9;color:#475569}
.mode-badge.builder{background:#e0f2fe;color:#0369a1}
</style>
</div>