|
|
@@ -0,0 +1,895 @@
|
|
|
+<!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", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f0f2f5; color: #333; }
|
|
|
+
|
|
|
+/* Layout */
|
|
|
+.app { max-width: 900px; margin: 0 auto; min-height: 100vh; }
|
|
|
+.header { background: #fff; padding: 16px 20px; border-bottom: 1px solid #e8e8e8; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100; }
|
|
|
+.header h1 { font-size: 18px; font-weight: 600; }
|
|
|
+.header .store-name { font-size: 13px; color: #999; }
|
|
|
+
|
|
|
+/* Content */
|
|
|
+.content { padding: 16px; }
|
|
|
+
|
|
|
+/* Button */
|
|
|
+.btn { padding: 8px 20px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s; }
|
|
|
+.btn-primary { background: #ff6b35; color: #fff; }
|
|
|
+.btn-primary:hover { background: #e55a2b; }
|
|
|
+.btn-default { background: #fff; color: #666; border: 1px solid #d9d9d9; }
|
|
|
+.btn-default:hover { border-color: #ff6b35; color: #ff6b35; }
|
|
|
+.btn-danger { background: #fff; color: #ff4d4f; border: 1px solid #ff4d4f; }
|
|
|
+.btn-danger:hover { background: #fff1f0; }
|
|
|
+.btn-sm { padding: 4px 12px; font-size: 12px; }
|
|
|
+.btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
|
+
|
|
|
+/* Card */
|
|
|
+.card { background: #fff; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
|
|
|
+.card-header { padding: 14px 16px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
|
|
|
+.card-header h3 { font-size: 15px; font-weight: 600; }
|
|
|
+.card-body { padding: 16px; }
|
|
|
+
|
|
|
+/* Status Tags */
|
|
|
+.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
|
|
|
+.tag-active { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
|
|
|
+.tag-pending { background: #fff7e6; color: #fa8c16; border: 1px solid #ffd591; }
|
|
|
+.tag-expired { background: #f5f5f5; color: #999; border: 1px solid #d9d9d9; }
|
|
|
+
|
|
|
+/* Promotion List Item */
|
|
|
+.promo-item { padding: 14px 16px; border-bottom: 1px solid #f5f5f5; display: flex; justify-content: space-between; align-items: center; }
|
|
|
+.promo-item:last-child { border-bottom: none; }
|
|
|
+.promo-info { flex: 1; }
|
|
|
+.promo-info .name { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
|
|
|
+.promo-info .detail { font-size: 12px; color: #999; }
|
|
|
+.promo-info .detail span { margin-right: 12px; }
|
|
|
+.promo-type-icon { display: inline-block; width: 22px; height: 22px; border-radius: 4px; text-align: center; line-height: 22px; font-size: 12px; color: #fff; margin-right: 6px; vertical-align: middle; }
|
|
|
+.type-manjian { background: #ff6b35; }
|
|
|
+.type-zhekou { background: #2196f3; }
|
|
|
+.type-ban { background: #9c27b0; }
|
|
|
+.type-xinke { background: #43e97b; }
|
|
|
+
|
|
|
+/* Modal / Drawer */
|
|
|
+.drawer-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 200; display: none; }
|
|
|
+.drawer-overlay.show { display: block; }
|
|
|
+.drawer { position: fixed; right: -600px; top: 0; bottom: 0; width: 580px; max-width: 100%; background: #fff; z-index: 201; transition: right 0.3s ease; display: flex; flex-direction: column; }
|
|
|
+.drawer.show { right: 0; }
|
|
|
+.drawer-header { padding: 16px 20px; border-bottom: 1px solid #e8e8e8; display: flex; justify-content: space-between; align-items: center; }
|
|
|
+.drawer-header h2 { font-size: 17px; font-weight: 600; }
|
|
|
+.drawer-close { font-size: 20px; cursor: pointer; color: #999; background: none; border: none; padding: 4px; }
|
|
|
+.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
|
|
|
+.drawer-footer { padding: 14px 20px; border-top: 1px solid #e8e8e8; display: flex; justify-content: flex-end; gap: 10px; }
|
|
|
+
|
|
|
+/* Form */
|
|
|
+.form-group { margin-bottom: 20px; }
|
|
|
+.form-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; color: #333; }
|
|
|
+.form-label .required { color: #ff4d4f; margin-right: 2px; }
|
|
|
+.form-hint { font-size: 12px; color: #999; margin-top: 4px; }
|
|
|
+.form-input { width: 100%; padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; outline: none; transition: border-color 0.2s; }
|
|
|
+.form-input:focus { border-color: #ff6b35; box-shadow: 0 0 0 2px rgba(255,107,53,0.1); }
|
|
|
+
|
|
|
+/* Type Selector */
|
|
|
+.type-selector { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
|
|
|
+.type-card { border: 2px solid #e8e8e8; border-radius: 8px; padding: 14px 10px; text-align: center; cursor: pointer; transition: all 0.2s; }
|
|
|
+.type-card:hover { border-color: #ff6b35; }
|
|
|
+.type-card.selected { border-color: #ff6b35; background: #fff8f0; }
|
|
|
+.type-card .icon { font-size: 24px; margin-bottom: 6px; }
|
|
|
+.type-card .label { font-size: 13px; font-weight: 500; }
|
|
|
+.type-card .desc { font-size: 11px; color: #999; margin-top: 2px; }
|
|
|
+.type-card.disabled { opacity: 0.4; cursor: not-allowed; position: relative; }
|
|
|
+.type-card.disabled::after { content: '已互斥'; position: absolute; top: 4px; right: 4px; font-size: 10px; background: #ff4d4f; color: #fff; padding: 1px 5px; border-radius: 3px; }
|
|
|
+
|
|
|
+/* Tiers (满减) */
|
|
|
+.tier-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
|
|
|
+.tier-row .tier-text { font-size: 14px; color: #666; white-space: nowrap; }
|
|
|
+.tier-input { width: 80px; padding: 6px 10px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 14px; text-align: center; outline: none; }
|
|
|
+.tier-input:focus { border-color: #ff6b35; }
|
|
|
+.tier-remove { cursor: pointer; color: #ff4d4f; font-size: 18px; background: none; border: none; padding: 2px 6px; }
|
|
|
+.add-tier { color: #ff6b35; cursor: pointer; font-size: 13px; background: none; border: none; padding: 4px 0; }
|
|
|
+.add-tier:hover { text-decoration: underline; }
|
|
|
+
|
|
|
+/* Product Selector */
|
|
|
+.product-select-area { border: 1px solid #e8e8e8; border-radius: 8px; overflow: hidden; }
|
|
|
+.product-search { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }
|
|
|
+.product-search input { width: 100%; border: none; outline: none; font-size: 13px; padding: 4px 0; }
|
|
|
+.product-list { max-height: 320px; overflow-y: auto; }
|
|
|
+.product-item { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid #f5f5f5; transition: background 0.15s; }
|
|
|
+.product-item:hover { background: #fafafa; }
|
|
|
+.product-item.selected { background: #fff8f0; }
|
|
|
+.product-check { width: 18px; height: 18px; border-radius: 3px; border: 1px solid #d9d9d9; margin-right: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; }
|
|
|
+.product-item.selected .product-check { background: #ff6b35; border-color: #ff6b35; }
|
|
|
+.product-check::after { content: '✓'; color: #fff; font-size: 12px; font-weight: 700; display: none; }
|
|
|
+.product-item.selected .product-check::after { display: block; }
|
|
|
+.product-img { width: 40px; height: 40px; border-radius: 4px; background: #f5f5f5; margin-right: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
|
|
|
+.product-meta { flex: 1; min-width: 0; }
|
|
|
+.product-meta .pname { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
|
+.product-meta .pprice { font-size: 12px; color: #999; }
|
|
|
+.product-rate { width: 72px; text-align: center; }
|
|
|
+.product-rate input { width: 52px; padding: 4px 6px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; text-align: center; outline: none; }
|
|
|
+.product-rate input:focus { border-color: #ff6b35; }
|
|
|
+.product-rate span { font-size: 11px; color: #999; }
|
|
|
+.product-result { display: inline-block; padding: 2px 8px; background: #fff2e8; border-radius: 4px; font-size: 12px; color: #ff6b35; font-weight: 500; min-width: 50px; text-align: center; }
|
|
|
+
|
|
|
+/* Selected summary */
|
|
|
+.selected-summary { margin-top: 12px; padding: 12px; background: #fafafa; border-radius: 6px; }
|
|
|
+.selected-summary .title { font-size: 13px; font-weight: 500; margin-bottom: 8px; color: #666; }
|
|
|
+.selected-item { display: flex; align-items: center; padding: 6px 0; font-size: 13px; }
|
|
|
+.selected-item .sname { flex: 1; }
|
|
|
+.selected-item .srate { color: #ff6b35; font-weight: 500; margin-right: 8px; }
|
|
|
+.selected-item .sresult { color: #666; }
|
|
|
+.selected-item .sremove { color: #ff4d4f; cursor: pointer; margin-left: 8px; }
|
|
|
+
|
|
|
+/* Mutex Warning */
|
|
|
+.mutex-warning { background: #fff7e6; border: 1px solid #ffd591; border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px; }
|
|
|
+.mutex-warning .icon { font-size: 16px; flex-shrink: 0; }
|
|
|
+.mutex-warning .text { font-size: 13px; color: #ad6800; line-height: 1.6; }
|
|
|
+
|
|
|
+/* Step indicator */
|
|
|
+.steps { display: flex; margin-bottom: 20px; }
|
|
|
+.step { flex: 1; text-align: center; position: relative; }
|
|
|
+.step .step-dot { width: 28px; height: 28px; border-radius: 50%; background: #e8e8e8; color: #999; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
|
|
|
+.step.active .step-dot { background: #ff6b35; color: #fff; }
|
|
|
+.step.done .step-dot { background: #52c41a; color: #fff; }
|
|
|
+.step .step-label { font-size: 12px; color: #999; display: block; }
|
|
|
+.step.active .step-label { color: #ff6b35; font-weight: 500; }
|
|
|
+.step::after { content: ''; position: absolute; top: 14px; left: 55%; right: -45%; height: 2px; background: #e8e8e8; }
|
|
|
+.step:last-child::after { display: none; }
|
|
|
+.step.done::after { background: #52c41a; }
|
|
|
+
|
|
|
+/* Empty state */
|
|
|
+.empty { text-align: center; padding: 40px 20px; color: #999; }
|
|
|
+.empty .icon { font-size: 48px; margin-bottom: 12px; }
|
|
|
+.empty p { font-size: 14px; margin-bottom: 16px; }
|
|
|
+
|
|
|
+/* Toast */
|
|
|
+.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #52c41a; color: #fff; padding: 10px 24px; border-radius: 6px; font-size: 14px; z-index: 300; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
|
|
|
+.toast.show { display: block; animation: fadeInOut 2s ease; }
|
|
|
+@keyframes fadeInOut { 0% { opacity: 0; transform: translateX(-50%) translateY(-10px); } 15% { opacity: 1; transform: translateX(-50%) translateY(0); } 80% { opacity: 1; } 100% { opacity: 0; } }
|
|
|
+
|
|
|
+/* Tabs */
|
|
|
+.tabs { display: flex; border-bottom: 2px solid #f0f0f0; margin-bottom: 16px; }
|
|
|
+.tab-btn { padding: 10px 20px; font-size: 14px; color: #666; cursor: pointer; border: none; background: none; position: relative; font-weight: 500; }
|
|
|
+.tab-btn.active { color: #ff6b35; }
|
|
|
+.tab-btn.active::after { content: ''; position: absolute; bottom: -2px; left: 0; right: 0; height: 2px; background: #ff6b35; }
|
|
|
+.tab-panel { display: none; }
|
|
|
+.tab-panel.active { display: block; }
|
|
|
+
|
|
|
+/* Coupon batch card */
|
|
|
+.coupon-card { border: 1px solid #e8e8e8; border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; position: relative; }
|
|
|
+.coupon-card::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; background: #ff6b35; border-radius: 0 2px 2px 0; }
|
|
|
+.coupon-card .coupon-name { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
|
|
|
+.coupon-card .coupon-info { font-size: 12px; color: #999; display: flex; gap: 16px; }
|
|
|
+.coupon-card .coupon-stock { margin-top: 8px; }
|
|
|
+.stock-bar { height: 4px; background: #f0f0f0; border-radius: 2px; margin-top: 4px; }
|
|
|
+.stock-fill { height: 100%; background: #ff6b35; border-radius: 2px; transition: width 0.3s; }
|
|
|
+
|
|
|
+/* Divider */
|
|
|
+.divider { border: none; border-top: 1px dashed #e8e8e8; margin: 16px 0; }
|
|
|
+</style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+
|
|
|
+<div class="app">
|
|
|
+ <div class="header">
|
|
|
+ <div>
|
|
|
+ <h1>营销管理</h1>
|
|
|
+ <span class="store-name">🍔 好味道快餐店</span>
|
|
|
+ </div>
|
|
|
+ <button class="btn btn-primary" onclick="openDrawer('promotion')">+ 创建促销活动</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="content">
|
|
|
+ <!-- Tabs -->
|
|
|
+ <div class="tabs">
|
|
|
+ <button class="tab-btn active" onclick="switchMainTab('promotions')">促销活动</button>
|
|
|
+ <button class="tab-btn" onclick="switchMainTab('coupons')">优惠券管理</button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Promotions Tab -->
|
|
|
+ <div id="panel-promotions" class="tab-panel active">
|
|
|
+ <div class="mutex-warning">
|
|
|
+ <span class="icon">⚠️</span>
|
|
|
+ <div class="text">
|
|
|
+ <strong>互斥规则:</strong>满减、折扣商品、第二份半价三种活动同一时间只能开启一种。新客立减可与以上任意一种叠加使用。
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-header">
|
|
|
+ <h3>活动列表</h3>
|
|
|
+ </div>
|
|
|
+ <div id="promo-list">
|
|
|
+ <div class="promo-item">
|
|
|
+ <div class="promo-info">
|
|
|
+ <div class="name"><span class="promo-type-icon type-manjian">减</span> 全场满减</div>
|
|
|
+ <div class="detail"><span>满20减5 / 满40减12 / 满60减20</span><span>2026-06-01 ~ 2026-06-30</span></div>
|
|
|
+ </div>
|
|
|
+ <div style="display:flex;align-items:center;gap:8px;">
|
|
|
+ <span class="tag tag-active">进行中</span>
|
|
|
+ <button class="btn btn-sm btn-danger" onclick="endPromo(this)">结束</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="promo-item">
|
|
|
+ <div class="promo-info">
|
|
|
+ <div class="name"><span class="promo-type-icon type-xinke">新</span> 新客立减</div>
|
|
|
+ <div class="detail"><span>新客立减3元</span><span>2026-06-01 ~ 2026-06-30</span></div>
|
|
|
+ </div>
|
|
|
+ <div style="display:flex;align-items:center;gap:8px;">
|
|
|
+ <span class="tag tag-active">进行中</span>
|
|
|
+ <button class="btn btn-sm btn-danger" onclick="endPromo(this)">结束</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-header"><h3>已结束活动</h3></div>
|
|
|
+ <div>
|
|
|
+ <div class="promo-item" style="opacity:0.5">
|
|
|
+ <div class="promo-info">
|
|
|
+ <div class="name"><span class="promo-type-icon type-zhekou">折</span> 夏日折扣</div>
|
|
|
+ <div class="detail"><span>3个商品参加折扣</span><span>2026-05-01 ~ 2026-05-15</span></div>
|
|
|
+ </div>
|
|
|
+ <span class="tag tag-expired">已结束</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- Coupons Tab -->
|
|
|
+ <div id="panel-coupons" class="tab-panel">
|
|
|
+ <div class="card">
|
|
|
+ <div class="card-header">
|
|
|
+ <h3>优惠券列表</h3>
|
|
|
+ <button class="btn btn-primary btn-sm" onclick="openDrawer('coupon')">+ 创建优惠券</button>
|
|
|
+ </div>
|
|
|
+ <div id="coupon-list">
|
|
|
+ <div class="coupon-card">
|
|
|
+ <div class="coupon-name">满30减5优惠券(同享券)</div>
|
|
|
+ <div class="coupon-info">
|
|
|
+ <span>满减券 / 同享</span>
|
|
|
+ <span>有效期 7天</span>
|
|
|
+ <span>已领 45/100</span>
|
|
|
+ </div>
|
|
|
+ <div class="coupon-stock">
|
|
|
+ <div class="stock-bar"><div class="stock-fill" style="width:45%"></div></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="coupon-card">
|
|
|
+ <div class="coupon-name">宫保鸡丁5折券</div>
|
|
|
+ <div class="coupon-info">
|
|
|
+ <span>商品券 / 折扣券</span>
|
|
|
+ <span>有效期 30天</span>
|
|
|
+ <span>已领 23/50</span>
|
|
|
+ </div>
|
|
|
+ <div class="coupon-stock">
|
|
|
+ <div class="stock-bar"><div class="stock-fill" style="width:46%"></div></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+<!-- Drawer Overlay -->
|
|
|
+<div class="drawer-overlay" id="drawer-overlay" onclick="closeDrawer()"></div>
|
|
|
+
|
|
|
+<!-- Drawer -->
|
|
|
+<div class="drawer" id="drawer">
|
|
|
+ <div class="drawer-header">
|
|
|
+ <h2 id="drawer-title">创建促销活动</h2>
|
|
|
+ <button class="drawer-close" onclick="closeDrawer()">✕</button>
|
|
|
+ </div>
|
|
|
+ <div class="drawer-body" id="drawer-body">
|
|
|
+ <!-- Dynamic content -->
|
|
|
+ </div>
|
|
|
+ <div class="drawer-footer" id="drawer-footer">
|
|
|
+ <button class="btn btn-default" onclick="closeDrawer()">取消</button>
|
|
|
+ <button class="btn btn-primary" id="drawer-confirm" onclick="confirmCreate()">确认创建</button>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+
|
|
|
+<!-- Toast -->
|
|
|
+<div class="toast" id="toast"></div>
|
|
|
+
|
|
|
+<script>
|
|
|
+// Products data
|
|
|
+const products = [
|
|
|
+ { id: 1, name: '宫保鸡丁', price: 20, emoji: '🍗' },
|
|
|
+ { id: 2, name: '麻婆豆腐', price: 18, emoji: '🥘' },
|
|
|
+ { id: 3, name: '可乐', price: 6, emoji: '🥤' },
|
|
|
+ { id: 4, name: '雪碧', price: 6, emoji: '🧊' },
|
|
|
+ { id: 5, name: '薯条', price: 8, emoji: '🍟' },
|
|
|
+ { id: 6, name: '鸡腿饭', price: 25, emoji: '🍚' },
|
|
|
+ { id: 7, name: '酸辣汤', price: 12, emoji: '🍲' },
|
|
|
+ { id: 8, name: '鸡蛋炒饭', price: 15, emoji: '🍳' },
|
|
|
+ { id: 9, name: '红烧肉', price: 28, emoji: '🥩' },
|
|
|
+ { id: 10, name: '青菜', price: 10, emoji: '🥬' },
|
|
|
+];
|
|
|
+
|
|
|
+let currentType = null;
|
|
|
+let selectedProducts = {};
|
|
|
+let drawerMode = '';
|
|
|
+
|
|
|
+function switchMainTab(name) {
|
|
|
+ document.querySelectorAll('.tab-btn').forEach((b, i) => b.classList.toggle('active', ['promotions','coupons'][i] === name));
|
|
|
+ document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
|
|
|
+ document.getElementById('panel-' + name).classList.add('active');
|
|
|
+}
|
|
|
+
|
|
|
+function openDrawer(mode) {
|
|
|
+ drawerMode = mode;
|
|
|
+ currentType = null;
|
|
|
+ selectedProducts = {};
|
|
|
+ document.getElementById('drawer-overlay').classList.add('show');
|
|
|
+ document.getElementById('drawer').classList.add('show');
|
|
|
+ document.getElementById('drawer-title').textContent = mode === 'promotion' ? '创建促销活动' : '创建优惠券';
|
|
|
+ renderDrawerContent();
|
|
|
+}
|
|
|
+
|
|
|
+function closeDrawer() {
|
|
|
+ document.getElementById('drawer-overlay').classList.remove('show');
|
|
|
+ document.getElementById('drawer').classList.remove('show');
|
|
|
+}
|
|
|
+
|
|
|
+function renderDrawerContent() {
|
|
|
+ const body = document.getElementById('drawer-body');
|
|
|
+ if (drawerMode === 'promotion') {
|
|
|
+ renderPromotionForm(body);
|
|
|
+ } else {
|
|
|
+ renderCouponForm(body);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function renderPromotionForm(body) {
|
|
|
+ body.innerHTML = `
|
|
|
+ <div class="steps" id="form-steps">
|
|
|
+ <div class="step active" id="step1"><span class="step-dot">1</span><span class="step-label">选择类型</span></div>
|
|
|
+ <div class="step" id="step2"><span class="step-dot">2</span><span class="step-label">设置规则</span></div>
|
|
|
+ <div class="step" id="step3"><span class="step-dot">3</span><span class="step-label">确认提交</span></div>
|
|
|
+ </div>
|
|
|
+ <div id="step-content">
|
|
|
+ ${renderStep1()}
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function renderStep1() {
|
|
|
+ const hasActive = { manjian: true, zhekou: false, ban: false }; // simulate: 满减 is active
|
|
|
+ return `
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 选择促销类型</label>
|
|
|
+ <div class="type-selector">
|
|
|
+ <div class="type-card ${currentType==='manjian'?'selected':''} ${hasActive.manjian?'disabled':''}"
|
|
|
+ onclick="${hasActive.manjian?'':'selectType(\"manjian\")'}">
|
|
|
+ <div class="icon">📦</div>
|
|
|
+ <div class="label">满减</div>
|
|
|
+ <div class="desc">订单满X减Y</div>
|
|
|
+ ${hasActive.manjian?'<div style="font-size:10px;color:#999;margin-top:4px">已有进行中活动</div>':''}
|
|
|
+ </div>
|
|
|
+ <div class="type-card ${currentType==='zhekou'?'selected':''} ${hasActive.zhekou?'disabled':''}"
|
|
|
+ onclick="${hasActive.zhekou?'':'selectType(\"zhekou\")'}">
|
|
|
+ <div class="icon">🏷️</div>
|
|
|
+ <div class="label">折扣商品</div>
|
|
|
+ <div class="desc">指定商品打折</div>
|
|
|
+ ${hasActive.zhekou?'<div style="font-size:10px;color:#999;margin-top:4px">与满减互斥</div>':''}
|
|
|
+ </div>
|
|
|
+ <div class="type-card ${currentType==='ban'?'selected':''} ${hasActive.ban?'disabled':''}"
|
|
|
+ onclick="${hasActive.ban?'':'selectType(\"ban\")'}">
|
|
|
+ <div class="icon">🔄</div>
|
|
|
+ <div class="label">第二份半价</div>
|
|
|
+ <div class="desc">买2件第2件半价</div>
|
|
|
+ ${hasActive.ban?'<div style="font-size:10px;color:#999;margin-top:4px">与满减互斥</div>':''}
|
|
|
+ </div>
|
|
|
+ <div class="type-card ${currentType==='xinke'?'selected':''}" onclick="selectType('xinke')">
|
|
|
+ <div class="icon">🆕</div>
|
|
|
+ <div class="label">新客立减</div>
|
|
|
+ <div class="desc">首次下单减X元</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="text-align:right;margin-top:20px;">
|
|
|
+ <button class="btn btn-primary" onclick="goStep2()" ${currentType?'':'disabled'} id="next-step1">下一步 →</button>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function selectType(type) {
|
|
|
+ currentType = type;
|
|
|
+ renderDrawerContent();
|
|
|
+}
|
|
|
+
|
|
|
+function goStep2() {
|
|
|
+ if (!currentType) return;
|
|
|
+ document.getElementById('step1').className = 'step done';
|
|
|
+ document.getElementById('step2').className = 'step active';
|
|
|
+ const content = document.getElementById('step-content');
|
|
|
+ content.innerHTML = renderStep2Content();
|
|
|
+}
|
|
|
+
|
|
|
+function renderStep2Content() {
|
|
|
+ let html = '';
|
|
|
+ if (currentType === 'manjian') {
|
|
|
+ html = renderManjianForm();
|
|
|
+ } else if (currentType === 'zhekou') {
|
|
|
+ html = renderZhekouForm();
|
|
|
+ } else if (currentType === 'ban') {
|
|
|
+ html = renderBanForm();
|
|
|
+ } else if (currentType === 'xinke') {
|
|
|
+ html = renderXinkeForm();
|
|
|
+ }
|
|
|
+ html += `
|
|
|
+ <hr class="divider">
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label">活动时间</label>
|
|
|
+ <div style="display:flex;gap:10px;align-items:center;">
|
|
|
+ <input type="date" class="form-input" style="width:auto" value="2026-06-01">
|
|
|
+ <span>~</span>
|
|
|
+ <input type="date" class="form-input" style="width:auto" value="2026-06-30">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div style="display:flex;justify-content:space-between;margin-top:20px;">
|
|
|
+ <button class="btn btn-default" onclick="goBackStep1()">← 上一步</button>
|
|
|
+ <button class="btn btn-primary" onclick="goStep3()">下一步 →</button>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ return html;
|
|
|
+}
|
|
|
+
|
|
|
+function renderManjianForm() {
|
|
|
+ return `
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 设置满减档位</label>
|
|
|
+ <div class="form-hint" style="margin-bottom:12px">建议根据客单价分布设置2-3个档位,每个档位自动匹配最优</div>
|
|
|
+ <div id="tier-list">
|
|
|
+ <div class="tier-row" data-tier="0">
|
|
|
+ <span class="tier-text">满</span>
|
|
|
+ <input class="tier-input" type="number" placeholder="20" value="20">
|
|
|
+ <span class="tier-text">减</span>
|
|
|
+ <input class="tier-input" type="number" placeholder="5" value="5">
|
|
|
+ <span class="tier-text">元</span>
|
|
|
+ </div>
|
|
|
+ <div class="tier-row" data-tier="1">
|
|
|
+ <span class="tier-text">满</span>
|
|
|
+ <input class="tier-input" type="number" placeholder="40" value="40">
|
|
|
+ <span class="tier-text">减</span>
|
|
|
+ <input class="tier-input" type="number" placeholder="12" value="12">
|
|
|
+ <span class="tier-text">元</span>
|
|
|
+ <button class="tier-remove" onclick="removeTier(this)">✕</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <button class="add-tier" onclick="addTier()">+ 添加档位</button>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function renderZhekouForm() {
|
|
|
+ return `
|
|
|
+ <div class="mutex-warning" style="margin-bottom:16px;">
|
|
|
+ <span class="icon">💡</span>
|
|
|
+ <div class="text">
|
|
|
+ <strong>操作说明:</strong>从下方商品列表中勾选要参加折扣的商品,<strong>每个商品可以设置不同的折扣率</strong>。
|
|
|
+ 用户下单时,参加折扣的商品按折扣价计算,未参加的商品仍按原价。折扣商品和满减活动互斥,用户系统自动选最优。
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 选择折扣商品并设置折扣率</label>
|
|
|
+ <div class="product-select-area">
|
|
|
+ <div class="product-search">
|
|
|
+ <input type="text" placeholder="🔍 搜索商品名称..." oninput="filterProducts(this.value)">
|
|
|
+ </div>
|
|
|
+ <div class="product-list" id="product-list">
|
|
|
+ ${products.map(p => renderProductItem(p)).join('')}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="selected-summary" id="selected-summary" style="display:none;">
|
|
|
+ <div class="title">已选商品(点击折扣率可修改)</div>
|
|
|
+ <div id="selected-items"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function renderProductItem(p) {
|
|
|
+ const sel = selectedProducts[p.id];
|
|
|
+ return `
|
|
|
+ <div class="product-item ${sel?'selected':''}" id="pitem-${p.id}">
|
|
|
+ <div class="product-check" onclick="toggleProduct(${p.id})">${sel?'✓':''}</div>
|
|
|
+ <div class="product-img">${p.emoji}</div>
|
|
|
+ <div class="product-meta">
|
|
|
+ <div class="pname">${p.name}</div>
|
|
|
+ <div class="pprice">原价 ¥${p.price}</div>
|
|
|
+ </div>
|
|
|
+ <div class="product-rate" id="prate-${p.id}" style="${sel?'':'opacity:0.3;pointer-events:none'}">
|
|
|
+ <input type="number" value="${sel?sel.rate:7}" min="1" max="9" step="0.1" onchange="updateRate(${p.id}, this.value)" style="width:48px"> <span>折</span>
|
|
|
+ </div>
|
|
|
+ <div class="product-result" id="presult-${p.id}">${sel?'¥'+(p.price*sel.rate/10).toFixed(1):'-'}</div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function toggleProduct(id) {
|
|
|
+ if (selectedProducts[id]) {
|
|
|
+ delete selectedProducts[id];
|
|
|
+ } else {
|
|
|
+ const p = products.find(x => x.id === id);
|
|
|
+ selectedProducts[id] = { rate: 7 }; // default 7折
|
|
|
+ }
|
|
|
+ refreshProductUI();
|
|
|
+}
|
|
|
+
|
|
|
+function updateRate(id, val) {
|
|
|
+ const rate = parseFloat(val) || 7;
|
|
|
+ selectedProducts[id].rate = rate;
|
|
|
+ refreshProductUI();
|
|
|
+}
|
|
|
+
|
|
|
+function refreshProductUI() {
|
|
|
+ const list = document.getElementById('product-list');
|
|
|
+ list.innerHTML = products.map(p => renderProductItem(p)).join('');
|
|
|
+ updateSelectedSummary();
|
|
|
+}
|
|
|
+
|
|
|
+function updateSelectedSummary() {
|
|
|
+ const summary = document.getElementById('selected-summary');
|
|
|
+ const items = document.getElementById('selected-items');
|
|
|
+ const ids = Object.keys(selectedProducts);
|
|
|
+ if (ids.length === 0) {
|
|
|
+ summary.style.display = 'none';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ summary.style.display = 'block';
|
|
|
+ items.innerHTML = ids.map(id => {
|
|
|
+ const p = products.find(x => x.id == id);
|
|
|
+ const rate = selectedProducts[id].rate;
|
|
|
+ const result = (p.price * rate / 10).toFixed(1);
|
|
|
+ return `
|
|
|
+ <div class="selected-item">
|
|
|
+ <span class="sname">${p.emoji} ${p.name}(原价¥${p.price})</span>
|
|
|
+ <span class="srate">${rate}折</span>
|
|
|
+ <span class="sresult">→ ¥${result}</span>
|
|
|
+ <span class="sremove" onclick="toggleProduct(${p.id})">移除</span>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ }).join('');
|
|
|
+}
|
|
|
+
|
|
|
+function filterProducts(keyword) {
|
|
|
+ const filtered = products.filter(p => p.name.includes(keyword));
|
|
|
+ document.getElementById('product-list').innerHTML = filtered.map(p => renderProductItem(p)).join('');
|
|
|
+ updateSelectedSummary();
|
|
|
+}
|
|
|
+
|
|
|
+function renderBanForm() {
|
|
|
+ return `
|
|
|
+ <div class="mutex-warning" style="margin-bottom:16px;">
|
|
|
+ <span class="icon">💡</span>
|
|
|
+ <div class="text">
|
|
|
+ <strong>操作说明:</strong>从商品列表中勾选参加"第二份半价"的商品。用户买2件同一商品时,第2件自动半价。
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 选择参加第二份半价的商品</label>
|
|
|
+ <div class="product-select-area">
|
|
|
+ <div class="product-list" id="product-list">
|
|
|
+ ${products.map(p => {
|
|
|
+ const sel = selectedProducts[p.id];
|
|
|
+ return `
|
|
|
+ <div class="product-item ${sel?'selected':''}" id="pitem-${p.id}">
|
|
|
+ <div class="product-check" onclick="toggleBanProduct(${p.id})">${sel?'✓':''}</div>
|
|
|
+ <div class="product-img">${p.emoji}</div>
|
|
|
+ <div class="product-meta">
|
|
|
+ <div class="pname">${p.name}</div>
|
|
|
+ <div class="pprice">原价 ¥${p.price} → 第2件 ¥${(p.price*0.5).toFixed(1)}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ }).join('')}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function toggleBanProduct(id) {
|
|
|
+ if (selectedProducts[id]) {
|
|
|
+ delete selectedProducts[id];
|
|
|
+ } else {
|
|
|
+ selectedProducts[id] = true;
|
|
|
+ }
|
|
|
+ document.getElementById('product-list').innerHTML = products.map(p => {
|
|
|
+ const sel = selectedProducts[p.id];
|
|
|
+ return `
|
|
|
+ <div class="product-item ${sel?'selected':''}" id="pitem-${p.id}">
|
|
|
+ <div class="product-check" onclick="toggleBanProduct(${p.id})">${sel?'✓':''}</div>
|
|
|
+ <div class="product-img">${p.emoji}</div>
|
|
|
+ <div class="product-meta">
|
|
|
+ <div class="pname">${p.name}</div>
|
|
|
+ <div class="pprice">原价 ¥${p.price} → 第2件 ¥${(p.price*0.5).toFixed(1)}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ }).join('');
|
|
|
+}
|
|
|
+
|
|
|
+function renderXinkeForm() {
|
|
|
+ return `
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 新客立减金额</label>
|
|
|
+ <div style="display:flex;align-items:center;gap:8px;">
|
|
|
+ <span style="font-size:14px;color:#666;">首次在本店下单减</span>
|
|
|
+ <input class="tier-input" type="number" value="3" style="width:80px">
|
|
|
+ <span style="font-size:14px;color:#666;">元</span>
|
|
|
+ </div>
|
|
|
+ <div class="form-hint">建议设置2-5元,可与满减/折扣/第二份半价叠加使用</div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function addTier() {
|
|
|
+ const list = document.getElementById('tier-list');
|
|
|
+ const count = list.children.length;
|
|
|
+ const row = document.createElement('div');
|
|
|
+ row.className = 'tier-row';
|
|
|
+ row.dataset.tier = count;
|
|
|
+ row.innerHTML = `
|
|
|
+ <span class="tier-text">满</span>
|
|
|
+ <input class="tier-input" type="number" placeholder="60">
|
|
|
+ <span class="tier-text">减</span>
|
|
|
+ <input class="tier-input" type="number" placeholder="20">
|
|
|
+ <span class="tier-text">元</span>
|
|
|
+ <button class="tier-remove" onclick="removeTier(this)">✕</button>
|
|
|
+ `;
|
|
|
+ list.appendChild(row);
|
|
|
+}
|
|
|
+
|
|
|
+function removeTier(btn) {
|
|
|
+ btn.parentElement.remove();
|
|
|
+}
|
|
|
+
|
|
|
+function goBackStep1() {
|
|
|
+ document.getElementById('step1').className = 'step active';
|
|
|
+ document.getElementById('step2').className = 'step';
|
|
|
+ document.getElementById('step-content').innerHTML = renderStep1();
|
|
|
+}
|
|
|
+
|
|
|
+function goStep3() {
|
|
|
+ document.getElementById('step2').className = 'step done';
|
|
|
+ document.getElementById('step3').className = 'step active';
|
|
|
+ document.getElementById('step-content').innerHTML = renderStep3();
|
|
|
+ document.getElementById('drawer-footer').innerHTML = `
|
|
|
+ <button class="btn btn-default" onclick="goBackStep2()">上一步</button>
|
|
|
+ <button class="btn btn-primary" onclick="confirmCreate()">✓ 确认创建</button>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function renderStep3() {
|
|
|
+ let summary = '';
|
|
|
+ const typeNames = { manjian: '满减活动', zhekou: '折扣商品', ban: '第二份半价', xinke: '新客立减' };
|
|
|
+ summary += `<div style="margin-bottom:12px;font-size:15px;font-weight:600;">📋 创建确认</div>`;
|
|
|
+ summary += `<div style="font-size:14px;margin-bottom:4px;"><strong>类型:</strong>${typeNames[currentType]}</div>`;
|
|
|
+
|
|
|
+ if (currentType === 'manjian') {
|
|
|
+ summary += `<div style="font-size:14px;margin-bottom:4px;"><strong>档位:</strong></div>`;
|
|
|
+ summary += `<div style="background:#fafafa;padding:10px;border-radius:6px;margin-bottom:12px;">`;
|
|
|
+ document.querySelectorAll('.tier-row').forEach(row => {
|
|
|
+ const inputs = row.querySelectorAll('.tier-input');
|
|
|
+ summary += `<div style="font-size:13px;padding:2px 0;">满 <strong>${inputs[0].value}</strong> 减 <strong style="color:#ff6b35">${inputs[1].value}</strong> 元</div>`;
|
|
|
+ });
|
|
|
+ summary += `</div>`;
|
|
|
+ } else if (currentType === 'zhekou') {
|
|
|
+ const ids = Object.keys(selectedProducts);
|
|
|
+ summary += `<div style="font-size:14px;margin-bottom:4px;"><strong>折扣商品(${ids.length}个):</strong></div>`;
|
|
|
+ summary += `<div style="background:#fafafa;padding:10px;border-radius:6px;margin-bottom:12px;">`;
|
|
|
+ ids.forEach(id => {
|
|
|
+ const p = products.find(x => x.id == id);
|
|
|
+ const rate = selectedProducts[id].rate;
|
|
|
+ summary += `<div style="font-size:13px;padding:2px 0;">${p.emoji} ${p.name}:原价¥${p.price} → <strong style="color:#ff6b35">${rate}折 ¥${(p.price*rate/10).toFixed(1)}</strong></div>`;
|
|
|
+ });
|
|
|
+ summary += `</div>`;
|
|
|
+ } else if (currentType === 'ban') {
|
|
|
+ const ids = Object.keys(selectedProducts);
|
|
|
+ summary += `<div style="font-size:14px;margin-bottom:4px;"><strong>参加商品(${ids.length}个):</strong></div>`;
|
|
|
+ summary += `<div style="background:#fafafa;padding:10px;border-radius:6px;margin-bottom:12px;">`;
|
|
|
+ ids.forEach(id => {
|
|
|
+ const p = products.find(x => x.id == id);
|
|
|
+ summary += `<div style="font-size:13px;padding:2px 0;">${p.emoji} ${p.name}:买2件 = ¥${p.price} + ¥${(p.price*0.5).toFixed(1)} = <strong style="color:#ff6b35">¥${(p.price*1.5).toFixed(1)}</strong></div>`;
|
|
|
+ });
|
|
|
+ summary += `</div>`;
|
|
|
+ } else if (currentType === 'xinke') {
|
|
|
+ summary += `<div style="font-size:14px;margin-bottom:4px;">新客首次下单减 <strong style="color:#ff6b35">3元</strong></div>`;
|
|
|
+ }
|
|
|
+
|
|
|
+ summary += `<div style="font-size:14px;"><strong>活动时间:</strong>2026-06-01 ~ 2026-06-30</div>`;
|
|
|
+ summary += `<div class="mutex-warning" style="margin-top:16px;">
|
|
|
+ <span class="icon">⚠️</span>
|
|
|
+ <div class="text">
|
|
|
+ ${currentType === 'xinke' ? '新客立减可与满减/折扣/第二份半价叠加使用' : '创建此活动后,由于互斥规则,与当前进行中的<strong>满减活动</strong>将需要二选一。请确认是否继续。'}
|
|
|
+ </div>
|
|
|
+ </div>`;
|
|
|
+
|
|
|
+ return summary;
|
|
|
+}
|
|
|
+
|
|
|
+function goBackStep2() {
|
|
|
+ document.getElementById('step2').className = 'step active';
|
|
|
+ document.getElementById('step3').className = 'step';
|
|
|
+ document.getElementById('step-content').innerHTML = renderStep2Content();
|
|
|
+ document.getElementById('drawer-footer').innerHTML = `
|
|
|
+ <button class="btn btn-default" onclick="closeDrawer()">取消</button>
|
|
|
+ <button class="btn btn-primary" onclick="goStep3()">下一步 →</button>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function confirmCreate() {
|
|
|
+ closeDrawer();
|
|
|
+ showToast('✓ 促销活动创建成功!');
|
|
|
+}
|
|
|
+
|
|
|
+function endPromo(btn) {
|
|
|
+ if (confirm('确定要结束此活动吗?结束后不可恢复。')) {
|
|
|
+ const item = btn.closest('.promo-item');
|
|
|
+ item.querySelector('.tag').className = 'tag tag-expired';
|
|
|
+ item.querySelector('.tag').textContent = '已结束';
|
|
|
+ item.style.opacity = '0.5';
|
|
|
+ btn.remove();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function showToast(msg) {
|
|
|
+ const toast = document.getElementById('toast');
|
|
|
+ toast.textContent = msg;
|
|
|
+ toast.classList.add('show');
|
|
|
+ setTimeout(() => toast.classList.remove('show'), 2000);
|
|
|
+}
|
|
|
+
|
|
|
+// Coupon form
|
|
|
+function renderCouponForm(body) {
|
|
|
+ body.innerHTML = `
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 优惠券名称</label>
|
|
|
+ <input class="form-input" placeholder="如:满30减5优惠券" value="满30减5优惠券">
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 券类型</label>
|
|
|
+ <div style="display:flex;gap:10px;">
|
|
|
+ <div class="type-card selected" style="flex:1" onclick="selectCouponType(this, 'manjian')">
|
|
|
+ <div class="label">满减券</div>
|
|
|
+ <div class="desc">满X减Y元</div>
|
|
|
+ </div>
|
|
|
+ <div class="type-card" style="flex:1" onclick="selectCouponType(this, 'shangpin')">
|
|
|
+ <div class="label">商品券</div>
|
|
|
+ <div class="desc">指定商品折扣/兑换</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div id="coupon-rule-area">
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label">同享/互斥</label>
|
|
|
+ <div style="display:flex;gap:10px;">
|
|
|
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer;font-size:14px;">
|
|
|
+ <input type="radio" name="mutex" value="0" checked> 同享券(可与满减叠加)
|
|
|
+ </label>
|
|
|
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer;font-size:14px;">
|
|
|
+ <input type="radio" name="mutex" value="1"> 互斥券(不可与满减叠加)
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 使用门槛</label>
|
|
|
+ <div style="display:flex;align-items:center;gap:8px;">
|
|
|
+ <span style="font-size:14px;color:#666;">满</span>
|
|
|
+ <input class="tier-input" type="number" value="30" style="width:80px">
|
|
|
+ <span style="font-size:14px;color:#666;">元可用,减</span>
|
|
|
+ <input class="tier-input" type="number" value="5" style="width:80px">
|
|
|
+ <span style="font-size:14px;color:#666;">元</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <hr class="divider">
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 发放总量</label>
|
|
|
+ <input class="form-input" type="number" value="100" style="width:200px">
|
|
|
+ <div class="form-hint">每个用户限领1张</div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 领取时间</label>
|
|
|
+ <div style="display:flex;gap:10px;align-items:center;">
|
|
|
+ <input type="date" class="form-input" style="width:auto" value="2026-06-01">
|
|
|
+ <span>~</span>
|
|
|
+ <input type="date" class="form-input" style="width:auto" value="2026-06-30">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 领取后有效天数</label>
|
|
|
+ <div style="display:flex;gap:10px;align-items:center;">
|
|
|
+ <input class="form-input" type="number" value="7" style="width:100px">
|
|
|
+ <span style="font-size:14px;color:#666;">天</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="mutex-warning">
|
|
|
+ <span class="icon">💡</span>
|
|
|
+ <div class="text">
|
|
|
+ 发放方式:<strong>店内领券</strong> — 用户进入店铺时可在领券区看到并领取,下单时手动选择使用。
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+}
|
|
|
+
|
|
|
+function selectCouponType(el, type) {
|
|
|
+ el.parentElement.querySelectorAll('.type-card').forEach(c => c.classList.remove('selected'));
|
|
|
+ el.classList.add('selected');
|
|
|
+ const area = document.getElementById('coupon-rule-area');
|
|
|
+ if (type === 'shangpin') {
|
|
|
+ area.innerHTML = `
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label">商品券类型</label>
|
|
|
+ <div style="display:flex;gap:10px;">
|
|
|
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer;font-size:14px;">
|
|
|
+ <input type="radio" name="sp_type" value="discount" checked> 折扣券(指定商品X折)
|
|
|
+ </label>
|
|
|
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer;font-size:14px;">
|
|
|
+ <input type="radio" name="sp_type" value="exchange"> 抵用券(指定商品免费兑换)
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 选择适用商品</label>
|
|
|
+ <div class="product-select-area">
|
|
|
+ <div class="product-list" style="max-height:200px;">
|
|
|
+ ${products.slice(0,6).map(p => `
|
|
|
+ <div class="product-item" onclick="this.classList.toggle('selected');this.querySelector('.product-check').innerHTML=this.classList.contains('selected')?'✓':'';">
|
|
|
+ <div class="product-check"></div>
|
|
|
+ <div class="product-img">${p.emoji}</div>
|
|
|
+ <div class="product-meta">
|
|
|
+ <div class="pname">${p.name}</div>
|
|
|
+ <div class="pprice">¥${p.price}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `).join('')}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 折扣率</label>
|
|
|
+ <div style="display:flex;align-items:center;gap:8px;">
|
|
|
+ <input class="tier-input" type="number" value="5" step="0.1" style="width:80px">
|
|
|
+ <span style="font-size:14px;color:#666;">折</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ } else {
|
|
|
+ area.innerHTML = `
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label">同享/互斥</label>
|
|
|
+ <div style="display:flex;gap:10px;">
|
|
|
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer;font-size:14px;">
|
|
|
+ <input type="radio" name="mutex" value="0" checked> 同享券(可与满减叠加)
|
|
|
+ </label>
|
|
|
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer;font-size:14px;">
|
|
|
+ <input type="radio" name="mutex" value="1"> 互斥券(不可与满减叠加)
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="form-label"><span class="required">*</span> 使用门槛</label>
|
|
|
+ <div style="display:flex;align-items:center;gap:8px;">
|
|
|
+ <span style="font-size:14px;color:#666;">满</span>
|
|
|
+ <input class="tier-input" type="number" value="30" style="width:80px">
|
|
|
+ <span style="font-size:14px;color:#666;">元可用,减</span>
|
|
|
+ <input class="tier-input" type="number" value="5" style="width:80px">
|
|
|
+ <span style="font-size:14px;color:#666;">元</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `;
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+</body>
|
|
|
+</html>
|