diff --git a/public/index.html b/public/index.html index 5d1c4fb..31a68a8 100644 --- a/public/index.html +++ b/public/index.html @@ -58,11 +58,13 @@ .deals-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; } .deal-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.15s; } .deal-card:active { transform: scale(0.98); } - .deal-img { width: 100%; height: 90px; background: #f3f4f6; border-radius: 8px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; font-size: 32px; } - .deal-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } + .deal-img { width: 100%; height: 100px; background: linear-gradient(135deg, #f3f4f6, #e5e7eb); border-radius: 8px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; } + .deal-img img { width: 100%; height: 100%; object-fit: cover; } + .deal-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; height: 2.8em; } .deal-price { color: #ef4444; font-weight: 700; font-size: 16px; } - .deal-price span { font-size: 12px; } - .deal-tag { display: inline-block; background: #fef2f2; color: #ef4444; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: 600; } + .deal-price span { font-size: 12px; text-decoration: line-through; color: #9ca3af; margin-left: 4px; } + .deal-tag { display: inline-block; background: linear-gradient(135deg, #ef4444, #f97316); color: white; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: 600; } + .deal-commission { font-size: 11px; color: var(--primary); margin-top: 4px; font-weight: 600; } /* Linbao List */ .linbao-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; } @@ -79,7 +81,8 @@ .product-item { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; cursor: pointer; transition: background 0.15s; } .product-item:last-child { border-bottom: none; } .product-item:active { background: #f9fafb; } - .product-img { width: 72px; height: 72px; background: #f3f4f6; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; } + .product-img { width: 72px; height: 72px; background: linear-gradient(135deg, #f3f4f6, #e5e7eb); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; overflow: hidden; } + .product-img img { width: 100%; height: 100%; object-fit: cover; } .product-info { flex: 1; min-width: 0; } .product-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .product-shop { font-size: 11px; color: var(--text-light); margin-bottom: 6px; } @@ -137,15 +140,15 @@
-
0
+
6
今日特价
-
0
+
2
覆盖平台
-
¥0
+
¥12
已帮省下
@@ -211,8 +214,11 @@ // State let currentTab = 'home'; - // API Base + // API Base - 留空使用相对路径,服务器通过nginx转发/api到后端 const API_BASE = ''; + + // Platform config + const PLATFORM_NAME = { taobao: '淘宝', jd: '京东', pinduoduo: '拼多多' }; // DOM Elements const searchInput = document.getElementById('searchInput'); @@ -231,7 +237,7 @@ await Promise.all([loadDeals(), loadLinbao()]); updateStats(); apiDot.classList.add('active'); - apiStatusEl.textContent = '本地运行'; + apiStatusEl.textContent = '服务正常'; } // Load Deals @@ -255,11 +261,11 @@ return; } dealsGrid.innerHTML = deals.map(deal => ` -
-
🏷️
+
+
${deal.title}
${deal.title}
-
¥${deal.price}¥${deal.originalPrice}
-
${deal.discount}
+
¥${deal.price}¥${deal.originalPrice}${deal.discount}
+
🎁 预估返 ¥${deal.commission || 0}
`).join(''); } @@ -271,7 +277,6 @@ const json = await res.json(); if (json.success) { renderLinbao(json.data); - statCoupon.textContent = json.data.length; } } catch (e) { linbaoList.innerHTML = '
📢
暂无线报
'; @@ -285,7 +290,7 @@ return; } linbaoList.innerHTML = items.map(item => ` -
+
${item.title}
🔥 ${item.hot} @@ -319,15 +324,16 @@ // Render Search Results function renderSearchResults(products) { searchResults.innerHTML = products.map(p => ` -
-
🏷️
+
+
${p.title}
${p.title}
🏪 ${p.shop}
¥${p.price} - 领${p.coupon}元券 + -¥${p.coupon}券
+
🎁 返 ¥${p.commission || 0}
`).join(''); @@ -338,10 +344,21 @@ // Stats updated from data } - // Placeholder actions - function openDeal(id) { console.log('open deal', id); } - function openLinbao(id) { console.log('open linbao', id); } - function goToCoupon(id) { console.log('go to coupon', id); alert('请复制链接到淘宝/京东app打开'); } + // Actions + function openDeal(deal) { + if (deal.link && deal.link !== '#') { + window.open(deal.link, '_blank'); + } else { + alert('复制商品链接,请在淘宝/京东App打开购买~'); + } + } + function goToCoupon(product) { + if (product.link && product.link !== '#') { + window.open(product.link, '_blank'); + } else { + alert('复制商品链接,请在淘宝/京东App打开购买~'); + } + } // Event Listeners searchBtn.addEventListener('click', () => doSearch(searchInput.value)); diff --git a/server.js b/server.js index 5b2a979..f8a45e9 100644 --- a/server.js +++ b/server.js @@ -65,57 +65,74 @@ function generateMockResults(keyword) { return [ { id: '1', - title: `${keyword} 空气炸锅 智能版`, - price: 199, - originalPrice: 299, - coupon: 50, + title: `苏泊尔空气炸锅5.5L大容量${keyword}智能款`, + price: 189, + originalPrice: 399, + coupon: 60, commission: 15, - shop: '某某电器旗舰店', - link: '#', - platform: 'taobao' + shop: '苏泊尔官方旗舰店', + link: 'https://s.click.taobao.com/abc123', + platform: 'taobao', + img: 'https://img.alicdn.com/bao/uploaded/O1CN01Z1a2b3_!!600000000.jpg' }, { id: '2', - title: `${keyword} 破壁机 多功能`, + title: `九阳破壁机L12-Y5多功能全自动${keyword}`, price: 299, - originalPrice: 499, - coupon: 80, + originalPrice: 699, + coupon: 100, commission: 25, - shop: '厨房电器专营店', - link: '#', - platform: 'taobao' + shop: '九阳厨房电器旗舰店', + link: 'https://s.click.taobao.com/def456', + platform: 'taobao', + img: 'https://img.alicdn.com/bao/uploaded/O1CN01C3d4e5_!!600000000.jpg' }, { id: '3', - title: `${keyword} 电饭煲 智能预约`, + title: `美的${keyword}电饭煲MB-RE476智能预约`, price: 159, - originalPrice: 259, - coupon: 40, + originalPrice: 399, + coupon: 50, commission: 12, - shop: '品牌电器直营', - link: '#', - platform: 'jd' + shop: '美的官方旗舰店', + link: 'https://u.jd.com/gh789', + platform: 'jd', + img: 'https://img.alicdn.com/bao/uploaded/O1CN01F6h7i8_!!600000000.jpg' + }, + { + id: '4', + title: `小米手环8 NFC版${keyword}运动健康监测`, + price: 229, + originalPrice: 399, + coupon: 30, + commission: 18, + shop: '小米官方旗舰店', + link: 'https://s.click.taobao.com/jkl012', + platform: 'taobao', + img: 'https://img.alicdn.com/bao/uploaded/O1CN01G8m9n0_!!600000000.jpg' } ]; } function generateMockDeals() { return [ - { id: 'd1', title: '苏泊尔空气炸锅', price: 189, originalPrice: 299, discount: '63折', endTime: '2026-06-05' }, - { id: 'd2', title: '九阳破壁机', price: 299, originalPrice: 599, discount: '5折', endTime: '2026-06-05' }, - { id: 'd3', title: '美的电饭煲', price: 159, originalPrice: 299, discount: '53折', endTime: '2026-06-05' }, - { id: 'd4', title: '小米手环8', price: 199, originalPrice: 299, discount: '67折', endTime: '2026-06-06' }, - { id: 'd5', title: '华为手表GT4', price: 899, originalPrice: 1488, discount: '6折', endTime: '2026-06-07' } + { id: 'd1', title: '苏泊尔空气炸锅5.5L大容量智能款', price: 189, originalPrice: 399, discount: '47折', endTime: '2026-06-25', img: 'https://img.alicdn.com/bao/uploaded/O1CN01abc123_!!600000000.jpg', platform: 'taobao', commission: 15 }, + { id: 'd2', title: '九阳破壁机L12-Y536多功能全自动', price: 299, originalPrice: 699, discount: '43折', endTime: '2026-06-25', img: 'https://img.alicdn.com/bao/uploaded/O1CN01def456_!!600000000.jpg', platform: 'taobao', commission: 25 }, + { id: 'd3', title: '美的电饭煲MB-RE476智能预约', price: 159, originalPrice: 399, discount: '40折', endTime: '2026-06-23', img: 'https://img.alicdn.com/bao/uploaded/O1CN01ghi789_!!600000000.jpg', platform: 'jd', commission: 12 }, + { id: 'd4', title: '小米手环8 NFC版运动健康', price: 229, originalPrice: 399, discount: '57折', endTime: '2026-06-26', img: 'https://img.alicdn.com/bao/uploaded/O1CN01jkl012_!!600000000.jpg', platform: 'taobao', commission: 18 }, + { id: 'd5', title: '戴森吹风机HD15负离子护发', price: 2199, originalPrice: 3299, discount: '67折', endTime: '2026-06-28', img: 'https://img.alicdn.com/bao/uploaded/O1CN01mno345_!!600000000.jpg', platform: 'taobao', commission: 180 }, + { id: 'd6', title: '添可洗地机2.0 LED智能清洁', price: 1499, originalPrice: 2599, discount: '58折', endTime: '2026-06-24', img: 'https://img.alicdn.com/bao/uploaded/O1CN01pqr678_!!600000000.jpg', platform: 'jd', commission: 120 } ]; } function generateMockLinbao() { return [ - { id: 'l1', title: '淘宝618预售开启,付定金可抵双倍', source: '官方', time: '10分钟前', hot: 98 }, - { id: 'l2', title: '美团外卖新用户立减15元', source: '美团', time: '30分钟前', hot: 85 }, - { id: 'l3', title: '京东闪购不定时放大额券', source: '京东', time: '1小时前', hot: 92 }, - { id: 'l4', title: '饿了么端午红包来袭', source: '饿了么', time: '2小时前', hot: 78 }, - { id: 'l5', title: '拼多多百亿补贴再加码', source: '拼多多', time: '3小时前', hot: 88 } + { id: 'l1', title: '🎉 淘宝618预售开启!付定金可抵双倍,AirPods Pro低至999', source: '官方公告', time: '10分钟前', hot: 98, url: 'https://taobao.com' }, + { id: 'l2', title: '🔥 京东PLUS会员专属大额券,500-50全场通用', source: '京东', time: '30分钟前', hot: 92, url: 'https://jd.com' }, + { id: 'l3', title: '💰 美团外卖新用户首单立减15元,红包秒到账', source: '美团', time: '1小时前', hot: 85, url: 'https://meituan.com' }, + { id: 'l4', title: '🛒 拼多多百亿补贴再加码,iPhone15 Pro Max直降500', source: '拼多多', time: '2小时前', hot: 95, url: 'https://pinduoduo.com' }, + { id: 'l5', title: '⏰ 饿了么端午粽子专场,满39减10', source: '饿了么', time: '3小时前', hot: 78, url: 'https://elem.com' }, + { id: 'l6', title: '📱 抖音618好物节,直播间专属优惠来袭', source: '抖音', time: '4小时前', hot: 88, url: 'https://douyin.com' } ]; }