智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>店铺管理 - 电商库存管理系统</title>
  7. <script src="https://cdn.tailwindcss.com"></script>
  8. </head>
  9. <body class="bg-gray-50 min-h-screen">
  10. <nav class="bg-blue-600 text-white shadow-lg">
  11. <div class="container mx-auto px-4 py-4">
  12. <div class="flex justify-between items-center">
  13. <div class="flex items-center space-x-3">
  14. <span class="text-2xl">📦</span>
  15. <h1 class="text-xl font-bold">电商库存管理系统</h1>
  16. </div>
  17. <div class="flex space-x-4">
  18. <a href="/" class="hover:bg-blue-500 px-3 py-2 rounded">首页</a>
  19. <a href="/shops" class="bg-blue-500 px-3 py-2 rounded">店铺</a>
  20. <a href="/products" class="hover:bg-blue-500 px-3 py-2 rounded">商品</a>
  21. <a href="/inventory" class="hover:bg-blue-500 px-3 py-2 rounded">库存</a>
  22. <a href="/orders" class="hover:bg-blue-500 px-3 py-2 rounded">订单</a>
  23. </div>
  24. </div>
  25. </div>
  26. </nav>
  27. <main class="container mx-auto px-4 py-8">
  28. <div class="flex justify-between items-center mb-8">
  29. <div>
  30. <h2 class="text-3xl font-bold text-gray-800">🏪 店铺管理</h2>
  31. <p class="text-gray-600 mt-2">管理多平台电商店铺</p>
  32. </div>
  33. <button onclick="showAddModal()" class="bg-green-600 text-white px-6 py-3 rounded-lg hover:bg-green-700 transition">
  34. ➕ 添加店铺
  35. </button>
  36. </div>
  37. <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6" id="shopList">
  38. <div class="col-span-full text-center text-gray-500 py-8">加载中...</div>
  39. </div>
  40. </main>
  41. <div id="addModal" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
  42. <div class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4">
  43. <div class="p-6">
  44. <div class="flex justify-between items-center mb-4">
  45. <h3 class="text-xl font-bold">➕ 添加店铺</h3>
  46. <button onclick="hideModal()" class="text-gray-500 hover:text-gray-700 text-2xl">&times;</button>
  47. </div>
  48. <form id="shopForm" class="space-y-4">
  49. <div>
  50. <label class="block text-sm font-medium text-gray-700 mb-1">店铺名称 *</label>
  51. <input type="text" name="name" required class="w-full border border-gray-300 rounded-lg px-3 py-2">
  52. </div>
  53. <div>
  54. <label class="block text-sm font-medium text-gray-700 mb-1">平台 *</label>
  55. <select name="platform" class="w-full border border-gray-300 rounded-lg px-3 py-2">
  56. <option value="taobao">淘宝</option>
  57. <option value="jd">京东</option>
  58. <option value="pdd">拼多多</option>
  59. </select>
  60. </div>
  61. <div>
  62. <label class="block text-sm font-medium text-gray-700 mb-1">店铺 ID</label>
  63. <input type="text" name="shop_id" class="w-full border border-gray-300 rounded-lg px-3 py-2">
  64. </div>
  65. <div class="flex space-x-3 pt-4">
  66. <button type="button" onclick="hideModal()" class="flex-1 bg-gray-200 py-2 rounded-lg">取消</button>
  67. <button type="submit" class="flex-1 bg-green-600 text-white py-2 rounded-lg">保存</button>
  68. </div>
  69. </form>
  70. </div>
  71. </div>
  72. </div>
  73. <script>
  74. const API_BASE = '';
  75. async function loadShops() {
  76. const res = await fetch(`${API_BASE}/api/shops`);
  77. const data = await res.json();
  78. if (data.success) renderShops(data.data);
  79. }
  80. function renderShops(shops) {
  81. const container = document.getElementById('shopList');
  82. if (shops.length === 0) {
  83. container.innerHTML = '<div class="col-span-full text-center text-gray-500 py-8">暂无店铺数据</div>';
  84. return;
  85. }
  86. const platformIcons = { taobao: '🍑', jd: '🐶', pdd: '💰' };
  87. const platformNames = { taobao: '淘宝', jd: '京东', pdd: '拼多多' };
  88. container.innerHTML = shops.map(s => `
  89. <div class="bg-white rounded-lg shadow p-6 hover:shadow-md transition">
  90. <div class="flex items-center justify-between mb-3">
  91. <h3 class="text-lg font-bold">${s.name}</h3>
  92. <span class="text-2xl">${platformIcons[s.platform] || '🏪'}</span>
  93. </div>
  94. <p class="text-gray-600 mb-2">平台:${platformNames[s.platform] || s.platform}</p>
  95. <p class="text-gray-500 text-sm mb-4">店铺 ID: ${s.shop_id || '-'}</p>
  96. <div class="flex space-x-2">
  97. <span class="px-2 py-1 ${s.status === 'active' ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-600'} text-xs rounded">
  98. ${s.status === 'active' ? '✅ 运营中' : '❌ 已停用'}
  99. </span>
  100. </div>
  101. </div>
  102. `).join('');
  103. }
  104. function showAddModal() {
  105. document.getElementById('addModal').classList.remove('hidden');
  106. document.getElementById('addModal').classList.add('flex');
  107. }
  108. function hideModal() {
  109. document.getElementById('addModal').classList.add('hidden');
  110. document.getElementById('addModal').classList.remove('flex');
  111. document.getElementById('shopForm').reset();
  112. }
  113. document.getElementById('shopForm').addEventListener('submit', async (e) => {
  114. e.preventDefault();
  115. const formData = new FormData(e.target);
  116. const data = Object.fromEntries(formData);
  117. const res = await fetch(`${API_BASE}/api/shops`, {
  118. method: 'POST',
  119. headers: { 'Content-Type': 'application/json' },
  120. body: JSON.stringify(data)
  121. });
  122. const result = await res.json();
  123. if (result.success) {
  124. alert('✅ 店铺添加成功');
  125. hideModal();
  126. loadShops();
  127. } else {
  128. alert('❌ ' + result.error);
  129. }
  130. });
  131. document.addEventListener('DOMContentLoaded', loadShops);
  132. </script>
  133. </body>
  134. </html>