532 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			HTML
		
	
	
	
		
		
			
		
	
	
			532 lines
		
	
	
		
			16 KiB
		
	
	
	
		
			HTML
		
	
	
	
|  | <!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: #f7f7f7; | |||
|  |         } | |||
|  | 
 | |||
|  |         .header { | |||
|  |             background-color: #013820; | |||
|  |             color: white; | |||
|  |             padding: 15px 20px; | |||
|  |             font-size: 18px; | |||
|  |             font-weight: bold; | |||
|  |             text-align: center; | |||
|  |             position: sticky; | |||
|  |             top: 0; | |||
|  |             z-index: 100; | |||
|  |         } | |||
|  | 
 | |||
|  |         .tabs { | |||
|  |             background-color: white; | |||
|  |             display: flex; | |||
|  |             justify-content: space-around; | |||
|  |             padding: 12px 0; | |||
|  |             position: sticky; | |||
|  |             top: 48px; | |||
|  |             z-index: 99; | |||
|  |             box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | |||
|  |         } | |||
|  | 
 | |||
|  |         .tab-item { | |||
|  |             font-size: 15px; | |||
|  |             color: #1f1f1f; | |||
|  |             cursor: pointer; | |||
|  |             padding: 8px 16px; | |||
|  |             position: relative; | |||
|  |             transition: all 0.3s; | |||
|  |         } | |||
|  | 
 | |||
|  |         .tab-item.active { | |||
|  |             font-size: 18px; | |||
|  |             font-weight: bold; | |||
|  |             color: #1f1f1f; | |||
|  |         } | |||
|  | 
 | |||
