|
|
@@ -144,53 +144,46 @@ class MemberPage extends BasePage<MemberController> {
|
|
|
|
|
|
Widget buildGoodsList() {
|
|
|
return Obx(() {
|
|
|
- if (controller.goodsList.isEmpty) {
|
|
|
+ final goods = controller.goodsList;
|
|
|
+ final itemCount = goods.length;
|
|
|
+
|
|
|
+ if (itemCount == 0) {
|
|
|
return Container();
|
|
|
}
|
|
|
- if (controller.goodsList.length == 1) {
|
|
|
- return Container(
|
|
|
- padding: EdgeInsets.symmetric(horizontal: 14.w),
|
|
|
- //height: 165.w,
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- _createSpecialProduct(controller.goodsList.first)
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
- } else if (controller.goodsList.length == 2) {
|
|
|
- return Container(
|
|
|
- padding: EdgeInsets.symmetric(horizontal: 14.w),
|
|
|
- //height: 165.w,
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- Expanded(child: _ordinaryProductWidget(controller.goodsList.first)),
|
|
|
- SizedBox(width: 8,),
|
|
|
- Expanded(child: _ordinaryProductWidget(controller.goodsList[1]))
|
|
|
- ],
|
|
|
- )
|
|
|
- ],
|
|
|
- ),
|
|
|
- );
|
|
|
+
|
|
|
+ final widgets = <Widget>[];
|
|
|
+
|
|
|
+ // 添加第一个商品(特殊样式)
|
|
|
+ if (itemCount >= 1) {
|
|
|
+ widgets.add(_createSpecialProduct(goods[0]));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果有多个商品,添加普通样式商品
|
|
|
+ if (itemCount >= 2) {
|
|
|
+ widgets.add(SizedBox(height: 7.w));
|
|
|
+
|
|
|
+ final rowItems = <Widget>[];
|
|
|
+ // 计算可显示的普通商品数量(最多2个)
|
|
|
+ final ordinaryCount = itemCount >= 3 ? 2 : 1;
|
|
|
+
|
|
|
+ for (int i = 1; i <= ordinaryCount + 1 && i < itemCount; i++) {
|
|
|
+ rowItems.add(Expanded(child: _ordinaryProductWidget(goods[i])));
|
|
|
+ // 为除最后一个商品外的每个商品添加间距
|
|
|
+ if (i < ordinaryCount + 1 && i < itemCount - 1) {
|
|
|
+ rowItems.add(SizedBox(width: 8));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ widgets.add(Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: rowItems,
|
|
|
+ ));
|
|
|
}
|
|
|
+
|
|
|
return Container(
|
|
|
padding: EdgeInsets.symmetric(horizontal: 14.w),
|
|
|
- //height: 165.w,
|
|
|
child: Column(
|
|
|
- children: [
|
|
|
- _createSpecialProduct(controller.goodsList.first),
|
|
|
- SizedBox(height: 7.w,),
|
|
|
- Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- Expanded(child: _ordinaryProductWidget(controller.goodsList[1])),
|
|
|
- SizedBox(width: 8,),
|
|
|
- Expanded(child: _ordinaryProductWidget(controller.goodsList[2]))
|
|
|
- ],
|
|
|
- )
|
|
|
- ],
|
|
|
+ children: widgets,
|
|
|
),
|
|
|
);
|
|
|
});
|