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(