dm-design/商家端web/2.1 营销工具/2.1.1 会员功能/积分商城/已选择商品-弹窗.html

557 lines
17 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>已选择商品</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 20px;
}
.modal {
background: white;
border-radius: 8px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
width: 100%;
max-width: 500px;
position: relative;
overflow: hidden;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 24px;
border-bottom: 1px solid #f0f0f0;
background-color: #fafafa;
}
.modal-title {
font-size: 18px;
font-weight: 600;
color: #333;
}
.close-btn {
width: 24px;
height: 24px;
border: none;
background: none;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: #666;
font-size: 18px;
border-radius: 4px;
transition: background-color 0.2s;
}
.close-btn:hover {
background-color: #f5f5f5;
}
.modal-content {
padding: 24px;
}
.product-info {
margin-bottom: 24px;
padding: 16px;
background-color: #f8f9fa;
border-radius: 6px;
border: 1px solid #e9ecef;
}
.info-row {
display: flex;
margin-bottom: 8px;
font-size: 14px;
}
.info-row:last-child {
margin-bottom: 0;
}
.info-label {
color: #666;
width: 80px;
flex-shrink: 0;
}
.info-value {
color: #333;
flex: 1;
}
.form-group {
margin-bottom: 20px;
}
.form-label {
display: block;
margin-bottom: 8px;
font-size: 14px;
color: #333;
font-weight: 500;
}
.required {
color: #ff4757;
}
.input-wrapper {
position: relative;
}
.form-input {
width: 100%;
padding: 10px 12px;
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 14px;
transition: border-color 0.2s;
}
.form-input:focus {
outline: none;
border-color: #1890ff;
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}
.number-input-group {
display: flex;
align-items: center;
border: 1px solid #d9d9d9;
border-radius: 4px;
overflow: hidden;
background: white;
}
.number-input-group:focus-within {
border-color: #1890ff;
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}
.number-btn {
width: 32px;
height: 40px;
border: none;
background: #fafafa;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #666;
transition: background-color 0.2s;
}
.number-btn:hover {
background-color: #f0f0f0;
}
.number-btn:disabled {
cursor: not-allowed;
color: #ccc;
}
.number-input {
flex: 1;
border: none;
padding: 10px 12px;
font-size: 14px;
text-align: center;
outline: none;
}
.select-wrapper {
position: relative;
}
.form-select {
width: 100%;
padding: 10px 32px 10px 12px;
border: 1px solid #d9d9d9;
border-radius: 4px;
font-size: 14px;
background: white;
cursor: pointer;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
.form-select:focus {
outline: none;
border-color: #1890ff;
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}
.select-arrow {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
color: #666;
}
.limit-setting {
display: flex;
gap: 12px;
align-items: flex-end;
}
.limit-input {
flex: 1;
}
.limit-select {
flex: 0 0 100px;
}
.radio-group {
display: flex;
gap: 20px;
margin-top: 8px;
}
.radio-option {
display: flex;
align-items: center;
cursor: pointer;
position: relative;
}
.radio-option input[type="radio"] {
margin: 0;
margin-right: 8px;
width: 16px;
height: 16px;
cursor: pointer;
}
.radio-option label {
font-size: 14px;
color: #333;
cursor: pointer;
margin: 0;
}
.exchange-only,
.discount-only {
transition: opacity 0.3s ease;
}
.modal-footer {
padding: 16px 24px;
border-top: 1px solid #f0f0f0;
display: flex;
gap: 12px;
justify-content: flex-end;
}
.btn {
padding: 8px 24px;
border-radius: 4px;
font-size: 14px;
cursor: pointer;
transition: all 0.2s;
border: 1px solid;
min-width: 80px;
}
.btn-cancel {
background: white;
color: #666;
border-color: #d9d9d9;
}
.btn-cancel:hover {
background: #f5f5f5;
border-color: #bfbfbf;
}
.btn-primary {
background: #1890ff;
color: white;
border-color: #1890ff;
}
.btn-primary:hover {
background: #40a9ff;
border-color: #40a9ff;
}
@media (max-width: 480px) {
.modal {
margin: 0;
border-radius: 0;
height: 100vh;
max-width: none;
}
.modal-content {
padding: 20px;
}
.modal-footer {
padding: 16px 20px;
}
.btn {
flex: 1;
}
}
</style>
</head>
<body>
<div class="modal">
<div class="modal-header">
<h2 class="modal-title">已选择商品</h2>
<button class="close-btn" onclick="closeModal()">×</button>
</div>
<div class="modal-content">
<div class="product-info">
<div class="info-row">
<span class="info-label">商品ID:</span>
<span class="info-value">192401649879976960</span>
</div>
<div class="info-row">
<span class="info-label">商品名称:</span>
<span class="info-value">黑木耳</span>
</div>
<div class="info-row">
<span class="info-label">归属摊位:</span>
<span class="info-value">牛生蔬菜店</span>
</div>
<div class="info-row">
<span class="info-label">规格名称:</span>
<span class="info-value">小份</span>
</div>
<div class="info-row">
<span class="info-label">SKU-ID:</span>
<span class="info-value">194105142774503836</span>
</div>
<div class="info-row">
<span class="info-label">商品原价:</span>
<span class="info-value">¥12.80</span>
</div>
</div>
<div class="form-group">
<label class="form-label">库存设置 <span class="required">*</span></label>
<div class="number-input-group">
<button class="number-btn" onclick="decreaseStock()">-</button>
<input type="number" class="number-input" id="stockInput" value="10" min="0">
<button class="number-btn" onclick="increaseStock()">+</button>
</div>
</div>
<div class="form-group">
<label class="form-label">积分类型 <span class="required">*</span></label>
<div class="radio-group">
<div class="radio-option">
<input type="radio" id="pointsDiscount" name="pointsType" value="discount" checked onchange="toggleFieldsByType()">
<label for="pointsDiscount">积分优惠购</label>
</div>
<div class="radio-option">
<input type="radio" id="pointsExchange" name="pointsType" value="exchange" onchange="toggleFieldsByType()">
<label for="pointsExchange">积分换购</label>
</div>
<div class="radio-option">
<input type="radio" id="pointsDouble" name="pointsType" value="double" onchange="toggleFieldsByType()">
<label for="pointsDouble">双倍积分</label>
</div>
</div>
</div>
<!-- 积分换购专用字段 -->
<div class="form-group exchange-only">
<label class="form-label">兑换所需积分设置 <span class="required">*</span></label>
<div class="number-input-group">
<button class="number-btn" onclick="decreasePoints()">-</button>
<input type="number" class="number-input" id="pointsInput" value="1" min="1">
<button class="number-btn" onclick="increasePoints()">+</button>
</div>
</div>
<!-- 积分优惠购专用字段 -->
<div class="form-group discount-only" style="display: none;">
<label class="form-label">优惠购所需积分 <span class="required">*</span></label>
<div class="number-input-group">
<button class="number-btn" onclick="decreaseDiscountPoints()">-</button>
<input type="number" class="number-input" id="discountPointsInput" value="1" min="1">
<button class="number-btn" onclick="increaseDiscountPoints()">+</button>
</div>
</div>
<div class="form-group discount-only" style="display: none;">
<label class="form-label">优惠购商品价格 <span class="required">*</span></label>
<div class="input-wrapper">
<input type="number" class="form-input" id="discountPriceInput" placeholder="请输入优惠购价格" step="0.01" min="0">
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-cancel" onclick="closeModal()">取消</button>
<button class="btn btn-primary" onclick="confirmSelection()">确认</button>
</div>
</div>
<script>
// 积分设置(兑换专用)
function increasePoints() {
const input = document.getElementById('pointsInput');
input.value = parseInt(input.value) + 1;
}
function decreasePoints() {
const input = document.getElementById('pointsInput');
const currentValue = parseInt(input.value);
if (currentValue > 1) {
input.value = currentValue - 1;
}
}
// 优惠购积分设置
function increaseDiscountPoints() {
const input = document.getElementById('discountPointsInput');
input.value = parseInt(input.value) + 1;
}
function decreaseDiscountPoints() {
const input = document.getElementById('discountPointsInput');
const currentValue = parseInt(input.value);
if (currentValue > 1) {
input.value = currentValue - 1;
}
}
// 库存设置
function increaseStock() {
const input = document.getElementById('stockInput');
input.value = parseInt(input.value) + 1;
}
function decreaseStock() {
const input = document.getElementById('stockInput');
const currentValue = parseInt(input.value);
if (currentValue > 0) {
input.value = currentValue - 1;
}
}
// 关闭弹窗
function closeModal() {
// 这里可以添加关闭弹窗的逻辑
console.log('关闭弹窗');
// 实际应用中可能会隐藏弹窗或者跳转页面
// window.close(); // 如果是新窗口
// 或者隐藏弹窗元素
}
// 切换字段显示
function toggleFieldsByType() {
const pointsType = document.querySelector('input[name="pointsType"]:checked').value;
const exchangeFields = document.querySelectorAll('.exchange-only');
const discountFields = document.querySelectorAll('.discount-only');
if (pointsType === 'exchange') {
// 积分换购:显示兑换字段,隐藏优惠购字段
exchangeFields.forEach(field => field.style.display = 'block');
discountFields.forEach(field => field.style.display = 'none');
} else if (pointsType === 'discount') {
// 积分优惠购:隐藏兑换字段,显示优惠购字段
exchangeFields.forEach(field => field.style.display = 'none');
discountFields.forEach(field => field.style.display = 'block');
} else {
// 双倍积分:隐藏所有字段
exchangeFields.forEach(field => field.style.display = 'none');
discountFields.forEach(field => field.style.display = 'none');
}
}
// 确认选择
function confirmSelection() {
const pointsType = document.querySelector('input[name="pointsType"]:checked').value;
const stock = document.getElementById('stockInput').value;
let data = {
productId: '192401649879976960',
productName: '黑木耳100g',
shopName: '牛生蔬菜店',
skuId: '194105142774503836',
pointsType: pointsType,
stock: stock
};
if (pointsType === 'exchange') {
// 积分换购验证
const points = document.getElementById('pointsInput').value;
if (!points || !stock) {
alert('请填写所有必填项');
return;
}
data.points = points;
} else if (pointsType === 'discount') {
// 积分优惠购验证
const discountPoints = document.getElementById('discountPointsInput').value;
const discountPrice = document.getElementById('discountPriceInput').value;
if (!discountPoints || !stock || !discountPrice) {
alert('请填写所有必填项');
return;
}
data.discountPoints = discountPoints;
data.discountPrice = discountPrice;
}
// 双倍积分无需额外验证
console.log('提交数据:', data);
alert('设置成功!');
}
// 键盘事件处理
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') {
closeModal();
}
});
// 点击背景关闭弹窗
document.addEventListener('click', function(e) {
if (e.target === document.body) {
closeModal();
}
});
// 页面加载时初始化字段显示
document.addEventListener('DOMContentLoaded', function() {
toggleFieldsByType();
});
</script>
</body>
</html>