From 9b6effe63d971beb40403e21473dc05cdd3d519c Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 07:19:35 -0800 Subject: [PATCH] =?UTF-8?q?debug(pre-planting):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E6=B5=81=E7=A8=8B=E8=AF=A6=E7=BB=86=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BB=A5=E6=8E=92=E6=9F=A5=20List=20cast=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- .../mobile-app/lib/core/network/api_client.dart | 2 ++ .../pages/pre_planting_purchase_page.dart | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/mobile-app/lib/core/network/api_client.dart b/frontend/mobile-app/lib/core/network/api_client.dart index 6eb1305d..c0554ade 100644 --- a/frontend/mobile-app/lib/core/network/api_client.dart +++ b/frontend/mobile-app/lib/core/network/api_client.dart @@ -384,7 +384,9 @@ class ApiClient { case DioExceptionType.badResponse: final statusCode = error.response?.statusCode; final data = error.response?.data; + debugPrint('[ApiClient] ▼▼▼ badResponse: status=$statusCode, data=$data, dataType=${data.runtimeType}'); final rawMsg = data is Map ? data['message'] : null; + debugPrint('[ApiClient] ▼▼▼ rawMsg=$rawMsg, rawMsgType=${rawMsg.runtimeType}'); final message = rawMsg is List ? (rawMsg as List).join(', ') : (rawMsg?.toString() ?? '请求失败'); diff --git a/frontend/mobile-app/lib/features/pre_planting/presentation/pages/pre_planting_purchase_page.dart b/frontend/mobile-app/lib/features/pre_planting/presentation/pages/pre_planting_purchase_page.dart index d0eb3215..5295680a 100644 --- a/frontend/mobile-app/lib/features/pre_planting/presentation/pages/pre_planting_purchase_page.dart +++ b/frontend/mobile-app/lib/features/pre_planting/presentation/pages/pre_planting_purchase_page.dart @@ -348,12 +348,14 @@ class _PrePlantingPurchasePageState final prePlantingService = ref.read(prePlantingServiceProvider); // 创建预种订单(后端自动完成:扣款 → 分配权益 → 检查合并) + final pc = _isFirstPurchase ? _selectedProvinceCode : _position?.provinceCode; + final cc = _isFirstPurchase ? _selectedCityCode : _position?.cityCode; + debugPrint('[PrePlantingPurchase] ★ createOrder: qty=$_quantity, isFirst=$_isFirstPurchase, provinceCode=$pc, cityCode=$cc'); final response = await prePlantingService.createOrder( portionCount: _quantity, - // 首次购买时传省市信息,续购时后端自动复用 - provinceCode: _isFirstPurchase ? _selectedProvinceCode : _position?.provinceCode, + provinceCode: pc, provinceName: _isFirstPurchase ? _selectedProvinceName : _position?.provinceName, - cityCode: _isFirstPurchase ? _selectedCityCode : _position?.cityCode, + cityCode: cc, cityName: _isFirstPurchase ? _selectedCityName : _position?.cityName, ); @@ -376,8 +378,9 @@ class _PrePlantingPurchasePageState // 返回上一页(Profile 页面会自动刷新) context.pop(true); } - } catch (e) { - debugPrint('[PrePlantingPurchase] 购买失败: $e'); + } catch (e, stack) { + debugPrint('[PrePlantingPurchase] ★ 购买失败 type=${e.runtimeType}: $e'); + debugPrint('[PrePlantingPurchase] ★ stackTrace: $stack'); if (mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(