fix: 优化购物车移动端布局样式
- 使用CSS Grid重构商品项布局,替代绝对定位 - 商品图片增大到60x60px - 在商品名下方显示单价(移动端专用) - 在底部行右侧显示小计金额 - 优化数量选择器尺寸适配移动端 - 整体布局更稳定清晰 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,11 @@
|
||||
奖励: +{{ item.product?.credit_reward }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<!-- 移动端单价显示 -->
|
||||
<div class="mobile-price" style="display: none;">
|
||||
<span class="price-label">单价</span>
|
||||
<span class="price-value">¥{{ item.product?.price }}</span>
|
||||
</div>
|
||||
<p v-if="!item.product?.is_active" class="item-off">已下架</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,9 +66,9 @@
|
||||
</div>
|
||||
|
||||
<div class="item-quantity">
|
||||
<el-input-number
|
||||
v-model="item.quantity"
|
||||
:min="1"
|
||||
<el-input-number
|
||||
v-model="item.quantity"
|
||||
:min="1"
|
||||
:max="getMaxQuantity(item.product)"
|
||||
size="small"
|
||||
@change="(val: number) => updateQuantity(item, val)"
|
||||
@@ -71,6 +76,11 @@
|
||||
<span v-if="item.product?.stock !== undefined && item.product?.stock <= 10" class="stock-tip">
|
||||
仅剩 {{ item.product?.stock }} 件
|
||||
</span>
|
||||
<!-- 移动端小计显示 -->
|
||||
<div class="mobile-subtotal" style="display: none;">
|
||||
<span class="subtotal-label">小计</span>
|
||||
<span class="subtotal-value">¥{{ ((item.product?.price || 0) * item.quantity).toFixed(2) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item-subtotal">
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user