| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546 |
- <!DOCTYPE html>
- <html lang="zh-TW">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
- <title>美團外賣 - 結算頁優惠券選擇 Demo</title>
- <style>
- * { margin: 0; padding: 0; box-sizing: border-box; }
- body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang TC', 'Microsoft JhengHei', sans-serif; background: #f5f5f5; color: #333; }
- .phone-frame {
- width: 375px; height: 812px; margin: 20px auto;
- border: 3px solid #333; border-radius: 40px; overflow: hidden;
- background: #f5f5f5; position: relative;
- box-shadow: 0 10px 40px rgba(0,0,0,0.2);
- }
- /* Header */
- .header {
- background: linear-gradient(135deg, #FFD100, #FFB800);
- padding: 44px 16px 12px; position: sticky; top: 0; z-index: 10;
- }
- .header h1 { font-size: 18px; font-weight: 600; text-align: center; }
- /* Scrollable content */
- .content { height: calc(812px - 56px - 60px); overflow-y: auto; padding-bottom: 20px; }
- /* Section card */
- .card {
- background: #fff; margin: 10px 12px; border-radius: 12px;
- padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
- }
- /* Address */
- .address-section { display: flex; align-items: center; gap: 10px; }
- .address-icon { font-size: 22px; }
- .address-info { flex: 1; }
- .address-name { font-size: 15px; font-weight: 600; }
- .address-name span { font-weight: 400; color: #999; margin-left: 8px; font-size: 13px; }
- .address-detail { font-size: 13px; color: #666; margin-top: 2px; }
- .address-arrow { color: #ccc; font-size: 16px; }
- /* Items */
- .section-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; color: #333; }
- .merchant-tag {
- display: inline-block; background: #FFF3E0; color: #FF8C00;
- font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-left: 8px; font-weight: 400;
- }
- .order-item {
- display: flex; justify-content: space-between; align-items: center;
- padding: 8px 0; border-bottom: 1px solid #f5f5f5;
- }
- .order-item:last-child { border-bottom: none; }
- .item-name { font-size: 14px; color: #333; }
- .item-name .qty { color: #999; margin-left: 4px; font-size: 12px; }
- .item-price { font-size: 14px; color: #333; }
- .subtotal-row { display: flex; justify-content: space-between; padding-top: 10px; border-top: 1px dashed #eee; margin-top: 4px; }
- .subtotal-label { font-size: 14px; color: #666; }
- .subtotal-amount { font-size: 15px; font-weight: 600; }
- /* Discount section */
- .discount-item {
- display: flex; justify-content: space-between; align-items: center;
- padding: 10px 0; border-bottom: 1px solid #f8f8f8;
- }
- .discount-item:last-child { border-bottom: none; }
- .discount-left { display: flex; align-items: center; gap: 8px; flex: 1; }
- .discount-label { font-size: 14px; color: #333; }
- .discount-tag {
- font-size: 10px; padding: 1px 5px; border-radius: 3px; font-weight: 500;
- }
- .tag-auto { background: #E8F5E9; color: #4CAF50; }
- .tag-merchant { background: #FFF3E0; color: #FF8C00; }
- .tag-platform { background: #E3F2FD; color: #1E88E5; }
- .discount-amount { font-size: 14px; color: #FF5722; font-weight: 500; }
- .discount-select {
- display: flex; align-items: center; gap: 4px;
- font-size: 13px; color: #999; cursor: pointer;
- }
- .discount-select .arrow { font-size: 14px; transition: transform 0.2s; }
- /* Fee rows */
- .fee-row {
- display: flex; justify-content: space-between; padding: 6px 0;
- font-size: 13px; color: #999;
- }
- /* Total bar */
- .total-bar {
- display: flex; justify-content: space-between; align-items: center;
- padding-top: 12px; border-top: 1px solid #eee; margin-top: 4px;
- }
- .saved-amount { font-size: 13px; color: #FF5722; }
- .total-amount { font-size: 20px; font-weight: 700; color: #333; }
- .total-amount span { font-size: 13px; color: #999; margin-right: 4px; }
- /* Misc options */
- .misc-item {
- display: flex; justify-content: space-between; align-items: center;
- padding: 10px 0; border-bottom: 1px solid #f5f5f5;
- }
- .misc-item:last-child { border-bottom: none; }
- .misc-label { font-size: 14px; color: #333; }
- .misc-value { font-size: 13px; color: #999; display: flex; align-items: center; gap: 4px; }
- /* Submit button */
- .submit-bar {
- position: absolute; bottom: 0; left: 0; right: 0;
- background: #fff; padding: 10px 16px 28px;
- border-top: 1px solid #eee; display: flex; align-items: center; justify-content: space-between;
- }
- .submit-info { font-size: 13px; color: #999; }
- .submit-info .price { font-size: 22px; color: #FF5722; font-weight: 700; }
- .submit-btn {
- background: linear-gradient(135deg, #FFD100, #FFB800); border: none;
- padding: 12px 32px; border-radius: 24px; font-size: 16px;
- font-weight: 600; color: #333; cursor: pointer;
- }
- .submit-btn:hover { filter: brightness(1.05); }
- /* Bottom Sheet Overlay */
- .sheet-overlay {
- position: absolute; top: 0; left: 0; right: 0; bottom: 0;
- background: rgba(0,0,0,0.5); z-index: 100;
- opacity: 0; pointer-events: none; transition: opacity 0.3s;
- }
- .sheet-overlay.active { opacity: 1; pointer-events: auto; }
- /* Bottom Sheet */
- .bottom-sheet {
- position: absolute; bottom: 0; left: 0; right: 0;
- background: #fff; border-radius: 16px 16px 0 0;
- z-index: 101; transform: translateY(100%);
- transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
- max-height: 70%;
- }
- .bottom-sheet.active { transform: translateY(0); }
- .sheet-header {
- display: flex; justify-content: space-between; align-items: center;
- padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
- position: sticky; top: 0; background: #fff; z-index: 1;
- }
- .sheet-title { font-size: 16px; font-weight: 600; }
- .sheet-close {
- width: 28px; height: 28px; border-radius: 50%; background: #f0f0f0;
- display: flex; align-items: center; justify-content: center;
- font-size: 16px; color: #999; cursor: pointer; border: none;
- }
- .sheet-body { overflow-y: auto; max-height: calc(70vh - 56px); padding: 12px 16px 28px; }
- /* Coupon card */
- .coupon-card {
- display: flex; border-radius: 10px; margin-bottom: 10px;
- overflow: hidden; cursor: pointer; border: 2px solid transparent;
- transition: border-color 0.2s, opacity 0.2s;
- position: relative;
- }
- .coupon-card.selected { border-color: #FF5722; }
- .coupon-card.disabled { opacity: 0.5; cursor: not-allowed; }
- .coupon-amount-side {
- width: 90px; display: flex; flex-direction: column;
- align-items: center; justify-content: center;
- padding: 12px 8px; color: #fff;
- }
- .coupon-amount-side.merchant { background: linear-gradient(135deg, #FF8C00, #FF6D00); }
- .coupon-amount-side.platform { background: linear-gradient(135deg, #1E88E5, #1565C0); }
- .coupon-amount-side.disabled-bg { background: #bbb !important; }
- .coupon-symbol { font-size: 12px; }
- .coupon-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
- .coupon-condition { font-size: 10px; margin-top: 2px; opacity: 0.9; }
- .coupon-info-side {
- flex: 1; padding: 10px 14px; background: #fff;
- display: flex; flex-direction: column; justify-content: center;
- }
- .coupon-name { font-size: 14px; font-weight: 600; color: #333; }
- .coupon-desc { font-size: 12px; color: #999; margin-top: 3px; }
- .coupon-expire { font-size: 11px; color: #bbb; margin-top: 3px; }
- .coupon-reason { font-size: 11px; color: #FF5722; margin-top: 3px; }
- .coupon-check {
- position: absolute; top: 10px; right: 10px;
- width: 22px; height: 22px; border-radius: 50%;
- display: flex; align-items: center; justify-content: center;
- }
- .coupon-check.checked { background: #FF5722; color: #fff; }
- .coupon-check.unchecked { border: 1.5px solid #ddd; }
- .sheet-divider {
- text-align: center; color: #ccc; font-size: 12px;
- padding: 10px 0; position: relative;
- }
- .sheet-divider::before, .sheet-divider::after {
- content: ''; position: absolute; top: 50%; width: 30%;
- border-top: 1px solid #eee;
- }
- .sheet-divider::before { left: 0; }
- .sheet-divider::after { right: 0; }
- /* Tabs in sheet */
- .sheet-tabs {
- display: flex; border-bottom: 1px solid #f0f0f0; margin-bottom: 4px;
- }
- .sheet-tab {
- flex: 1; text-align: center; padding: 10px; font-size: 14px;
- color: #999; cursor: pointer; position: relative;
- }
- .sheet-tab.active { color: #333; font-weight: 600; }
- .sheet-tab.active::after {
- content: ''; position: absolute; bottom: 0; left: 30%; right: 30%;
- height: 3px; background: #FF5722; border-radius: 2px;
- }
- .sheet-tab .badge {
- display: inline-block; background: #FF5722; color: #fff;
- font-size: 10px; padding: 0 5px; border-radius: 8px;
- margin-left: 2px; vertical-align: top;
- }
- /* Realtime update flash */
- .flash { animation: flashHighlight 0.6s ease; }
- @keyframes flashHighlight {
- 0% { background: #FFF8E1; }
- 100% { background: transparent; }
- }
- /* Responsive */
- @media (max-width: 400px) {
- .phone-frame { width: 100%; height: 100vh; border: none; border-radius: 0; margin: 0; }
- .content { height: calc(100vh - 56px - 60px); }
- }
- </style>
- </head>
- <body>
- <div class="phone-frame">
- <div class="header">
- <h1>提交訂單</h1>
- </div>
- <div class="content">
- <!-- Address -->
- <div class="card">
- <div class="address-section">
- <div class="address-icon">📍</div>
- <div class="address-info">
- <div class="address-name">張先生<span>138****8888</span></div>
- <div class="address-detail">台北市中山區南京東路一段120號3樓</div>
- </div>
- <div class="address-arrow">›</div>
- </div>
- </div>
- <!-- Delivery time -->
- <div class="card" style="padding: 12px 16px;">
- <div style="display:flex; justify-content:space-between; align-items:center;">
- <span style="font-size:14px;">🕐 盡快送達(約25-35分鐘)</span>
- <span style="font-size:13px; color:#999;">›</span>
- </div>
- </div>
- <!-- Order items -->
- <div class="card">
- <div class="section-title">
- 好吃便當店
- <span class="merchant-tag">品牌</span>
- </div>
- <div class="order-item">
- <span class="item-name">招牌排骨便當<span class="qty">×1</span></span>
- <span class="item-price">¥85</span>
- </div>
- <div class="order-item">
- <span class="item-name">珍珠奶茶<span class="qty">×2</span></span>
- <span class="item-price">¥60</span>
- </div>
- <div class="subtotal-row">
- <span class="subtotal-label">小計</span>
- <span class="subtotal-amount">¥145</span>
- </div>
- </div>
- <!-- Discounts -->
- <div class="card" id="discountCard">
- <div class="section-title">優惠明細</div>
- <!-- 商家滿減 (auto) -->
- <div class="discount-item">
- <div class="discount-left">
- <span class="discount-label">商家滿減</span>
- <span class="discount-tag tag-auto">自動</span>
- </div>
- <span class="discount-amount" id="merchantPromo">-¥20</span>
- </div>
- <!-- 商家優惠券 (selectable) -->
- <div class="discount-item" id="merchantCouponRow" onclick="openSheet('merchant')">
- <div class="discount-left">
- <span class="discount-label">商家優惠券</span>
- <span class="discount-tag tag-merchant">選1張</span>
- </div>
- <div class="discount-select">
- <span class="discount-amount" id="merchantCouponAmount">-¥15</span>
- <span class="arrow">›</span>
- </div>
- </div>
- <!-- 平台紅包 (selectable) -->
- <div class="discount-item" id="platformCouponRow" onclick="openSheet('platform')">
- <div class="discount-left">
- <span class="discount-label">平台紅包</span>
- <span class="discount-tag tag-platform">選1張</span>
- </div>
- <div class="discount-select">
- <span class="discount-amount" id="platformCouponAmount">-¥18</span>
- <span class="arrow">›</span>
- </div>
- </div>
- <div style="height: 4px;"></div>
- <div class="fee-row">
- <span>配送費</span><span>¥15</span>
- </div>
- <div class="fee-row">
- <span>包裝費</span><span>¥5</span>
- </div>
- </div>
- <!-- Misc -->
- <div class="card">
- <div class="misc-item">
- <span class="misc-label">📝 備註</span>
- <span class="misc-value">口味偏好等<span>›</span></span>
- </div>
- <div class="misc-item">
- <span class="misc-label">🥢 餐具</span>
- <span class="misc-value">1份<span>›</span></span>
- </div>
- <div class="misc-item">
- <span class="misc-label">🧾 發票</span>
- <span class="misc-value">不需要<span>›</span></span>
- </div>
- </div>
- <!-- Total -->
- <div class="card" id="totalCard">
- <div class="total-bar">
- <span class="saved-amount">已優惠 ¥53</span>
- <div>
- <span class="total-amount"><span>實付</span>¥112</span>
- </div>
- </div>
- </div>
- </div>
- <!-- Submit bar -->
- <div class="submit-bar">
- <div class="submit-info">
- <span>實付 </span><span class="price" id="submitPrice">¥112</span>
- </div>
- <button class="submit-btn">提交訂單</button>
- </div>
- <!-- Overlay -->
- <div class="sheet-overlay" id="sheetOverlay" onclick="closeSheet()"></div>
- <!-- Merchant coupon sheet -->
- <div class="bottom-sheet" id="merchantSheet">
- <div class="sheet-header">
- <span class="sheet-title">商家優惠券</span>
- <button class="sheet-close" onclick="closeSheet()">✕</button>
- </div>
- <div class="sheet-tabs">
- <div class="sheet-tab active">可用<span class="badge">3</span></div>
- <div class="sheet-tab">不可用<span class="badge">1</span></div>
- </div>
- <div class="sheet-body" id="merchantSheetBody"></div>
- </div>
- <!-- Platform coupon sheet -->
- <div class="bottom-sheet" id="platformSheet">
- <div class="sheet-header">
- <span class="sheet-title">平台紅包</span>
- <button class="sheet-close" onclick="closeSheet()">✕</button>
- </div>
- <div class="sheet-tabs">
- <div class="sheet-tab active">可用<span class="badge">3</span></div>
- <div class="sheet-tab">不可用<span class="badge">1</span></div>
- </div>
- <div class="sheet-body" id="platformSheetBody"></div>
- </div>
- </div>
- <script>
- const subtotal = 145;
- const deliveryFee = 15;
- const packageFee = 5;
- const merchantPromo = 20; // fixed auto
- // Available merchant coupons
- const merchantCoupons = [
- { id: 'm1', name: '滿減券', desc: '全店通用', condition: '滿100元可用', threshold: 100, amount: 15, expire: '2026-06-30', usable: true },
- { id: 'm2', name: '滿減券', desc: '全店通用', condition: '滿80元可用', threshold: 80, amount: 10, expire: '2026-06-15', usable: true },
- { id: 'm3', name: '折扣券', desc: '限奶茶類', condition: '滿50元可用', threshold: 50, amount: 5, expire: '2026-06-20', usable: true },
- { id: 'm4', name: '滿減券', desc: '全店通用', condition: '滿200元可用', threshold: 200, amount: 40, expire: '2026-06-25', usable: false, reason: '訂單不滿200元,無法使用' },
- ];
- // Available platform coupons
- const platformCoupons = [
- { id: 'p1', name: '天天神券', desc: '全場通用', condition: '滿50元可用', threshold: 50, amount: 18, expire: '2026-06-28', usable: true },
- { id: 'p2', name: '會員專享券', desc: '全場通用', condition: '滿100元可用', threshold: 100, amount: 25, expire: '2026-06-30', usable: true },
- { id: 'p3', name: '新人紅包', desc: '全場通用', condition: '滿30元可用', threshold: 30, amount: 5, expire: '2026-06-22', usable: true },
- { id: 'p4', name: '神會員券', desc: '全場通用', condition: '滿50元可用', threshold: 50, amount: 15, expire: '2026-07-01', usable: false, reason: '需開通神會員' },
- ];
- let selectedMerchant = 'm1';
- let selectedPlatform = 'p1';
- function getDiscountedSubtotal() {
- return subtotal - merchantPromo;
- }
- function calcTotal() {
- const mc = merchantCoupons.find(c => c.id === selectedMerchant);
- const pc = platformCoupons.find(c => c.id === selectedPlatform);
- const mcAmt = mc ? mc.amount : 0;
- const pcAmt = pc ? pc.amount : 0;
- const totalSaved = merchantPromo + mcAmt + pcAmt;
- const total = subtotal - totalSaved + deliveryFee + packageFee;
- return { mcAmt, pcAmt, totalSaved, total };
- }
- function updateUI() {
- const { mcAmt, pcAmt, totalSaved, total } = calcTotal();
- document.getElementById('merchantCouponAmount').textContent = mcAmt ? `-¥${mcAmt}` : '未選擇';
- document.getElementById('platformCouponAmount').textContent = pcAmt ? `-¥${pcAmt}` : '未選擇';
- const totalCard = document.getElementById('totalCard');
- totalCard.innerHTML = `<div class="total-bar">
- <span class="saved-amount">已優惠 ¥${totalSaved}</span>
- <div><span class="total-amount"><span>實付</span>¥${total}</span></div>
- </div>`;
- document.getElementById('submitPrice').textContent = `¥${total}`;
- // Flash effect
- totalCard.classList.remove('flash');
- void totalCard.offsetWidth;
- totalCard.classList.add('flash');
- }
- function renderCoupons(coupons, selectedId, type) {
- const bodyId = type === 'merchant' ? 'merchantSheetBody' : 'platformSheetBody';
- const body = document.getElementById(bodyId);
- const usable = coupons.filter(c => c.usable);
- const unusable = coupons.filter(c => !c.usable);
- let html = '';
- usable.forEach(c => {
- const sel = c.id === selectedId;
- const sideClass = type === 'merchant' ? 'merchant' : 'platform';
- html += `
- <div class="coupon-card ${sel ? 'selected' : ''}" onclick="selectCoupon('${type}', '${c.id}')">
- <div class="coupon-amount-side ${sideClass}">
- <span class="coupon-symbol">¥</span>
- <span class="coupon-value">${c.amount}</span>
- <span class="coupon-condition">${c.condition}</span>
- </div>
- <div class="coupon-info-side">
- <div class="coupon-name">${c.name}</div>
- <div class="coupon-desc">${c.desc}</div>
- <div class="coupon-expire">有效期至 ${c.expire}</div>
- </div>
- <div class="coupon-check ${sel ? 'checked' : 'unchecked'}">${sel ? '✓' : ''}</div>
- </div>`;
- });
- if (unusable.length > 0) {
- html += `<div class="sheet-divider">不可用</div>`;
- unusable.forEach(c => {
- html += `
- <div class="coupon-card disabled">
- <div class="coupon-amount-side disabled-bg">
- <span class="coupon-symbol">¥</span>
- <span class="coupon-value">${c.amount}</span>
- <span class="coupon-condition">${c.condition}</span>
- </div>
- <div class="coupon-info-side">
- <div class="coupon-name">${c.name}</div>
- <div class="coupon-desc">${c.desc}</div>
- <div class="coupon-reason">${c.reason}</div>
- </div>
- </div>`;
- });
- }
- body.innerHTML = html;
- }
- function selectCoupon(type, id) {
- if (type === 'merchant') {
- selectedMerchant = selectedMerchant === id ? null : id;
- renderCoupons(merchantCoupons, selectedMerchant, 'merchant');
- } else {
- selectedPlatform = selectedPlatform === id ? null : id;
- renderCoupons(platformCoupons, selectedPlatform, 'platform');
- }
- updateUI();
- }
- function openSheet(type) {
- const overlay = document.getElementById('sheetOverlay');
- overlay.classList.add('active');
- if (type === 'merchant') {
- const sheet = document.getElementById('merchantSheet');
- sheet.classList.add('active');
- renderCoupons(merchantCoupons, selectedMerchant, 'merchant');
- } else {
- const sheet = document.getElementById('platformSheet');
- sheet.classList.add('active');
- renderCoupons(platformCoupons, selectedPlatform, 'platform');
- }
- }
- function closeSheet() {
- document.getElementById('sheetOverlay').classList.remove('active');
- document.getElementById('merchantSheet').classList.remove('active');
- document.getElementById('platformSheet').classList.remove('active');
- }
- // Init
- updateUI();
- </script>
- </body>
- </html>
|