细节修改
This commit is contained in:
parent
a777aca121
commit
4f0c1f6f73
@ -507,10 +507,6 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 视频项构建
|
||||
// 视频项构建
|
||||
// 视频项构建
|
||||
// 视频项构建
|
||||
Widget _buildVideoItem(Map<String, dynamic> video) {
|
||||
return GestureDetector(
|
||||
@ -687,7 +683,6 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
|
||||
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 商品Tab
|
||||
Widget _buildProductTab() {
|
||||
if (_productResults.isEmpty && !_isLoading) {
|
||||
@ -712,7 +707,7 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisSpacing: 8,
|
||||
childAspectRatio: 0.55,
|
||||
childAspectRatio: 0.65, // 调整为与视频相同的宽高比
|
||||
),
|
||||
itemCount: _productResults.length,
|
||||
itemBuilder: (context, index) {
|
||||
@ -783,46 +778,68 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 商品图片 - 宽度100%,高度自适应
|
||||
// 商品图片 - 使用AspectRatio保持固定宽高比,与视频一致
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(_itemCornerRadius),
|
||||
topRight: Radius.circular(_itemCornerRadius),
|
||||
),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 0.8, // 保持与视频相同的宽高比
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
color: Colors.grey[200],
|
||||
child: product['pic'] != null
|
||||
child: product['pic'] != null && product['pic'].toString().isNotEmpty
|
||||
? Image.network(
|
||||
product['pic'].toString(),
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: SizedBox(
|
||||
height: 110,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Center(
|
||||
child: Icon(Icons.shopping_bag, color: Colors.grey, size: 32),
|
||||
child: Icon(
|
||||
Icons.shopping_bag,
|
||||
color: Colors.grey,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: Container(
|
||||
color: Colors.grey[200],
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.shopping_bag,
|
||||
color: Colors.grey,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 商品信息 - 固定在容器底部
|
||||
),
|
||||
),
|
||||
// 商品信息
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(6),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.end, // 内容靠底部对齐
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// 商品名称
|
||||
Text(
|
||||
product['name']?.toString() ?? '未知商品',
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.2,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
// 价格和销量信息
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -835,7 +852,7 @@ class _SearchResultPageState extends State<SearchResultPage> with SingleTickerPr
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'已售 ${product['sales']?.toString() ?? '0'}',
|
||||
'已售 ${Utils.graceNumber(product['sales'] ?? 0)}',
|
||||
style: const TextStyle(
|
||||
fontSize: 9,
|
||||
color: Colors.grey,
|
||||
|
@ -113,7 +113,16 @@ class Utils {
|
||||
}
|
||||
|
||||
// 大数字转换
|
||||
static String graceNumber(int number) {
|
||||
static String graceNumber(dynamic value) {
|
||||
int number;
|
||||
if (value is int) {
|
||||
number = value;
|
||||
} else if (value is String) {
|
||||
number = int.tryParse(value) ?? 0;
|
||||
} else {
|
||||
number = 0;
|
||||
}
|
||||
|
||||
if (number == 0) return "0";
|
||||
|
||||
if (number < 1000) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user