From 7152303f54a76dac5ec342da638f3ca1bf4dcb61 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Wed, 19 Mar 2025 10:06:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=AE=A2=E5=8D=95=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/app/app_date_picker.dart | 4 +- lib/common/widgets/app/app_price.dart | 2 +- lib/pages/order_history/view.dart | 65 ++++++++------ .../order_history_detail/controller.dart | 3 +- lib/pages/order_history_detail/view.dart | 84 ++++++++++++++++++- 5 files changed, 129 insertions(+), 29 deletions(-) diff --git a/lib/common/widgets/app/app_date_picker.dart b/lib/common/widgets/app/app_date_picker.dart index a6dc5a7..c5c4a2f 100644 --- a/lib/common/widgets/app/app_date_picker.dart +++ b/lib/common/widgets/app/app_date_picker.dart @@ -137,7 +137,7 @@ Future?> appShowDatePicker( } Navigator.of(context).pop(slectDateTime); }, - ).width(200.w), + ).width(300.w), SizedBox(width: 30.w), FButton( style: FButtonStyle.destructive, @@ -148,7 +148,7 @@ Future?> appShowDatePicker( ), ), onPress: () => Navigator.of(context).pop(null), - ).width(200.w), + ).width(300.w), ], ), ); diff --git a/lib/common/widgets/app/app_price.dart b/lib/common/widgets/app/app_price.dart index e001551..49a1c60 100644 --- a/lib/common/widgets/app/app_price.dart +++ b/lib/common/widgets/app/app_price.dart @@ -21,7 +21,7 @@ Widget appPrice(BuildContext context, dynamic price) { ), Text( priceNum.toStringAsFixed(2), - style: theme.typography.lg.copyWith( + style: theme.typography.xl.copyWith( color: theme.colorScheme.error, height: 1, ), diff --git a/lib/pages/order_history/view.dart b/lib/pages/order_history/view.dart index 2a2af32..eb011da 100644 --- a/lib/pages/order_history/view.dart +++ b/lib/pages/order_history/view.dart @@ -32,6 +32,44 @@ class OrderHistoryPage extends GetView { ].toColumn(); } + Widget _buildTypeTab(BuildContext context) { + final theme = FTheme.of(context); + return Obx( + () => controller.tabList + .map((v) { + final active = v.status.code == controller.currentStatus.value.code; + return Text( + "${v.status.title}(${v.total})", + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: theme.typography.xl2.copyWith( + height: 1, + color: active + ? theme.colorScheme.background + : theme.colorScheme.primary, + ), + ) + .center() + .width(180.w) + .height(60.h) + .decorated( + color: active + ? theme.colorScheme.primary + : theme.colorScheme.background, + border: Border.all( + color: theme.colorScheme.primary, + width: 1, + ), + borderRadius: theme.style.borderRadius / 2, + ) + .onTap(() => controller.doTab(v.status)); + }) + .toList() + .toRowSpace(space: 20.w), + ); + } + Widget _buildCondition(BuildContext context, double headerHeight) { final theme = FTheme.of(context); return [ @@ -39,30 +77,9 @@ class OrderHistoryPage extends GetView { FAssets.icons.chevronLeft, size: theme.typography.xl4.fontSize, ).alignLeft().width(headerHeight).onTap(() => Get.back()), - Obx( - () => controller.tabList - .map((v) { - final active = - v.status.code == controller.currentStatus.value.code; - return FButton( - style: active ? FButtonStyle.primary : FButtonStyle.secondary, - label: Text( - "${v.status.title}(${v.total})", - maxLines: 1, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: theme.typography.lg.copyWith( - color: active - ? theme.colorScheme.secondary - : theme.colorScheme.primary, - ), - ).width(150.w), - onPress: () => controller.doTab(v.status), - ); - }) - .toList() - .toRowSpace(space: 20.w), - ).scrollable(scrollDirection: Axis.horizontal).expanded(), + _buildTypeTab(context) + .scrollable(scrollDirection: Axis.horizontal) + .expanded(), // 用餐时间段 appRadioHourTypeDialog(context, controller.hourTypeC) .width(300.w) diff --git a/lib/pages/order_history_detail/controller.dart b/lib/pages/order_history_detail/controller.dart index cfdcb55..943434a 100644 --- a/lib/pages/order_history_detail/controller.dart +++ b/lib/pages/order_history_detail/controller.dart @@ -6,7 +6,7 @@ class OrderHistoryDetailController extends GetxController { int detailId = -1; - Rx detailData = null.obs; + Rx detailData = Rx(null); RxList shopCardList = [].obs; @@ -41,6 +41,7 @@ class OrderHistoryDetailController extends GetxController { final detail = await appC.dataBase.getOrderDao.findById( detailId, ); + if (detail == null) return; detailData.value = detail; } diff --git a/lib/pages/order_history_detail/view.dart b/lib/pages/order_history_detail/view.dart index 10af162..71f25fb 100644 --- a/lib/pages/order_history_detail/view.dart +++ b/lib/pages/order_history_detail/view.dart @@ -1,4 +1,5 @@ import 'package:common_utils/common_utils.dart'; +import 'package:data_table_2/data_table_2.dart'; import 'package:ducafe_ui_core/ducafe_ui_core.dart'; import 'package:flutter/material.dart'; import 'package:forui/forui.dart'; @@ -28,6 +29,7 @@ class OrderHistoryDetailPage extends GetView { ].toRow().marginOnly(bottom: 20.h); } + // 左侧 Widget _buildLeft(BuildContext context) { return [ FTile( @@ -126,8 +128,88 @@ class OrderHistoryDetailPage extends GetView { .scrollable(); } + // 右侧 Widget _buildRight(BuildContext context) { - return [].toColumn().scrollable(); + return [ + _buildCarTable(context).expanded(), + orderAllPrice( + context, + totalPrice: controller.detailData.value?.price ?? 0, + amountMealPrice: controller.detailData.value?.extraPrice ?? 0, + productPrice: "商品总价", + ), + ].toColumn(); + } + + // 购物车 + Widget _buildCarTable(BuildContext context) { + final theme = FTheme.of(context); + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + final width = constraints.maxWidth; + final hdHeight = 70.h; + final hdWidth = width / 4.1; + return Obx( + () => DataTable2( + columnSpacing: 12.w, + horizontalMargin: 12.w, + minWidth: 600.w, + showBottomBorder: true, + headingTextStyle: theme.typography.lg, + dataTextStyle: theme.typography.base, + dataRowHeight: hdHeight, + columns: [ + DataColumn2( + label: Text("名称", textAlign: TextAlign.center), + headingRowAlignment: MainAxisAlignment.center, + fixedWidth: hdWidth, + ), + DataColumn2( + label: Text("数量", textAlign: TextAlign.center), + headingRowAlignment: MainAxisAlignment.center, + fixedWidth: hdWidth, + ), + DataColumn2( + label: Text("单价", textAlign: TextAlign.center), + headingRowAlignment: MainAxisAlignment.center, + fixedWidth: hdWidth, + ), + DataColumn2( + label: Text("总价", textAlign: TextAlign.center), + headingRowAlignment: MainAxisAlignment.center, + fixedWidth: hdWidth, + ), + ], + rows: controller.shopCardList.map((v) { + return DataRow( + cells: [ + DataCell( + Text( + v.productName, + textAlign: TextAlign.center, + ).center(), + ), + DataCell( + Text( + v.nature == ProductNature.DEFAULT + ? v.productNumber.toString() + : "${v.productWidget}/kg", + textAlign: TextAlign.center, + ).center(), + ), + DataCell( + appPrice(context, v.productPrice).center(), + ), + DataCell( + appPrice(context, v.totalPrice).center(), + ), + ], + ); + }).toList(), + ), + ); + }, + ); } @override