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