Browse Source

首页没有数据就不展示对应的布局

liukai 1 month ago
parent
commit
efa491cb79
1 changed files with 34 additions and 29 deletions
  1. 34 29
      packages/cpt_main/lib/modules/home/home_page.dart

+ 34 - 29
packages/cpt_main/lib/modules/home/home_page.dart

@@ -170,7 +170,8 @@ class HomePage extends HookConsumerWidget {
                       _buildCategoryWidget(context, ref),
 
                       //轮播图片 (动态)
-                      _buildBannerImage(ref, bannerIndex),
+                      if (state.homeIndex?.banners != null && state.homeIndex?.banners.isNotEmpty == true)
+                        _buildBannerImage(ref, bannerIndex),
 
                       //最新的新闻(动态)
                       _buildLastNews(context, ref),
@@ -189,41 +190,45 @@ class HomePage extends HookConsumerWidget {
                       ),
 
                       //最新交易列表 (动态)
-                      _buildLastTransaction(context, state),
+                      if (state.homeIndex?.latestTransactions != null && state.homeIndex?.latestTransactions.isNotEmpty == true)
+                        _buildLastTransaction(context, state),
 
                       //房产新闻
-                      SliverToBoxAdapter(
-                        child: Row(
-                          children: [
-                            MyTextView(
-                              marginTop: 30,
-                              marginLeft: 15,
-                              marginBottom: 14,
-                              S.current.property_news,
-                              textColor: context.appColors.textBlack,
-                              fontSize: 16,
-                              isFontMedium: true,
-                            ).expanded(),
-                            MyTextView(
-                              marginTop: 30,
-                              marginLeft: 15,
-                              marginRight: 15,
-                              marginBottom: 14,
-                              onClick: viewModel.gotoPropertyNewsPage,
-                              S.current.all,
-                              textColor: context.appColors.textBlack,
-                              fontSize: 15,
-                              isFontMedium: true,
-                            )
-                          ],
+                      if (state.homeIndex?.propertyNews != null && state.homeIndex?.propertyNews.isNotEmpty == true)
+                        SliverToBoxAdapter(
+                          child: Row(
+                            children: [
+                              MyTextView(
+                                marginTop: 30,
+                                marginLeft: 15,
+                                marginBottom: 14,
+                                S.current.property_news,
+                                textColor: context.appColors.textBlack,
+                                fontSize: 16,
+                                isFontMedium: true,
+                              ).expanded(),
+                              MyTextView(
+                                marginTop: 30,
+                                marginLeft: 15,
+                                marginRight: 15,
+                                marginBottom: 14,
+                                onClick: viewModel.gotoPropertyNewsPage,
+                                S.current.all,
+                                textColor: context.appColors.textBlack,
+                                fontSize: 15,
+                                isFontMedium: true,
+                              )
+                            ],
+                          ),
                         ),
-                      ),
 
                       //房产新闻列表 (动态)
-                      _buildPropertyNews(context, ref),
+                      if (state.homeIndex?.propertyNews != null && state.homeIndex?.propertyNews.isNotEmpty == true)
+                        _buildPropertyNews(context, ref),
 
                       //管理员介绍 (固定)
-                      _buildManagementGuides(context, ref),
+                      if (state.homeIndex?.strataManagementGuides != null && state.homeIndex?.strataManagementGuides.isNotEmpty == true)
+                        _buildManagementGuides(context, ref),
 
                       //间距
                       _buildSliverSpace(15),