diff --git a/CHANGELOG-client.md b/CHANGELOG-client.md index 792a60b..84c86e1 100644 --- a/CHANGELOG-client.md +++ b/CHANGELOG-client.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.68] - 2026-06-21 + +### 改进 +- 店铺公开商品页:每个商品卡片显示「在库 N」数量,且只展示有货商品 + ## [1.0.67] - 2026-06-21 ### 改进 diff --git a/client/lib/screens/public/public_shop_products_screen.dart b/client/lib/screens/public/public_shop_products_screen.dart index a3a6d72..6438c87 100644 --- a/client/lib/screens/public/public_shop_products_screen.dart +++ b/client/lib/screens/public/public_shop_products_screen.dart @@ -269,6 +269,12 @@ class _ProductCard extends StatelessWidget { final name = item['name'] as String? ?? ''; final series = item['series'] as String? ?? ''; final spec = item['spec'] as String? ?? ''; + final unit = item['unit'] as String? ?? ''; + final qtyNum = (item['quantity'] as num?)?.toDouble() ?? 0; + // 去掉整数的 .0 尾巴:5.0 → 5,1.5 → 1.5 + final qtyStr = qtyNum == qtyNum.roundToDouble() + ? qtyNum.toInt().toString() + : qtyNum.toString(); final images = (item['images'] as List? ?? []) .cast>(); final imageUrl = images.isNotEmpty @@ -339,7 +345,18 @@ class _ProductCard extends StatelessWidget { const Spacer(), Row( children: [ - const Spacer(), + Flexible( + child: Text( + '在库 $qtyStr$unit', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 11, + color: _kBurgundy, + fontWeight: FontWeight.w600), + ), + ), + const SizedBox(width: 4), Container( padding: const EdgeInsets.symmetric( horizontal: 8, vertical: 3),