debug(pre-planting): 添加购买流程详细日志以排查 List cast 错误

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-28 07:19:35 -08:00
parent 606d3c0b22
commit 9b6effe63d
2 changed files with 10 additions and 5 deletions

View File

@ -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() ?? '请求失败');

View File

@ -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(