|  |         .tab-item.active::after { | |||
|  |             content: ''; | |||
|  |             position: absolute; | |||
|  |             bottom: -6px; | |||
|  |             left: 50%; | |||
|  |             transform: translateX(-50%); | |||
|  |             width: 100%; | |||
|  |             height: 7px; | |||
|  |             background: linear-gradient(150deg, #FFC534 0%, #FF8421 100%); | |||
|  |             border-radius: 4px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .order-list { | |||
|  |             padding: 10px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .order-card { | |||
|  |             background-color: white; | |||
|  |             border-radius: 8px; | |||
|  |             padding: 10px; | |||
|  |             margin-bottom: 10px; | |||
|  |             cursor: pointer; | |||
|  |         } | |||
|  | 
 | |||
|  |         .order-header { | |||
|  |             display: flex; | |||
|  |             justify-content: space-between; | |||
|  |             align-items: center; | |||
|  |             margin-bottom: 10px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .shop-info { | |||
|  |             display: flex; | |||
|  |             align-items: center; | |||
|  |         } | |||
|  | 
 | |||
|  |         .shop-icon { | |||
|  |             width: 13px; | |||
|  |             height: 12px; | |||
|  |             margin-right: 7px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .shop-name { | |||
|  |             font-size: 15px; | |||
|  |             font-weight: bold; | |||
|  |             color: #1f1f1f; | |||
|  |             margin-right: 7px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .market-name { | |||
|  |             font-size: 15px; | |||
|  |             color: #575859; | |||
|  |         } | |||
|  | 
 | |||
|  |         .order-status { | |||
|  |             font-size: 15px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .status-normal { | |||
|  |             color: #808080; | |||
|  |         } | |||
|  | 
 | |||
|  |         .status-important { | |||
|  |             color: #FF6300; | |||
|  |         } | |||
|  | 
 | |||
|  |         .order-content { | |||
|  |             display: flex; | |||
|  |             justify-content: space-between; | |||
|  |             align-items: center; | |||
|  |             padding: 10px 0; | |||
|  |         } | |||
|  | 
 | |||
|  |         .product-images { | |||
|  |             display: flex; | |||
|  |             gap: 10px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .product-img { | |||
|  |             width: 68px; | |||
|  |             height: 68px; | |||
|  |             border-radius: 8px; | |||
|  |             background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%); | |||
|  |             display: flex; | |||
|  |             align-items: center; | |||
|  |             justify-content: center; | |||
|  |             font-size: 32px; | |||
|  |             border: 1px solid #ddd; | |||
|  |         } | |||
|  | 
 | |||
|  |         .order-price { | |||
|  |             text-align: right; | |||
|  |         } | |||
|  | 
 | |||
|  |         .price-value { | |||
|  |             font-size: 21px; | |||
|  |             color: #1f1f1f; | |||
|  |         } | |||
|  | 
 | |||
|  |         .price-symbol { | |||
|  |             font-size: 15px; | |||
|  |             position: relative; | |||
|  |             bottom: 2px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .product-count { | |||
|  |             display: flex; | |||
|  |             align-items: center; | |||
|  |             justify-content: flex-end; | |||
|  |             margin-top: 5px; | |||
|  |             color: #808080; | |||
|  |             font-size: 13px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .arrow-icon { | |||
|  |             width: 4px; | |||
|  |             height: 7px; | |||
|  |             margin-left: 4px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .order-actions { | |||
|  |             display: flex; | |||
|  |             justify-content: flex-end; | |||
|  |             gap: 10px; | |||
|  |             margin-top: 10px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .btn { | |||
|  |             padding: 8px 20px; | |||
|  |             border-radius: 4px; | |||
|  |             border: 1px solid; | |||
|  |             font-size: 14px; | |||
|  |             cursor: pointer; | |||
|  |             transition: all 0.3s; | |||
|  |         } | |||
|  | 
 | |||
|  |         .btn-primary { | |||
|  |             background-color: #013820; | |||
|  |             color: white; | |||
|  |             border-color: #013820; | |||
|  |         } | |||
|  | 
 | |||
|  |         .btn-primary:hover { | |||
|  |             background-color: #025530; | |||
|  |         } | |||
|  | 
 | |||
|  |         .btn-info { | |||
|  |             background-color: white; | |||
|  |             color: #013820; | |||
|  |             border-color: #013820; | |||
|  |         } | |||
|  | 
 | |||
|  |         .btn-info:hover { | |||
|  |             background-color: #f5f5f5; | |||
|  |         } | |||
|  | 
 | |||
|  |         .empty-view { | |||
|  |             text-align: center; | |||
|  |             padding: 50px 20px; | |||
|  |             color: #999; | |||
|  |             font-size: 14px; | |||
|  |         } | |||
|  | 
 | |||
|  |         .hidden { | |||
|  |             display: none; | |||
|  |         } | |||
|  |     </style> | |||
|  | </head> | |||
|  | <body> | |||
|  |     <div class="header">我的订单</div> | |||
|  | 
 | |||
|  |     <div class="tabs"> | |||
|  |         <div class="tab-item active" data-tab="0">全部订单</div> | |||
|  |         <div class="tab-item" data-tab="1">待发货</div> | |||
|  |         <div class="tab-item" data-tab="2">待收货</div> | |||
|  |         <div class="tab-item" data-tab="3">待评价</div> | |||
|  |         <div class="tab-item" data-tab="4">退款/售后</div> | |||
|  |     </div> | |||
|  | 
 | |||
|  |     <div class="order-list" id="orderList"> | |||
|  |         <!-- 订单卡片动态生成 --> | |||
|  |     </div> | |||
|  | 
 | |||
|  |     <script> | |||
|  |         // 模拟订单数据 | |||
|  |         const mockOrders = [ | |||
|  |             { | |||
|  |                 unitOrderNo: 'ORDER20250116001', | |||
|  |                 unitType: 2, | |||
|  |                 shopName: '新鲜蔬菜店', | |||
|  |                 marketName: '大妈集市', | |||
|  |                 status: 1, // 待发货 | |||
|  |                 refundStatus: 0, | |||
|  |                 productImgs: '🥬,🥕,🥔', | |||
|  |                 totalMoney: 88.50, | |||
|  |                 productCount: 5, | |||
|  |                 orderCategory: 1, | |||
|  |             }, | |||
|  |             { | |||
|  |                 unitOrderNo: 'ORDER20250116002', | |||
|  |                 unitType: 2, | |||
|  |                 shopName: '水果超市', | |||
|  |                 marketName: '大妈集市', | |||
|  |                 status: 3, // 待收货 | |||
|  |                 refundStatus: 0, | |||
|  |                 productImgs: '🍎,🍌', | |||
|  |                 totalMoney: 128.00, | |||
|  |                 productCount: 3, | |||
|  |                 orderCategory: 1, | |||
|  |             }, | |||
|  |             { | |||
|  |                 unitOrderNo: 'ORDER20250116003', | |||
|  |                 unitType: 2, | |||
|  |                 shopName: '肉类专营店', | |||
|  |                 marketName: '大妈集市', | |||
|  |                 status: 5, // 已完成 | |||
|  |                 refundStatus: 0, | |||
|  |                 productImgs: '🥩', | |||
|  |                 totalMoney: 256.80, | |||
|  |                 productCount: 2, | |||
|  |                 orderCategory: 1, | |||
|  |                 evaluated: false, | |||
|  |             }, | |||
|  |             { | |||
|  |                 unitOrderNo: 'ORDER20250116004', | |||
|  |                 unitType: 1, | |||
|  |                 marketName: '大妈集市', | |||
|  |                 status: 0, // 待付款 | |||
|  |                 refundStatus: 0, | |||
|  |                 productImgs: '🍞,🥐', | |||
|  |                 totalMoney: 99.90, | |||
|  |                 productCount: 4, | |||
|  |                 orderCategory: 1, | |||
|  |             }, | |||
|  |         ]; | |||
|  | 
 | |||
|  |         // 订单状态枚举 | |||
|  |         const OrderStatus = { | |||
|  |             WAIT_PAY: 0, | |||
|  |             WAIT_PREPARE: 1, | |||
|  |             WAIT_RECEIVE: 2, | |||
|  |             WAIT_CONFIRM: 3, | |||
|  |             COMPLETE: 5, | |||
|  |             CANCEL: 6, | |||
|  |             REFUNDING: 7, | |||
|  |             REFUND: 8, | |||
|  |         }; | |||
|  | 
 | |||
|  |         let currentTab = 0; | |||
|  | 
 | |||
|  |         // 初始化页面 | |||
|  |         function init() { | |||
|  |             // 绑定tab点击事件 | |||
|  |             document.querySelectorAll('.tab-item').forEach(tab => { | |||
|  |                 tab.addEventListener('click', function() { | |||
|  |                     // 移除所有active状态 | |||
|  |                     document.querySelectorAll('.tab-item').forEach(t => t.classList.remove('active')); | |||
|  |                     // 添加当前active状态 | |||
|  |                     this.classList.add('active'); | |||
|  |                     // 获取tab索引 | |||
|  |                     currentTab = parseInt(this.dataset.tab); | |||
|  |                     // 渲染订单列表 | |||
|  |                     renderOrders(); | |||
|  |                 }); | |||
|  |             }); | |||
|  | 
 | |||
|  |             // 初始渲染 | |||
|  |             renderOrders(); | |||
|  |         } | |||
|  | 
 | |||
|  |         // 根据tab过滤订单 | |||
|  |         function filterOrders(orders, tabIndex) { | |||
|  |             switch (tabIndex) { | |||
|  |                 case 0: // 全部订单 | |||
|  |                     return orders; | |||
|  |                 case 1: // 待发货 | |||
|  |                     return orders.filter(o => o.status === OrderStatus.WAIT_PREPARE); | |||
|  |                 case 2: // 待收货 | |||
|  |                     return orders.filter(o => o.status === OrderStatus.WAIT_CONFIRM); | |||
|  |                 case 3: // 待评价 | |||
|  |                     return orders.filter(o => o.status === OrderStatus.COMPLETE && !o.evaluated); | |||
|  |                 case 4: // 退款/售后 | |||
|  |                     return orders.filter(o => o.refundStatus !== 0 || o.status === OrderStatus.REFUNDING || o.status === OrderStatus.REFUND); | |||
|  |                 default: | |||
|  |                     return orders; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         // 获取订单状态文本和样式 | |||
|  |         function getOrderStatus(order) { | |||
|  |             const { status, refundStatus } = order; | |||
|  | 
 | |||
|  |             if (refundStatus === -2) { | |||
|  |                 return { text: '申请退款中', isImportant: true }; | |||
|  |             } | |||
|  | 
 | |||
|  |             let text = ''; | |||
|  |             let isImportant = false; | |||
|  | 
 | |||
|  |             switch (status) { | |||
|  |                 case OrderStatus.WAIT_PAY: | |||
|  |                     text = '待付款'; | |||
|  |                     isImportant = true; | |||
|  |                     break; | |||
|  |                 case OrderStatus.WAIT_PREPARE: | |||
|  |                     text = '待发货'; | |||
|  |                     isImportant = false; | |||
|  |                     break; | |||
|  |                 case OrderStatus.WAIT_CONFIRM: | |||
|  |                     text = '待收货'; | |||
|  |                     isImportant = true; | |||
|  |                     break; | |||
|  |                 case OrderStatus.COMPLETE: | |||
|  |                     text = '已完成'; | |||
|  |                     isImportant = false; | |||
|  |                     break; | |||
|  |                 case OrderStatus.CANCEL: | |||
|  |                     text = '已取消'; | |||
|  |                     isImportant = false; | |||
|  |                     break; | |||
|  |                 case OrderStatus.REFUNDING: | |||
|  |                     text = '退款中'; | |||
|  |                     isImportant = false; | |||
|  |                     break; | |||
|  |                 case OrderStatus.REFUND: | |||
|  |                     text = '已退款'; | |||
|  |                     isImportant = false; | |||
|  |                     break; | |||
|  |                 default: | |||
|  |                     text = '未知状态'; | |||
|  |                     isImportant = false; | |||
|  |             } | |||
|  | 
 | |||
|  |             return { text, isImportant }; | |||
|  |         } | |||
|  | 
 | |||
|  |         // 渲染订单列表 | |||
|  |         function renderOrders() { | |||
|  |             const orderListEl = document.getElementById('orderList'); | |||
|  |             const filteredOrders = filterOrders(mockOrders, currentTab); | |||
|  | 
 | |||
|  |             if (filteredOrders.length === 0) { | |||
|  |                 orderListEl.innerHTML = '<div class="empty-view">暂无订单数据哦</div>'; | |||
|  |                 return; | |||
|  |             } | |||
|  | 
 | |||
|  |             orderListEl.innerHTML = filteredOrders.map(order => { | |||
|  |                 const statusInfo = getOrderStatus(order); | |||
|  |                 const productImages = order.productImgs.split(',').slice(0, 3); | |||
|  | 
 | |||
|  |                 return ` | |||
|  |                     <div class="order-card" onclick="toOrderDetail('${order.unitOrderNo}')"> | |||
|  |                         <div class="order-header"> | |||
|  |                             <div class="shop-info"> | |||
|  |                                 <span class="shop-icon">🏪</span> | |||
|  |                                 ${order.unitType === 2 ? ` | |||
|  |                                     <span class="shop-name">${order.shopName}</span> | |||
|  |                                     <span class="market-name">(${order.marketName})</span> | |||
|  |                                 ` : ` | |||
|  |                                     <span class="market-name">${order.marketName}</span> | |||
|  |                                 `} | |||
|  |                             </div> | |||
|  |                             <div class="order-status ${statusInfo.isImportant ? 'status-important' : 'status-normal'}"> | |||
|  |                                 ${statusInfo.text} | |||
|  |                             </div> | |||
|  |                         </div> | |||
|  |                         <div class="order-content"> | |||
|  |                             <div class="product-images"> | |||
|  |                                 ${productImages.map(emoji => `<div class="product-img">${emoji}</div>`).join('')} | |||
|  |                             </div> | |||
|  |                             <div class="order-price"> | |||
|  |                                 <div class="price-value"> | |||
|  |                                     <span class="price-symbol">¥</span>${order.totalMoney.toFixed(2)} | |||
|  |                                 </div> | |||
|  |                                 <div class="product-count"> | |||
|  |                                     共${order.productCount}件 | |||
|  |                                     <span class="arrow-icon">›</span> | |||
|  |                                 </div> | |||
|  |                             </div> | |||
|  |                         </div> | |||
|  |                         ${renderOrderActions(order)} | |||
|  |                     </div> | |||
|  |                 `; | |||
|  |             }).join(''); | |||
|  |         } | |||
|  | 
 | |||
|  |         // 渲染订单操作按钮 | |||
|  |         function renderOrderActions(order) { | |||
|  |             const { status, orderCategory } = order; | |||
|  |             let buttons = ''; | |||
|  | 
 | |||
|  |             // 待付款 | |||
|  |             if (status === OrderStatus.WAIT_PAY && orderCategory === 1) { | |||
|  |                 buttons = ` | |||
|  |                     <div class="order-actions"> | |||
|  |                         <button class="btn btn-info" onclick="event.stopPropagation(); cancelOrder('${order.unitOrderNo}')">取消订单</button> | |||
|  |                         <button class="btn btn-primary" onclick="event.stopPropagation(); payOrder('${order.unitOrderNo}')">去结算</button> | |||
|  |                     </div> | |||
|  |                 `; | |||
|  |             } | |||
|  |             // 待收货 | |||
|  |             else if (status === OrderStatus.WAIT_CONFIRM) { | |||
|  |                 buttons = ` | |||
|  |                     <div class="order-actions"> | |||
|  |                         <button class="btn btn-primary" onclick="event.stopPropagation(); confirmReceive('${order.unitOrderNo}')">确认收货</button> | |||
|  |                     </div> | |||
|  |                 `; | |||
|  |             } | |||
|  |             // 已完成 | |||
|  |             else if (status === OrderStatus.COMPLETE && orderCategory === 1) { | |||
|  |                 buttons = ` | |||
|  |                     <div class="order-actions"> | |||
|  |                         <button class="btn btn-info" onclick="event.stopPropagation(); addToCart('${order.unitOrderNo}')">加入购物车</button> | |||
|  |                         <button class="btn btn-primary" onclick="event.stopPropagation(); orderAgain('${order.unitOrderNo}')">再来一单</button> | |||
|  |                         ${!order.evaluated ? `<button class="btn btn-primary" onclick="event.stopPropagation(); goReview('${order.unitOrderNo}')">去评价</button>` : ''} | |||
|  |                     </div> | |||
|  |                 `; | |||
|  |             } | |||
|  | 
 | |||
|  |             return buttons; | |||
|  |         } | |||
|  | 
 | |||
|  |         // 跳转到订单详情 | |||
|  |         function toOrderDetail(unitOrderNo) { | |||
|  |             console.log('跳转到订单详情:', unitOrderNo); | |||
|  |             window.location.href = `order-detail.html?unitOrderNo=${unitOrderNo}`; | |||
|  |         } | |||
|  | 
 | |||
|  |         // 取消订单 | |||
|  |         function cancelOrder(unitOrderNo) { | |||
|  |             if (confirm('是否确认取消订单?')) { | |||
|  |                 console.log('取消订单:', unitOrderNo); | |||
|  |                 alert('取消订单成功'); | |||
|  |                 renderOrders(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         // 支付订单 | |||
|  |         function payOrder(unitOrderNo) { | |||
|  |             console.log('去支付:', unitOrderNo); | |||
|  |             alert('跳转到支付页面'); | |||
|  |         } | |||
|  | 
 | |||
|  |         // 确认收货 | |||
|  |         function confirmReceive(unitOrderNo) { | |||
|  |             if (confirm('是否确认收货?')) { | |||
|  |                 console.log('确认收货:', unitOrderNo); | |||
|  |                 alert('确认收货成功'); | |||
|  |                 renderOrders(); | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         // 再来一单 | |||
|  |         function orderAgain(unitOrderNo) { | |||
|  |             console.log('再来一单:', unitOrderNo); | |||
|  |             alert('跳转到结算页面'); | |||
|  |         } | |||
|  | 
 | |||
|  |         // 加入购物车 | |||
|  |         function addToCart(unitOrderNo) { | |||
|  |             console.log('加入购物车:', unitOrderNo); | |||
|  |             alert('加入购物车成功'); | |||
|  |         } | |||
|  | 
 | |||
|  |         // 去评价 | |||
|  |         function goReview(unitOrderNo) { | |||
|  |             console.log('去评价:', unitOrderNo); | |||
|  |             alert('跳转到评价页面'); | |||
|  |         } | |||
|  | 
 | |||
|  |         // 页面加载完成后初始化 | |||
|  |         document.addEventListener('DOMContentLoaded', init); | |||
|  |     </script> | |||
|  | </body> | |||
|  | </html> |