From 606d3c0b22b8f0249b7404098cf17a3467f65b82 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 28 Feb 2026 06:56:49 -0800 Subject: [PATCH] =?UTF-8?q?fix(pre-planting):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E5=A4=B1=E8=B4=A5=E6=97=B6=20List?= =?UTF-8?q?=20=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=92=8C=E7=BB=AD=E8=B4=AD=E7=9C=81=E5=B8=82=E7=BC=BA=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. api_client.dart: NestJS validation error 返回 message 为数组时, 用 join(', ') 转为字符串,避免直接传给 ApiException(String) 崩溃 2. pre_planting_purchase_page.dart: 续购时传 _position 中已保存的 provinceCode/cityCode,满足后端 DTO 必填校验 Co-Authored-By: Claude Sonnet 4.6 --- frontend/mobile-app/lib/core/network/api_client.dart | 5 ++++- .../presentation/pages/pre_planting_purchase_page.dart | 8 ++++---- 2 files changed, 8 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 939dc3ed..6eb1305d 100644 --- a/frontend/mobile-app/lib/core/network/api_client.dart +++ b/frontend/mobile-app/lib/core/network/api_client.dart @@ -384,7 +384,10 @@ class ApiClient { case DioExceptionType.badResponse: final statusCode = error.response?.statusCode; final data = error.response?.data; - final message = data is Map ? data['message'] ?? '请求失败' : '请求失败'; + final rawMsg = data is Map ? data['message'] : null; + final message = rawMsg is List + ? (rawMsg as List).join(', ') + : (rawMsg?.toString() ?? '请求失败'); switch (statusCode) { case 400: 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 b507f02d..d0eb3215 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 @@ -351,10 +351,10 @@ class _PrePlantingPurchasePageState final response = await prePlantingService.createOrder( portionCount: _quantity, // 首次购买时传省市信息,续购时后端自动复用 - provinceCode: _isFirstPurchase ? _selectedProvinceCode : null, - provinceName: _isFirstPurchase ? _selectedProvinceName : null, - cityCode: _isFirstPurchase ? _selectedCityCode : null, - cityName: _isFirstPurchase ? _selectedCityName : null, + provinceCode: _isFirstPurchase ? _selectedProvinceCode : _position?.provinceCode, + provinceName: _isFirstPurchase ? _selectedProvinceName : _position?.provinceName, + cityCode: _isFirstPurchase ? _selectedCityCode : _position?.cityCode, + cityName: _isFirstPurchase ? _selectedCityName : _position?.cityName, ); debugPrint(