From 3d72f6c71473ff49caa3b408dd39239792ed786d Mon Sep 17 00:00:00 2001 From: Kroytz Date: Fri, 31 Jul 2026 14:41:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(uniapp):=20cart=E4=B9=9F=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yshop-drink-uniapp-vue3/pages/menu/menu.vue | 99 ++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/yshop-drink-uniapp-vue3/pages/menu/menu.vue b/yshop-drink-uniapp-vue3/pages/menu/menu.vue index 5184c86..5a36e8d 100644 --- a/yshop-drink-uniapp-vue3/pages/menu/menu.vue +++ b/yshop-drink-uniapp-vue3/pages/menu/menu.vue @@ -242,6 +242,33 @@ + + + + + 商品合计 + ¥{{ cartGoodsTotal.toFixed(2) }} + + + 配送费 + ¥{{ cartDeliveryFee.toFixed(2) }} + 免配送费 + + + 应付总额 + ¥{{ cartTotalWithDelivery }} + + {{ deliveryTipText }} + + + @@ -425,6 +452,20 @@ const deliveryTipText = computed(() => { } return '' }) +// 购物车弹窗结算栏:商品合计、配送费、应付总额 +const cartGoodsTotal = computed(() => parseFloat(getCartGoodsPrice.value) || 0) +const cartDeliveryFee = computed(() => { + if (orderType.value !== 'takeout') return 0 + if (canShowDeliveryTip.value && deliveryTipReady.value) return menuDeliveryFee.value || 0 + return 0 +}) +const cartTotalWithDelivery = computed(() => + (cartGoodsTotal.value + cartDeliveryFee.value).toFixed(2) +) +const cartPayBtnText = computed(() => { + if (!cart.value.length) return '去点单' + return disabledPay.value ? `差${spread.value}元起送` : '去结算' +}) const filteredGoods = computed(() => { const query = keyword.value.trim().toLowerCase() if (!query) return goods.value @@ -1601,6 +1642,8 @@ page { display: flex; flex-direction: column; justify-content: center; + padding-right: $spacing-row-lg; + padding-left: $spacing-row-base; color: $text-color-base; &__amount { @@ -1648,7 +1691,7 @@ page { flex-direction: column; height: 100%; padding: 0 $spacing-row-lg; - margin-bottom: $menu-cart-list-bottom; + margin-bottom: $menu-gap-base; .item { position: relative; @@ -1695,6 +1738,60 @@ page { } } } + + .cart-footer { + display: flex; + align-items: center; + justify-content: space-between; + padding: $menu-gap-base $spacing-row-lg; + background-color: $text-color-white; + border-top: 1rpx solid $border-color; + + .summary { + flex: 1; + min-width: 0; + margin-right: $spacing-row-lg; + + .row { + display: flex; + align-items: center; + justify-content: space-between; + font-size: $font-size-sm; + line-height: 1.5; + color: $text-color-base; + + .value.free { + color: $color-primary; + } + + &.total { + margin-top: 4rpx; + font-weight: 700; + + .value { + font-size: 32rpx; + color: $color-primary; + } + } + } + + .tip { + margin-top: 6rpx; + font-size: 20rpx; + line-height: 1.3; + color: #a8907a; + } + } + + .checkout-btn { + flex: 0 0 auto; + height: 72rpx; + padding: 0 48rpx; + font-size: $font-size-base; + line-height: 72rpx; + border-radius: 36rpx; + } + } } // 页面级工具类