| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>店铺管理 - 电商库存管理系统</title>
- <script src="https://cdn.tailwindcss.com"></script>
- </head>
- <body class="bg-gray-50 min-h-screen">
- <nav class="bg-blue-600 text-white shadow-lg">
- <div class="container mx-auto px-4 py-4">
- <div class="flex justify-between items-center">
- <div class="flex items-center space-x-3">
- <span class="text-2xl">📦</span>
- <h1 class="text-xl font-bold">电商库存管理系统</h1>
- </div>
- <div class="flex space-x-4">
- <a href="/" class="hover:bg-blue-500 px-3 py-2 rounded">首页</a>
- <a href="/shops" class="bg-blue-500 px-3 py-2 rounded">店铺</a>
- <a href="/products" class="hover:bg-blue-500 px-3 py-2 rounded">商品</a>
- <a href="/inventory" class="hover:bg-blue-500 px-3 py-2 rounded">库存</a>
- <a href="/orders" class="hover:bg-blue-500 px-3 py-2 rounded">订单</a>
- </div>
- </div>
- </div>
- </nav>
-
- <main class="container mx-auto px-4 py-8">
- <div class="flex justify-between items-center mb-8">
- <div>
- <h2 class="text-3xl font-bold text-gray-800">🏪 店铺管理</h2>
- <p class="text-gray-600 mt-2">管理多平台电商店铺</p>
- </div>
- <button onclick="showAddModal()" class="bg-green-600 text-white px-6 py-3 rounded-lg hover:bg-green-700 transition">
- ➕ 添加店铺
- </button>
- </div>
-
- <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6" id="shopList">
- <div class="col-span-full text-center text-gray-500 py-8">加载中...</div>
- </div>
- </main>
-
- <div id="addModal" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
- <div class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4">
- <div class="p-6">
- <div class="flex justify-between items-center mb-4">
- <h3 class="text-xl font-bold">➕ 添加店铺</h3>
- <button onclick="hideModal()" class="text-gray-500 hover:text-gray-700 text-2xl">×</button>
- </div>
- <form id="shopForm" class="space-y-4">
- <div>
- <label class="block text-sm font-medium text-gray-700 mb-1">店铺名称 *</label>
- <input type="text" name="name" required class="w-full border border-gray-300 rounded-lg px-3 py-2">
- </div>
- <div>
- <label class="block text-sm font-medium text-gray-700 mb-1">平台 *</label>
- <select name="platform" class="w-full border border-gray-300 rounded-lg px-3 py-2">
- <option value="taobao">淘宝</option>
- <option value="jd">京东</option>
- <option value="pdd">拼多多</option>
- </select>
- </div>
- <div>
- <label class="block text-sm font-medium text-gray-700 mb-1">店铺 ID</label>
- <input type="text" name="shop_id" class="w-full border border-gray-300 rounded-lg px-3 py-2">
- </div>
- <div class="flex space-x-3 pt-4">
- <button type="button" onclick="hideModal()" class="flex-1 bg-gray-200 py-2 rounded-lg">取消</button>
- <button type="submit" class="flex-1 bg-green-600 text-white py-2 rounded-lg">保存</button>
- </div>
- </form>
- </div>
- </div>
- </div>
-
- <script>
- const API_BASE = '';
-
- async function loadShops() {
- const res = await fetch(`${API_BASE}/api/shops`);
- const data = await res.json();
- if (data.success) renderShops(data.data);
- }
-
- function renderShops(shops) {
- const container = document.getElementById('shopList');
- if (shops.length === 0) {
- container.innerHTML = '<div class="col-span-full text-center text-gray-500 py-8">暂无店铺数据</div>';
- return;
- }
- const platformIcons = { taobao: '🍑', jd: '🐶', pdd: '💰' };
- const platformNames = { taobao: '淘宝', jd: '京东', pdd: '拼多多' };
- container.innerHTML = shops.map(s => `
- <div class="bg-white rounded-lg shadow p-6 hover:shadow-md transition">
- <div class="flex items-center justify-between mb-3">
- <h3 class="text-lg font-bold">${s.name}</h3>
- <span class="text-2xl">${platformIcons[s.platform] || '🏪'}</span>
- </div>
- <p class="text-gray-600 mb-2">平台:${platformNames[s.platform] || s.platform}</p>
- <p class="text-gray-500 text-sm mb-4">店铺 ID: ${s.shop_id || '-'}</p>
- <div class="flex space-x-2">
- <span class="px-2 py-1 ${s.status === 'active' ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-600'} text-xs rounded">
- ${s.status === 'active' ? '✅ 运营中' : '❌ 已停用'}
- </span>
- </div>
- </div>
- `).join('');
- }
-
- function showAddModal() {
- document.getElementById('addModal').classList.remove('hidden');
- document.getElementById('addModal').classList.add('flex');
- }
- function hideModal() {
- document.getElementById('addModal').classList.add('hidden');
- document.getElementById('addModal').classList.remove('flex');
- document.getElementById('shopForm').reset();
- }
-
- document.getElementById('shopForm').addEventListener('submit', async (e) => {
- e.preventDefault();
- const formData = new FormData(e.target);
- const data = Object.fromEntries(formData);
- const res = await fetch(`${API_BASE}/api/shops`, {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data)
- });
- const result = await res.json();
- if (result.success) {
- alert('✅ 店铺添加成功');
- hideModal();
- loadShops();
- } else {
- alert('❌ ' + result.error);
- }
- });
-
- document.addEventListener('DOMContentLoaded', loadShops);
- </script>
- </body>
- </html>
|