This commit is contained in:
aaron 2025-08-10 19:27:58 +08:00
parent 0fd991a1ce
commit 9b2647aa47
8 changed files with 589 additions and 54 deletions

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单管理 - USDT商城</title>
<title>订单管理 - 加密世界商城</title>
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/admin.css">
</head>

View File

@ -16,6 +16,40 @@ body {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* 页面头部样式 */
.site-header {
text-align: center;
padding: 40px 20px;
background: linear-gradient(145deg, #1a1a1a 0%, #2d2d2d 100%);
border-radius: 20px;
margin-bottom: 40px;
box-shadow:
0 20px 40px rgba(0, 0, 0, 0.4),
inset 0 1px 0 rgba(255, 255, 255, 0.1);
border: 1px solid #333;
}
.site-header h1 {
font-size: 2.5em;
color: #ffffff;
margin-bottom: 10px;
font-weight: 700;
background: linear-gradient(45deg, #ffd700, #ffed4a);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}
.site-header p {
font-size: 1.1em;
color: #b0b0b0;
margin: 0;
}
main {
@ -24,16 +58,17 @@ main {
gap: 40px;
align-items: start;
position: relative;
flex: 1;
}
/* 订单管理按钮 */
.admin-floating-btn {
/* 联系我们按钮 */
.contact-floating-btn {
position: fixed;
top: 30px;
right: 30px;
z-index: 1000;
background: linear-gradient(135deg, #ffd700, #ffed4a);
color: #000;
background: linear-gradient(135deg, #28a745, #20c997);
color: white;
border: none;
border-radius: 50px;
padding: 12px 25px;
@ -43,12 +78,12 @@ main {
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}
.admin-floating-btn:hover {
.contact-floating-btn:hover {
transform: translateY(-3px);
box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5);
box-shadow: 0 8px 25px rgba(40, 167, 69, 0.5);
}
/* 产品卡片 */
@ -141,6 +176,135 @@ main {
border: 1px solid #333;
}
/* 表单区域样式 */
.order-summary-section,
.shipping-info-section {
margin-bottom: 30px;
}
.order-summary-section .form-group {
margin-bottom: 0;
}
.section-title {
color: #ffffff;
font-size: 1.3em;
font-weight: 600;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #ffd700;
display: flex;
align-items: center;
}
.section-title::before {
content: '';
width: 4px;
height: 20px;
background: linear-gradient(135deg, #ffd700, #ffed4a);
border-radius: 2px;
margin-right: 10px;
}
/* 分割线样式 */
.section-divider {
height: 1px;
background: linear-gradient(90deg, transparent, #444, transparent);
margin: 30px 0;
position: relative;
}
.section-divider::after {
content: '';
position: absolute;
top: -2px;
left: 50%;
transform: translateX(-50%);
width: 8px;
height: 4px;
background: #ffd700;
border-radius: 2px;
}
/* 价格汇总样式 */
.price-summary {
background: linear-gradient(145deg, #0a0a0a, #1a1a1a);
border-radius: 12px;
padding: 20px;
border: 1px solid #333;
margin-top: 15px;
}
.price-line {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0;
color: #e0e0e0;
font-size: 1.1em;
}
.price-line:first-child {
border-bottom: 1px solid #444;
margin-bottom: 8px;
padding-bottom: 12px;
}
.discount-line {
color: #28a745 !important;
font-weight: 600;
}
.subtotal-line {
color: #ffc107;
text-decoration: line-through;
opacity: 0.7;
}
.total-line {
font-weight: bold;
font-size: 1.3em;
color: #ffd700;
padding-top: 8px;
border-top: 1px solid #444;
margin-top: 8px;
}
#unit-price {
color: #ffd700;
}
/* 优惠提示样式 */
.discount-tips {
margin-top: 20px;
padding: 15px;
background: linear-gradient(145deg, #0f1419, #1a2332);
border-radius: 10px;
border: 1px solid #2c3e50;
}
.tip-item {
display: flex;
align-items: center;
margin-bottom: 10px;
color: #b0b0b0;
font-size: 14px;
}
.tip-item:last-child {
margin-bottom: 0;
}
.tip-badge {
width: 20px;
text-align: center;
margin-right: 8px;
}
.tip-item strong {
color: #ffd700;
}
.form-group {
margin-bottom: 25px;
}
@ -495,6 +659,14 @@ main {
/* 响应式设计 */
@media (max-width: 768px) {
.site-header h1 {
font-size: 2em;
}
.site-header p {
font-size: 1em;
}
main {
grid-template-columns: 1fr;
gap: 30px;
@ -519,12 +691,22 @@ main {
margin: 20px;
}
.admin-floating-btn {
.contact-floating-btn {
top: 20px;
right: 20px;
padding: 10px 20px;
font-size: 12px;
}
.footer-content {
flex-direction: column;
text-align: center;
gap: 15px;
}
.admin-link-btn {
align-self: center;
}
}
/* 管理员登录表单样式 */
@ -608,4 +790,137 @@ main {
border: 1px solid #ff4757;
border-radius: 6px;
text-align: center;
}
/* 联系我们模态框样式 */
.contact-info {
text-align: center;
color: #e0e0e0;
}
.contact-info h4 {
color: #ffffff;
margin-bottom: 15px;
font-size: 1.4em;
font-weight: 600;
}
.contact-info > p {
color: #b0b0b0;
margin-bottom: 25px;
font-size: 1.1em;
}
.qr-code-container {
margin: 25px 0;
padding: 25px;
background: linear-gradient(145deg, #0a0a0a, #1a1a1a);
border-radius: 15px;
border: 2px dashed #444;
position: relative;
}
.qr-code-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(45deg, transparent 49%, rgba(40, 167, 69, 0.1) 50%, transparent 51%);
pointer-events: none;
border-radius: 13px;
}
.wechat-qr {
max-width: 200px;
max-height: 200px;
border-radius: 10px;
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
border: 2px solid #28a745;
}
.qr-error {
color: #ff4757;
font-size: 14px;
padding: 20px;
background: rgba(255, 71, 87, 0.1);
border-radius: 10px;
border: 1px solid #ff4757;
}
.qr-error p {
margin: 8px 0;
}
.contact-tips {
background: linear-gradient(145deg, #0f2e0f, #1a4a1a);
padding: 20px;
border-radius: 12px;
border: 1px solid #28a745;
margin-top: 25px;
position: relative;
}
.contact-tips::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 4px;
background: linear-gradient(135deg, #28a745, #20c997);
border-radius: 2px;
}
.contact-tips p {
margin: 10px 0;
color: #a8e6a1;
font-size: 15px;
font-weight: 500;
padding-left: 15px;
}
/* 页面底部样式 */
.site-footer {
margin-top: 60px;
padding: 30px 0;
background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
border-radius: 20px;
border: 1px solid #333;
text-align: center;
}
.footer-content {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 20px;
padding: 0 30px;
}
.footer-content p {
color: #b0b0b0;
margin: 0;
font-size: 14px;
}
.admin-link-btn {
background: linear-gradient(135deg, #444, #555);
color: #e0e0e0;
border: 1px solid #666;
border-radius: 25px;
padding: 8px 16px;
font-size: 12px;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
}
.admin-link-btn:hover {
background: linear-gradient(135deg, #555, #666);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

BIN
public/images/wechat_qr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

View File

@ -3,14 +3,20 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>USDT 商城</title>
<title>加密世界商城 Crypto Shopping Maill</title>
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/spinner.css">
</head>
<body>
<div class="container">
<!-- 浮动管理按钮 -->
<button class="admin-floating-btn" onclick="showAdminLogin()">订单管理</button>
<!-- 页面头部 -->
<header class="site-header">
<h1>加密世界商城</h1>
<p>专业的数字货币商品交易平台</p>
</header>
<!-- 联系我们按钮 -->
<button class="contact-floating-btn" onclick="showContactModal()">联系我们</button>
<main>
<!-- 产品展示区 -->
@ -34,40 +40,79 @@
<!-- 购买表单区 -->
<section class="order-section">
<form id="orderForm">
<!-- 数量选择 -->
<div class="form-group">
<label for="quantity">购买数量:</label>
<div class="quantity-controls">
<button type="button" id="decrease-qty">-</button>
<input type="number" id="quantity" name="quantity" value="1" min="1" max="999">
<button type="button" id="increase-qty">+</button>
<!-- 购买数量和金额汇总 -->
<div class="order-summary-section">
<h3 class="section-title">购买数量 & 金额汇总</h3>
<div class="form-group">
<label for="quantity">购买数量:</label>
<div class="quantity-controls">
<button type="button" id="decrease-qty">-</button>
<input type="number" id="quantity" name="quantity" value="1" min="1" max="999">
<button type="button" id="increase-qty">+</button>
</div>
</div>
<div class="total-price">
总价:<span id="total-price">$99.99</span> USDT
<div class="price-summary">
<div class="price-line">
<span>单价:</span>
<span>$<span id="unit-price">99.99</span> USDT</span>
</div>
<div class="price-line discount-line" id="discount-line" style="display: none;">
<span>优惠:</span>
<span id="discount-text"></span>
</div>
<div class="price-line subtotal-line" id="subtotal-line" style="display: none;">
<span>小计:</span>
<span id="subtotal-price"></span>
</div>
<div class="price-line total-line">
<span>总价:</span>
<span id="total-price">$99.99 USDT</span>
</div>
</div>
<!-- 优惠提示 -->
<div class="discount-tips">
<div class="tip-item">
<span class="tip-badge">💰</span>
<span>购买2个享受<strong>9.5折</strong>优惠</span>
</div>
<div class="tip-item">
<span class="tip-badge">🎉</span>
<span>购买5个及以上享受<strong>9折</strong>优惠</span>
</div>
</div>
</div>
<!-- 客户信息 -->
<div class="form-group">
<label for="customer_name">姓名:*</label>
<input type="text" id="customer_name" name="customer_name" required>
</div>
<!-- 配送信息分割线 -->
<div class="section-divider"></div>
<div class="form-group">
<label for="customer_email">邮箱:</label>
<input type="email" id="customer_email" name="customer_email">
</div>
<!-- 配送信息 -->
<div class="shipping-info-section">
<h3 class="section-title">配送信息</h3>
<div class="form-group">
<label for="customer_name">收货人姓名:*</label>
<input type="text" id="customer_name" name="customer_name" required>
</div>
<div class="form-group">
<label for="customer_phone">电话:</label>
<input type="tel" id="customer_phone" name="customer_phone">
</div>
<div class="form-group">
<label for="customer_phone">联系电话:*</label>
<input type="tel" id="customer_phone" name="customer_phone" required
placeholder="请输入11位手机号码">
</div>
<!-- 收货地址 -->
<div class="form-group">
<label for="shipping_address">收货地址:*</label>
<textarea id="shipping_address" name="shipping_address" rows="3" required
placeholder="请输入详细的收货地址,包括省市区县和具体地址"></textarea>
<div class="form-group">
<label for="customer_email">邮箱地址:*</label>
<input type="email" id="customer_email" name="customer_email" required
placeholder="请输入邮箱地址">
</div>
<!-- 收货地址 -->
<div class="form-group">
<label for="shipping_address">详细地址:*</label>
<textarea id="shipping_address" name="shipping_address" rows="3" required
placeholder="请输入详细的收货地址,包括省市区县和具体地址"></textarea>
</div>
</div>
<!-- 提交按钮 -->
@ -79,6 +124,14 @@
</section>
</main>
<!-- 页面底部 -->
<footer class="site-footer">
<div class="footer-content">
<p>&copy; 2024 加密世界商城 - 安全可靠的数字货币交易平台</p>
<button class="admin-link-btn" onclick="showAdminLogin()">管理入口</button>
</div>
</footer>
<!-- 订单确认模态框 -->
<div id="orderModal" class="modal" style="display: none;">
<div class="modal-content">
@ -135,6 +188,29 @@
</div>
</div>
<!-- 联系我们模态框 -->
<div id="contactModal" class="modal" style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h3>联系我们</h3>
<span class="close" onclick="closeContactModal()">&times;</span>
</div>
<div class="modal-body">
<div class="contact-info">
<h4>微信联系</h4>
<p>扫描下方二维码添加微信好友</p>
<div class="qr-code-container">
<img src="/images/wechat_qr.png" alt="微信二维码" class="wechat-qr" onerror="this.style.display='none'; document.querySelector('.qr-error').style.display='block';">
<div class="qr-error" style="display: none;">
<p>⚠️ 二维码图片未找到</p>
<p>请联系管理员添加微信二维码图片至 /images/wechat_qr.png</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 管理员登录模态框 -->
<div id="adminLoginModal" class="modal" style="display: none;">
<div class="modal-content">

View File

@ -30,6 +30,7 @@ async function loadProductData() {
document.getElementById('product-name').textContent = currentProduct.name;
document.getElementById('product-description').textContent = currentProduct.description;
document.getElementById('product-price').textContent = currentProduct.price.toFixed(2);
document.getElementById('unit-price').textContent = currentProduct.price.toFixed(2);
updateTotalPrice();
} catch (error) {
@ -61,6 +62,17 @@ function setupEventListeners() {
quantityInput.addEventListener('input', updateTotalPrice);
quantityInput.addEventListener('change', validateQuantity);
// 手机号验证
document.getElementById('customer_phone').addEventListener('blur', validatePhone);
document.getElementById('customer_phone').addEventListener('input', function(e) {
// 只允许输入数字
e.target.value = e.target.value.replace(/[^0-9]/g, '');
// 限制长度为11位
if (e.target.value.length > 11) {
e.target.value = e.target.value.slice(0, 11);
}
});
// 表单提交
orderForm.addEventListener('submit', handleOrderSubmit);
@ -84,8 +96,45 @@ function updateTotalPrice() {
if (!currentProduct) return;
const quantity = parseInt(quantityInput.value) || 1;
const total = (currentProduct.price * quantity).toFixed(2);
totalPriceElement.textContent = `$${total}`;
const unitPrice = currentProduct.price;
const originalTotal = unitPrice * quantity;
// 计算折扣
let discount = 0;
let discountText = '';
let finalTotal = originalTotal;
if (quantity >= 5) {
discount = 0.1; // 9折优惠10%
discountText = '5个及以上 9折优惠';
finalTotal = originalTotal * 0.9;
} else if (quantity >= 2) {
discount = 0.05; // 9.5折优惠5%
discountText = '2个 9.5折优惠';
finalTotal = originalTotal * 0.95;
}
// 更新显示
const discountLine = document.getElementById('discount-line');
const subtotalLine = document.getElementById('subtotal-line');
const discountTextElement = document.getElementById('discount-text');
const subtotalPriceElement = document.getElementById('subtotal-price');
if (discount > 0) {
// 显示优惠信息
discountLine.style.display = 'flex';
subtotalLine.style.display = 'flex';
const discountAmount = originalTotal - finalTotal;
discountTextElement.textContent = `-$${discountAmount.toFixed(2)} USDT (${discountText})`;
subtotalPriceElement.textContent = `$${originalTotal.toFixed(2)} USDT`;
} else {
// 隐藏优惠信息
discountLine.style.display = 'none';
subtotalLine.style.display = 'none';
}
totalPriceElement.textContent = `$${finalTotal.toFixed(2)} USDT`;
}
// 验证数量
@ -110,9 +159,24 @@ async function handleOrderSubmit(e) {
// 获取表单数据
const formData = new FormData(orderForm);
const quantity = parseInt(formData.get('quantity'));
// 计算最终价格(包含折扣)
const unitPrice = currentProduct.price;
const originalTotal = unitPrice * quantity;
let finalTotal = originalTotal;
if (quantity >= 5) {
finalTotal = originalTotal * 0.9; // 9折
} else if (quantity >= 2) {
finalTotal = originalTotal * 0.95; // 9.5折
}
const orderData = {
product_id: currentProduct.id,
quantity: parseInt(formData.get('quantity')),
quantity: quantity,
unit_price: unitPrice,
total_amount: finalTotal, // 使用折扣后的价格
customer_name: formData.get('customer_name').trim(),
customer_email: formData.get('customer_email').trim(),
customer_phone: formData.get('customer_phone').trim(),
@ -120,8 +184,20 @@ async function handleOrderSubmit(e) {
};
// 验证必填字段
if (!orderData.customer_name || !orderData.shipping_address) {
alert('请填写姓名和收货地址');
if (!orderData.customer_name || !orderData.customer_phone || !orderData.customer_email || !orderData.shipping_address) {
alert('请填写所有必填信息');
return;
}
// 验证手机号格式
if (!validatePhoneNumber(orderData.customer_phone)) {
alert('请输入正确的11位手机号码');
return;
}
// 验证邮箱格式
if (!validateEmail(orderData.customer_email)) {
alert('请输入正确的邮箱地址');
return;
}
@ -315,12 +391,51 @@ function validateEmail(email) {
return emailRegex.test(email);
}
// 工具函数:验证电话号码
function validatePhone(phone) {
const phoneRegex = /^[\d\s\-\+\(\)]+$/;
// 工具函数:验证手机号码
function validatePhoneNumber(phone) {
const phoneRegex = /^1[3-9]\d{9}$/;
return phoneRegex.test(phone);
}
// 手机号失焦验证
function validatePhone() {
const phoneInput = document.getElementById('customer_phone');
const phone = phoneInput.value.trim();
if (phone && !validatePhoneNumber(phone)) {
phoneInput.style.borderColor = '#ff4757';
showFieldError(phoneInput, '请输入正确的11位手机号码');
} else {
phoneInput.style.borderColor = '#444';
hideFieldError(phoneInput);
}
}
// 显示字段错误
function showFieldError(input, message) {
hideFieldError(input); // 先清除已有错误
const errorDiv = document.createElement('div');
errorDiv.className = 'field-error';
errorDiv.textContent = message;
errorDiv.style.cssText = 'color: #ff4757; font-size: 12px; margin-top: 5px; padding-left: 5px;';
input.parentNode.appendChild(errorDiv);
}
// 隐藏字段错误
function hideFieldError(input) {
const existingError = input.parentNode.querySelector('.field-error');
if (existingError) {
existingError.remove();
}
}
// 工具函数:验证电话号码(保留兼容性)
function validatePhone(phone) {
return validatePhoneNumber(phone);
}
// 管理员登录相关函数
function showAdminLogin() {
document.getElementById('adminLoginModal').style.display = 'flex';
@ -333,6 +448,15 @@ function closeAdminLogin() {
document.getElementById('loginError').style.display = 'none';
}
// 联系我们相关函数
function showContactModal() {
document.getElementById('contactModal').style.display = 'flex';
}
function closeContactModal() {
document.getElementById('contactModal').style.display = 'none';
}
function verifyAdminPassword() {
const password = document.getElementById('adminPassword').value;
const errorDiv = document.getElementById('loginError');
@ -353,6 +477,7 @@ function verifyAdminPassword() {
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeAdminLogin();
closeContactModal();
}
});

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>手动支付确认 - USDT商城</title>
<title>手动支付确认 - 加密世界商城</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>支付成功 - USDT商城</title>
<title>支付成功 - 加密世界商城</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>

View File

@ -53,9 +53,9 @@ const UPAY_API_URL = 'https://api-test.upay.ink/v1/api/open';
// 产品配置
const PRODUCTS = {
'premium-product': {
name: '比特币彩票抽奖机',
name: 'Bitaxe 601 比特币刮刮乐',
price: 100,
description: '这是我们的比特币彩票抽奖机,质量优秀'
description: '这是我们的比特币刮刮乐,质量优秀'
}
};
@ -80,6 +80,8 @@ app.post('/api/orders', async (req, res) => {
const {
product_id,
quantity,
unit_price,
total_amount,
customer_name,
customer_email,
customer_phone,
@ -92,7 +94,24 @@ app.post('/api/orders', async (req, res) => {
}
const product = PRODUCTS[product_id];
const total_amount = product.price * quantity;
// 验证价格计算(防止客户端篡改)
const expectedUnitPrice = product.price;
const originalTotal = expectedUnitPrice * quantity;
let expectedTotal = originalTotal;
// 服务器端折扣计算验证
if (quantity >= 5) {
expectedTotal = originalTotal * 0.9; // 9折
} else if (quantity >= 2) {
expectedTotal = originalTotal * 0.95; // 9.5折
}
// 价格验证(允许小数点误差)
if (Math.abs(total_amount - expectedTotal) > 0.01) {
return res.status(400).json({ error: '价格计算错误' });
}
const order_id = 'ORDER_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
// 保存订单到数据库
@ -103,7 +122,7 @@ app.post('/api/orders', async (req, res) => {
`);
stmt.run([
order_id, product.name, quantity, product.price, total_amount,
order_id, product.name, quantity, expectedUnitPrice, expectedTotal,
customer_name, customer_email, customer_phone, shipping_address
], function(err) {
if (err) {
@ -114,7 +133,7 @@ app.post('/api/orders', async (req, res) => {
res.json({
success: true,
order_id,
total_amount,
total_amount: expectedTotal,
message: '订单创建成功'
});
});