From eba269edbed75d1c8a37b5ec0be6ebad14cbb16b Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 31 May 2026 10:33:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E7=A7=BB=E5=8A=A8=E7=AB=AF=E5=B8=83=E5=B1=80=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用CSS Grid重构商品项布局,替代绝对定位 - 商品图片增大到60x60px - 在商品名下方显示单价(移动端专用) - 在底部行右侧显示小计金额 - 优化数量选择器尺寸适配移动端 - 整体布局更稳定清晰 Co-Authored-By: Claude Opus 4.8 --- frontend/src/views/user/Cart.vue | 211 ++++++++++++++++++++----------- 1 file changed, 139 insertions(+), 72 deletions(-) diff --git a/frontend/src/views/user/Cart.vue b/frontend/src/views/user/Cart.vue index f7d712f..5f585c9 100644 --- a/frontend/src/views/user/Cart.vue +++ b/frontend/src/views/user/Cart.vue @@ -52,6 +52,11 @@ 奖励: +{{ item.product?.credit_reward }} + +

已下架

@@ -61,9 +66,9 @@
- 仅剩 {{ item.product?.stock }} 件 + +
@@ -963,74 +973,72 @@ onMounted(() => { /* 商品项 - 卡片式布局 */ .cart-item { - display: flex !important; - flex-direction: column !important; - padding: 10px !important; - position: relative !important; - gap: 8px !important; - min-width: 0 !important; + display: grid !important; + grid-template-columns: 24px 1fr auto !important; + grid-template-rows: auto auto !important; + grid-template-areas: + "check product delete" + "check bottom bottom" !important; + padding: 12px !important; + gap: 10px !important; + align-items: start !important; } - /* 复选框 - 绝对定位左上角 */ + /* 复选框 */ .cart-item > .el-checkbox { - position: absolute !important; - top: 8px !important; - left: 8px !important; - z-index: 10 !important; + grid-area: check !important; + margin-right: 0 !important; + width: auto !important; + position: static !important; } - /* 商品图片+名称 - 第一行 */ + /* 商品信息区 */ .cart-item > .item-product { + grid-area: product !important; display: flex !important; flex-direction: row !important; align-items: flex-start !important; - gap: 8px !important; - padding-left: 32px !important; - padding-right: 50px !important; + gap: 10px !important; min-width: 0 !important; width: 100% !important; + padding: 0 !important; } - /* 隐藏单价 */ + /* 隐藏单价列 */ .cart-item > .item-price { display: none !important; } - /* 删除按钮 - 绝对定位右上角 */ + /* 删除按钮 */ .cart-item > .item-action { - position: absolute !important; - top: 8px !important; - right: 8px !important; - z-index: 10 !important; + grid-area: delete !important; + width: auto !important; + position: static !important; } - /* 数量+小计 - 第二行 */ + /* 数量行 - 包含单价、数量、小计 */ .cart-item > .item-quantity { + grid-area: bottom !important; display: flex !important; flex-direction: row !important; align-items: center !important; justify-content: space-between !important; - padding-left: 32px !important; width: 100% !important; + padding: 0 !important; + gap: 8px !important; + flex-wrap: wrap !important; } - /* 小计放在数量行的右侧 */ + /* 隐藏原来的小计列 */ .cart-item > .item-subtotal { display: none !important; } - /* 在数量行内显示价格 */ - .item-quantity::after { - content: "¥" attr(data-price); - font-size: 14px; - font-weight: 600; - color: #f56c6c; - } - .item-product .item-image { - width: 45px !important; - height: 45px !important; + width: 60px !important; + height: 60px !important; flex-shrink: 0 !important; + border-radius: 6px !important; } .item-info { @@ -1040,101 +1048,160 @@ onMounted(() => { } .item-name { - font-size: 13px !important; - line-height: 1.3 !important; - margin-bottom: 2px !important; + font-size: 14px !important; + line-height: 1.4 !important; + margin-bottom: 4px !important; word-break: break-all !important; } .item-tags { - display: none !important; + flex-wrap: wrap !important; + gap: 4px !important; + + .el-tag { + font-size: 10px !important; + padding: 0 4px !important; + height: 18px !important; + line-height: 16px !important; + } } + /* 移动端价格显示在商品名下方 */ + .item-info .mobile-price { + display: inline-flex !important; + align-items: baseline !important; + gap: 4px !important; + margin-top: 4px !important; + } + + .item-info .mobile-price .price-label { + font-size: 12px !important; + color: rgba(255, 255, 255, 0.5) !important; + } + + .item-info .mobile-price .price-value { + font-size: 15px !important; + font-weight: 600 !important; + color: #fff !important; + } + + /* 数量选择器 */ .item-quantity :deep(.el-input-number) { - width: 80px !important; + width: 100px !important; + } + + .item-quantity :deep(.el-input-number .el-input__wrapper) { + padding: 0 4px !important; + } + + .item-quantity :deep(.el-input-number .el-input__inner) { + font-size: 13px !important; } .item-quantity .stock-tip { - display: none !important; + font-size: 10px !important; + width: 100% !important; + text-align: center !important; + margin-top: 2px !important; + } + + /* 移动端小计显示 */ + .mobile-subtotal { + display: flex !important; + flex-direction: column !important; + align-items: flex-end !important; + gap: 2px !important; + } + + .mobile-subtotal .subtotal-label { + font-size: 11px !important; + color: rgba(255, 255, 255, 0.4) !important; + } + + .mobile-subtotal .subtotal-value { + font-size: 16px !important; + font-weight: 600 !important; + color: #f56c6c !important; } /* 地址 */ .checkout-section { - padding: 10px !important; + padding: 12px !important; } .section-title { - font-size: 13px !important; - margin-bottom: 8px !important; + font-size: 14px !important; + margin-bottom: 10px !important; } .address-item { - padding: 8px !important; + padding: 10px !important; + gap: 10px !important; } .address-name { - font-size: 13px !important; + font-size: 14px !important; } .address-phone { - font-size: 12px !important; + font-size: 13px !important; } .address-detail { - font-size: 11px !important; + font-size: 12px !important; } /* 支付方式 */ .payment-methods { grid-template-columns: repeat(2, 1fr) !important; - gap: 6px !important; + gap: 8px !important; } .payment-item { - padding: 8px 4px !important; + padding: 10px 6px !important; } .payment-icon { - font-size: 20px !important; + font-size: 22px !important; } .payment-name { - font-size: 11px !important; + font-size: 12px !important; } /* 订单摘要 */ .cart-summary-panel { - padding: 10px !important; + padding: 12px !important; } .summary-title { - font-size: 14px !important; - margin-bottom: 8px !important; - padding-bottom: 6px !important; + font-size: 15px !important; + margin-bottom: 12px !important; + padding-bottom: 10px !important; } .summary-row { - font-size: 12px !important; - margin-bottom: 6px !important; - } - - .summary-total .total-amount { - font-size: 16px !important; - } - - .summary-count { - font-size: 12px !important; + font-size: 13px !important; margin-bottom: 8px !important; } + .summary-total .total-amount { + font-size: 18px !important; + } + + .summary-count { + font-size: 13px !important; + margin-bottom: 12px !important; + } + .checkout-btn { - height: 38px !important; - font-size: 14px !important; + height: 44px !important; + font-size: 15px !important; } .summary-actions { - margin-top: 8px !important; - padding-top: 8px !important; + margin-top: 12px !important; + padding-top: 12px !important; } }