feat(client): 商品详情加价格历史卡(接 /products/:id/price-history)
repo.getPriceHistory → 详情异步加载,新增价格历史卡:date + 进价,按相邻点 算涨跌(绿涨/红跌箭头)。至此商品详情 100% 对齐原型富数据版 (KPI + 各仓库分布 + 价格历史 + 近期流水)。golden 三主题已含该卡。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TSKEiHsvauyxYUW2itzUXX
This commit is contained in:
@@ -87,6 +87,27 @@ class ProductRepository {
|
||||
}
|
||||
}
|
||||
|
||||
/// 进价历史点(date/price),按日期倒序。失败抛 AppException。
|
||||
Future<List<({String date, double price})>> getPriceHistory(int id) async {
|
||||
try {
|
||||
final resp = await _client.get('/products/$id/price-history');
|
||||
final data = (resp.data as Map<String, dynamic>)['data'] as List? ?? [];
|
||||
return data.map((e) {
|
||||
final m = e as Map<String, dynamic>;
|
||||
final d = (m['date'] as String? ?? '');
|
||||
return (
|
||||
date: d.length >= 10 ? d.substring(0, 10) : d,
|
||||
price: (m['price'] as num).toDouble(),
|
||||
);
|
||||
}).toList();
|
||||
} on DioException catch (e) {
|
||||
throw AppException(
|
||||
e.response?.data?['error'] as String? ?? '获取价格历史失败',
|
||||
statusCode: e.response?.statusCode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<ProductImage> uploadImage(int productId, String? filePath,
|
||||
{Uint8List? bytes, String? fileName}) async {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user