From 2550efa43a486503ce437409f2e647f3e7702876 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Thu, 28 Aug 2025 19:08:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=95=86=E5=93=81=E6=80=BB=E4=BB=B6?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/order/mixin/order_mixin.dart | 12 +++- lib/common/widgets/order/order_common.dart | 67 ++++++++++++------- lib/pages/supermarket_order/controller.dart | 1 + lib/pages/supermarket_order/view.dart | 1 + 4 files changed, 55 insertions(+), 26 deletions(-) diff --git a/lib/common/widgets/order/mixin/order_mixin.dart b/lib/common/widgets/order/mixin/order_mixin.dart index 6dfe175..5116e27 100644 --- a/lib/common/widgets/order/mixin/order_mixin.dart +++ b/lib/common/widgets/order/mixin/order_mixin.dart @@ -36,6 +36,9 @@ mixin OrderMixin { // 总价 RxInt totalPrice = RxInt(0); + // 商品总件数量 + RxInt totalProduct = RxInt(0); + // 额外需要支付的金额土豪税 RxInt amountMealPrice = RxInt(0); @@ -433,11 +436,14 @@ mixin OrderMixin { // 计算总价 void computedTotalPrice({isSendSubScreen = true}) { - int total = 0; + int currentTotalPrice = 0; + int currentTotalProduct = 0; for (var e in shopCardList) { - total += e.totalPrice; + currentTotalPrice += e.totalPrice; + currentTotalProduct += e.productNumber; } - totalPrice.value = total; + totalPrice.value = currentTotalPrice; + totalProduct.value = currentTotalProduct; if (isSendSubScreen) sendSubScreen(); } diff --git a/lib/common/widgets/order/order_common.dart b/lib/common/widgets/order/order_common.dart index 36f262d..b953d64 100644 --- a/lib/common/widgets/order/order_common.dart +++ b/lib/common/widgets/order/order_common.dart @@ -12,6 +12,7 @@ Widget orderAllPrice( required num totalPrice, required num amountMealPrice, num? payPrice, + num? productCount, String productPrice = "菜品总价", bool visibleProductPrice = true, bool visibleAmountMealPrice = true, @@ -27,29 +28,49 @@ Widget orderAllPrice( ), ), [ - Text( - productPrice, - style: theme.typography.lg, - ), - appPrice(context, totalPrice), - ].toRow().offstage(offstage: !visibleProductPrice), - [ - Text( - "额外支付", - style: theme.typography.lg, - ), - appPrice(context, amountMealPrice), - ].toRow().offstage(offstage: !visibleAmountMealPrice), - [ - Text( - "实际扣款", - style: theme.typography.lg, - ), - appPrice( - context, - payPrice, - ), - ].toRow(), + [ + [ + Text( + productPrice, + style: theme.typography.lg, + ), + appPrice(context, totalPrice), + ].toRow().offstage(offstage: !visibleProductPrice), + [ + Text( + "额外支付", + style: theme.typography.lg, + ), + appPrice(context, amountMealPrice), + ].toRow().offstage(offstage: !visibleAmountMealPrice), + [ + Text( + "实际扣款", + style: theme.typography.lg, + ), + appPrice( + context, + payPrice, + ), + ].toRow(), + ].toColumn(), + [ + [ + Text( + "件数", + style: theme.typography.lg, + ), + Text( + "$productCount", + style: theme.typography.lg.copyWith( + color: theme.colorScheme.error, + ), + ), + ].toRow().offstage(offstage: productCount == null), + ].toColumn() + ].toRow( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start), FDivider( style: theme.dividerStyles.verticalStyle.copyWith( color: theme.colorScheme.primary, diff --git a/lib/pages/supermarket_order/controller.dart b/lib/pages/supermarket_order/controller.dart index e12fe00..71c9046 100644 --- a/lib/pages/supermarket_order/controller.dart +++ b/lib/pages/supermarket_order/controller.dart @@ -438,6 +438,7 @@ class SupermarketOrderController extends GetxController with OrderMixin { shopCardList.clear(); payUser.value = null; totalPrice.value = 0; + totalProduct.value = 0; amountMealPrice.value = 0; } diff --git a/lib/pages/supermarket_order/view.dart b/lib/pages/supermarket_order/view.dart index 80651fd..2b03ee1 100644 --- a/lib/pages/supermarket_order/view.dart +++ b/lib/pages/supermarket_order/view.dart @@ -269,6 +269,7 @@ class SupermarketOrderPage extends GetView { totalPrice: controller.totalPrice.value, amountMealPrice: controller.amountMealPrice.value, productPrice: "商品总价", + productCount: controller.totalProduct.value, ), ), SizedBox(height: 20.h),