Browse Source

Merge branch 'dev' of http://git.wmzhubo.com/guadoutech/YYHome into dev

“shanwenxin” 3 months ago
parent
commit
797981e4b7
100 changed files with 3701 additions and 2611 deletions
  1. 1 1
      app/lib/main.dart
  2. 1 1
      packages/cpt_auth/lib/modules/auth_login/auth_login_page.dart
  3. 24 12
      packages/cpt_community/lib/components/garage_card.dart
  4. 5 1
      packages/cpt_community/lib/components/newsfeed_card_content.dart
  5. 92 44
      packages/cpt_community/lib/modules/community/community_page.dart
  6. 18 0
      packages/cpt_community/lib/modules/community/community_pageview_idx_data.dart
  7. 5 1
      packages/cpt_community/lib/modules/community/community_state.dart
  8. 191 75
      packages/cpt_community/lib/modules/community/community_vm.dart
  9. 1 1
      packages/cpt_community/lib/modules/community/community_vm.g.dart
  10. 9 4
      packages/cpt_community/lib/modules/community/following/following_page.dart
  11. 0 15
      packages/cpt_community/lib/modules/community/following/following_state.dart
  12. 86 57
      packages/cpt_community/lib/modules/community/following/following_vm.dart
  13. 1 1
      packages/cpt_community/lib/modules/community/following/following_vm.g.dart
  14. 6 3
      packages/cpt_community/lib/modules/community/foryou/foryou_page.dart
  15. 0 19
      packages/cpt_community/lib/modules/community/foryou/foryou_state.dart
  16. 85 58
      packages/cpt_community/lib/modules/community/foryou/foryou_vm.dart
  17. 1 1
      packages/cpt_community/lib/modules/community/foryou/foryou_vm.g.dart
  18. 46 32
      packages/cpt_community/lib/modules/community/news/news_page.dart
  19. 0 15
      packages/cpt_community/lib/modules/community/news/news_state.dart
  20. 93 184
      packages/cpt_community/lib/modules/community/news/news_vm.dart
  21. 1 1
      packages/cpt_community/lib/modules/community/news/news_vm.g.dart
  22. 2 0
      packages/cpt_community/lib/modules/community/newsfeed_detail/comments_input.dart
  23. 229 143
      packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_page.dart
  24. 17 27
      packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_state.dart
  25. 264 109
      packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_vm.dart
  26. 1 1
      packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_vm.g.dart
  27. 12 6
      packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_page.dart
  28. 24 4
      packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_vm.dart
  29. 1 1
      packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_vm.g.dart
  30. 6 5
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_page.dart
  31. 0 71
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_respository.dart
  32. 0 18
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_state.dart
  33. 158 92
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.dart
  34. 1 1
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.g.dart
  35. 7 6
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_page.dart
  36. 0 71
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_respository.dart
  37. 0 19
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_state.dart
  38. 198 141
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart
  39. 1 1
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.g.dart
  40. 47 22
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_page.dart
  41. 3 2
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_state.dart
  42. 36 4
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_vm.dart
  43. 1 1
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_vm.g.dart
  44. 21 6
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_page.dart
  45. 5 1
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_state.dart
  46. 109 7
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.dart
  47. 1 1
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.g.dart
  48. 27 20
      packages/cpt_community/lib/modules/my_following/components/item_following.dart
  49. 54 0
      packages/cpt_community/lib/modules/my_following/components/item_following_vm.dart
  50. 10 11
      packages/cpt_facility/lib/modules/book_confirm/book_confirm_view_model.g.dart
  51. 3 2
      packages/cpt_community/lib/modules/my_following/my_follow/my_follow_page.dart
  52. 0 9
      packages/cpt_community/lib/modules/my_following/my_follow/my_follow_state.dart
  53. 101 72
      packages/cpt_community/lib/modules/my_following/my_follow/my_follow_vm.dart
  54. 1 1
      packages/cpt_community/lib/modules/my_following/my_follow/my_follow_vm.g.dart
  55. 2 1
      packages/cpt_community/lib/modules/my_following/my_follower/my_follower_page.dart
  56. 0 6
      packages/cpt_community/lib/modules/my_following/my_follower/my_follower_state.dart
  57. 94 74
      packages/cpt_community/lib/modules/my_following/my_follower/my_follower_vm.dart
  58. 1 1
      packages/cpt_community/lib/modules/my_following/my_follower/my_follower_vm.g.dart
  59. 4 2
      packages/cpt_community/lib/modules/my_following/my_following_state.dart
  60. 6 3
      packages/cpt_community/lib/modules/my_following/my_following_vm.dart
  61. 1 1
      packages/cpt_community/lib/modules/my_following/my_following_vm.g.dart
  62. 4 0
      packages/cpt_community/lib/modules/my_following/tabs_data.dart
  63. 59 0
      packages/cpt_community/lib/modules/my_posts/components/my_posts_sale_rent_item.dart
  64. 37 0
      packages/cpt_community/lib/modules/my_posts/components/my_posts_sale_rent_item_vm.dart
  65. 27 0
      packages/cpt_community/lib/modules/my_posts/components/my_posts_sale_rent_item_vm.g.dart
  66. 4 41
      packages/cpt_community/lib/modules/my_posts/my_posts_forrent/my_posts_forrent_page.dart
  67. 134 117
      packages/cpt_community/lib/modules/my_posts/my_posts_forrent/my_posts_forrent_vm.dart
  68. 1 1
      packages/cpt_community/lib/modules/my_posts/my_posts_forrent/my_posts_forrent_vm.g.dart
  69. 3 40
      packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_page.dart
  70. 0 18
      packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_state.dart
  71. 166 149
      packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_vm.dart
  72. 1 1
      packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_vm.g.dart
  73. 259 0
      packages/cpt_community/lib/respository/common_garage.dart
  74. 11 11
      packages/cpt_community/lib/respository/newsfeed_news_repository.g.dart
  75. 478 0
      packages/cpt_community/lib/respository/common_newsfeed.dart
  76. 29 0
      packages/cpt_community/lib/respository/common_newsfeed.g.dart
  77. 0 65
      packages/cpt_community/lib/respository/newsfeed_comment_repository.dart
  78. 0 29
      packages/cpt_community/lib/respository/newsfeed_comment_repository.g.dart
  79. 0 99
      packages/cpt_community/lib/respository/newsfeed_following_repository.dart
  80. 0 30
      packages/cpt_community/lib/respository/newsfeed_following_repository.g.dart
  81. 0 99
      packages/cpt_community/lib/respository/newsfeed_foryou_repository.dart
  82. 0 29
      packages/cpt_community/lib/respository/newsfeed_foryou_repository.g.dart
  83. 0 98
      packages/cpt_community/lib/respository/newsfeed_news_repository.dart
  84. 0 65
      packages/cpt_community/lib/respository/newsfeed_publish_repository.dart
  85. 0 29
      packages/cpt_community/lib/respository/newsfeed_publish_repository.g.dart
  86. 1 1
      packages/cpt_community/lib/router/page/community_page_router.dart
  87. 100 15
      packages/cpt_community/lib/router/page/community_page_router.gr.dart
  88. 17 17
      packages/cpt_facility/lib/modules/book_confirm/book_confirm_page.dart
  89. 0 3
      packages/cpt_facility/lib/modules/book_confirm/book_confirm_state.dart
  90. 0 29
      packages/cpt_facility/lib/modules/book_confirm/book_confirm_view_model.dart
  91. 54 33
      packages/cpt_facility/lib/modules/booking/facility_booking_page.dart
  92. 24 4
      packages/cpt_facility/lib/modules/booking/facility_booking_state.dart
  93. 111 15
      packages/cpt_facility/lib/modules/booking/facility_booking_view_model.dart
  94. 1 1
      packages/cpt_facility/lib/modules/booking/facility_booking_view_model.g.dart
  95. 1 1
      packages/cpt_facility/lib/modules/facility/active/facility_active_screen.dart
  96. 3 2
      packages/cpt_facility/lib/modules/facility/active/facility_active_state.dart
  97. 48 70
      packages/cpt_facility/lib/modules/facility/active/facility_active_view_model.dart
  98. 8 7
      packages/cpt_facility/lib/modules/facility/active/item_facility_active.dart
  99. 6 3
      packages/cpt_facility/lib/modules/facility/book/facility_book_screen.dart
  100. 0 0
      packages/cpt_facility/lib/modules/facility/book/facility_book_state.dart

+ 1 - 1
app/lib/main.dart

@@ -42,7 +42,7 @@ void main() async {
   await AppInitializer.initializeRunalone();
 
   //组件路由的注入
-  final serviceManager = ComponentServiceManager()
+  ComponentServiceManager()
     ..addServiceProvider(mainServiceProvider)
     ..addServiceProvider(authServiceProvider)
     ..addServiceProvider(appServiceProvider)

+ 1 - 1
packages/cpt_auth/lib/modules/auth_login/auth_login_page.dart

@@ -121,7 +121,7 @@ class AuthLoginPage extends HookConsumerWidget {
               MyButton(
                 onPressed: viewModel.doLogin,
                 text: S.current.login,
-                isEnabled: state.isLoginBtnEnable,
+                enable: state.isLoginBtnEnable,
                 textColor: Colors.white,
                 disabledTextColor: Colors.white,
                 backgroundColor: context.appColors.btnBgDefault,

+ 24 - 12
packages/cpt_community/lib/components/garage_card.dart

@@ -6,6 +6,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
 import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:shared/utils/color_utils.dart';
+import 'package:shared/utils/ext_dart.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_load_image.dart';
@@ -52,6 +53,16 @@ class GarageCard extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
+    List? card_resources = itemObj.getValue<List>("resources", [])?? [];
+    String card_img = card_resources.length>0? card_resources[0]:"";
+    String card_title = itemObj.getValue("title", "");
+    String card_price = itemObj.getValue("price", "");
+    String card_created_at = itemObj.getValue("created_at", "");
+    Map<String, dynamic>? card_account = itemObj.getValue<Map<String,dynamic>>("account", null);
+    String card_avator = card_account?['avator']?? "";
+    String card_publish_name = card_account?['name']?? "";
+    bool card_liked = itemObj.getValue("liked", false);
+    int card_likes_count = itemObj.getValue("likes_count", 0);
     return Column(
       children: [
         // 图片
@@ -63,7 +74,7 @@ class GarageCard extends StatelessWidget {
               child: ClipRRect(
                 borderRadius: const BorderRadius.only(topLeft: Radius.circular(8), topRight: Radius.circular(8),),
                 child: MyLoadImage(
-                  itemObj['goods_img'],
+                  card_img,
                   width: 166.5,
                   height: 102.5,
                   isCircle: false,
@@ -84,7 +95,7 @@ class GarageCard extends StatelessWidget {
             children: [
               Expanded(
                 child: MyTextView(
-                  itemObj['title'],
+                  card_title,
                   maxLines: 1,
                   isTextEllipsis: true,
                   textAlign: TextAlign.left,
@@ -105,7 +116,7 @@ class GarageCard extends StatelessWidget {
             children: [
               Expanded(
                 child: MyTextView(
-                  itemObj['price'],
+                  card_price,
                   maxLines: 1,
                   isTextEllipsis: true,
                   textAlign: TextAlign.start,
@@ -116,15 +127,15 @@ class GarageCard extends StatelessWidget {
               ),
               // 动态的 收藏数
               CollectionWidget(
-                  collectionNum: itemObj['collection_num'],
-                  isCollection: itemObj['isCollection'],
+                  collectionNum: card_likes_count,
+                  isCollection: card_liked,
                   onClickColleciotn: onClickColleciotn,
               ),
             ],
           ),
         ),
-        // 发布人信息
-        Expanded(
+          // 发布人信息
+          Expanded(
           child: Padding(
             padding: EdgeInsets.only(left: (useType == GarageCardUseType.forSale || useType == GarageCardUseType.forRent)?10:0, right: 10),
             child: Row(
@@ -133,7 +144,7 @@ class GarageCard extends StatelessWidget {
               children: [
                 if (useType == GarageCardUseType.forSale || useType == GarageCardUseType.forRent)
                   MyLoadImage(
-                    itemObj['publisher_avator'],
+                    card_avator,
                     width: 30,
                     height: 30,
                     isCircle: true,
@@ -148,7 +159,7 @@ class GarageCard extends StatelessWidget {
                     children: [
                       if (useType == GarageCardUseType.forSale || useType == GarageCardUseType.forRent)
                         MyTextView(
-                          itemObj['publisher'],
+                          card_publish_name,
                           maxLines: 1,
                           isTextEllipsis: true,
                           textAlign: TextAlign.start,
@@ -160,7 +171,7 @@ class GarageCard extends StatelessWidget {
                       else
                         const SizedBox.shrink(),
                       MyTextView(
-                        itemObj['publish_time'],
+                        card_created_at,
                         maxLines: 1,
                         isTextEllipsis: true,
                         textAlign: TextAlign.start,
@@ -223,12 +234,13 @@ class CollectionWidget extends HookConsumerWidget {
           )
         ]
         // 点击 收餐/取消收藏
-    ).onTap((){
+    ).onTap(() async{
         // Log.d("点击了收藏按钮  ${isCollectionState.value}");
         // ToastEngine.show("点击了收藏按钮 ${isCollectionState.value}");
-        bool result = onClickColleciotn?.call(isCollectionState.value);
+        bool result = await onClickColleciotn?.call(isCollectionState.value);
         if(result){
           isCollectionState.value = !isCollectionState.value;
+          collectionNumState.value = (collectionNumState.value + (isCollectionState.value? 1: -1))<0? 0: (collectionNumState.value + (isCollectionState.value? 1: -1));
           if(isCollectionState.value){
             ToastEngine.show("Collect Success");
           }else {

+ 5 - 1
packages/cpt_community/lib/components/newsfeed_card_content.dart

@@ -1,3 +1,5 @@
+import 'dart:math';
+
 import 'package:auto_route/src/route/page_route_info.dart';
 import 'package:cpt_community/components/comments_dialog.dart';
 import 'package:cpt_community/modules/community/community_page.dart';
@@ -6,6 +8,7 @@ import 'package:flutter/material.dart';
 import 'package:flutter/widgets.dart';
 import 'package:plugin_basic/modules/global_web_page.dart';
 import 'package:plugin_basic/modules/preview_photo_page.dart';
+import 'package:plugin_basic/router/basic_page_router.dart';
 import 'package:router/componentRouter/component_service_manager.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/color_utils.dart';
@@ -119,7 +122,8 @@ class NewsFeedCardContent extends StatelessWidget {
                             // 点击图片预览
                             // 过滤掉非字符串类型的元素
                             List<String> filteredImages = totalImageUrls?.whereType<String>().toList() ?? [];
-                            PreviewPhotoPage.startInstance(context: context, images: filteredImages, position: index);
+                            // PreviewPhotoPage.startInstance(context: context, images: filteredImages, position: index);
+                            context.appRouter.push(PreviewPhotoPageRoute(images: filteredImages, position: index));
                           }
                         },
                       ),

+ 92 - 44
packages/cpt_community/lib/modules/community/community_page.dart

@@ -84,51 +84,99 @@ class CommunityPage extends HookConsumerWidget {
               backgroundColor: context.appColors.backgroundWhite,
             ),
           backgroundColor: context.appColors.backgroundDefault,
-          body: AutoTabsRouter.pageView(
-            key: tabsRouterKey,
-            routes: const [
-              NewsPageRoute(),
-              FollowingPageRoute(),
-              ForyouPageRoute(),
-              ForsalePageRoute(),
-              ForrentPageRoute(),
-            ],
-            // physics: const NeverScrollableScrollPhysics(), // 禁止滚动
-            builder: (context, child, pageController) {
-              final tabsRouter = AutoTabsRouter.of(context);
-
-              return NestedScrollView(
-                headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
-                  return [
-                    // top 组件,转换为 Sliver 组件
-                    SliverToBoxAdapter(
-                      child: _buildTopSection(context, ref, vm, state),
-                    ),
-                    // tab 组件,使用 SliverPersistentHeader 实现吸顶
-                    // SliverPersistentHeader(
-                    //   pinned: true,
-                    //   delegate: CustomSliverPersistentHeaderDelegate(
-                    //     child: _buildTabsSection(context, ref, tabsRouter, vm, state),
-                    //   ),
-                    // ),
-                    // SliverToBoxAdapter(
-                    //   child: _buildPostSection(context, ref, vm, state),
-                    // ),
-                  ];
-                },
-                body: Column(
-                  mainAxisSize: MainAxisSize.max,
-                  children: [
-                    _buildTabsSection(context, ref, tabsRouter, vm, state),
-                    _buildPostSection(context, ref, vm, state),
-                    Expanded(
-                        child: child
-                    ),
-                  ],
-                ), // post 组件和其他内容
-              );
+          body:  NestedScrollView(
+            headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
+              return [
+              // top 组件,转换为 Sliver 组件
+              SliverToBoxAdapter(
+              child: _buildTopSection(context, ref, vm, state),
+              ),
+              // tab 组件,使用 SliverPersistentHeader 实现吸顶
+              // SliverPersistentHeader(
+              //   pinned: true,
+              //   delegate: CustomSliverPersistentHeaderDelegate(
+              //     child: _buildTabsSection(context, ref, tabsRouter, vm, state),
+              //   ),
+              // ),
+              // SliverToBoxAdapter(
+              //   child: _buildPostSection(context, ref, vm, state),
+              // ),
+              ];
             },
-          ),
+            body: Column(
+              mainAxisSize: MainAxisSize.max,
+              children: [
+                Expanded(
+                    child: AutoTabsRouter.pageView(
+                      key: tabsRouterKey,
+                      routes: const [
+                        NewsPageRoute(),
+                        FollowingPageRoute(),
+                        ForyouPageRoute(),
+                        ForsalePageRoute(),
+                        ForrentPageRoute(),
+                      ],
+                      builder: (context, child, pageController) {
+                            final tabsRouter = AutoTabsRouter.of(context);
+                        return Column(
+                          children: [
+                            _buildTabsSection(context, ref, tabsRouter, vm, state),
+                            _buildPostSection(context, ref, vm, state),
+                            Expanded(child: child),
+                          ],
+                        );
+                      },
+                    )
+                )
+              ]
+            )
+          )
+
+          // AutoTabsRouter.pageView(
+          //   key: tabsRouterKey,
+          //   routes: const [
+          //     NewsPageRoute(),
+          //     FollowingPageRoute(),
+          //     ForyouPageRoute(),
+          //     ForsalePageRoute(),
+          //     ForrentPageRoute(),
+          //   ],
+          //   // physics: const NeverScrollableScrollPhysics(), // 禁止滚动
+          //   builder: (context, child, pageController) {
+          //     final tabsRouter = AutoTabsRouter.of(context);
+          //
+          //     return NestedScrollView(
+          //       headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
+          //         return [
+          //           // top 组件,转换为 Sliver 组件
+          //           SliverToBoxAdapter(
+          //             child: _buildTopSection(context, ref, vm, state),
+          //           ),
+          //           // tab 组件,使用 SliverPersistentHeader 实现吸顶
+          //           // SliverPersistentHeader(
+          //           //   pinned: true,
+          //           //   delegate: CustomSliverPersistentHeaderDelegate(
+          //           //     child: _buildTabsSection(context, ref, tabsRouter, vm, state),
+          //           //   ),
+          //           // ),
+          //           // SliverToBoxAdapter(
+          //           //   child: _buildPostSection(context, ref, vm, state),
+          //           // ),
+          //         ];
+          //       },
+          //       body: Column(
+          //         mainAxisSize: MainAxisSize.max,
+          //         children: [
+          //           _buildTabsSection(context, ref, tabsRouter, vm, state),
+          //           _buildPostSection(context, ref, vm, state),
+          //           Expanded(
+          //               child: child
+          //           ),
+          //         ],
+          //       ), // post 组件和其他内容
+          //     );
+          //   },
+          // ),
         );
     }
 

+ 18 - 0
packages/cpt_community/lib/modules/community/community_pageview_idx_data.dart

@@ -1,7 +1,25 @@
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+
+import '../garage/for_rent/for_rent_vm.dart';
+import '../garage/for_sale/for_sale_vm.dart';
+import 'following/following_vm.dart';
+import 'foryou/foryou_vm.dart';
+import 'news/news_state.dart';
+import 'news/news_vm.dart';
+
 class CommunityPageViewIdxData {
   static const int news = 0;
   static const int following = 1;
   static const int forYou = 2;
   static const int forSale = 3;
   static const int forRent = 4;
+
+
+  static Map<int, String> get values => {
+    0: "news",
+    1: "following",
+    2: "forYou",
+    3: "forSale",
+    4: "forRent",
+  };
 }

+ 5 - 1
packages/cpt_community/lib/modules/community/community_state.dart

@@ -6,6 +6,7 @@ class CommunityVmState {
   List<Map<String, dynamic>>? topSectionsData;
   List<String>? newsFeedTabsList;
   List<String>? garageSaleTabsList;
+  List<Map<String, dynamic>>? garageCategoryList = []; // garageCategoryList
   int currentCategoryIdx = 0;   // 0: news feed, 1: garage sale
   int currentPageViewIdx = 0;
   int lastNewsfeedTabIdx = 0; // 上一次newsfeed 的 tabIdx
@@ -22,6 +23,7 @@ class CommunityVmState {
     lastGarageTabIdx,
     newsFeedTabsList,
     garageSaleTabsList,
+    List<Map<String, dynamic>>? garageCategoryList,
     this.tabsRouter,
     this.pageController,
   }) : topSectionsData = topSectionsData?? [
@@ -46,7 +48,7 @@ class CommunityVmState {
   garageSaleTabsList = garageSaleTabsList?? [
     "For Sale",
     "For Rent",
-  ];
+  ], garageCategoryList = garageCategoryList?? [];
 
   CommunityVmState copyWith({
     List<Map<String, dynamic>>? topSectionsData,
@@ -56,6 +58,7 @@ class CommunityVmState {
     int? currentPageViewIdx,
     int? lastNewsfeedTabIdx,
     int? lastGarageTabIdx,
+    List<Map<String, dynamic>>? garageCategoryList,
     dynamic? tabsRouter,
     dynamic? pageController,
   }) {
@@ -67,6 +70,7 @@ class CommunityVmState {
       currentPageViewIdx: currentPageViewIdx ?? this.currentPageViewIdx,
       lastNewsfeedTabIdx: lastNewsfeedTabIdx ?? this.lastNewsfeedTabIdx,
       lastGarageTabIdx: lastGarageTabIdx ?? this.lastGarageTabIdx,
+      garageCategoryList: garageCategoryList ?? this.garageCategoryList,
       tabsRouter: tabsRouter ?? this.tabsRouter,
       pageController: pageController ?? this.pageController,
     );

+ 191 - 75
packages/cpt_community/lib/modules/community/community_vm.dart

@@ -1,9 +1,15 @@
 
 import 'package:cpt_community/components/comments_dialog.dart';
+import 'package:cpt_community/modules/community/following/following_vm.dart';
+import 'package:cpt_community/modules/community/news/news_vm.dart';
+import 'package:cpt_community/respository/common_garage.dart';
+import 'package:cpt_community/respository/common_newsfeed.dart';
 import 'package:cpt_community/router/page/community_page_router.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
 import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_riverpod/flutter_riverpod.dart';
 import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -13,11 +19,16 @@ import 'package:auto_route/auto_route.dart';
 import 'package:widgets/dialog/app_custom_dialog.dart';
 import 'package:widgets/my_checkbox_group.dart';
 
+import '../garage/for_rent/for_rent_vm.dart';
+import '../garage/for_sale/for_sale_vm.dart';
 import '../garage/garagesale_post/garagesale_post_page.dart';
 import '../my_following/my_following_page.dart';
 import '../my_posts/my_posts_page.dart';
 import 'community_page.dart';
+import 'community_pageview_idx_data.dart';
 import 'community_state.dart';
+import 'foryou/foryou_vm.dart';
+import 'news/news_state.dart';
 import 'newsfeed_post/newsfeed_post_page.dart';
 
 part 'community_vm.g.dart';
@@ -25,7 +36,15 @@ part 'community_vm.g.dart';
 @riverpod
 class CommunityVm extends _$CommunityVm {
   get topSectionsData => state.topSectionsData;
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
+  late CommonGarageRespository commonGarageRespositoryInstance;
 
+  final Map<int, dynamic> providerMap = {};
+
+// 根据索引获取 Provider
+  ProviderBase getProvider(int index) {
+    return providerMap[index]!;
+  }
 
   CommunityVmState initState() {
     return CommunityVmState(
@@ -47,24 +66,51 @@ class CommunityVm extends _$CommunityVm {
 
   @override
   CommunityVmState build(){
+    // 引入数据仓库
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     final state = initState();
-
     // 第一帧渲染完成
-
     WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
+      // 存入 一组 pageView的 vm
+      CommunityPageViewIdxData.values.forEach((key, value) {
+        switch(key){
+          case 0:
+            providerMap[key] = ref.read(newsVmProvider.notifier);
+            break;
+          case 1:
+            providerMap[key] = ref.read(followingVmProvider.notifier);
+            break;
+          case 2:
+            providerMap[key] = ref.read(foryouVmProvider.notifier);
+            break;
+          case 3:
+            providerMap[key] = ref.read(forsaleVmProvider.notifier);
+            break;
+          case 4:
+            providerMap[key] = ref.read(forrentVmProvider.notifier);
+        }
+      });
 
+      // 获取第一个 provider
+      // final newsVmProvider = providerMap[0]['provider'] as AutoDisposeNotifierProviderImpl<NewsVm, NewsState>;
+      // Log.d("444444  ${newsVmProvider}");
+      // ref.read(newsVmProvider.notifier).test();
+    });
+    Log.d("-------------community vm-------------build---------------------");
+    ref.onDispose((){
+      Log.d("-------------community vm-------------dispose---------------------");
     });
-    Log.d("--------------------------build---------------------");
-
     return state;
   }
 
   tabsRouterChange(){
     Log.d("----tabsRouterChange---${tabsRouterKey.currentState?.controller?.activeIndex}-");
+    
     state = state.copyWith(currentPageViewIdx: tabsRouterKey.currentState?.controller?.activeIndex ?? 0);
   }
 
-  // 切换tab
+  // 点击tab 切换tab
   handlerChangeTab(int tabIndex, TabsRouter? tabsRouter, int? categoryIdx) {
     tabsRouter = (tabsRouter?? tabsRouterKey.currentState?.controller)!;
     categoryIdx = categoryIdx ?? state.currentCategoryIdx;
@@ -75,6 +121,15 @@ class CommunityVm extends _$CommunityVm {
     }
   }
 
+  // 获取当前pageView 的vm
+  getCurrentPageViewVm(int? pageViewIdx){
+    if(pageViewIdx !=null){
+      return providerMap[pageViewIdx];
+    }else {
+      return getCurrentPageViewVm(state.currentPageViewIdx);
+    }
+  }
+
   // 切换news feed和garage sale
   handlerSwitchNewsfeedOrGaragesale( int categoryIdx, BuildContext? context, TabsRouter? tabsRouter){
     tabsRouter = (tabsRouter?? tabsRouterKey.currentState?.controller)!;
@@ -95,6 +150,8 @@ class CommunityVm extends _$CommunityVm {
     );
   }
 
+  // 返回当前 pageView 页面的 vm
+
   // 判断当前pageview 页面正处于显示状态
   Future isCurrentPageViewShowing(int pageViewIdx) async{
     // 延迟获取结果
@@ -104,75 +161,106 @@ class CommunityVm extends _$CommunityVm {
     return isShowing;
   }
 
+  // 获取garage sale 分类选项
+  Future getGarageSaleCategoryOptions() async{
+    final Map<String, dynamic> params = {};
+    final result = await commonGarageRespositoryInstance.fetchGarageCateGoryList(params);
+    return result;
+  }
   // 选择 garage sale 导航栏点击 选择分类
   handlerChooseGarageCategory(BuildContext context) async {
-    List<Map<String, dynamic>> categoryList = [
-      {
-        'id': '1',
-        'label': 'Kids',
-      },
-      {
-        'id': '2',
-        'label': 'Homeware',
-      },
-      {
-        'id': '3',
-        'label': 'Fashion',
-      },
-      {
-        'id': '4',
-        'label': 'Electronics',
-      },
-      {
-        'id': '5',
-        'label': 'Sports',
-      },
-      {
-        'id': '6',
-        'label': 'Furniture',
-      },
-      {
-        'id': '7',
-        'label': 'Others',
-      },
+    List<Map<String, dynamic>> garageCategoryList = [
+      // {
+      //   'id': '1',
+      //   'name': 'Kids',
+      // },
+      // {
+      //   'id': '2',
+      //   'name': 'Homeware',
+      // },
+      // {
+      //   'id': '3',
+      //   'name': 'Fashion',
+      // },
+      // {
+      //   'id': '4',
+      //   'name': 'Electronics',
+      // },
+      // {
+      //   'id': '5',
+      //   'name': 'Sports',
+      // },
+      // {
+      //   'id': '6',
+      //   'name': 'Furniture',
+      // },
+      // {
+      //   'id': '7',
+      //   'name': 'Others',
+      // },
     ];
-    await DialogEngine.show(
-        tag: "chooseGarageSaleCategory",
-        position: DialogPosition.center,
-        widget: AppCustomDialog(
-          message: '',
-          dialogWidth: MediaQuery.of(context).size.width * 0.8,
-          // contentBoxMaxHeight: 350,
-          // contentBoxMinHeight: 300,
-          confirmTxt: "Ok",
-          messageBuilder: (BuildContext context){
-            return Container(
-              color: context.appColors.textWhite,
-              child: Column(
-                mainAxisAlignment: MainAxisAlignment.start,
-                crossAxisAlignment: CrossAxisAlignment.start,
-                children: [
-                  MyCheckboxGroup(
-                      isSingleSelect: false,
-                      labelStyle: const TextStyle(
-                        fontSize: 16,
-                        fontWeight: FontWeight.w500,
-                      ),
-                      items: categoryList,
-                      onChanged: (List<Map<String, dynamic>> selectedItems){
-                        Log.d("----MyCheckboxGroup onChanged  $selectedItems");
-                      }
-                  )
-                ],
-              ),
-            );
-          },
-          isShowCancelBtn:false,
-          confirmAction: (){
-
-          },
-        )
-    );
+
+    // 获取分类列表
+    try {
+      final result = await getGarageSaleCategoryOptions();
+      if(result.isSuccess){
+        final listJson = result.getListJson();
+        // 将 listJson 转换为 List<Map<String, dynamic>>
+        garageCategoryList = (listJson as List?)?.map((item) => item as Map<String, dynamic>).toList() ?? [];
+        state = state.copyWith(
+            garageCategoryList: garageCategoryList
+        );
+
+        await DialogEngine.show(
+            tag: "chooseGarageSaleCategory",
+            position: DialogPosition.center,
+            widget: AppCustomDialog(
+              message: '',
+              dialogWidth: MediaQuery.of(context).size.width * 0.8,
+              // contentBoxMaxHeight: 350,
+              // contentBoxMinHeight: 300,
+              isShowConfirmBtn: state.garageCategoryList!.length > 0 ? true: false,
+              confirmTxt: "Ok",
+              messageBuilder: (BuildContext context){
+                return Container(
+                  color: context.appColors.textWhite,
+                  child: Column(
+                    mainAxisAlignment: MainAxisAlignment.start,
+                    crossAxisAlignment: CrossAxisAlignment.start,
+                    children: state.garageCategoryList!.length > 0 ? [
+                      MyCheckboxGroup(
+                          isSingleSelect: false,
+                          labelStyle: const TextStyle(
+                            fontSize: 16,
+                            fontWeight: FontWeight.w500,
+                          ),
+                          items: state.garageCategoryList!,
+                          onChanged: (List<Map<String, dynamic>> selectedItems){
+                            Log.d("----MyCheckboxGroup onChanged  $selectedItems");
+                          }
+                      )
+                    ]: [
+                      Container(
+                        child: CircularProgressIndicator(
+                          strokeWidth: 3,
+                          valueColor: AlwaysStoppedAnimation(context.appColors.textDarkGray),
+                        ),
+                      )
+                    ],
+                  ),
+                );
+              },
+              isShowCancelBtn:false,
+              confirmAction: (){
+
+              },
+            )
+        );
+      }
+    }catch(error){
+      Log.d("---------------- $error");
+    }
+
   }
 
   // 点击了导航栏的 like btn
@@ -189,12 +277,11 @@ class CommunityVm extends _$CommunityVm {
 
   // 点击了导航栏的 filter btn
   handlerClickNavbarFilterBtn(BuildContext? context,){
-    ToastEngine.show("点击 filter");
     handlerChooseGarageCategory(context!);
   }
 
   // 点击发布的按钮 跳转到 newsfeed 发布的页面
-  void handlerGotoNewsfeedPost(context){
+  void handlerGotoNewsfeedPost(BuildContext? context){
     // AutoRouter.of(context).pushNamed(RouterPath.newsFeedPost);
     NewsfeedPostPage.startInstance();
     // MyPostsPage.startInstance();
@@ -202,8 +289,37 @@ class CommunityVm extends _$CommunityVm {
   }
 
   // 点击发布的按钮 跳转到garagesale 发布的页面
-  void handlerGotoGaragePost(context){
-    GaragesalePostPage.startInstance();
+  void handlerGotoGaragePost(BuildContext? context){
+    int  type = 1;
+    CommunityPageViewIdxData.values.forEach((key, value){
+        if(value == "forSale" ){
+          if(state.currentPageViewIdx == key){
+            type = 1;
+          }
+        }else if(value == "forRent"){
+          if(state.currentPageViewIdx == key){
+            type = 2;
+          }
+        }
+    });
+    GaragesalePostPage.startInstance(type: type);
+  }
+
+  // 点击了 卡片上的 关注按钮
+  Future<bool> commonClickCardFollowBtn(BuildContext? context,int to_user_id,bool isFollowed, int? idx) async{
+    try{
+      Map<String, dynamic> params = {
+        "to_user_id": to_user_id
+      };
+      final result = await commonNewsFeedRespositoryInstance.handlerFollowOrCancel(params);
+      if(result.isSuccess){
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      return false;
+    }
   }
 }
 

+ 1 - 1
packages/cpt_community/lib/modules/community/community_vm.g.dart

@@ -6,7 +6,7 @@ part of 'community_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$communityVmHash() => r'9d2a5247072e1a6032db058cc0f21591bc739d07';
+String _$communityVmHash() => r'ad31041e0609827cdf51a497e69f71ab48355fbc';
 
 /// See also [CommunityVm].
 @ProviderFor(CommunityVm)

+ 9 - 4
packages/cpt_community/lib/modules/community/following/following_page.dart

@@ -3,6 +3,7 @@ import 'package:auto_route/auto_route.dart';
 import 'package:flutter/rendering.dart';
 import 'package:flutter_hooks/flutter_hooks.dart';
 import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:plugin_basic/basic_export.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:shared/utils/ext_dart.dart';
@@ -20,6 +21,8 @@ import '../../../components/newfeed_card_header.dart';
 import '../../../components/newsfeed_card_content.dart';
 import '../../../components/newsfeed_card_footer.dart';
 import '../../../router/page/community_page_router.dart';
+import '../community_page.dart';
+import '../community_pageview_idx_data.dart';
 import 'following_vm.dart';
 
 @RoutePage()
@@ -39,6 +42,7 @@ class FollowingPage extends HookConsumerWidget {
   Widget build(BuildContext context, WidgetRef ref) {
     final vm = ref.read(followingVmProvider.notifier);
     final state = ref.watch(followingVmProvider);
+    bool isVisible = false;
     useEffect((){
       // 组件挂载时执行 - 执行接口请求
       Future.microtask(() => vm.initPageData());
@@ -57,15 +61,15 @@ class FollowingPage extends HookConsumerWidget {
           mainAxisSize: MainAxisSize.max,
           children: [
             Expanded(
-              child: EasyRefresh(
+              child:  EasyRefresh(
                 controller: vm.refreshController,
                 key: UniqueKey(),
                 onLoad: () async{
-                  Log.d("----onLoad");
+                  Log.d("--following--onLoad");
                   vm.loadMore();
                 },
                 onRefresh: () async{
-                  Log.d("----onRefresh");
+                  Log.d("--following--onRefresh");
                   vm.onRefresh();
                 },
                 child: LoadStateLayout(
@@ -97,6 +101,7 @@ class FollowingPage extends HookConsumerWidget {
     String card_created_at = item.getValue("created_at", "");
     Map<String, dynamic>? card_account = item.getValue<Map<String,dynamic>>("account", {});
     String card_avator = card_account?['avator']?? "";
+    String card_count_name = card_account?['name']?? "";
     bool card_followed = card_account?['followed']??false;
     String card_content = item.getValue("content", "");
     List? card_resources = item.getValue<List>("resources", [])?? [];
@@ -128,7 +133,7 @@ class FollowingPage extends HookConsumerWidget {
                 Container(
                   child: NewsFeedCardHeader(
                     key: UniqueKey(),
-                    title: card_title,
+                    title: card_count_name,
                     avator: card_avator,
                     time: card_created_at,
                   ),

+ 0 - 15
packages/cpt_community/lib/modules/community/following/following_state.dart

@@ -4,17 +4,11 @@ class FollowingState {
   //页面 LoadView 状态的展示
   LoadState loadingState;
   String? errorMessage;
-  int? page;
-  int? limit = 10;
-  int? count = 0;
   List<Map<String, dynamic>>? list = [];
 
   FollowingState({
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     this.list,
   });
 
@@ -29,9 +23,6 @@ class FollowingState {
     return FollowingState(
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       list: list ?? this.list,
     );
   }
@@ -40,9 +31,6 @@ class FollowingState {
     return {
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'list': this.list,
     };
   }
@@ -51,9 +39,6 @@ class FollowingState {
     return FollowingState(
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       list: map['list'] as List<Map<String, dynamic>>,
     );
   }

+ 86 - 57
packages/cpt_community/lib/modules/community/following/following_vm.dart

@@ -1,4 +1,3 @@
-import 'package:cpt_community/respository/newsfeed_following_repository.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:domain/entity/newsfeed_following_entity.dart';
 import 'package:flutter/cupertino.dart';
@@ -10,6 +9,7 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
+import '../../../respository/common_newsfeed.dart';
 import '../../../router/page/community_page_router.dart';
 import '../community_pageview_idx_data.dart';
 import '../community_vm.dart';
@@ -19,7 +19,11 @@ part 'following_vm.g.dart';
 
 @riverpod
 class FollowingVm extends _$FollowingVm {
-  late NewsFeedFollowingRepository repositoryInstance;
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
+  
   bool _needShowPlaceholder = false; //是否展示LoadingView
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
@@ -36,9 +40,9 @@ class FollowingVm extends _$FollowingVm {
   @override
   FollowingState build(){
     // 引入数据仓库
-    repositoryInstance = ref.read(newsFeedFollowingRepositoryProvider);
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     final state = initState();
-    Log.d("--------------------------build---------------------");
+    Log.d("---------------following-----------build---------------------");
 
     return state;
   }
@@ -63,31 +67,30 @@ class FollowingVm extends _$FollowingVm {
     if(isShowing){
       Log.d("----following_vm-----loadMore");
       // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= state.count){
+      // if(state.list.length >= _count){
       //   return;
       // }else {
-      //   int page = state.page + 1;
+      //   int page = _page + 1;
       //   state = state.copyWith(page: page,);
       //   getListData();
       // }
-      // 检查 page 是否为 null,并初始化为 1
-      int newCurPage = state.page ?? 1;
-      state = state.copyWith(page: ++newCurPage);
+      _page++;
       getListData();
     }else {
-      refreshController.finishRefresh();
+      refreshController.finishLoad();
     }
   }
 
 
   // 下拉刷新
   Future onRefresh() async {
+    Log.d("--following--following_vm-----onRefresh ");
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.following);
     if(isShowing){
       // 当前pageView 页面正处于显示状态
       Log.d("----following_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
-      state = state.copyWith(page: 1);
+      _page = 1;
       getListData();
     }else {
       refreshController.finishRefresh();
@@ -98,9 +101,11 @@ class FollowingVm extends _$FollowingVm {
   Future retryRequest() async {
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.following);
     if(isShowing){
-      state = state.copyWith(page: 1);
+      _page = 1;
       _needShowPlaceholder = true;
       getListData();
+    }else {
+      refreshController.finishRefresh();
     }
   }
 
@@ -110,16 +115,16 @@ class FollowingVm extends _$FollowingVm {
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
-    Log.d("加载listData数据---------------start--${state.page}---");
+    Log.d("加载listData数据---------------start--${_page}---");
 
     try {
       //请求网络
       Map<String, dynamic>  params = {
-        "page": state.page,
-        "limit": state.limit,
+        "page": _page,
+        "limit": _limit,
       };
       Log.d("请求参数------$params");
-      final result = await repositoryInstance.fetchFollowingList(params);
+      final result = await commonNewsFeedRespositoryInstance.fetchFollowingList(params);
       //校验成功失败
       if (result.isSuccess) {
         handlerResultList((result.data  as NewsfeedFollowingEntity).list);
@@ -132,14 +137,14 @@ class FollowingVm extends _$FollowingVm {
       ToastEngine.show("Error: $e");
     }
     // // 最后赋值
-    _needShowPlaceholder = false;
+    // _needShowPlaceholder = false;
   }
 
 
   void handlerResultList(List<NewsfeedFollowingList>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
-      if (state.page == 1) {
+      if (_page == 1) {
         //刷新的方式
         state.list!.clear();
         state.list!.addAll(list.map((item) => item.toJson()).toList());
@@ -154,7 +159,7 @@ class FollowingVm extends _$FollowingVm {
         refreshController.finishLoad();
       }
     } else {
-      if (state.page == 1) {
+      if (_page == 1) {
         //展示无数据的布局
         state.list!.clear();
         changeLoadingState(LoadState.State_Empty, null);
@@ -163,43 +168,60 @@ class FollowingVm extends _$FollowingVm {
         //展示加载完成,没有更多数据了
         if(state.list!.length == 0){
           changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishLoad();
         }else {
           if(_needShowPlaceholder){
             changeLoadingState(LoadState.State_Success, null);
           }
         }
+        //更新展示的状态
         refreshController.finishLoad(IndicatorResult.noMore);
       }
     }
   }
 
   // 点赞/取消点赞
-  Future handlerLikeClick(int id, bool isLike, int itemidx) async {
+  Future handlerLikeClick(int id, bool isLike, int? itemidx) async {
     try {
-      final result = await repositoryInstance.fetchLikeClick({
+      List<Map<String, dynamic>> listCopyDta =  List.from(state.list!);
+      final result = await commonNewsFeedRespositoryInstance.fetchLikeClick({
         "id": id,
       });
       if (result.isSuccess) {
-        //重新赋值data或list
-        // final json = result.getDataJson();
-        // var data = NewsfeedNewsEntity.fromJson(json!);
-        //重新赋值data或list
-        // state.list![id].liked = data.list![0].liked;
-        // state.list![id].likeno = data.list![0].likeno;
-        final String toastMsg = isLike ? "Cancel successfully": "Liked successfully";
-        ToastEngine.show(toastMsg);
-        // 修改 state.list[itemIdx] 中的 like 状态 和 likes_count
-        state.list![itemidx]['liked'] = !isLike;
-        if(isLike){
-          // 取消点赞
-          if(state.list![itemidx]['likes_count']>0){
-            state.list![itemidx]['likes_count'] = state.list![itemidx]['likes_count'] - 1;
+        if(itemidx != null){
+          // 修改 listCopyDta[itemIdx] 中的 like 状态 和 likes_count
+          listCopyDta![itemidx]['liked'] = !isLike;
+
+          if(isLike){
+            // 取消点赞
+            if(listCopyDta![itemidx]['likes_count']>0){
+              listCopyDta![itemidx]['likes_count'] = listCopyDta![itemidx]['likes_count'] - 1;
+            }
+          }else {
+            listCopyDta![itemidx]['likes_count'] = listCopyDta![itemidx]['likes_count'] + 1;
           }
         }else {
-          state.list![itemidx]['likes_count'] = state.list![itemidx]['likes_count'] + 1;
+          // 详情中的点赞 需要找到对应的 item 进行 修改 like 和 likes_count
+          listCopyDta!.forEach((carditem) {
+            if(carditem['id'] == id){
+              carditem['liked'] = !isLike;
+              if(isLike){
+                // 取消点赞
+                if(carditem['likes_count']>0){
+                  carditem['likes_count'] = carditem['likes_count'] - 1;
+                }
+              }else {
+                carditem['likes_count'] = carditem['likes_count'] + 1;
+              }
+            }
+          });
         }
-        //重新赋值data或list
-        changeLoadingState(LoadState.State_Success, null);
+
+        state = state.copyWith(list: listCopyDta);
+
+        final String toastMsg = isLike ? "Cancel successfully": "Liked successfully";
+        ToastEngine.show(toastMsg);
+
         return true;
       }else {
         return false;
@@ -230,27 +252,34 @@ class FollowingVm extends _$FollowingVm {
         break;
     }
   }
-  Future handlerFollow(BuildContext context, bool isFollow) async{
+  // 关注/取消关注
+  Future<bool> handlerFollow(BuildContext? context, int to_user_id,int cardId, bool isFollow) async{
     Log.d("点击了 关注");
-    // try {
-    //   //请求网络
-    //   Map<String, dynamic>  params = {
-    //
-    //   };
-    //   Log.d("请求参数------$params");
-    //   final result = await repositoryInstance.fetchNewsList(params);
-    //   //校验成功失败
-    //   if (result.isSuccess) {
-    //     handlerResultList((result.data  as NewsfeedNewsEntity).list);
-    //   } else {
-    //     String errorMessage = result.errorMsg!;
-    //     changeLoadingState(LoadState.State_Error, errorMessage);
-    //     ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //   }
-    // } catch (e) {
-    //   ToastEngine.show("Error: $e");
-    // }
+    try {
+      final result = await commonNewsFeedRespositoryInstance.handlerFollowOrCancel({
+        "to_user_id": to_user_id,
+      });
+      if(result.isSuccess){
+        // 修改cardId 对应的 card item 的 account 里面的 followed
+        if(cardId!=null){
+          final listCopyDta = List<Map<String, dynamic>>.from(state.list!);
+          listCopyDta!.forEach((carditem) {
+            if(carditem['id'] == cardId){
+              carditem['account']['followed'] = !carditem['account']['followed'];
+            }
+          });
+          state = state.copyWith(list: listCopyDta);
+        }
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      Log.d("error: $error");
+      return false;
+    }
   }
+
   // 去详情页面
   void handlerGotoDetail(BuildContext? context, int id){
     Log.d("去详情页面");

+ 1 - 1
packages/cpt_community/lib/modules/community/following/following_vm.g.dart

@@ -6,7 +6,7 @@ part of 'following_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$followingVmHash() => r'440282038f9410a19f56dec59438ed8b7e13d10f';
+String _$followingVmHash() => r'a8a3de76398c9469283ba056d29fb15ff314b280';
 
 /// See also [FollowingVm].
 @ProviderFor(FollowingVm)

+ 6 - 3
packages/cpt_community/lib/modules/community/foryou/foryou_page.dart

@@ -20,6 +20,8 @@ import '../../../components/newfeed_card_header.dart';
 import '../../../components/newsfeed_card_content.dart';
 import '../../../components/newsfeed_card_footer.dart';
 import '../../../router/page/community_page_router.dart';
+import '../community_page.dart';
+import '../community_pageview_idx_data.dart';
 import '../community_vm.dart';
 import 'foryou_vm.dart';
 
@@ -63,11 +65,11 @@ class ForyouPage extends HookConsumerWidget {
                 controller: vm.refreshController,
                 key: UniqueKey(),
                 onLoad: () async{
-                  Log.d("----onLoad");
+                  Log.d("--foryou--onLoad");
                   vm.loadMore();
                 },
                 onRefresh: () async{
-                  Log.d("----onRefresh");
+                  Log.d("--foryou--onRefresh");
                   vm.onRefresh();
                 },
                 child: LoadStateLayout(
@@ -99,6 +101,7 @@ class ForyouPage extends HookConsumerWidget {
     String card_created_at = item.getValue("created_at", "");
     Map<String, dynamic>? card_account = item.getValue<Map<String,dynamic>>("account", {});
     String card_avator = card_account?['avator']?? "";
+    String card_count_name = card_account?['name']?? "";
     bool card_followed = card_account?['followed']??false;
     String card_content = item.getValue("content", "");
     List? card_resources = item.getValue<List>("resources", [])?? [];
@@ -130,7 +133,7 @@ class ForyouPage extends HookConsumerWidget {
                 Container(
                   child: NewsFeedCardHeader(
                     key: UniqueKey(),
-                    title: card_title,
+                    title: card_count_name,
                     avator: card_avator,
                     time: card_created_at,
                   ),

+ 0 - 19
packages/cpt_community/lib/modules/community/foryou/foryou_state.dart

@@ -4,35 +4,22 @@ class ForyouState {
   //页面 LoadView 状态的展示
   LoadState loadingState;
   String? errorMessage;
-  int? page;
-  int? limit = 10;
-  int? count = 0;
-
   List<Map<String, dynamic>>? list = [];
 
   ForyouState({
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     this.list,
   });
 
   ForyouState copyWith({
     LoadState? loadingState,
     String? errorMessage,
-    int? page,
-    int? limit,
-    int? count,
     List<Map<String, dynamic>>? list,
   }) {
     return ForyouState(
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       list: list ?? this.list,
     );
   }
@@ -41,9 +28,6 @@ class ForyouState {
     return {
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'list': this.list,
     };
   }
@@ -52,9 +36,6 @@ class ForyouState {
     return ForyouState(
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       list: map['list'] as List<Map<String, dynamic>>,
     );
   }

+ 85 - 58
packages/cpt_community/lib/modules/community/foryou/foryou_vm.dart

@@ -9,7 +9,7 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
-import '../../../respository/newsfeed_foryou_repository.dart';
+import '../../../respository/common_newsfeed.dart';
 import '../../../router/page/community_page_router.dart';
 import '../community_pageview_idx_data.dart';
 import '../community_vm.dart';
@@ -20,9 +20,11 @@ part 'foryou_vm.g.dart';
 
 @riverpod
 class ForyouVm extends _$ForyouVm {
-  late NewsFeedForyouRepository repositoryInstance;
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
   bool _needShowPlaceholder = false; //是否展示LoadingView
-
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -31,6 +33,7 @@ class ForyouVm extends _$ForyouVm {
 
   ForyouState initState() {
     return ForyouState(
+        loadingState: LoadState.State_Loading,
         list: []
     );
   }
@@ -38,7 +41,7 @@ class ForyouVm extends _$ForyouVm {
   @override
   ForyouState build(){
     // 引入数据仓库
-    repositoryInstance = ref.read(newsFeedForyouRepositoryProvider);
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -65,19 +68,18 @@ class ForyouVm extends _$ForyouVm {
     if(isShowing){
       Log.d("----foryou_vm-----loadMore");
       // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= state.count){
+      // if(state.list.length >= _count){
       //   return;
       // }else {
-      //   int page = state.page + 1;
+      //   int page = _page + 1;
       //   state = state.copyWith(page: page,);
       //   getListData();
       // }
       // 检查 page 是否为 null,并初始化为 1
-      int newCurPage = state.page ?? 1;
-      state = state.copyWith(page: ++newCurPage);
+      _page++;
       getListData();
     }else {
-      refreshController.finishRefresh();
+      refreshController.finishLoad();
     }
   }
 
@@ -89,7 +91,7 @@ class ForyouVm extends _$ForyouVm {
       // 当前pageView 页面正处于显示状态
       Log.d("----forsale_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
-      state = state.copyWith(page: 1);
+      _page = 1;
       getListData();
     }else {
       refreshController.finishRefresh();
@@ -100,7 +102,7 @@ class ForyouVm extends _$ForyouVm {
   Future retryRequest() async {
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forYou);
     if(isShowing){
-      state = state.copyWith(page: 1);
+      _page = 1;
       _needShowPlaceholder = true;
       getListData();
     }
@@ -113,12 +115,12 @@ class ForyouVm extends _$ForyouVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("加载listData数据---------------start--${state.page}---");
+    Log.d("加载listData数据---------------start--${_page}---");
     //   try {
     //     //请求网络
     //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
+    //       "page": _page,
+    //       "limit": _limit,
     //     };
     //     Log.d("请求参数------$params");
     //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
@@ -219,7 +221,7 @@ class ForyouVm extends _$ForyouVm {
     //   },
     // ];
     //
-    // if (state.page == 1) {
+    // if (_page == 1) {
     //   //刷新的方式
     //   state = state.copyWith(list: listData);
     //   refreshController.finishRefresh();
@@ -240,11 +242,11 @@ class ForyouVm extends _$ForyouVm {
     try {
       //请求网络
       Map<String, dynamic>  params = {
-        "page": state.page,
-        "limit": state.limit,
+        "page": _page,
+        "limit": _limit,
       };
       Log.d("请求参数------$params");
-      final result = await repositoryInstance.fetchForyouList(params);
+      final result = await commonNewsFeedRespositoryInstance.fetchForyouList(params);
       //校验成功失败
       if (result.isSuccess) {
         handlerResultList((result.data  as NewsfeedForyouEntity).list);
@@ -262,7 +264,7 @@ class ForyouVm extends _$ForyouVm {
   void handlerResultList(List<NewsfeedForyouList>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
-      if (state.page == 1) {
+      if (_page == 1) {
         //刷新的方式
         state.list!.clear();
         state.list!.addAll(list.map((item) => item.toJson()).toList());
@@ -277,7 +279,7 @@ class ForyouVm extends _$ForyouVm {
         refreshController.finishLoad();
       }
     } else {
-      if (state.page == 1) {
+      if (_page == 1) {
         //展示无数据的布局
         state.list!.clear();
         changeLoadingState(LoadState.State_Empty, null);
@@ -286,43 +288,60 @@ class ForyouVm extends _$ForyouVm {
         //展示加载完成,没有更多数据了
         if(state.list!.length == 0){
           changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishLoad();
         }else {
           if(_needShowPlaceholder){
             changeLoadingState(LoadState.State_Success, null);
           }
         }
+        //更新展示的状态
         refreshController.finishLoad(IndicatorResult.noMore);
       }
     }
   }
 
   // 点赞/取消点赞
-  Future handlerLikeClick(int id, bool isLike, int itemidx) async {
+  Future handlerLikeClick(int id, bool isLike, int? itemidx) async {
     try {
-      final result = await repositoryInstance.fetchLikeClick({
+      List<Map<String, dynamic>> listCopyDta =  List.from(state.list!);
+      final result = await commonNewsFeedRespositoryInstance.fetchLikeClick({
         "id": id,
       });
       if (result.isSuccess) {
-        //重新赋值data或list
-        // final json = result.getDataJson();
-        // var data = NewsfeedNewsEntity.fromJson(json!);
-        //重新赋值data或list
-        // state.list![id].liked = data.list![0].liked;
-        // state.list![id].likeno = data.list![0].likeno;
-        final String toastMsg = isLike ? "Cancel successfully": "Liked successfully";
-        ToastEngine.show(toastMsg);
-        // 修改 state.list[itemIdx] 中的 like 状态 和 likes_count
-        state.list![itemidx]['liked'] = !isLike;
-        if(isLike){
-          // 取消点赞
-          if(state.list![itemidx]['likes_count']>0){
-            state.list![itemidx]['likes_count'] = state.list![itemidx]['likes_count'] - 1;
+        if(itemidx != null){
+          // 修改 listCopyDta[itemIdx] 中的 like 状态 和 likes_count
+          listCopyDta![itemidx]['liked'] = !isLike;
+
+          if(isLike){
+            // 取消点赞
+            if(listCopyDta![itemidx]['likes_count']>0){
+              listCopyDta![itemidx]['likes_count'] = listCopyDta![itemidx]['likes_count'] - 1;
+            }
+          }else {
+            listCopyDta![itemidx]['likes_count'] = listCopyDta![itemidx]['likes_count'] + 1;
           }
         }else {
-          state.list![itemidx]['likes_count'] = state.list![itemidx]['likes_count'] + 1;
+          // 详情中的点赞 需要找到对应的 item 进行 修改 like 和 likes_count
+          listCopyDta!.forEach((carditem) {
+            if(carditem['id'] == id){
+              carditem['liked'] = !isLike;
+              if(isLike){
+                // 取消点赞
+                if(carditem['likes_count']>0){
+                  carditem['likes_count'] = carditem['likes_count'] - 1;
+                }
+              }else {
+                carditem['likes_count'] = carditem['likes_count'] + 1;
+              }
+            }
+          });
         }
-        //重新赋值data或list
-        changeLoadingState(LoadState.State_Success, null);
+
+        state = state.copyWith(list: listCopyDta);
+
+        final String toastMsg = isLike ? "Cancel successfully": "Liked successfully";
+        ToastEngine.show(toastMsg);
+
         return true;
       }else {
         return false;
@@ -353,27 +372,35 @@ class ForyouVm extends _$ForyouVm {
         break;
     }
   }
-  Future handlerFollow(BuildContext context, bool isFollow) async{
+
+  // 关注/取消关注
+  Future<bool> handlerFollow(BuildContext? context, int to_user_id,int cardId, bool isFollow) async{
     Log.d("点击了 关注");
-    // try {
-    //   //请求网络
-    //   Map<String, dynamic>  params = {
-    //
-    //   };
-    //   Log.d("请求参数------$params");
-    //   final result = await repositoryInstance.fetchNewsList(params);
-    //   //校验成功失败
-    //   if (result.isSuccess) {
-    //     handlerResultList((result.data  as NewsfeedNewsEntity).list);
-    //   } else {
-    //     String errorMessage = result.errorMsg!;
-    //     changeLoadingState(LoadState.State_Error, errorMessage);
-    //     ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //   }
-    // } catch (e) {
-    //   ToastEngine.show("Error: $e");
-    // }
+    try {
+      final result = await commonNewsFeedRespositoryInstance.handlerFollowOrCancel({
+        "to_user_id": to_user_id,
+      });
+      if(result.isSuccess){
+        // 修改cardId 对应的 card item 的 account 里面的 followed
+        if(cardId!=null){
+          final listCopyDta = List<Map<String, dynamic>>.from(state.list!);
+          listCopyDta!.forEach((carditem) {
+            if(carditem['id'] == cardId){
+              carditem['account']['followed'] = !carditem['account']['followed'];
+            }
+          });
+          state = state.copyWith(list: listCopyDta);
+        }
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      Log.d("error: $error");
+      return false;
+    }
   }
+
   // 去详情页面
   void handlerGotoDetail(BuildContext? context, int id){
     Log.d("去详情页面");

+ 1 - 1
packages/cpt_community/lib/modules/community/foryou/foryou_vm.g.dart

@@ -6,7 +6,7 @@ part of 'foryou_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$foryouVmHash() => r'3e8bcaf6a2fde125f5957bccdec1076baaca385b';
+String _$foryouVmHash() => r'e80b452f3614a1872c18adb1a315443982185738';
 
 /// See also [ForyouVm].
 @ProviderFor(ForyouVm)

+ 46 - 32
packages/cpt_community/lib/modules/community/news/news_page.dart

@@ -42,6 +42,7 @@ class NewsPage extends HookConsumerWidget {
   Widget build(BuildContext context, WidgetRef ref) {
     final vm = ref.read(newsVmProvider.notifier);
     final state = ref.watch(newsVmProvider);
+
     useEffect((){
       // 组件挂载时执行 - 执行接口请求
       Future.microtask(() => vm.initPageData());
@@ -65,11 +66,11 @@ class NewsPage extends HookConsumerWidget {
               controller: vm.refreshController,
               key: UniqueKey(),
               onLoad: () async{
-                Log.d("----onLoad");
+                Log.d("--news--onLoad");
                 vm.loadMore();
               },
               onRefresh: () async{
-                Log.d("----onRefresh");
+                Log.d("--news--onRefresh");
                 vm.onRefresh();
               },
               child: LoadStateLayout(
@@ -98,15 +99,20 @@ class NewsPage extends HookConsumerWidget {
 
   Widget _buildNewsItem(BuildContext context, WidgetRef ref, Map<String, dynamic> item, vm, int itemIdx){
     String card_title = item.getValue("title", "");
+    int card_id = item.getValue("id", null);
     String card_created_at = item.getValue("created_at", "");
-    Map<String, dynamic>? card_account = item.getValue<Map<String,dynamic>>("account", {});
+    Map<String, dynamic>? card_account = item.getValue<Map<String,dynamic>>("account", null);
     String card_avator = card_account?['avator']?? "";
+    String card_count_name = card_account?['name']?? "";
     bool card_followed = card_account?['followed']??false;
+    int card_count_id = card_account?['id']?? null;
     String card_content = item.getValue("content", "");
     List? card_resources = item.getValue<List>("resources", [])?? [];
     bool card_liked = item.getValue("liked", false);
     int card_likes_count = item.getValue("likes_count", 0);
     int card_comments_count = item.getValue("comments_count", 0);
+
+
     return Container(
         margin: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
         padding: const EdgeInsets.only(left: 15, right: 15,top: 17,bottom: 0),
@@ -132,7 +138,7 @@ class NewsPage extends HookConsumerWidget {
                   Container(
                     child: NewsFeedCardHeader(
                       key: UniqueKey(),
-                      title: card_title,
+                      title: card_count_name,
                       avator: card_avator,
                       time: card_created_at,
                     ),
@@ -173,34 +179,42 @@ class NewsPage extends HookConsumerWidget {
                 ]
             ),
             // 右上角 关注/取消关注 按钮
-            Visibility(
-              visible: card_followed ? false: true,
-              child: Positioned(
-                  right: 10,
-                  top: -5,
-                  child: Container(
-                    width: 83.5,
-                    height: 45.5,
-                    alignment: Alignment.center,
-                    // decoration: BoxDecoration(
-                    //   color:  ColorUtils.string2Color('#4161D0'),
-                    //   borderRadius: BorderRadius.circular(5),
-                    // ),
-                    child: MyButton(
-                      text: '+Follow',
-                      textColor: Colors.white,
-                      backgroundColor: ColorUtils.string2Color('#4161D0'),
-                      radius: 8,
-                      minHeight: 27.5,
-                      padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
-                      fontWeight: FontWeight.w400,
-                      fontSize: 14,
-                      onPressed: (){
-                        vm.handlerFollow(context, card_followed);
-                      },
-                    ),
-                  )
-              ),
+            Positioned(
+                right: 10,
+                top: -5,
+                child: Container(
+                  width: 83.5,
+                  height: 50.5,
+                  alignment: Alignment.center,
+                  // decoration: BoxDecoration(
+                  //   color:  ColorUtils.string2Color('#4161D0'),
+                  //   borderRadius: BorderRadius.circular(5),
+                  // ),
+                  child: HookBuilder(
+                    builder: (context) {
+                      final isFollowedState = useState<bool>(card_followed);
+                      return MyButton(
+                        text: isFollowedState.value ? 'Followed': '+Follow',
+                        textColor: isFollowedState.value ?  context.appColors.disEnableGray: context.appColors.textWhite,
+                        disabledTextColor: context.appColors.disEnableGray,
+                        backgroundColor: isFollowedState.value ? Colors.transparent : ColorUtils.string2Color('#4161D0'),
+                        side: BorderSide(color: !isFollowedState.value ? Colors.transparent : context.appColors.disEnableGray, width: 0.5),
+                        radius: 8,
+                        minHeight: 27.5,
+                        padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
+                        fontWeight: FontWeight.w400,
+                        fontSize: 14,
+                        onPressed: () async{
+                          bool asyncResult = await vm.handlerFollow(context,card_count_id, card_id,  isFollowedState.value );
+                          if(asyncResult){
+                            // 成功  关注->取消关注  取消关注->关注
+                            isFollowedState.value = !isFollowedState.value;
+                          }
+                        },
+                      );
+                    }
+                  ),
+                )
             )
           ],
         ),

+ 0 - 15
packages/cpt_community/lib/modules/community/news/news_state.dart

@@ -4,18 +4,12 @@ class NewsState {
   //页面 LoadView 状态的展示
   LoadState loadingState;
   String? errorMessage;
-  int? page;
-  int? limit = 10;
-  int? count = 0;
   List<Map<String, dynamic>>? list = [];
 
 
   NewsState({
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     this.list,
   });
 
@@ -31,9 +25,6 @@ class NewsState {
     return NewsState(
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       list: list ?? this.list,
     );
   }
@@ -42,9 +33,6 @@ class NewsState {
     return {
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'list': this.list,
     };
   }
@@ -53,9 +41,6 @@ class NewsState {
     return NewsState(
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       list: map['list'] as List<Map<String, dynamic>>,
     );
   }

+ 93 - 184
packages/cpt_community/lib/modules/community/news/news_vm.dart

@@ -1,3 +1,4 @@
+import 'package:cpt_community/respository/common_newsfeed.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:domain/entity/newsfeed_news_entity.dart';
 import 'package:flutter/cupertino.dart';
@@ -9,18 +10,23 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
-import '../../../respository/newsfeed_news_repository.dart';
 import '../../../router/page/community_page_router.dart';
 import '../community_pageview_idx_data.dart';
 import '../community_vm.dart';
 import '../newsfeed_detail/newsfeed_detail_page.dart';
+import '../newsfeed_detail/newsfeed_detail_vm.dart';
 import 'news_state.dart';
 
 part 'news_vm.g.dart';
 
 @riverpod
 class NewsVm extends _$NewsVm {
-  late NewsFeedNewsRepository repositoryInstance;
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
+
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
+  
   bool _needShowPlaceholder = false; //是否展示LoadingView
 
   // Refresh 控制器
@@ -38,7 +44,7 @@ class NewsVm extends _$NewsVm {
   @override
   NewsState build(){
     // 引入数据仓库
-    repositoryInstance = ref.read(newsFeedNewsRepositoryProvider);
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -65,19 +71,17 @@ class NewsVm extends _$NewsVm {
     if(isShowing){
       Log.d("----news_vm-----loadMore");
       // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= state.count){
+      // if(state.list.length >= _count){
       //   return;
       // }else {
-      //   int page = state.page + 1;
+      //   int page = _page + 1;
       //   state = state.copyWith(page: page,);
       //   getListData();
       // }
-      // 检查 page 是否为 null,并初始化为 1
-      int newCurPage = state.page ?? 1;
-      state = state.copyWith(page: ++newCurPage);
-      getListData();
+      _page++;
+      getListData(isLoadMore: true);
     }else {
-      refreshController.finishRefresh();
+      refreshController.finishLoad();
     }
   }
 
@@ -89,7 +93,7 @@ class NewsVm extends _$NewsVm {
       // 当前pageView 页面正处于显示状态
       Log.d("----forsale_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
-      state = state.copyWith(page: 1);
+      _page = 1;
       getListData();
     }else {
       refreshController.finishRefresh();
@@ -100,154 +104,34 @@ class NewsVm extends _$NewsVm {
   Future retryRequest() async {
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.news);
     if(isShowing){
-      state = state.copyWith(page: 1);
+      _page = 1;
       _needShowPlaceholder = true;
       getListData();
+    }else {
+      refreshController.finishRefresh();
     }
   }
 
 
   // 获取list 列表数据
-  Future getListData<T>() async {
+  Future getListData<T>({bool? isLoadMore}) async {
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("加载listData数据---------------start--${state.page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-    //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
-    //     Log.d("请求完成结果------${result.data}");
-    //     //校验成功失败
-    //     if (result.isSuccess) {
-    //       // state = state.copyWith(serverTime: result.data);
-    //       state = state;
-    //   handleList(listResult.data?.rows);
-    //       ToastEngine.show("获取数据成功");
-    //     } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    //       ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //     }
-    //   } catch (e) {
-    //     ToastEngine.show("Error: $e");
-    //   }
-
-    // await Future.delayed(const Duration(milliseconds: 1500));
-    // final List<Map<String, dynamic>> listData = [
-    //   {
-    //     'id':1,
-    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-    //     'title': 'William Jefferson',
-    //     'isFollow': false,
-    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-    //     'imageUrls': ['https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500','https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500','https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500'],
-    //     'time': 'June 17,2016 at 7:23 p.m.',
-    //     'isLike': true,
-    //     'likeno': 12
-    //   },
-    //   {
-    //     'id':2,
-    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-    //     'title': 'William fdsaf的飞洒发生的',
-    //     'isFollow': true,
-    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-    //     'imageUrls': [],
-    //     'time': 'June 17,2016 at 7:23 p.m.',
-    //     'isLike': true,
-    //     'likeno': 12
-    //   },
-    //   {
-    //     'id':3,
-    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-    //     'title': 'Fsjfkds  dfsk',
-    //     'isFollow': false,
-    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-    //     'imageUrls': [],
-    //     'time': 'June 17,2016 at 7:23 p.m.',
-    //     'isLike': false,
-    //     'likeno': 12
-    //   },
-    //   {
-    //     'id':4,
-    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-    //     'title': 'Fsjfkds  dfsk',
-    //     'isFollow': false,
-    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-    //     'imageUrls': [],
-    //     'time': 'June 17,2016 at 7:23 p.m.',
-    //     'isLike': false,
-    //     'likeno': 12
-    //   },
-    //   {
-    //     'id':5,
-    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-    //     'title': 'Fsjfkds  dfsk',
-    //     'isFollow': false,
-    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-    //     'imageUrls': [],
-    //     'time': 'June 17,2016 at 7:23 p.m.',
-    //     'isLike': false,
-    //     'likeno': 12
-    //   },
-    //   {
-    //     'id':6,
-    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-    //     'title': 'Fsjfkds  dfsk',
-    //     'isFollow': false,
-    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-    //     'imageUrls': [],
-    //     'time': 'June 17,2016 at 7:23 p.m.',
-    //     'isLike': false,
-    //     'likeno': 12
-    //   },
-    //   {
-    //     'id':7,
-    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-    //     'title': '放大发大水',
-    //     'isFollow': false,
-    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-    //     'imageUrls': [],
-    //     'time': 'June 17,2016 at 7:23 p.m.',
-    //     'isLike': false,
-    //     'likeno': 12
-    //   },
-    // ];
-    //
-    // if (state.page == 1) {
-    //   //刷新的方式
-    //   state = state.copyWith(list: listData);
-    //   refreshController.finishRefresh();
-    //   // //更新展示的状态
-    //   changeLoadingState(LoadState.State_Success, null);
-    // } else {
-    //   //加载更多
-    //   final allList = state.list;
-    //   allList?.addAll(listData);
-    //   state = state.copyWith(list: allList);
-    //   refreshController.finishLoad();
-    //
-    // }
-    //
-    // // 最后赋值
-    // _needShowPlaceholder = false;
+    Log.d("加载listData数据---------------start--${_page}---");
 
     try {
       //请求网络
       Map<String, dynamic>  params = {
-        "page": state.page,
-        "limit": state.limit,
+        "page": _page,
+        "limit": _limit,
       };
       Log.d("请求参数------$params");
-      final result = await repositoryInstance.fetchNewsList(params);
+      final result = await commonNewsFeedRespositoryInstance.fetchNewsList(params);
       //校验成功失败
       if (result.isSuccess) {
-        handlerResultList((result.data  as NewsfeedNewsEntity).list);
+        handlerResultList((result.data  as NewsfeedNewsEntity).list, isLoadMore ?? false);
       } else {
         String errorMessage = result.errorMsg!;
         changeLoadingState(LoadState.State_Error, errorMessage);
@@ -259,25 +143,25 @@ class NewsVm extends _$NewsVm {
   }
 
 
-  void handlerResultList(List<NewsfeedNewsList>? list) {
+  void handlerResultList(List<NewsfeedNewsList>? list, bool isLoadMore) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
-      if (state.page == 1) {
+      if (_page == 1) {
         //刷新的方式
         state.list!.clear();
         state.list!.addAll(list.map((item) => item.toJson()).toList());
         refreshController.finishRefresh();
-
         //更新展示的状态
         changeLoadingState(LoadState.State_Success, null);
       } else {
         //加载更多
         final allList = state.list;
+        allList!.addAll(list.map((item) => item.toJson()).toList());
         state = state.copyWith(list: allList);
         refreshController.finishLoad();
       }
     } else {
-      if (state.page == 1) {
+      if (_page == 1) {
         //展示无数据的布局
         state.list!.clear();
         changeLoadingState(LoadState.State_Empty, null);
@@ -286,43 +170,60 @@ class NewsVm extends _$NewsVm {
         //展示加载完成,没有更多数据了
         if(state.list!.length == 0){
           changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishLoad();
         }else {
           if(_needShowPlaceholder){
             changeLoadingState(LoadState.State_Success, null);
           }
         }
+        //更新展示的状态
         refreshController.finishLoad(IndicatorResult.noMore);
       }
     }
   }
 
   // 点赞/取消点赞
-  Future handlerLikeClick(int id, bool isLike, int itemidx) async {
+  Future handlerLikeClick(int id, bool isLike, int? itemidx) async {
     try {
-      final result = await repositoryInstance.fetchLikeClick({
+      List<Map<String, dynamic>> listCopyDta =  List.from(state.list!);
+      final result = await commonNewsFeedRespositoryInstance.fetchLikeClick({
         "id": id,
       });
       if (result.isSuccess) {
-        //重新赋值data或list
-        // final json = result.getDataJson();
-        // var data = NewsfeedNewsEntity.fromJson(json!);
-        //重新赋值data或list
-        // state.list![id].liked = data.list![0].liked;
-        // state.list![id].likeno = data.list![0].likeno;
-        final String toastMsg = isLike ? "Cancel successfully": "Liked successfully";
-        ToastEngine.show(toastMsg);
-        // 修改 state.list[itemIdx] 中的 like 状态 和 likes_count
-        state.list![itemidx]['liked'] = !isLike;
-        if(isLike){
-          // 取消点赞
-          if(state.list![itemidx]['likes_count']>0){
-            state.list![itemidx]['likes_count'] = state.list![itemidx]['likes_count'] - 1;
+        if(itemidx != null){
+          // 修改 listCopyDta[itemIdx] 中的 like 状态 和 likes_count
+          listCopyDta![itemidx]['liked'] = !isLike;
+
+          if(isLike){
+            // 取消点赞
+            if(listCopyDta![itemidx]['likes_count']>0){
+              listCopyDta![itemidx]['likes_count'] = listCopyDta![itemidx]['likes_count'] - 1;
+            }
+          }else {
+            listCopyDta![itemidx]['likes_count'] = listCopyDta![itemidx]['likes_count'] + 1;
           }
         }else {
-          state.list![itemidx]['likes_count'] = state.list![itemidx]['likes_count'] + 1;
+          // 详情中的点赞 需要找到对应的 item 进行 修改 like 和 likes_count
+          listCopyDta!.forEach((carditem) {
+            if(carditem['id'] == id){
+              carditem['liked'] = !isLike;
+              if(isLike){
+                // 取消点赞
+                if(carditem['likes_count']>0){
+                  carditem['likes_count'] = carditem['likes_count'] - 1;
+                }
+              }else {
+                carditem['likes_count'] = carditem['likes_count'] + 1;
+              }
+            }
+          });
         }
-        //重新赋值data或list
-        changeLoadingState(LoadState.State_Success, null);
+
+        state = state.copyWith(list: listCopyDta);
+
+        final String toastMsg = isLike ? "Cancel successfully": "Liked successfully";
+        ToastEngine.show(toastMsg);
+
         return true;
       }else {
         return false;
@@ -333,7 +234,7 @@ class NewsVm extends _$NewsVm {
   }
 
   // 点击 like comments  share
-  Future<bool?> handlerClickActionBtn(String? actionStr, Map<String, dynamic> item, int itemidx) async{
+  Future<bool?> handlerClickActionBtn(String? actionStr, Map<String, dynamic> item, int? itemidx) async{
     final id = item['id'];
     final liked = item.getValue('liked', false);
     switch (actionStr) {
@@ -353,30 +254,38 @@ class NewsVm extends _$NewsVm {
         break;
     }
   }
-  Future handlerFollow(BuildContext context, bool isFollow) async{
+
+  // 关注/取消关注
+  Future<bool> handlerFollow(BuildContext? context, int to_user_id,int cardId, bool isFollow) async{
     Log.d("点击了 关注");
-    // try {
-    //   //请求网络
-    //   Map<String, dynamic>  params = {
-    //
-    //   };
-    //   Log.d("请求参数------$params");
-    //   final result = await repositoryInstance.fetchNewsList(params);
-    //   //校验成功失败
-    //   if (result.isSuccess) {
-    //     handlerResultList((result.data  as NewsfeedNewsEntity).list);
-    //   } else {
-    //     String errorMessage = result.errorMsg!;
-    //     changeLoadingState(LoadState.State_Error, errorMessage);
-    //     ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //   }
-    // } catch (e) {
-    //   ToastEngine.show("Error: $e");
-    // }
+    try {
+      final result = await commonNewsFeedRespositoryInstance.handlerFollowOrCancel({
+        "to_user_id": to_user_id,
+      });
+      if(result.isSuccess){
+        // 修改cardId 对应的 card item 的 account 里面的 followed
+        if(cardId!=null){
+          final listCopyDta = List<Map<String, dynamic>>.from(state.list!);
+          listCopyDta!.forEach((carditem) {
+            if(carditem['id'] == cardId){
+              carditem['account']['followed'] = !carditem['account']['followed'];
+            }
+          });
+          state = state.copyWith(list: listCopyDta);
+        }
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      Log.d("error: $error");
+      return false;
+    }
   }
+
   // 去详情页面
   void handlerGotoDetail(BuildContext? context, int id){
     Log.d("去详情页面");
-    appRouter.push(NewsfeedDetailPageRoute(id: id, type:'news'));
+    appRouter.push(NewsfeedDetailPageRoute(id: id, type: 'news'));
   }
 }

+ 1 - 1
packages/cpt_community/lib/modules/community/news/news_vm.g.dart

@@ -6,7 +6,7 @@ part of 'news_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$newsVmHash() => r'e8eaf4270dd8636d5b34f539949f030d84fc5758';
+String _$newsVmHash() => r'c560bb4c7f8779dd4e8227c0833de74f3307505a';
 
 /// See also [NewsVm].
 @ProviderFor(NewsVm)

+ 2 - 0
packages/cpt_community/lib/modules/community/newsfeed_detail/comments_input.dart

@@ -66,6 +66,8 @@ class CommentsTextareaInput extends HookConsumerWidget {
             },
             onChanged: (text) {
               // 当文本改变时,更新字符数量
+              Log.d("text  $text");
+              Log.d("4  ${state.commentFieldInfo!['controller']?.text}");
               if(showCounter){
                 noteCount.value = text.length;
               }

+ 229 - 143
packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_page.dart

@@ -1,6 +1,7 @@
 import 'package:cpt_community/router/page/community_page_router.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/newsfeed_detail_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:flutter_hooks/flutter_hooks.dart';
@@ -8,6 +9,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:plugin_basic/provider/app_config/app_config.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/color_utils.dart';
+import 'package:shared/utils/ext_dart.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/load_state_layout.dart';
@@ -30,9 +32,9 @@ class NewsfeedDetailPage extends HookConsumerWidget {
   final int? id;
   final String? type;  // news  following foryou
 
-  const NewsfeedDetailPage({Key? key, required this.id, required this.type}) : super(key: key);
+  const NewsfeedDetailPage({Key? key, @PathParam('id') required this.id, @PathParam('type') required this.type}) : super(key: key);
   // 启动当前页面
-  static void startInstance({BuildContext? context, int? id, String? type='news'}) {
+  static void startInstance({BuildContext? context, int? id, String? type = 'news'}) {
     if (context != null) {
       context.router.push(NewsfeedDetailPageRoute(id: id, type: type));
     } else {
@@ -47,9 +49,14 @@ class NewsfeedDetailPage extends HookConsumerWidget {
     final state = ref.watch(newsfeedDetailVmProvider);
     GlobalKey _likeButtonKey = GlobalKey<MyLikeButtonState>();
 
+    NewsfeedDetailEntity?  detailInfo = state.detailInfo!;
+
+    List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
+
     useEffect((){
+      vm.setCurrentDetailType(type!);
       // 组件挂载时执行 - 执行接口请求
-      Future.microtask(() => vm.initPageData(id: id));
+      Future.microtask(() => vm.initPageData(id: id, type: type));
       return () {
         // 组件卸载时执行
       };
@@ -66,52 +73,66 @@ class NewsfeedDetailPage extends HookConsumerWidget {
       body: Column(
           mainAxisSize: MainAxisSize.max,
           children:[
-              Expanded(
+            Expanded(
                 child: EasyRefresh(
                   controller: vm.refreshController,
                   // 上拉加载
                   onLoad: () async{
                     Log.d("----onLoad");
-                    vm.loadMore();
+                    vm.loadMore(id:id, type: type);
                   },
                   // 下拉刷新
                   onRefresh: () async{
                     Log.d("----onRefresh");
-                    vm.onRefresh();
+                    vm.onRefresh(id:id, type: type);
                   },
                   child: LoadStateLayout(
                     state: state.loadingState,
                     errorMessage: state.errorMessage,
                     errorRetry: () {
-                      vm.retryRequest();
+                      vm.retryRequest(id:id, type: type);
                     },
                     successSliverWidget: [
                       SliverList(
                         delegate: SliverChildListDelegate(
                             [
-                            _buildTopCard(context, ref),
-                            ConstrainedBox(
-                              constraints: BoxConstraints(
-                                minHeight: MediaQuery.of(context).size.height - 250 - 150,
-                              ),
-                              child: _buildCommentListCard(context, ref),
-                            )
-                          ]
+                              _buildTopCard(context, ref, detailInfo),
+                              ConstrainedBox(
+                                constraints: BoxConstraints(
+                                  minHeight: MediaQuery.of(context).size.height - 250 - 150,
+                                ),
+                                child: _buildCommentListCard(context, ref, detailInfo),
+                              )
+                            ]
                         ),
                       )
                     ],
                   ),
                 ),
               ),
-              _buildBottomActionSection(context, ref, _likeButtonKey),
+            (detailInfo != null && detailInfo.id != null)? _buildBottomActionSection(context, ref,vm, _likeButtonKey): SizedBox.shrink(),
           ]
       )
     );
   }
 
-  Widget _buildTopCard(BuildContext context, WidgetRef ref){
+  Widget _buildTopCard(BuildContext context, WidgetRef ref,NewsfeedDetailEntity detailInfo ){
     final vm = ref.read(newsfeedDetailVmProvider.notifier);
-    final state = ref.watch(newsfeedDetailVmProvider);
+    String card_title = "";
+    int card_id = detailInfo!.id??0;
+    String card_created_at = detailInfo!.createdAt ?? "";
+    NewsfeedDetailAccount card_account = detailInfo!.account?? NewsfeedDetailAccount();
+    int card_count_id = card_account!.id??0;
+    String card_avator = card_account!.avatar?? '';
+    String card_count_name = card_account!.name?? '';
+    bool card_followed = card_account!.followed??false;
+    String card_content = detailInfo!.content??"";
+    bool? card_liked = detailInfo!.liked;
+    num card_likes_count = detailInfo!.likesCount?? 0;
+    num card_comments_count = detailInfo!.commentsCount?? 0;
+    List? card_resources = detailInfo!.resources?? [];
+
+
     return Stack(
       children: [
         Container(
@@ -136,16 +157,16 @@ class NewsfeedDetailPage extends HookConsumerWidget {
                 // 卡片头部(头像 标题 时间)
                 NewsFeedCardHeader(
                   key: UniqueKey(),
-                  title: state?.detailInfo!['title'],
-                  avator: state?.detailInfo['avator'],
-                  time: state?.detailInfo['time'],
+                  title: card_count_name,
+                  avator: card_avator,
+                  time: card_created_at,
                 ),
                 const SizedBox(height: 15),
                 // 卡片中间 (文字和图片)
                 NewsFeedCardContent(
                   key: UniqueKey(),
-                  content: state.detailInfo['content'],
-                  imageUrls: state.detailInfo['imageUrls'],
+                  content: card_content,
+                  imageUrls: card_resources,
                     textMaxLines: 5000,
                 ),
                 const SizedBox(height: 26),
@@ -153,134 +174,182 @@ class NewsfeedDetailPage extends HookConsumerWidget {
           ),
         ),
         // 右上角 关注/取消关注 按钮
-        Visibility(
-          visible: !state.detailInfo['isFollow'],
-          child: Positioned(
-              right: 40,
-              top: 35,
-              child: Container(
-                width: 83.5,
-                height: 45.5,
-                alignment: Alignment.center,
-                // decoration: BoxDecoration(
-                //   color:  ColorUtils.string2Color('#4161D0'),
-                //   borderRadius: BorderRadius.circular(5),
-                // ),
-                child: MyButton(
-                  text: '+Follow',
-                  textColor: Colors.white,
-                  backgroundColor: ColorUtils.string2Color('#4161D0'),
-                  radius: 8,
-                  minHeight: 27.5,
-                  padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
-                  fontWeight: FontWeight.w400,
-                  fontSize: 14,
-                  onPressed: (){
-                    // Navigator.pop(context);
-                  },
-                ),
-              )
-          ),
+        Positioned(
+            right: 40,
+            top: 35,
+            child: Container(
+              width: 83.5,
+              height: 45.5,
+              alignment: Alignment.center,
+              // decoration: BoxDecoration(
+              //   color:  ColorUtils.string2Color('#4161D0'),
+              //   borderRadius: BorderRadius.circular(5),
+              // ),
+              child: HookBuilder(
+                  builder: (context) {
+                    final isFollowedState = useState<bool>(card_followed);
+                    return MyButton(
+                      text: isFollowedState.value ? 'Followed': '+Follow',
+                      textColor: isFollowedState.value ?  context.appColors.disEnableGray: context.appColors.textWhite,
+                      disabledTextColor: context.appColors.disEnableGray,
+                      backgroundColor: isFollowedState.value ? Colors.transparent : ColorUtils.string2Color('#4161D0'),
+                      side: BorderSide(color: !isFollowedState.value ? Colors.transparent : context.appColors.disEnableGray, width: 0.5),
+                      radius: 8,
+                      minHeight: 27.5,
+                      padding: const EdgeInsets.only(left: 5, right: 5,top:9,bottom:9),
+                      fontWeight: FontWeight.w400,
+                      fontSize: 14,
+                      onPressed: () async{
+                        bool asyncResult = await vm.handlerFollow(context,card_count_id, card_id,  isFollowedState.value );
+                        if(asyncResult){
+                          // 成功  关注->取消关注  取消关注->关注
+                          isFollowedState.value = !isFollowedState.value;
+                          // 修改该item
+
+                        }
+                      },
+                    );
+                  }
+              ),
+            )
         )
       ],
     );
   }
 
-  Widget _buildCommentListCard(BuildContext context,  WidgetRef ref){
+  Widget _buildCommentListCard(BuildContext context,  WidgetRef ref, NewsfeedDetailEntity detailInfo){
     final vm = ref.read(newsfeedDetailVmProvider.notifier);
-    return Container(
-      margin: const EdgeInsets.only(left: 15, right: 15,top: 18,bottom: 18),
-      padding: const EdgeInsets.only(bottom: 30),
-      decoration: BoxDecoration(
-          color: context.appColors.textWhite,
-          borderRadius: BorderRadius.circular(10),
-          boxShadow: [
-            BoxShadow(
-              color: ColorUtils.string2Color("#E4E7EB").withOpacity(0.5),
-              spreadRadius: 0,
-              blurRadius: 4,
-              offset: const Offset(0, 4), // changes position of shadow
-            ),
-          ]
-      ),
-      child: Column(
-        crossAxisAlignment: CrossAxisAlignment.start,
-        mainAxisAlignment: MainAxisAlignment.start,
-        children: [
-          // 总评论数 总收藏数等
-          Row(
+    int likeCount = detailInfo!.likesCount??0;
+    List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
+    num commentCount = commentList?.length?? 0;
+    return HookBuilder(
+      builder: (context) {
+        return Container(
+          margin: const EdgeInsets.only(left: 15, right: 15,top: 18,bottom: 18),
+          padding: const EdgeInsets.only(bottom: 30),
+          decoration: BoxDecoration(
+              color: context.appColors.textWhite,
+              borderRadius: BorderRadius.circular(10),
+              boxShadow: [
+                BoxShadow(
+                  color: ColorUtils.string2Color("#E4E7EB").withOpacity(0.5),
+                  spreadRadius: 0,
+                  blurRadius: 4,
+                  offset: const Offset(0, 4), // changes position of shadow
+                ),
+              ]
+          ),
+          child: Column(
+            crossAxisAlignment: CrossAxisAlignment.start,
+            mainAxisAlignment: MainAxisAlignment.start,
             children: [
-              Expanded(
-                child: Container(
-                  padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
-                  child: Row(
-                    children: [
-                      MyTextView('Comments', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
-                      const SizedBox(width: 5,),
-                      MyTextView('(95)', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
-                    ]
-                  )
-                )
-              ),
-             // 收藏数
-             Expanded(
-                 child: Container(
-                   padding: const EdgeInsets.only(right: 20),
-                   child: Row(
-                     mainAxisAlignment: MainAxisAlignment.end,
-                     children: [
-                       const MyAssetImage(
-                         Assets.communityLikeActive,
-                         width: 15,
-                         height: 15,
-                       ),
-                       const SizedBox(width: 5,),
-                       MyTextView(
-                         '105K',
-                         textColor: ColorUtils.string2Color("#767676"),
-                         fontSize: 14,
-                         isFontLight: true,
+              // 总评论数 总收藏数等
+              Row(
+                children: [
+                  Expanded(
+                    child: Container(
+                      padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
+                      child: Row(
+                        children: [
+                          MyTextView('Comments', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
+                          const SizedBox(width: 5,),
+                          MyTextView('(${commentCount})', textColor: ColorUtils.string2Color("#2956B7"), fontSize: 15, isFontLight: true,),
+                        ]
+                      )
+                    )
+                  ),
+                 // 收藏数
+                 Expanded(
+                     child: Container(
+                       padding: const EdgeInsets.only(right: 20),
+                       child: Row(
+                         mainAxisAlignment: MainAxisAlignment.end,
+                         children: [
+                           const MyAssetImage(
+                             Assets.communityLikeActive,
+                             width: 15,
+                             height: 15,
+                           ),
+                           const SizedBox(width: 5,),
+                           MyTextView(
+                             '${likeCount}',
+                             textColor: ColorUtils.string2Color("#767676"),
+                             fontSize: 14,
+                             isFontLight: true,
+                           ),
+                         ],
                        ),
-                     ],
-                   ),
-                 ),
-             )
-            ],
-          ),
+                     ),
+                 )
+                ],
+              ),
 
-          // 分割线
-          Container(
-            height: 1,
-            color: context.appColors.dividerDefault,
-          ),
+              // 分割线
+              Container(
+                height: 1,
+                color: context.appColors.dividerDefault,
+              ),
 
-          Padding(
-            padding: const EdgeInsets.only(top: 16),
-            child: Column(
-              children: (vm.state.list.isNotEmpty )? vm.state.list.asMap().entries.map((entry) {
-                final item = entry.value;
-                final index = entry.key;
-                final lastIdx = vm.state.list.length - 1;
-                return _buildCommentItem(context, ref, item, index, lastIdx);
-              }).toList(): [
-                Center(
-                  child: SizedBox(
-                    height: 200,
-                    child: MyTextView("NO DATA"),
-                  ),
-                )
-              ],
-            ),
+              Padding(
+                padding: const EdgeInsets.only(top: 16),
+                child: Column(
+                  children: (commentList?.isNotEmpty ?? false)? commentList!.asMap().entries.map((entry) {
+                    NewsfeedDetailComments item = entry.value;
+                    final index = entry.key;
+                    final lastIdx = commentList.length - 1;
+                    int newsfeedId = detailInfo!.id!;
+                    int to_user_id = item.id!;
+                    String to_user_name = item!.account!.name!;
+                    return _buildCommentItem(context, ref, item, index, lastIdx).onTap((){
+                      // 点击 单条 评论 则对 此评论进行评论
+                      vm.handlerCommentClick(context, newsfeedId, to_user_id, to_user_name, true);
+                    });
+                  }).toList(): [
+                    // 没有数据的显示
+                    const Center(
+                      child: SizedBox(
+                        height: 250,
+                        child: MyAssetImage(Assets.baseServicePageNoData, width: 123.5, height: 115.5, fit: BoxFit.contain),
+                      ),
+                    )
+                  ],
+                ),
+              ),
+            ]
           ),
-        ]
-      ),
-    ).borderRadius(all:8);
+        ).borderRadius(all:8);
+      }
+    );
   }
 
 
   Widget _buildCommentItem(BuildContext context, WidgetRef ref, item, index, lastIdx){
     final vm = ref.read(newsfeedDetailVmProvider.notifier);
     final state = ref.watch(newsfeedDetailVmProvider);
+    final detailInfo = state.detailInfo!;
+    List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
+    num commentCount = commentList?.length?? 0;
+
+    NewsfeedDetailComments? comment_Item = commentList?[index];
+    int  comment_id = comment_Item!.id?? 0;
+    String comment_content = comment_Item!.content?? '';
+
+    String comment_time = comment_Item!.createdAt?? '';
+    NewsfeedDetailCommentsAccount? commentAccount_Item = commentList?[index].account;
+    String comment_avatar = commentAccount_Item?.avatar?? '';
+    int comment_account_id = commentAccount_Item?.id?? 0;
+    String comment_name = commentAccount_Item?.name?? "";
+
+    NewsfeedDetailCommentsToAccount? commentToAccount_Item = commentList?[index].toAccount;
+    String comment_toAccount_avatar = commentToAccount_Item?.avatar?? '';
+    int comment_toAccount_id = commentToAccount_Item?.id?? 0;
+    String comment_toAccount_name = commentToAccount_Item?.name?? "";
+
+    if(commentToAccount_Item !=null && comment_toAccount_name != null){
+      comment_content = '@$comment_toAccount_name: $comment_content';
+    }
+
+
     return Container(
       padding: const EdgeInsets.only(left: 20,right: 20),
       margin:  EdgeInsets.only(top: index> 0? 16: 0),
@@ -290,7 +359,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
         mainAxisSize: MainAxisSize.max,
         children: [
           MyLoadImage(
-            item['avator'],
+            comment_avatar,
             width: 43,
             height: 43,
             isCircle: true,
@@ -308,7 +377,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
                 crossAxisAlignment: CrossAxisAlignment.start,
                 children: [
                   MyTextView(
-                    item['userName'],
+                    comment_name,
                     isFontRegular: true,
                     fontSize: 14,
                     textColor: ColorUtils.string2Color('#2956B7'),
@@ -316,7 +385,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
                     isTextEllipsis: true,
                   ),
                   MyTextView(
-                    item['time'],
+                    comment_time,
                     isFontLight: true,
                     fontSize: 12,
                     marginTop: 10,
@@ -325,7 +394,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
                     isTextEllipsis: true,
                   ),
                   MyTextView(
-                    item['content'],
+                    comment_content,
                     isFontLight: true,
                     fontSize: 15,
                     marginTop: 10,
@@ -347,11 +416,23 @@ class NewsfeedDetailPage extends HookConsumerWidget {
   }
 
 
-  Widget _buildBottomActionSection(BuildContext context, WidgetRef ref , _likeButtonKey){
+  Widget _buildBottomActionSection(BuildContext context, WidgetRef ref ,vm,  _likeButtonKey){
     final state = ref.watch(newsfeedDetailVmProvider);
     final vm = ref.read(newsfeedDetailVmProvider.notifier);
-    bool isLike = state.detailInfo['isLike'];
+
+    NewsfeedDetailEntity  detailInfo = state.detailInfo!;
+
+    int newsfeedId = detailInfo!.id!;
+
+    int to_user_id = detailInfo!.account!.id!;
+    String to_user_name = detailInfo!.account!.name!;
+
+    // List<NewsfeedDetailComments>? commentList = detailInfo!.comments;
+
+    bool isLike = detailInfo!.liked?? false;
+
     return SafeArea(
+      bottom: true,
       child: Visibility(
         visible: state.loadingState == LoadState.State_Success,
         child: Container(
@@ -374,14 +455,19 @@ class NewsfeedDetailPage extends HookConsumerWidget {
                             children: [
                               MyLikeButton(
                                 key: _likeButtonKey,
-                                isLiked: false,
+                                isLiked: isLike,
                                 isCustomIcon: true,
                                 customIconWidth: 20,
                                 customIconHeight: 18,
                                 customIconActiveAssets: Assets.communityLikeActive,
                                 customIconUnActiveAssets: Assets.communityNewsfeedDetailLike,
-                                onLike: () {
+                                onLike: () async {
                                   Log.d('点击了like button');
+                                  bool asyncResult = await vm.handlerLikeClick(context, detailInfo!.id as int, isLike);
+                                  if(asyncResult){
+                                    // 成功
+
+                                  }
                                 },
                               ),
                               const SizedBox(width: 10,),
@@ -426,7 +512,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
                             ],
                           ),
                         ).onTap((){
-                          vm.handlerCommentClick(context);
+                          vm.handlerCommentClick(context, newsfeedId, to_user_id, to_user_name, false);
                         })
                       ],
                     ),

+ 17 - 27
packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_state.dart

@@ -1,30 +1,32 @@
+import 'package:domain/entity/newsfeed_detail_entity.dart';
+import 'package:flutter/cupertino.dart';
 import 'package:widgets/load_state_layout.dart';
 
+
 class NewsfeedDetailState {
   //页面 LoadView 状态的展示
   LoadState loadingState;
   String? errorMessage;
-
-  int? page;
-  int? limit = 10;
-  int? count = 1;
-
   // 评论框信息
   Map<String, dynamic>? commentFieldInfo;
 
-  Map<String, dynamic> detailInfo;
-  List<Map<String, dynamic>> list; // 评论列表
+  // 详情页信息
+  // DetailInfoData? detailInfo;
+  NewsfeedDetailEntity? detailInfo;
 
   NewsfeedDetailState({
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 1,
     Map<String, dynamic>? commentFieldInfo,
-    required this.detailInfo,
-    required this.list,
-  }): commentFieldInfo = commentFieldInfo ?? {},
+    NewsfeedDetailEntity? detailInfo,
+  }): detailInfo = detailInfo ?? NewsfeedDetailEntity(),
+        commentFieldInfo = commentFieldInfo ?? {
+    'value': '',
+    'controller': TextEditingController(),
+    'hintText': 'Please enter your comment',
+    'focusNode': FocusNode(),
+    'obsecure': false,
+  },
       errorMessage = errorMessage?? '';
 
   NewsfeedDetailState copyWith({
@@ -33,19 +35,15 @@ class NewsfeedDetailState {
     int? page,
     int? limit,
     int? count,
-    Map<String, dynamic>? detailInfo,
+    NewsfeedDetailEntity? detailInfo,
     Map<String, dynamic>? commentFieldInfo,
     List<Map<String, dynamic>>? list,
   }) {
     return NewsfeedDetailState(
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       commentFieldInfo: commentFieldInfo ?? this.commentFieldInfo,
       detailInfo: detailInfo ?? this.detailInfo,
-      list: list ?? this.list,
     );
   }
 
@@ -53,12 +51,8 @@ class NewsfeedDetailState {
     return {
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'commentFieldInfo': this.commentFieldInfo,
       'detailInfo': this.detailInfo,
-      'list': this.list,
     };
   }
 
@@ -66,12 +60,8 @@ class NewsfeedDetailState {
     return NewsfeedDetailState(
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       commentFieldInfo: map['commentFieldInfo'] as Map<String, dynamic>,
-      detailInfo: map['detailInfo'] as Map<String, dynamic>,
-      list: map['list'] as List<Map<String, dynamic>>,
+      detailInfo: map['detailInfo'] as NewsfeedDetailEntity,
     );
   }
 }

+ 264 - 109
packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_vm.dart

@@ -1,6 +1,10 @@
 
+import 'package:cpt_community/modules/community/following/following_vm.dart';
+import 'package:cpt_community/modules/community/foryou/foryou_vm.dart';
+import 'package:cpt_community/respository/common_newsfeed.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/newsfeed_detail_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
 import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
@@ -14,26 +18,23 @@ import 'package:widgets/my_text_view.dart';
 import 'package:widgets/widget_export.dart';
 import '../../../components/comments_dialog.dart';
 
+import '../news/news_vm.dart';
 import 'comments_input.dart';
 import 'newsfeed_detail_state.dart';
 import 'newsfeed_detail_page.dart';
 
 part 'newsfeed_detail_vm.g.dart';
 
+
 @riverpod
 class NewsfeedDetailVm extends _$NewsfeedDetailVm {
+  late CommonNewsFeedRespository repositoryInstance;
 
-  // 评论框信息
-  final Map<String, dynamic> _textFieldInfo= {
-    'value': '',
-    'controller': TextEditingController(),
-    'hintText': 'Please enter your comment',
-    'focusNode': FocusNode(),
-    'obsecure': false,
-  };
-
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
 
-  bool _needShowPlaceholder = false; //是否展示LoadingView
+  bool _needShowPlaceholder = true; //是否展示LoadingView
 
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
@@ -41,43 +42,20 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
     controlFinishLoad: true,   //允许加载
   );
 
+  int? _detailId;
+  String? _detailType = 'news';
+
+
   NewsfeedDetailState initState() {
-    return NewsfeedDetailState(
-      detailInfo: {
-        'id':1,
-        'avator': 'https://p4.itc.cn/q_70/images03/20231121/ab826c4a7efe4c9aa93ca6e00f9e0986.jpeg',
-        'title': 'William Jefferson',
-        'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]',
-        'imageUrls': [
-          'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-          'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-          'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-          'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-          'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        ],
-        'time': 'June 17,2016 at 7:23 p.m.',
-        'isLike': true,
-        'isFollow': false,
-        'likeno': 12,
-      },
-      list: [
-        {
-          'userId': 1,
-          'userName': 'William Jefferson',
-          'avator': 'https://iknow-pic.cdn.bcebos.com/d439b6003af33a87f27f0584d45c10385343b519',
-          'time': 'June 17,2016 at 7:23 p.m.',
-          'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]'
-        },
-      ],
-      commentFieldInfo: _textFieldInfo
-    );
+    return NewsfeedDetailState();
   }
 
 
   @override
   NewsfeedDetailState build(){
-     final state = initState();
-
+    // 引入数据仓库
+    repositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
+    final state = initState();
     // 第一次挂载后
     // WidgetsBinding.instance!.addPostFrameCallback((_) {
     // }
@@ -86,6 +64,11 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
     return state;
   }
 
+  setCurrentDetailType(String detailPageType){
+    Log.d("设置当前页面类型---------$detailPageType");
+    _detailType = detailPageType;
+  }
+
 //刷新页面状态
   void changeLoadingState(LoadState loadState, String? errorMsg) {
     state = state.copyWith(
@@ -95,58 +78,88 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
   }
 
   // 初始化页面数据
-  initPageData({int? id}) {
+  initPageData({int? id, String? type}) {
     Log.d("----property_news_vm-----initPageData   ${state.loadingState}");
-    onRefresh(id: id);
+    _detailId = id ?? _detailId;
+    if(type != null){
+      setCurrentDetailType(type);
+    }
+
+    onRefresh(id: _detailId, type: type);
   }
 
   // 上拉加载 更多
-  Future loadMore({int? id}) async {
+  Future loadMore({int? id, String? type}) async {
     Log.d("----property_news_vm-----loadMore");
-    // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.count){
-    //   return;
-    // }else {
-    //   int page = state.page + 1;
-    //   state = state.copyWith(page: page,);
-    //   getListData();
-    // }
-    // 检查 page 是否为 null,并初始化为 1
-    int newCurPage = state.page ?? 1;
-    state = state.copyWith(page: ++newCurPage);
-    getListData();
+    // _page++;
+    // getListData(id:id, type:type);
+    getDetailInfo(id:_detailId, type:_detailType, isRefresh: false);
+    // refreshController.finishLoad();
   }
 
 
   // 下拉刷新
-  Future onRefresh({int? id}) async {
+  Future onRefresh({int? id, String? type}) async {
     Log.d("----property_news_vm-----onRefresh ");
 
     // await Future.delayed(const Duration(seconds: 2));
-    state = state.copyWith(page: 1);
-    getListData();
+    _page = 1;
+    getDetailInfo(id:id, type:type);
   }
 
   // 重试请求
-  Future retryRequest() async {
+  Future retryRequest({int? id, String? type}) async {
     state = state.copyWith(page: 1);
     _needShowPlaceholder = true;
-    getListData();
+    getListData(id:id, type:type);
+  }
+
+  // 获取详情信息
+  Future getDetailInfo<T>({int? id, String? type, bool isRefresh = true}) async {
+    try{
+      if (_needShowPlaceholder) {
+        changeLoadingState(LoadState.State_Loading, null);
+      }
+      Map<String, dynamic> params = {
+        'id': id,
+      };
+      final result = await repositoryInstance.fetchNewsFeedDetailInfo(params);
+      if(result.isSuccess){
+
+        state = state.copyWith(
+          detailInfo: result.data as NewsfeedDetailEntity,
+        );
+
+        changeLoadingState(LoadState.State_Success, null);
+        if(isRefresh){
+          refreshController.finishRefresh();
+        }else {
+          refreshController.finishLoad(IndicatorResult.noMore);
+        }
+      }else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+
+      _needShowPlaceholder = false;
+    }catch(error){
+
+    }
   }
 
 
   // 获取list 列表数据
-  Future getListData<T>({int? id}) async {
+  Future getListData<T>({int? id, String? type}) async {
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
-
-    Log.d("加载listData数据---------------start--${state.page}---");
+    Log.d("加载listData数据---------------start--$_page---");
     //   try {
     //     //请求网络
     //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
+    //       "page": _page,
+    //       "limit": _limit,
     //     };
     //     Log.d("请求参数------$params");
     //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
@@ -166,51 +179,104 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
     //     ToastEngine.show("Error: $e");
     //   }
 
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    // final List<Map<String, dynamic>> listData = [
+    //   {
+    //     'userId': 1,
+    //     'userName': 'William Jefferson',
+    //     'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
+    //     'time': 'June 17,2016 at 7:23 p.m.',
+    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]'
+    //   },
+    //   {
+    //     'userId': 2,
+    //     'userName': 'Ander Jackson',
+    //     'avator': 'https://iknow-pic.cdn.bcebos.com/d439b6003af33a87f27f0584d45c10385343b519',
+    //     'time': 'June 17,2016 at 7:23 p.m.',
+    //     'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]'
+    //   },
+    // ];
+
+
+    // if (_page == 1) {
+    //   //刷新的方式
+    //   state = state.copyWith(list: listData);
+    //   refreshController.finishRefresh();
+    //   // //更新展示的状态
+    //   changeLoadingState(LoadState.State_Success, null);
+    // } else {
+    //   //加载更多
+    //   final allList = state.list;
+    //   allList.addAll(listData);
+    //   refreshController.finishLoad();
+    //   state = state.copyWith(list: allList);
+    // }
+    //
+    // // 最后赋值
+    // _needShowPlaceholder = false;
+
     await Future.delayed(const Duration(milliseconds: 1500));
-    final List<Map<String, dynamic>> listData = [
-      {
-        'userId': 1,
-        'userName': 'William Jefferson',
-        'avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-        'time': 'June 17,2016 at 7:23 p.m.',
-        'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]'
-      },
-      {
-        'userId': 2,
-        'userName': 'Ander Jackson',
-        'avator': 'https://iknow-pic.cdn.bcebos.com/d439b6003af33a87f27f0584d45c10385343b519',
-        'time': 'June 17,2016 at 7:23 p.m.',
-        'content': 'She said YES and our lives changed.Thank you all for coming to my propose today.We hope everyone can ……[More]'
-      },
-    ];
-
-
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
-    } else {
-      //加载更多
-      final allList = state.list;
-      allList.addAll(listData);
-      refreshController.finishLoad();
-      state = state.copyWith(list: allList);
+    refreshController.finishLoad();
+  }
+
+  // 点击了 关注/取消关注按钮
+  Future<bool> handlerFollow(BuildContext? context, int to_user_id,int cardId, bool isFollow) async{
+    Log.d("newsfeed_detail_vm 中 当前的 _detailType $_detailType 点击了 关注/取消关注");
+    bool result = false;
+    if(_detailType == 'news'){
+      Log.d("调用 newvm 中的关注/取消关注方法");
+      // 调用列表中的 点赞方法
+      final newsfeedVm = ref.read(newsVmProvider.notifier);
+      result = await newsfeedVm.handlerFollow(context, to_user_id, cardId, isFollow);
+    }else if(_detailType == 'following'){
+      Log.d("调用 followingVm 中的关注/取消关注方法");
+      // 调用列表中的 点赞方法
+      final followingVm = ref.read(followingVmProvider.notifier);
+      result = await followingVm.handlerFollow(context, to_user_id, cardId, isFollow);
+    }else if(_detailType == 'foryou'){
+      Log.d("调用 forYouVm 中的关注/取消关注方法");
+      // 调用列表中的 点赞方法
+      final forYouVm = ref.read(foryouVmProvider.notifier);
+      result = await forYouVm.handlerFollow(context, to_user_id, cardId, isFollow);
     }
 
-    // 最后赋值
-    _needShowPlaceholder = false;
+    if(result){
+      // 成功了
+      // 修改cardId 对应的 card item 的 account 里面的 followed
+      if(cardId!=null){
+        NewsfeedDetailEntity detailInfoDta = state.detailInfo!;
+        NewsfeedDetailAccount card_account = detailInfoDta!.account?? NewsfeedDetailAccount();
+        card_account.followed = !(card_account!.followed?? false);
+        state = state.copyWith(detailInfo: detailInfoDta);
+      }
+    }
+    return result;
   }
 
+  // 点击了 评论 按钮
+  handlerCommentClick(BuildContext context, int newsfeedId, int to_user_id, String to_user_name, bool isReply ) async{
+    Log.d("点击了评论按钮 newsfeedId:  $newsfeedId  to_user_id:  $to_user_id  to_user_name:  $to_user_name  isReply:  $isReply ");
+
+    String hintText = 'Please enter your comment';
+    if(isReply){
+      hintText = 'Reply to $to_user_name: ';
+      // 修改对话框的 提示文字
+    }else {
+      to_user_id = 0; // 评论对象ID(默认传0)
+      String hintText = 'Please enter your comment';
+    }
+    state = state.copyWith(commentFieldInfo: {
+      'value': '',
+      'controller': TextEditingController(),
+      'hintText': hintText,
+      'focusNode': FocusNode(),
+      'obsecure': false,
+    });
 
-  // 点击了 comment 按钮
-  handlerCommentClick(BuildContext context) async{
     BuildContext contextPage = context;
     // double height = MediaQuery.of(contextPage).size.height;
     double commentInputHeight = 150.0;
-    Log.d("点击了评论按钮");
-    await DialogEngine.show(
+        await DialogEngine.show(
       tag: "newsFeedComments",
       position: DialogPosition.bottom,
       widget: CommentsDialog(
@@ -254,12 +320,24 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
                 child: Center(
                   child: IconButton(
                     icon: Icon(Icons.send, color: context.appColors.textWhite, size: 25,),
-                    onPressed: (){
-                      Log.d("点击了发送按钮");
-                    },
+                    onPressed: null,
                   ),
                 ),
-              ),
+              ).onTap(() async{
+                Log.d("点击了发送按钮");
+                // 收起键盘
+                handlerKeyboardShowHide(false);
+                // 获取评论内容
+                String commentContent = getCommentContent()??'';
+                bool asyncResult = await handlerSubmitComment(context: context, newsfeedId: newsfeedId, to_user_id: to_user_id, commentContent: commentContent);
+                if(asyncResult){
+                  // 成功后 需要 清理输入框以及关闭 同时收起键盘 同时 刷新评论数据
+                  resetCommentField();
+                  DialogEngine.dismiss(tag: "newsFeedComments");
+                  // 刷新评论数据
+                  handlerSetCommentsList();
+                }
+              }),
             ]
           );
         },
@@ -267,10 +345,87 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
     );
   }
 
+  // 刷新评论列表
+  handlerSetCommentsList(){
+    onRefresh(id:_detailId,type: _detailType);
+  }
+
+  // 提交评论
+  Future<bool> handlerSubmitComment({BuildContext? context, required int newsfeedId, int? to_user_id = 0, required String commentContent} ) async{
+    Log.d("点击提交评论 newsfeedId: $newsfeedId  to_user_id: $to_user_id  commentContent; $commentContent");
+    try{
+      Map<String, dynamic> params = {
+        "id": newsfeedId,
+        "content": commentContent,
+        "to_user_id": to_user_id,
+      };
+      final result = await repositoryInstance.fetchNewsfeedCommentSubmit(params);
+      if(result.isSuccess){
+        // 成功后 需要 清理输入框以及关闭 同时收起键盘 同时 刷新评论数据
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      return false;
+    }
+  }
+
   // 点击了 Like 按钮
-  bool handlerLikeClick(){
-    Log.d("点击了点赞按钮");
-    return true;
+  Future<bool> handlerLikeClick(BuildContext? context, int id,  bool isLike) async{
+    Log.d("newsfeed_detail_vm 中 当前的 _detailType $_detailType 点击了点赞按钮 id:$id  isLike: $isLike");
+
+    bool result = false;
+    if(_detailType == 'news'){
+      Log.d("调用 newvm 中的点赞方法");
+      // 调用列表中的 点赞方法
+      final newsfeedVm = ref.read(newsVmProvider.notifier);
+      result = await newsfeedVm.handlerLikeClick(id, isLike, null);
+    }else if(_detailType == 'following'){
+      Log.d("调用 followingVm 中的点赞方法");
+      // 调用列表中的 点赞方法
+      final followingVm = ref.read(followingVmProvider.notifier);
+      result = await followingVm.handlerLikeClick(id, isLike, null);
+    }else if(_detailType == 'foryou'){
+      Log.d("调用 forYouVm 中的点赞方法");
+      // 调用列表中的 点赞方法
+      final forYouVm = ref.read(foryouVmProvider.notifier);
+      result = await forYouVm.handlerLikeClick(id, isLike, null);
+    }
+
+    if(result){
+      // 成功了
+      // 修改 comments 数量 和 收藏数
+      NewsfeedDetailEntity detailInfoCopy = state.detailInfo!;
+      int likeCount = detailInfoCopy!.likesCount??0;
+      bool liked = detailInfoCopy!.liked??false;
+      // List<NewsfeedDetailComments>? commentList = detailInfoCopy!.comments;
+      // num commentCount = commentList?.length?? 0;
+      detailInfoCopy!.liked = !liked;
+      if(isLike){
+        detailInfoCopy!.likesCount = likeCount - 1;
+      }else{
+        detailInfoCopy!.likesCount = likeCount + 1;
+      }
+      state = state.copyWith(detailInfo: detailInfoCopy);
+    }
+
+    return result;
+  }
+
+  // 隐藏/显示 键盘
+  void handlerKeyboardShowHide(bool show){
+    Log.d("点击了键盘显示/隐藏");
+    if(show){
+      state.commentFieldInfo?['focusNode']?.focus();
+    }else {
+      state.commentFieldInfo?['focusNode']?.unfocus();
+    }
+  }
+  // 获取评论内容
+  String getCommentContent(){
+    Log.d("评论框的内容 ${state.commentFieldInfo!['controller']?.text??''}");
+    return state.commentFieldInfo!['controller']?.text??'';
   }
 
   // 清空评论

+ 1 - 1
packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_vm.g.dart

@@ -6,7 +6,7 @@ part of 'newsfeed_detail_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$newsfeedDetailVmHash() => r'32fbd262aef1042cdde66553d6fe65f51f658e6b';
+String _$newsfeedDetailVmHash() => r'bce3c2cadc599ef8c7c814da65e8c81ed1a73e61';
 
 /// See also [NewsfeedDetailVm].
 @ProviderFor(NewsfeedDetailVm)

+ 12 - 6
packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_page.dart

@@ -1,3 +1,4 @@
+import 'package:cpt_community/modules/community/community_vm.dart';
 import 'package:cpt_community/router/page/community_page_router.dart';
 import 'package:cs_resources/generated/l10n.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
@@ -18,14 +19,16 @@ import 'newsfeed_post_vm.dart';
 
 @RoutePage()
 class NewsfeedPostPage extends HookConsumerWidget {
-  const NewsfeedPostPage({Key? key}) : super(key: key);
+  final VoidCallback? sCallback; // 成功回调函数
+  final VoidCallback? fCallback; // 失败回调函数
+  const NewsfeedPostPage({Key? key, this.sCallback, this.fCallback}) : super(key: key);
 
   //启动当前页面
-  static void startInstance({BuildContext? context}) {
+  static void startInstance({BuildContext? context, VoidCallback? sCallback, VoidCallback? fCallback}) {
     if (context != null) {
-      context.router.push(const NewsfeedPostPageRoute());
+      context.router.push(NewsfeedPostPageRoute(sCallback: sCallback, fCallback: fCallback));
     } else {
-      appRouter.push(const NewsfeedPostPageRoute());
+      appRouter.push(NewsfeedPostPageRoute(sCallback: sCallback, fCallback: fCallback));
     }
   }
 
@@ -99,7 +102,7 @@ class NewsfeedPostPage extends HookConsumerWidget {
                   children: [
                     Expanded(
                       child: MyButton(
-                        text: "Add Card",
+                        text: "Submit",
                         radius: 0,
                         minHeight: 50,
                         backgroundColor: context.appColors.textPrimary,
@@ -107,8 +110,10 @@ class NewsfeedPostPage extends HookConsumerWidget {
                         fontWeight: FontWeight.w500,
                         fontSize: 16,
                         onPressed: (){
+                          vm.submitNewsfeedPost(context, sCallback: sCallback, fCallback: fCallback);
+                          // final communitVm = ref.read(communityVmProvider.notifier);
+                          // communitVm.getCurrentPageViewVm(null).initPageData();
                           // Navigator.pop(context);
-                          vm.submitNewsfeedPost();
                         },
                       ),
                     ),
@@ -244,4 +249,5 @@ class NewsfeedPostPage extends HookConsumerWidget {
       ),
     );
   }
+
 }

+ 24 - 4
packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_vm.dart

@@ -1,4 +1,5 @@
 
+import 'package:cpt_community/respository/common_newsfeed.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:flutter/material.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
@@ -10,12 +11,14 @@ import 'package:auto_route/auto_route.dart';
 import 'package:shared/utils/util.dart';
 
 
+import '../community_vm.dart';
 import 'newsfeed_post_page_state.dart';
 
 part 'newsfeed_post_vm.g.dart';
 
 @riverpod
 class NewsfeedPostVm extends _$NewsfeedPostVm {
+  late CommonNewsFeedRespository repositoryInstance;
 
   NewsfeedPostPageState initState() {
     return NewsfeedPostPageState(
@@ -35,6 +38,8 @@ class NewsfeedPostVm extends _$NewsfeedPostVm {
 
   @override
   NewsfeedPostPageState build() {
+    // 引入数据仓库
+    repositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     // 初始化状态
     NewsfeedPostPageState state = initState();
 
@@ -105,7 +110,7 @@ class NewsfeedPostVm extends _$NewsfeedPostVm {
   }
 
   ///提交反馈
-  void submitNewsfeedPost() {
+  void submitNewsfeedPost(BuildContext? context, {VoidCallback? sCallback, VoidCallback? fCallback}) {
     state = state.copyWith(mindFieldErrorText: null);
 
     _dismissKeyboard(keyStr: 'mind');
@@ -122,9 +127,24 @@ class NewsfeedPostVm extends _$NewsfeedPostVm {
       return;
     }
 
-    //去成功页面
-    // FeedbackCreateSuccessPage.startInstance();
-    // 返回上一页
+    handlerSubmitPostNewsfeed(sCallback: sCallback, fCallback: fCallback);
+
+  }
+
+  Future handlerSubmitPostNewsfeed({VoidCallback? sCallback, VoidCallback? fCallback}) async{
+    try {
+      final result = await repositoryInstance.fetchNewsfeedPublish({
+        "content ": "test",
+        "resources": []
+      });
+      if (result.isSuccess) {
+        sCallback?.call();
+      }else {
+        fCallback?.call();
+      }
+    }catch(e){
+
+    }
   }
 
   //选中图片

+ 1 - 1
packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_vm.g.dart

@@ -6,7 +6,7 @@ part of 'newsfeed_post_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$newsfeedPostVmHash() => r'fe82190c049d9a9e370a5c4f0b6aba182b73b27f';
+String _$newsfeedPostVmHash() => r'9e99a570571851fd337207a06998ed8bf064f347';
 
 /// See also [NewsfeedPostVm].
 @ProviderFor(NewsfeedPostVm)

+ 6 - 5
packages/cpt_community/lib/modules/garage/for_rent/for_rent_page.dart

@@ -93,7 +93,7 @@ class ForrentPage extends HookConsumerWidget {
                   delegate: SliverChildBuilderDelegate(
                         (context, index) {
                       return  _buildForrentItem(context, ref, state.list[index], vm).onTap((){
-                        vm.handlerGotoDetail(state.list[index]['id']);
+                        vm.handlerGotoDetail(context: context, id: state.list[index]['id'], type: 'forRent');
                       });
                     },
                     childCount: state.list.length,
@@ -130,10 +130,11 @@ class ForrentPage extends HookConsumerWidget {
               Expanded(
                 child: GarageCard(
                     key: UniqueKey(),
-                    itemObj: item,
-                    onClickColleciotn: (dynamic collectionValue){
-                      Log.d("点击了收藏按钮  --${item['id']}-$collectionValue");
-                      return true;
+                    itemObj: item.cast<String, dynamic>(),
+                    onClickColleciotn: (dynamic collectionValue) async {
+                      Log.d("点击了收藏按钮  --id:${item['id']}- $collectionValue");
+                      int id = item['id'];
+                      return await vm.handlerClickCollection(id, collectionValue);
                     }
                 ),
               ),

+ 0 - 71
packages/cpt_community/lib/modules/garage/for_rent/for_rent_respository.dart

@@ -1,71 +0,0 @@
-import 'package:domain/constants/api_constants.dart';
-import 'package:domain/entity/server_time.dart';
-import 'package:plugin_platform/platform_export.dart';
-import 'package:plugin_platform/http/dio_engine.dart';
-import 'package:plugin_platform/http/http_result.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/util.dart';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:plugin_basic/provider/http_provider/http_provider.dart';
-
-import 'for_rent_state.dart';
-
-part 'for_rent_respository.g.dart';
-
-@Riverpod(keepAlive: true)
-ForrentRepository forrentRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
-  return ForrentRepository(dioEngine: dioEngine);
-}
-
-/*
- * 数据仓库
- */
-class ForrentRepository {
-  DioEngine dioEngine;
-
-  ForrentRepository({required this.dioEngine});
-
-  Future<HttpResult<Object>> fetchForrentList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-
-    // if (!Utils.isEmpty(type)) {
-    //   params["type"] = type!;
-    // }
-
-    params = data!;
-
-
-    Map<String, String> headers = {};
-
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/index.php/api/employee/extra/time', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.GET,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = ForrentState.fromMap(json!);
-      //重新赋值data或list
-      return result.convert<ForrentState>(data: data);
-    }
-    return result.convert();
-  }
-
-
-}

+ 0 - 18
packages/cpt_community/lib/modules/garage/for_rent/for_rent_state.dart

@@ -6,9 +6,6 @@ class ForrentState {
   LoadState loadingState;
   String? errorMessage;
 
-  int? page;
-  int? limit = 10;
-  int? count = 0;
   List<Map<String, dynamic>> list;
 
 
@@ -16,9 +13,6 @@ class ForrentState {
     this.activeTabIndex,
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     required this.list,
   });
 
@@ -26,18 +20,12 @@ class ForrentState {
     int? activeTabIndex,
     LoadState? loadingState,
     String? errorMessage,
-    int? page,
-    int? limit,
-    int? count,
     List<Map<String, dynamic>>? list,
   }) {
     return ForrentState(
       activeTabIndex: activeTabIndex ?? this.activeTabIndex,
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       list: list ?? this.list,
     );
   }
@@ -47,9 +35,6 @@ class ForrentState {
       'activeTabIndex': this.activeTabIndex,
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'list': this.list,
     };
   }
@@ -59,9 +44,6 @@ class ForrentState {
       activeTabIndex: map['activeTabIndex'] as int,
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       list: map['list'] as List<Map<String, dynamic>>,
     );
   }

+ 158 - 92
packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.dart

@@ -1,4 +1,5 @@
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/garage_sale_rent_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -7,20 +8,22 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
+import '../../../respository/common_garage.dart';
 import '../../../router/page/community_page_router.dart';
 import '../../community/community_pageview_idx_data.dart';
 import '../../community/community_vm.dart';
 import '../garagesale_detail/garagesale_detail_page.dart';
-import 'for_rent_respository.dart';
 import 'for_rent_state.dart';
 
 part 'for_rent_vm.g.dart';
 
 @riverpod
 class ForrentVm extends _$ForrentVm {
-  late ForrentRepository ForrentRepositoryInstance;
+  late CommonGarageRespository commonGarageRespositoryInstance;
   bool _needShowPlaceholder = false; //是否展示LoadingView
-
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -70,7 +73,7 @@ class ForrentVm extends _$ForrentVm {
   @override
   ForrentState build(){
     // 引入数据仓库
-    ForrentRepositoryInstance = ref.read(forrentRepositoryProvider);
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -87,7 +90,7 @@ class ForrentVm extends _$ForrentVm {
 
   // 初始化页面数据
   initPageData() {
-    Log.d("----for_rent_vm-----initPageData   ${state.loadingState}");
+    Log.d("----for_sale_vm-----initPageData   ${state.loadingState}");
     onRefresh();
   }
 
@@ -95,21 +98,20 @@ class ForrentVm extends _$ForrentVm {
   Future loadMore() async {
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forRent);
     if(isShowing){
-      Log.d("----for_rent_vm-----loadMore");
+      Log.d("----for_sale_vm-----loadMore");
       // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= state.count){
+      // if(state.list.length >= _count){
       //   return;
       // }else {
-      //   int page = state.page + 1;
+      //   int page = _page + 1;
       //   state = state.copyWith(page: page,);
       //   getListData();
       // }
       // 检查 page 是否为 null,并初始化为 1
-      int newCurPage = state.page ?? 1;
-      state = state.copyWith(page: ++newCurPage);
+      _page++;
       getListData();
     }else {
-      refreshController.finishRefresh();
+      refreshController.finishLoad();
     }
   }
 
@@ -119,14 +121,12 @@ class ForrentVm extends _$ForrentVm {
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forRent);
     if(isShowing){
       // 当前pageView 页面正处于显示状态
-      Log.d("----for_rent_vm-----onRefresh ");
+      Log.d("----forrent_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
-      state = state.copyWith(page: 1);
+      _page = 1;
       getListData();
     }else {
       refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
     }
   }
 
@@ -134,102 +134,168 @@ class ForrentVm extends _$ForrentVm {
   Future retryRequest() async {
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forRent);
     if(isShowing){
-      state = state.copyWith(page: 1);
+      _page = 1;
       _needShowPlaceholder = true;
       getListData();
+    }else {
+      refreshController.finishRefresh();
     }
   }
 
 
   // 获取list 列表数据
-  Future getListData<T>() async {
+  Future getListData<T>({bool? isLoadMore = false}) async {
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_rent加载listData数据---------------start--${state.page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-    //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
-    //     Log.d("请求完成结果------${result.data}");
-    //     //校验成功失败
-    //     if (result.isSuccess) {
-    //       // state = state.copyWith(serverTime: result.data);
-    //       state = state;
-    //   handleList(listResult.data?.rows);
-    //       ToastEngine.show("获取数据成功");
-    //     } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    //       ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //     }
-    //   } catch (e) {
-    //     ToastEngine.show("Error: $e");
-    //   }
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-    final List<Map<String, dynamic>> listData = [
-      {
-        'id':1,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':2,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':3,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-    ];
-
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
-    } else {
-      //加载更多
-      final allList = state.list;
-      allList?.addAll(listData);
-      state = state.copyWith(list: allList);
-      refreshController.finishLoad();
+    Log.d("for_rent加载listData数据---------------start--${_page}---");
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    // final List<Map<String, dynamic>> listData = [
+    //   {
+    //     'id':1,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':2,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':3,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    // ];
+
 
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "type": 2,  // 类型(1=Sale,2=Rent)
+        "page": _page,
+        "limit": _limit,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonGarageRespositoryInstance.fetchGarageDataList(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        handlerResultList(result.list?.cast<GarageSaleRentEntity>(), isLoadMore ?? false);
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
     }
 
     // 最后赋值
     _needShowPlaceholder = false;
   }
 
+  void handlerResultList(List<GarageSaleRentEntity>? list, bool isLoadMore) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        if(isLoadMore){
+
+        }else {
+
+        }
+        refreshController.finishRefresh();
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        allList!.addAll(list.map((item) => item.toJson()).toList());
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+      }
+    } else {
+      if (_page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if (_page == 1) {
+          //展示无数据的布局
+          state.list!.clear();
+          changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishRefresh();
+        } else {
+          //展示加载完成,没有更多数据了
+          if(state.list!.length == 0){
+            changeLoadingState(LoadState.State_Empty, null);
+            refreshController.finishLoad();
+          }else {
+            if(_needShowPlaceholder){
+              changeLoadingState(LoadState.State_Success, null);
+            }
+          }
+          //更新展示的状态
+          refreshController.finishLoad(IndicatorResult.noMore);
+        }
+      }
+    }
+  }
+
+
+  // 点击 收藏/取消收藏
+  Future<bool?> handlerClickCollection(int id, bool? isCollection) async{
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "id": id,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonGarageRespositoryInstance.fetchGarageColleciton(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        // 修改 该id 的 liked 和 likes_count 字段
+        state.list!.forEach((Map<String, dynamic> element) {
+          if(element['id'] == id){
+            element['liked'] = !element['liked'];
+            element['collection_num'] = element['liked'] ? element['collection_num'] + 1 : element['collection_num'] - 1;
+          }
+        });
+        return true;
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
+    }
+  }
   // 去详情页面
-  void handlerGotoDetail(id){
+  void handlerGotoDetail({BuildContext? context, required int id, String type='forRent'}){
     Log.d("去详情页面");
     appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forRent'));
   }

+ 1 - 1
packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.g.dart

@@ -6,7 +6,7 @@ part of 'for_rent_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$forrentVmHash() => r'1dc0df10f17ff092fd7f521c28a0cf71d9e0671c';
+String _$forrentVmHash() => r'64d0cddcdfa741792d5bdeae3a70c8c694e01461';
 
 /// See also [ForrentVm].
 @ProviderFor(ForrentVm)

+ 7 - 6
packages/cpt_community/lib/modules/garage/for_sale/for_sale_page.dart

@@ -96,7 +96,7 @@ class ForsalePage extends HookConsumerWidget {
                 delegate: SliverChildBuilderDelegate(
                       (context, index) {
                     return  _buildForsaleItem(context, ref, state.list[index], vm).onTap((){
-                      vm.handlerGotoDetail(state.list[index]['id']);
+                      vm.handlerGotoDetail(context: context, id: state.list[index]['id'], type: 'forSale');
                     });
                   },
                   childCount: state.list.length,
@@ -109,7 +109,7 @@ class ForsalePage extends HookConsumerWidget {
     );
   }
 
-  Widget _buildForsaleItem(BuildContext context, WidgetRef ref, item, vm){
+  Widget _buildForsaleItem(BuildContext context, WidgetRef ref, Map<String, dynamic> item, vm){
     return SizedBox(
       width: double.infinity,
       child: Container(
@@ -133,10 +133,11 @@ class ForsalePage extends HookConsumerWidget {
               Expanded(
                 child: GarageCard(
                   key: UniqueKey(),
-                  itemObj: item,
-                  onClickColleciotn: (dynamic collectionValue){
-                    Log.d("点击了收藏按钮  --${item['id']}-$collectionValue");
-                    return true;
+                  itemObj: item.cast<String, dynamic>(),
+                  onClickColleciotn: (dynamic collectionValue) async {
+                    Log.d("点击了收藏按钮  --id:${item['id']}- $collectionValue");
+                    int id = item['id'];
+                    return await vm.handlerClickCollection(id, collectionValue);
                   }
                 ),
               ),

+ 0 - 71
packages/cpt_community/lib/modules/garage/for_sale/for_sale_respository.dart

@@ -1,71 +0,0 @@
-import 'package:domain/constants/api_constants.dart';
-import 'package:domain/entity/server_time.dart';
-import 'package:plugin_platform/platform_export.dart';
-import 'package:plugin_platform/http/dio_engine.dart';
-import 'package:plugin_platform/http/http_result.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/util.dart';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:plugin_basic/provider/http_provider/http_provider.dart';
-
-import 'for_sale_state.dart';
-
-part 'for_sale_respository.g.dart';
-
-@Riverpod(keepAlive: true)
-ForsaleRepository newsRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
-  return ForsaleRepository(dioEngine: dioEngine);
-}
-
-/*
- * 数据仓库
- */
-class ForsaleRepository {
-  DioEngine dioEngine;
-
-  ForsaleRepository({required this.dioEngine});
-
-  Future<HttpResult<Object>> fetchForsaleList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-
-    // if (!Utils.isEmpty(type)) {
-    //   params["type"] = type!;
-    // }
-
-    params = data!;
-
-
-    Map<String, String> headers = {};
-
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/index.php/api/employee/extra/time', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.GET,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = ForsaleState.fromMap(json!);
-      //重新赋值data或list
-      return result.convert<ForsaleState>(data: data);
-    }
-    return result.convert();
-  }
-
-
-}

+ 0 - 19
packages/cpt_community/lib/modules/garage/for_sale/for_sale_state.dart

@@ -5,10 +5,6 @@ class ForsaleState {
   //页面 LoadView 状态的展示
   LoadState loadingState;
   String? errorMessage;
-
-  int? page;
-  int? limit = 10;
-  int? count = 0;
   List<Map<String, dynamic>> list;
 
 
@@ -16,9 +12,6 @@ class ForsaleState {
     this.activeTabIndex,
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     required this.list,
   });
 
@@ -26,9 +19,6 @@ class ForsaleState {
     int? activeTabIndex,
     LoadState? loadingState,
     String? errorMessage,
-    int? page,
-    int? limit,
-    int? count,
     List<Map<String, dynamic>>? list,
     List<String>? tabsList,
   }) {
@@ -36,9 +26,6 @@ class ForsaleState {
       activeTabIndex: activeTabIndex ?? this.activeTabIndex,
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       list: list ?? this.list,
     );
   }
@@ -48,9 +35,6 @@ class ForsaleState {
       'activeTabIndex': this.activeTabIndex,
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'list': this.list,
     };
   }
@@ -60,9 +44,6 @@ class ForsaleState {
       activeTabIndex: map['activeTabIndex'] as int,
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       list: map['list'] as List<Map<String, dynamic>>,
     );
   }

+ 198 - 141
packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart

@@ -1,5 +1,7 @@
 import 'package:cpt_community/modules/community/community_vm.dart';
+import 'package:cpt_community/respository/common_garage.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/garage_sale_rent_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -12,16 +14,17 @@ import '../../../router/page/community_page_router.dart';
 import '../../community/community_page.dart';
 import '../../community/community_pageview_idx_data.dart';
 import '../garagesale_detail/garagesale_detail_page.dart';
-import 'for_sale_respository.dart';
 import 'for_sale_state.dart';
 
 part 'for_sale_vm.g.dart';
 
 @riverpod
 class ForsaleVm extends _$ForsaleVm {
-  late ForsaleRepository ForsaleRepositoryInstance;
+  late CommonGarageRespository commonGarageRespositoryInstance;
   bool _needShowPlaceholder = false; //是否展示LoadingView
-
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
 
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
@@ -38,7 +41,7 @@ class ForsaleVm extends _$ForsaleVm {
   @override
   ForsaleState build(){
     // 引入数据仓库
-    ForsaleRepositoryInstance = ref.read(newsRepositoryProvider);
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -66,19 +69,18 @@ class ForsaleVm extends _$ForsaleVm {
     if(isShowing){
       Log.d("----for_sale_vm-----loadMore");
       // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= state.count){
+      // if(state.list.length >= _count){
       //   return;
       // }else {
-      //   int page = state.page + 1;
+      //   int page = _page + 1;
       //   state = state.copyWith(page: page,);
       //   getListData();
       // }
       // 检查 page 是否为 null,并初始化为 1
-      int newCurPage = state.page ?? 1;
-      state = state.copyWith(page: ++newCurPage);
+      _page++;
       getListData();
     }else {
-      refreshController.finishRefresh();
+      refreshController.finishLoad();
     }
   }
 
@@ -90,12 +92,10 @@ class ForsaleVm extends _$ForsaleVm {
       // 当前pageView 页面正处于显示状态
       Log.d("----forsale_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
-      state = state.copyWith(page: 1);
+      _page = 1;
       getListData();
     }else {
       refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
     }
   }
 
@@ -103,156 +103,213 @@ class ForsaleVm extends _$ForsaleVm {
   Future retryRequest() async {
     bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forSale);
     if(isShowing){
-      state = state.copyWith(page: 1);
+      _page = 1;
       _needShowPlaceholder = true;
       getListData();
+    }else {
+      refreshController.finishRefresh();
     }
   }
 
 
   // 获取list 列表数据
-  Future getListData<T>() async {
+  Future getListData<T>({bool? isLoadMore}) async {
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_sale_vm加载listData数据---------------start--${state.page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-    //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
-    //     Log.d("请求完成结果------${result.data}");
-    //     //校验成功失败
-    //     if (result.isSuccess) {
-    //       // state = state.copyWith(serverTime: result.data);
-    //       state = state;
-    //   handleList(listResult.data?.rows);
-    //       ToastEngine.show("获取数据成功");
-    //     } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    //       ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //     }
-    //   } catch (e) {
-    //     ToastEngine.show("Error: $e");
-    //   }
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-    final List<Map<String, dynamic>> listData = [
-      {
-        'id':1,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':2,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':3,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':4,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':5,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':6,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-    ];
+    Log.d("for_sale_vm加载listData数据---------------start--${_page}---");
 
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
-    } else {
-      //加载更多
-      final allList = state.list;
-      allList.addAll(listData);
-      state = state.copyWith(list: allList);
-      refreshController.finishLoad();
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    // final List<Map<String, dynamic>> listData = [
+    //   {
+    //     'id':1,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':2,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':3,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':4,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':5,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':6,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    // ];
+    //
+    // if (_page == 1) {
+    //   //刷新的方式
+    //   state = state.copyWith(list: listData);
+    //   refreshController.finishRefresh();
+    //   // //更新展示的状态
+    //   changeLoadingState(LoadState.State_Success, null);
+    // } else {
+    //   //加载更多
+    //   final allList = state.list;
+    //   allList.addAll(listData);
+    //   state = state.copyWith(list: allList);
+    //   refreshController.finishLoad();
+    //
+    // }
+    //
+    // // 最后赋值
+    // _needShowPlaceholder = false;
 
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "type": 1,  // 类型(1=Sale,2=Rent)
+        "page": _page,
+        "limit": _limit,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonGarageRespositoryInstance.fetchGarageDataList(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        handlerResultList(result.list?.cast<GarageSaleRentEntity>(), isLoadMore ?? false);
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
     }
 
-    // 最后赋值
-    _needShowPlaceholder = false;
   }
 
 
-  // 点击 like comments  share
-  void handlerClickActionBtn(String? actionStr, item){
-    final id = item['id'];
-    switch (actionStr) {
-      case 'like':
-        Log.d("点击了 点赞");
-        handlerGotoDetail(id);
-        break;
-      case 'comments':
-        Log.d("点击了 评论");
-        handlerGotoDetail(id);
-        break;
-      case 'share':
-        Log.d("点击了 分享");
-        handlerGotoDetail(id);
-        break;
-      default:
-        break;
+  void handlerResultList(List<GarageSaleRentEntity>? list, bool isLoadMore) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        allList!.addAll(list.map((item) => item.toJson()).toList());
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+      }
+    } else {
+      if (_page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if (_page == 1) {
+          //展示无数据的布局
+          state.list!.clear();
+          changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishRefresh();
+        } else {
+          //展示加载完成,没有更多数据了
+          if(state.list!.length == 0){
+            changeLoadingState(LoadState.State_Empty, null);
+            refreshController.finishLoad();
+          }else {
+            if(_needShowPlaceholder){
+              changeLoadingState(LoadState.State_Success, null);
+            }
+          }
+          //更新展示的状态
+          refreshController.finishLoad(IndicatorResult.noMore);
+        }
+      }
+    }
+  }
+
+
+  // 点击 收藏/取消收藏
+  Future<bool?> handlerClickCollection(int id, bool? isCollection) async{
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "id": id,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonGarageRespositoryInstance.fetchGarageColleciton(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        // 修改 该id 的 liked 和 likes_count 字段
+        state.list!.forEach((Map<String, dynamic> element) {
+          if(element['id'] == id){
+            element['liked'] = !element['liked'];
+            element['collection_num'] = element['liked'] ? element['collection_num'] + 1 : element['collection_num'] - 1;
+          }
+        });
+        return true;
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
     }
   }
   // 去详情页面
-  void handlerGotoDetail(id){
+  void handlerGotoDetail({BuildContext? context, required int id, String type='forSale'}){
     Log.d("去详情页面");
     appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forSale'));
   }

+ 1 - 1
packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.g.dart

@@ -6,7 +6,7 @@ part of 'for_sale_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$forsaleVmHash() => r'e94a8a4c8ca889796a23b37f6a1ae6dd6a709b23';
+String _$forsaleVmHash() => r'79de87553b92d59e522c27fd773b8da73170b7ea';
 
 /// See also [ForsaleVm].
 @ProviderFor(ForsaleVm)

+ 47 - 22
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_page.dart

@@ -17,16 +17,16 @@ import 'package:widgets/my_text_view.dart';
 
 @RoutePage()
 class GaragesaleDetailPage extends HookConsumerWidget {
-  final int? id;
-  final String? type;  // forSale  forRent
+  final int id;
+  final String type;  // forSale  forRent
 
   const GaragesaleDetailPage({Key? key, required this.id, required this.type}) : super(key: key);
   // 启动当前页面
   static void startInstance({BuildContext? context, int? id, String? type = 'forSale'}) {
     if (context != null) {
-      context.router.push(GaragesaleDetailPageRoute(id: id, type: type));
+      context.router.push(GaragesaleDetailPageRoute(id: id!, type: type!));
     } else {
-      appRouter.push(GaragesaleDetailPageRoute(id: id, type: type));
+      appRouter.push(GaragesaleDetailPageRoute(id: id!, type: type!));
     }
   }
 
@@ -37,7 +37,14 @@ class GaragesaleDetailPage extends HookConsumerWidget {
     final vm = ref.read(garagesaleDetailVmProvider.notifier);
     final String pageTitle = (type == 'forSale') ? 'For Sale' :'For Rent';
     GlobalKey _likeButtonKey = GlobalKey<MyLikeButtonState>();
+
+    String title =  '';
+    String price =  '';
+    String contactType = '';
+    String description = '';
+
     useEffect((){
+      vm.setInitPageData(id: id!, type: type);
       // 组件挂载时执行 - 执行接口请求
       Future.microtask(() => vm.initPageData());
       return () {
@@ -67,12 +74,22 @@ class GaragesaleDetailPage extends HookConsumerWidget {
                     scrollDirection: Axis.vertical,
                     physics: const BouncingScrollPhysics(),
                     clipBehavior: Clip.none,
-                    child: _buildContentBox(context, ref),
+                    child: _buildContentBox(context, ref,
+                      title:title,
+                      price:price,
+                      contactType:contactType,
+                      description:description,
+                    ),
                   ),
                 ),
                 Visibility(
-                  visible: state.loadingState == LoadState.State_Success && state.datas!['contactType'] == 'WhatsApp',
-                  child: _buildWhatsApp(context, ref),
+                  visible: state.loadingState == LoadState.State_Success,
+                  child: _buildWhatsApp(context, ref,
+                    title:title,
+                    price:price,
+                    contactType:contactType,
+                    description:description,
+                  ),
                 ),
               ]
             ),
@@ -80,14 +97,19 @@ class GaragesaleDetailPage extends HookConsumerWidget {
           // 底部联系信息
           Visibility(
             visible: state.loadingState == LoadState.State_Success,
-            child: _buildBottomConcatInfo(context, ref, _likeButtonKey),
+            child: _buildBottomConcatInfo(context, ref, _likeButtonKey,
+              title:title,
+              price:price,
+              contactType:contactType,
+              description:description,
+            ),
           )
         ],
       ),
     );
   }
 
-  Widget _buildWhatsApp(BuildContext context, WidgetRef ref) {
+  Widget _buildWhatsApp(BuildContext context, WidgetRef ref, {required String title, required String price, required String contactType, required String description}) {
     final vm = ref.read(garagesaleDetailVmProvider.notifier);
     return Positioned(
       right: 15.5,
@@ -102,13 +124,14 @@ class GaragesaleDetailPage extends HookConsumerWidget {
     );
   }
 
-  Widget _buildContentBox(BuildContext context, WidgetRef ref) {
+  Widget _buildContentBox(BuildContext context, WidgetRef ref, {required String title, required String price, required String contactType, required String description}) {
     final vm = ref.read(garagesaleDetailVmProvider.notifier);
     final state = ref.watch(garagesaleDetailVmProvider);
-    String title = state.datas!['title'] ?? '';
-    String price = state.datas!['price'] ?? '';
-    String contactType = state.datas!['contactType'] ?? '';
-    String description = state.datas!['description'] ?? '';
+    String goods_img = '';
+    String title =  '';
+    String price = '';
+    String contactType =  '';
+    String description = '';
     return Column(
       crossAxisAlignment: CrossAxisAlignment.start,
       children: [
@@ -117,7 +140,7 @@ class GaragesaleDetailPage extends HookConsumerWidget {
           width: double.infinity,
           height: 173.5,
           child: MyLoadImage(
-            state.datas!['goods_img'],
+            goods_img,
           ),
         ),
         Column(
@@ -145,14 +168,16 @@ class GaragesaleDetailPage extends HookConsumerWidget {
     );
   }
 
-  Widget _buildBottomConcatInfo(BuildContext context, WidgetRef ref, likeButtonKey) {
+  Widget _buildBottomConcatInfo(BuildContext context, WidgetRef ref, likeButtonKey, {required String title, required String price, required String contactType, required String description}) {
     final state = ref.watch(garagesaleDetailVmProvider);
-    String publisher = state.datas!['publisher'] ?? '';
-    String contactType = state.datas!['contactType'] ?? '';
-    String contactInfo = state.datas!['contactInfo'] ?? '';
-    String publisherAvatar = state.datas!['publisher_avatar'] ?? '';
-    String publisherTime = state.datas!['publisher_time'] ?? '';
-    int collectionNum = state.datas!['collection_num'] ?? 0;
+
+    String publisher =  '';
+    String contactType =  '';
+    String contactInfo =  '';
+    String publisherAvatar = '';
+    String publisherTime =  '';
+    int collectionNum =  0;
+
     return Container(
       height: 50,
       color: ColorUtils.string2Color('#4161D0'),

+ 3 - 2
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_state.dart

@@ -1,3 +1,4 @@
+import 'package:domain/entity/garage_sale_rent_detail_entity.dart';
 import 'package:widgets/load_state_layout.dart';
 
 class GarageDetailState {
@@ -8,7 +9,7 @@ class GarageDetailState {
   final int? id;
   final String? type;  // forsale  forrent
 
-  Map<String, dynamic> datas;
+  GarageSaleRentDetailEntity datas;
 
   GarageDetailState({
     this.loadingState = LoadState.State_Loading,
@@ -19,7 +20,7 @@ class GarageDetailState {
   });
 
   GarageDetailState copyWith({
-    Map<String, dynamic>? datas,
+    GarageSaleRentDetailEntity? datas,
     LoadState? loadingState,
     String? errorMessage,
     int? id,

+ 36 - 4
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_vm.dart

@@ -1,4 +1,6 @@
+import 'package:cpt_community/respository/common_garage.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/garage_sale_rent_detail_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -15,9 +17,12 @@ part 'garagesale_detail_vm.g.dart';
 
 @riverpod
 class GaragesaleDetailVm extends _$GaragesaleDetailVm {
-  // late GaragesaleDetailRepository GaragesaleDetailRepositoryInstance;
+  late CommonGarageRespository commonGarageRespositoryInstance;
   bool _needShowPlaceholder = false; //是否展示LoadingView
 
+  int _detailId = 0;
+  String _detailType = "";
+
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -26,14 +31,14 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
 
   GarageDetailState initState() {
     return GarageDetailState(
-        datas: {}
+        datas: GarageSaleRentDetailEntity()
     );
   }
 
   @override
   GarageDetailState build(){
     // 引入数据仓库
-    // GaragesaleDetailRepositoryInstance = ref.read(newsRepositoryProvider);
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -55,6 +60,10 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
     getDetailData();
   }
 
+  setInitPageData({required int id, required String type}){
+    _detailId = id;
+    _detailType = type;
+  }
   // 初始化页面数据
   initPageData() {
     Log.d("----property_news_vm-----initPageData   ${state.loadingState}");
@@ -91,7 +100,8 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
       'publisher_time': 'June 17,2024 at 7:23 PM'
     };
 
-    state = state.copyWith(datas: detailData);
+    state = state.copyWith(datas: GarageSaleRentDetailEntity(
+    ));
 
     changeLoadingState(LoadState.State_Success, null);
 
@@ -99,6 +109,28 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
 
     // 最后赋值
     _needShowPlaceholder = false;
+
+
+    // try {
+    //   Map<String, dynamic> params = {
+    //     "id": _detailId,
+    //   };
+    //   final result = await commonGarageRespositoryInstance.fetchGarageDetailInfo(params);
+    //   if(result.isSuccess){
+    //     state = state.copyWith(datas: result.data as GarageSaleRentDetailEntity);
+    //     changeLoadingState(LoadState.State_Success, null);
+    //     refreshController.finishRefresh();
+    //   } else {
+    //     String errorMessage = result.errorMsg!;
+    //     changeLoadingState(LoadState.State_Error, errorMessage);
+    //     ToastEngine.show(result.errorMsg ?? "Network Load Error");
+    //   }
+    // } catch (e) {
+    //   ToastEngine.show("Error: $e");
+    // }
+
+    // 最后赋值
+    _needShowPlaceholder = false;
   }
 
 

+ 1 - 1
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_vm.g.dart

@@ -7,7 +7,7 @@ part of 'garagesale_detail_vm.dart';
 // **************************************************************************
 
 String _$garagesaleDetailVmHash() =>
-    r'59335b8961337b00baf96d91bbc92da4b65d52de';
+    r'17076cfe86ec86c19b0285834671eb024b1dc4ae';
 
 /// See also [GaragesaleDetailVm].
 @ProviderFor(GaragesaleDetailVm)

+ 21 - 6
packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_page.dart

@@ -17,18 +17,22 @@ import 'package:widgets/shatter/form_require_text.dart';
 import 'package:widgets/ext/ex_widget.dart';
 
 
+import '../../community/community_vm.dart';
 import 'garagesale_post_vm.dart';
 
 @RoutePage()
 class GaragesalePostPage extends HookConsumerWidget {
-  const GaragesalePostPage({Key? key}) : super(key: key);
+  int type = 1;  // 类型(1=Sale,2=Rent)
+  final VoidCallback? sCallback; // 成功回调函数
+  final VoidCallback? fCallback; // 失败回调函数
+  GaragesalePostPage({Key? key, required this.type, this.sCallback, this.fCallback}) : super(key: key);
 
   //启动当前页面
-  static void startInstance({BuildContext? context}) {
+  static void startInstance({BuildContext? context, int type = 1, VoidCallback? sCallback, VoidCallback? fCallback}) {
     if (context != null) {
-      context.router.push(const GaragesalePostPageRoute());
+      context.router.push(GaragesalePostPageRoute(type:type, sCallback: sCallback, fCallback: fCallback));
     } else {
-      appRouter.push(const GaragesalePostPageRoute());
+      appRouter.push(GaragesalePostPageRoute(type:type, sCallback: sCallback, fCallback: fCallback));
     }
   }
 
@@ -37,6 +41,14 @@ class GaragesalePostPage extends HookConsumerWidget {
     final vm = ref.watch(garagesalePostVmProvider.notifier);
     final state = ref.watch(garagesalePostVmProvider);
 
+    useEffect((){
+      vm.initData(
+        type:type
+      );
+      return () => (){
+
+      };
+    },[]);
     return Scaffold(
       appBar: MyAppBar.appBar(
         context,
@@ -191,7 +203,7 @@ class GaragesalePostPage extends HookConsumerWidget {
                   children: [
                     Expanded(
                       child: MyButton(
-                        text: "Add Card",
+                        text: "Submit",
                         radius: 0,
                         minHeight: 50,
                         backgroundColor: context.appColors.textPrimary,
@@ -200,7 +212,10 @@ class GaragesalePostPage extends HookConsumerWidget {
                         fontSize: 16,
                         onPressed: (){
                           // Navigator.pop(context);
-                          vm.submitGaragesalePost();
+                          vm.submitGaragesalePost(context, sCallback: sCallback, fCallback: fCallback);
+                          // final communitVm = ref.read(communityVmProvider.notifier);
+                          // communitVm.getCurrentPageViewVm(null).initPageData();
+                          // Navigator.pop(context);
                         },
                       ),
                     ),

+ 5 - 1
packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_state.dart

@@ -33,7 +33,8 @@ class GaragesalePostPageState {
   String? saleSelectedOption;
 
   //category 类型选项
-  final List<String> categoryOptionsList = ["Kids", "Homeware", "Fashion", "Electronics","Sports","Furniture","Others"];
+  // final List<String> categoryOptionsList = ["Kids", "Homeware", "Fashion", "Electronics","Sports","Furniture","Others"];
+  List<String> categoryOptionsList = [];
   String? categorySelectedOption;
 
   // 选择的图片
@@ -42,6 +43,7 @@ class GaragesalePostPageState {
   GaragesalePostPageState({
     formData,
     required this.imgList,
+    required this.categoryOptionsList,
     this.titleErrorText,
     this.contactInfoErrorText,
     this.priceErrorText,
@@ -93,6 +95,7 @@ class GaragesalePostPageState {
   GaragesalePostPageState copyWith({
     Map<String, Map<String, dynamic>>? formData,
     List<String>? imgList,
+    List<String>? categoryOptionsList,
     String? titleErrorText,
     String? contactInfoErrorText,
     String? priceErrorText,
@@ -109,6 +112,7 @@ class GaragesalePostPageState {
       title: title ?? this.title,
       description: description ?? this.description,
       imgList: imgList ?? this.imgList,
+      categoryOptionsList: categoryOptionsList ?? this.categoryOptionsList,
       contactInformation: contactInformation ?? this.contactInformation,
       contactTypeSelectedOption: contactTypeSelectedOption ?? this.contactTypeSelectedOption,
       saleSelectedOption: saleSelectedOption ?? this.saleSelectedOption,

+ 109 - 7
packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.dart

@@ -1,4 +1,5 @@
 
+import 'package:cpt_community/modules/community/community_vm.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:flutter/material.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
@@ -11,6 +12,7 @@ import 'package:shared/utils/util.dart';
 import 'package:widgets/picker/option_pick_util.dart';
 
 
+import '../../../respository/common_garage.dart';
 import 'garagesale_post_page.dart';
 import 'garagesale_post_state.dart';
 
@@ -19,12 +21,19 @@ part 'garagesale_post_vm.g.dart';
 
 @riverpod
 class GaragesalePostVm extends _$GaragesalePostVm {
+  late CommonGarageRespository commonGarageRespositoryInstance;
+  List _resCategoryOptionsList = [];
+  int _initialSaleSelectIndex = 0;
+  String _initialSaleSelectedItem = '';
+  int _type = 1; // 类型(1=Sale,2=Rent)
+
   GaragesalePostPageState initState() {
     return GaragesalePostPageState(
       titleErrorText: null,
       contactInfoErrorText: null,
       priceErrorText: null,
       descriptionErrorText: '',
+      categoryOptionsList: [],
       formData: {
         'sale': {
           'value': '',
@@ -83,6 +92,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
 
   @override
   GaragesalePostPageState build() {
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     // 初始化状态
     GaragesalePostPageState state = initState();
 
@@ -97,6 +107,57 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     return state;
   }
 
+  initData({int? type}){
+    _type = type ?? 1;
+    Log.d("当前的type $_type");
+    // 初始化回显 sale 分类
+    initSaleCategory();
+    this.getGarageCategoryList();
+  }
+
+  initSaleCategory() {
+    state.saleOptionsList.asMap().forEach((index, item) => {
+      if(_type == 1){
+        if(item == 'For Sale'){
+          _initialSaleSelectIndex = index,
+          _initialSaleSelectedItem = item
+        }
+      }else if(_type == 2){
+        if(item == 'For Rent'){
+          _initialSaleSelectIndex = index,
+          _initialSaleSelectedItem = item
+        }
+      }
+    });
+    // state = state.copyWith(
+    //     saleSelectedOption:_initialSaleSelectedItem,
+    // );
+  }
+
+  Future getGarageCategoryList() async {
+    final communityVm = ref.read(communityVmProvider.notifier);
+    final result = await communityVm.getGarageSaleCategoryOptions();
+    if (result.isSuccess) {
+      // state.categoryOptions = result.data!;
+    //   将 [{id: 1, name: Kids}, {id: 2, name: Homeware}, {id: 3, name: Fashion}, {id: 4, name: Electronics}, {id: 5, name: Sports}, {id: 6, name: Furniture}, {id: 7, name: Others}] 处理成
+    //   ['Kids', 'Homeware', 'Fashion', 'Electronics', 'Sports', 'Furniture', 'Others']
+      final listJson = result.getListJson();
+      _resCategoryOptionsList = listJson;
+      Log.d("_resCategoryOptionsList   $_resCategoryOptionsList");
+
+      List<String> catList = (listJson as List)!.map((e) => (e['name'] as String)).toList()?? [];
+
+
+      Log.d("--initialSelectedItem----$_initialSaleSelectedItem-");
+
+       state = state.copyWith(
+         saleSelectedOption:_initialSaleSelectedItem,
+         categoryOptionsList: catList,
+       );
+    }
+    return result;
+  }
+
   //catogery 选择选项
   void pickCategoryCallback() {
     _dismissKeyboard(keyStr: 'title');
@@ -122,14 +183,17 @@ class GaragesalePostVm extends _$GaragesalePostVm {
 
     OptionPickerUtil.showCupertinoOptionPicker(
       items: state.saleOptionsList,
-      initialSelectIndex: 0,
+      initialSelectIndex: _initialSaleSelectIndex,
       onPickerChanged: (_, index) {
-        state = state.copyWith(saleSelectedOption: state.saleOptionsList[index]);
+        _initialSaleSelectIndex = index;
+        state = state.copyWith(
+            saleSelectedOption: state.saleOptionsList[index]
+        );
       },
     );
   }
 
-  //sale 选择选项
+  //concatType 选择选项
   void pickContactTypeCallback() {
     _dismissKeyboard(keyStr: 'title');
     _dismissKeyboard(keyStr: 'price');
@@ -189,7 +253,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
   }
 
   ///提交反馈
-  void submitGaragesalePost() {
+  void submitGaragesalePost(BuildContext context, {VoidCallback? sCallback, VoidCallback? fCallback}) {
     Log.d("GaragesalePostPageState 提交表单");
     state = state.copyWith(titleErrorText: null, descriptionErrorText: null);
     _dismissKeyboard(keyStr: "");
@@ -251,12 +315,50 @@ class GaragesalePostVm extends _$GaragesalePostVm {
       state = state.copyWith(descriptionErrorText: null);
     }
 
+    String totalContactStr = '';
+    if(contactTypeValue == 'Mobile Phone'){
+      totalContactStr = 'mobile:$contactInfoValue)';
+    }else if(contactTypeValue == 'WhatsApp'){
+      totalContactStr = 'whatsapp:$contactInfoValue)';
+    }else if(contactTypeValue == 'Email'){
+      totalContactStr = 'email:$contactInfoValue)';
+    }
 
-    //去成功页面
-    // FeedbackCreateSuccessPage.startInstance();
-    // 返回上一页
+    // 提交数据
+    handlerSubmitPost(
+      type: saleValue == 'For Sale'? 1:2,
+      titleValue: titleValue,
+      categoryId: 1,
+      priceValue: priceValue,
+      descriptionValue: descriptionValue,
+      contactValue: totalContactStr,
+      imgList: state.imgList,
+    );
   }
 
+  Future handlerSubmitPost({
+    required int type,
+    required String titleValue,
+    required int categoryId,
+    required String priceValue,
+    required String contactValue,
+    required String descriptionValue,
+    required List imgList,
+  }) async{
+    final params = <String, dynamic>{
+      "type": type, // 1 = Sale  2 = Rent
+      "category_id": categoryId,
+      "title": titleValue,
+      "price": priceValue,
+      "description": descriptionValue,
+      "contact": contactValue,  // string($例如:whatsapp:+8617671757687 或 mobile:+8617671757687)
+      "resources": imgList,
+    };
+    final result =  await commonGarageRespositoryInstance.fetchPublishGarage(params);
+    return result;
+  }
+
+
   //选中图片
   void setImgList(List<String> list) {
     state = state.copyWith(imgList: list);

+ 1 - 1
packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.g.dart

@@ -6,7 +6,7 @@ part of 'garagesale_post_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$garagesalePostVmHash() => r'cabc484eddab1b8e5322750ea9eee463dd6d2290';
+String _$garagesalePostVmHash() => r'5aa33663d0c96ddd7ed82f68dbb36488c7db4655';
 
 /// See also [GaragesalePostVm].
 @ProviderFor(GaragesalePostVm)

+ 27 - 20
packages/cpt_community/lib/modules/my_following/components/item_following.dart

@@ -1,4 +1,6 @@
 import 'package:cpt_community/components/comments_dialog.dart';
+import 'package:cpt_community/modules/my_following/my_follow/my_follow_vm.dart';
+import 'package:cpt_community/modules/my_following/my_follower/my_follower_vm.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:flutter/material.dart';
@@ -10,26 +12,26 @@ import 'package:widgets/my_button.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/my_text_view.dart';
 
-enum MyFollowingType {
-  isFollowType,
-  isFollowerType,
-}
+import 'item_following_vm.dart';
+
 
 class MyFollowingListItem extends StatelessWidget {
-  final MyFollowingType? itemType;
+  final String itemType;
   bool? hasBottomDriver = true;
   Map<String, dynamic> itemObj;
   void Function(dynamic)? onClickAction;
   MyFollowingListItem({
     super.key,
     required this.itemObj,
-    this.itemType = MyFollowingType.isFollowType,
+    itemType,
     this.hasBottomDriver=true,
     this.onClickAction
-  });
+  }): itemType = itemType ?? MyFollowingType['isFollowType'];
 
   @override
   Widget build(BuildContext context) {
+    String avator = itemObj?['avator']??'';
+    String name = itemObj?['name']??'';
     return Column(
       children: [
         Container(
@@ -42,13 +44,13 @@ class MyFollowingListItem extends StatelessWidget {
                   mainAxisAlignment: MainAxisAlignment.start,
                   children: [
                     MyLoadImage(
-                      'https://img1.baidu.com/it/u=2743394743,692629981&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800',
+                      avator,
                       width: 65,
                       height: 65,
                       isCircle: true,
                     ),
                     MyTextView(
-                      'Chin Lan',
+                      name,
                       fontSize: 17,
                       isFontMedium: true,
                       marginLeft: 17,
@@ -59,25 +61,30 @@ class MyFollowingListItem extends StatelessWidget {
                 }),
               ),
               // _buildIsFollowButton(context),
-              HookConsumer(
+              itemType == MyFollowingType['isFollowType'] ? HookConsumer(
                 builder: (context, ref, child) {
-                  final isFollow = useState(itemObj['isFollow']);
-                  return (!isFollow.value)? MyButton(
-                    text:'+Follow',
-                    onPressed: (){
+                  final isFollow = useState<bool>(true);
+                  return  MyButton(
+                    text: isFollow.value? 'Followed':'+Follow',
+                    onPressed: () async{
+                      final vm = ref.read(itemFollowingVmProvider.notifier);
                       // todo 调用接口 然后更新状态
-                      isFollow.value = !isFollow.value;
+                      int to_user_id = itemObj['id'];
+                      bool asyncResult = await vm.handlerFollow(context, to_user_id, isFollow.value, itemType!);
+                      if(asyncResult){
+                        isFollow.value = !isFollow.value;
+                      }
                     },
-                    textColor: context.appColors.textWhite,
-                    backgroundColor: context.appColors.textPrimary,
+                    textColor: isFollow.value? context.appColors.textDarkGray : context.appColors.textWhite,
+                    side: isFollow.value?  BorderSide(color: context.appColors.textDarkGray,width: 0.5) : BorderSide.none,
+                    backgroundColor: isFollow.value? Colors.transparent :context.appColors.textPrimary,
                     fontSize: 14,
                     fontWeight: FontWeight.w400,
                     minWidth: 67.5,
                     minHeight: 30.5,
-                  ): const SizedBox.shrink();
+                  );
                 },
-              )
-
+              ): const SizedBox.shrink()
             ],
           ),
         ),

+ 54 - 0
packages/cpt_community/lib/modules/my_following/components/item_following_vm.dart

@@ -0,0 +1,54 @@
+import 'package:flutter/cupertino.dart';
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:shared/utils/log_utils.dart';
+
+import '../../../respository/common_newsfeed.dart';
+import '../my_follow/my_follow_vm.dart';
+import '../my_follower/my_follower_vm.dart';
+import 'item_following.dart';
+
+part 'item_following_vm.g.dart';
+
+
+Map<String, dynamic> MyFollowingType = {
+  "isFollowType": '1',
+  "isFollowerType": '2',
+};
+
+@riverpod
+class ItemFollowingVm extends _$ItemFollowingVm {
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
+  @override
+  build(){
+    // 引入数据仓库
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
+    final state = {};
+    Log.d("--------------------------build---------------------");
+    return state;
+  }
+
+  // 关注/取消关注
+  Future<bool> handlerFollow(BuildContext? context, int to_user_id, bool isFollow, String itemType) async{
+    Log.d("点击了 关注");
+    try {
+      final result = await commonNewsFeedRespositoryInstance.handlerFollowOrCancel({
+        "to_user_id": to_user_id,
+      });
+      if(result.isSuccess){
+        if(itemType == MyFollowingType['isFollowType']){
+          // 删除 my_follow_list 中 id 为 to_user_id 的item
+          final myFollowVm = ref.read(myFollowVmProvider.notifier);
+          myFollowVm.softDeleteItem(to_user_id);
+        }else if(itemType == MyFollowingType['isFollowerType']){
+          // final myFlowerVm = ref.read(myFollowerVmProvider.notifier);
+        }
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      Log.d("error: $error");
+      return false;
+    }
+  }
+}

+ 10 - 11
packages/cpt_facility/lib/modules/book_confirm/book_confirm_view_model.g.dart

@@ -1,27 +1,26 @@
 // GENERATED CODE - DO NOT MODIFY BY HAND
 
-part of 'book_confirm_view_model.dart';
+part of 'item_following_vm.dart';
 
 // **************************************************************************
 // RiverpodGenerator
 // **************************************************************************
 
-String _$bookConfirmViewModelHash() =>
-    r'fdd3f7fffe200110bd14f0d3b2ce2d83c1d6a74a';
+String _$itemFollowingVmHash() => r'8e26a6f42135b31ef85d8bfe7bd1ba2ebdd0b9a1';
 
-/// See also [BookConfirmViewModel].
-@ProviderFor(BookConfirmViewModel)
-final bookConfirmViewModelProvider = AutoDisposeNotifierProvider<
-    BookConfirmViewModel, BookConfirmState>.internal(
-  BookConfirmViewModel.new,
-  name: r'bookConfirmViewModelProvider',
+/// See also [ItemFollowingVm].
+@ProviderFor(ItemFollowingVm)
+final itemFollowingVmProvider =
+    AutoDisposeNotifierProvider<ItemFollowingVm, Object?>.internal(
+  ItemFollowingVm.new,
+  name: r'itemFollowingVmProvider',
   debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
       ? null
-      : _$bookConfirmViewModelHash,
+      : _$itemFollowingVmHash,
   dependencies: null,
   allTransitiveDependencies: null,
 );
 
-typedef _$BookConfirmViewModel = AutoDisposeNotifier<BookConfirmState>;
+typedef _$ItemFollowingVm = AutoDisposeNotifier<Object?>;
 // ignore_for_file: type=lint
 // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 3 - 2
packages/cpt_community/lib/modules/my_following/my_follow/my_follow_page.dart

@@ -19,6 +19,7 @@ import 'package:widgets/widget_export.dart';
 
 import '../../../router/page/community_page_router.dart';
 import '../components/item_following.dart';
+import '../components/item_following_vm.dart';
 import 'my_follow_vm.dart';
 
 @RoutePage()
@@ -153,11 +154,11 @@ class MyFollowPage extends HookConsumerWidget {
     );
   }
 
-  Widget _buildFollowItem(BuildContext context,WidgetRef ref, item, vm, index, totalIndex) {
+  Widget _buildFollowItem(BuildContext context,WidgetRef ref, Map<String, dynamic> item, vm, index, totalIndex) {
     bool isLast = index == totalIndex - 1;
     return MyFollowingListItem(
         itemObj: item,
-        itemType: MyFollowingType.isFollowType,
+        itemType: MyFollowingType['isFollowType'],
         hasBottomDriver: isLast? false : true,
         onClickAction:(itemObj){
           print("点击了  ${itemObj['name']}");

+ 0 - 9
packages/cpt_community/lib/modules/my_following/my_follow/my_follow_state.dart

@@ -5,17 +5,11 @@ class MyFollowState {
   LoadState loadingState;
   String? errorMessage;
 
-  int? page;
-  int? limit = 10;
-  int? count = 0;
   List<Map<String, dynamic>> list;
 
   MyFollowState({
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     required this.list,
   });
 
@@ -30,9 +24,6 @@ class MyFollowState {
     return MyFollowState(
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       list: list ?? this.list,
     );
   }

+ 101 - 72
packages/cpt_community/lib/modules/my_following/my_follow/my_follow_vm.dart

@@ -1,4 +1,5 @@
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/myfollowing_list_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -6,13 +7,19 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
+import '../../../respository/common_newsfeed.dart';
 import '../my_following_vm.dart';
+import '../tabs_data.dart';
 import 'my_follow_state.dart';
 
 part 'my_follow_vm.g.dart';
 
 @riverpod
 class MyFollowVm extends _$MyFollowVm {
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
 
   bool _needShowPlaceholder = false; //是否展示LoadingView
 
@@ -30,6 +37,8 @@ class MyFollowVm extends _$MyFollowVm {
 
   @override
   MyFollowState build(){
+    // 引入数据仓库
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -53,17 +62,7 @@ class MyFollowVm extends _$MyFollowVm {
   // 上拉加载 更多
   Future loadMore() async {
     Log.d("----for_sale_vm-----loadMore");
-    // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.count){
-    //   return;
-    // }else {
-    //   int page = state.page + 1;
-    //   state = state.copyWith(page: page,);
-    //   getListData();
-    // }
-    // 检查 page 是否为 null,并初始化为 1
-    int newCurPage = state.page ?? 1;
-    state = state.copyWith(page: ++newCurPage);
+    _page++;
     getListData();
   }
 
@@ -71,15 +70,13 @@ class MyFollowVm extends _$MyFollowVm {
   // 下拉刷新
   Future onRefresh() async {
     Log.d("----forsale_vm-----onRefresh ");
-
-    // await Future.delayed(const Duration(seconds: 2));
-    state = state.copyWith(page: 1);
+    _page = 1;
     getListData();
   }
 
   // 重试请求
   Future retryRequest() async {
-    state = state.copyWith(page: 1);
+    _page = 1;
     _needShowPlaceholder = true;
     getListData();
   }
@@ -91,72 +88,104 @@ class MyFollowVm extends _$MyFollowVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_sale加载listData数据---------------start--${state.page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-    //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
-    //     Log.d("请求完成结果------${result.data}");
-    //     //校验成功失败
-    //     if (result.isSuccess) {
-    //       // state = state.copyWith(serverTime: result.data);
-    //       state = state;
-    //   handleList(listResult.data?.rows);
-    //       ToastEngine.show("获取数据成功");
-    //     } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    //       ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //     }
-    //   } catch (e) {
-    //     ToastEngine.show("Error: $e");
-    //   }
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-    final List<Map<String, dynamic>> listData = [
-      {
-        'id':1,
-        'avator': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'William Jefferson',
-        'isFollow': false,
-      },
-      {
-        'id':2,
-        'avator': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'William Jefferson',
-        'isFollow': true,
-      },
-    ];
-
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
-    } else {
-      //加载更多
-      final allList = state.list;
-      allList.addAll(listData);
-      state = state.copyWith(list: allList);
-      refreshController.finishLoad();
-
+    Log.d("for_sale加载listData数据---------------start--${_page}---");
+
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    // final List<Map<String, dynamic>> listData = [
+    //   {
+    //     'id':1,
+    //     'avator': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'William Jefferson',
+    //     'isFollow': false,
+    //   },
+    //   {
+    //     'id':2,
+    //     'avator': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'William Jefferson',
+    //     'isFollow': true,
+    //   },
+    // ];
+
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "keyword": "",
+        "page": _page,
+        "limit": _limit,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonNewsFeedRespositoryInstance.fetchMyFollowList(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        handlerResultList(result.list as List<MyfollowingListEntity>);
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
     }
 
-    // 最后赋值
-    _needShowPlaceholder = false;
+    // 更新 my_posts_tabs 里面的数字
+    updateMyFollowingTabsNum(tabsNamesData['Follow'], state.list!.length, 0);
+  }
+
+  void handlerResultList(List<MyfollowingListEntity>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        allList!.addAll(list.map((item) => item.toJson()).toList());
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+      }
+    } else {
+      if (_page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if(state.list!.length == 0){
+          changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishLoad();
+        }else {
+          if(_needShowPlaceholder){
+            changeLoadingState(LoadState.State_Success, null);
+          }
+        }
+        //更新展示的状态
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
+    }
+  }
 
+  // 更新 my_posts_tabs 里面的数字
+  updateMyFollowingTabsNum(String key, int num, int activeTabIdx){
     WidgetsBinding.instance.addPostFrameCallback((_) {
       // 需要更新 my_posts_tabs 里面的数字
       ref.read(myFollowingVmProvider.notifier)
-          .updateMyFollowingTabsNum( 'followCount', state.list!.length, 0);
+          .updateMyFollowingTabsNum(key, num, activeTabIdx );
     });
   }
 
+  softDeleteItem(int id){
+    state.list!.removeWhere((element) => element['id'] == id);
+    state = state.copyWith(list: state.list);
+    // 更新 my_posts_tabs 里面的数字
+    updateMyFollowingTabsNum(tabsNamesData['Follow'], state.list!.length, 0);
+  }
+
   handlerSearchChange(String value){}
 
   handlerSubmitSearch(String value){}

+ 1 - 1
packages/cpt_community/lib/modules/my_following/my_follow/my_follow_vm.g.dart

@@ -6,7 +6,7 @@ part of 'my_follow_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$myFollowVmHash() => r'ad3b17b9dadc3d2164fa56eda2596c2366f9a8f5';
+String _$myFollowVmHash() => r'740c4ae662c2edcebd62426a0fb7fe39804d31f8';
 
 /// See also [MyFollowVm].
 @ProviderFor(MyFollowVm)

+ 2 - 1
packages/cpt_community/lib/modules/my_following/my_follower/my_follower_page.dart

@@ -19,6 +19,7 @@ import 'package:widgets/widget_export.dart';
 
 import '../../../router/page/community_page_router.dart';
 import '../components/item_following.dart';
+import '../components/item_following_vm.dart';
 import 'my_follower_vm.dart';
 
 @RoutePage()
@@ -157,7 +158,7 @@ class MyFollowerPage extends HookConsumerWidget {
     bool isLast = index == totalIndex - 1;
     return MyFollowingListItem(
         itemObj: item,
-        itemType: MyFollowingType.isFollowerType,
+        itemType: MyFollowingType['isFollowerType'],
         hasBottomDriver: isLast? false : true,
         onClickAction:(itemObj){
           print("点击了  ${itemObj['name']}");

+ 0 - 6
packages/cpt_community/lib/modules/my_following/my_follower/my_follower_state.dart

@@ -13,9 +13,6 @@ class MyFollowerState {
   MyFollowerState({
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     required this.list,
   });
 
@@ -30,9 +27,6 @@ class MyFollowerState {
     return MyFollowerState(
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       list: list ?? this.list,
     );
   }

+ 94 - 74
packages/cpt_community/lib/modules/my_following/my_follower/my_follower_vm.dart

@@ -1,5 +1,6 @@
 import 'package:cpt_community/modules/my_following/my_following_vm.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/myfollowing_list_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -7,13 +8,18 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
+import '../../../respository/common_newsfeed.dart';
+import '../tabs_data.dart';
 import 'my_follower_state.dart';
 
 part 'my_follower_vm.g.dart';
 
 @riverpod
 class MyFollowerVm extends _$MyFollowerVm {
-
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
   bool _needShowPlaceholder = false; //是否展示LoadingView
 
   // Refresh 控制器
@@ -30,6 +36,8 @@ class MyFollowerVm extends _$MyFollowerVm {
 
   @override
   MyFollowerState build(){
+    // 引入数据仓库
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -57,17 +65,7 @@ class MyFollowerVm extends _$MyFollowerVm {
   // 上拉加载 更多
   Future loadMore() async {
     Log.d("----for_sale_vm-----loadMore");
-    // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.count){
-    //   return;
-    // }else {
-    //   int page = state.page + 1;
-    //   state = state.copyWith(page: page,);
-    //   getListData();
-    // }
-    // 检查 page 是否为 null,并初始化为 1
-    int newCurPage = state.page ?? 1;
-    state = state.copyWith(page: ++newCurPage);
+    _page++;
     getListData();
   }
 
@@ -75,15 +73,13 @@ class MyFollowerVm extends _$MyFollowerVm {
   // 下拉刷新
   Future onRefresh() async {
     Log.d("----forsale_vm-----onRefresh ");
-
-    // await Future.delayed(const Duration(seconds: 2));
-    state = state.copyWith(page: 1);
+    _page = 1;
     getListData();
   }
 
   // 重试请求
   Future retryRequest() async {
-    state = state.copyWith(page: 1);
+    _page = 1;
     _needShowPlaceholder = true;
     getListData();
   }
@@ -95,71 +91,95 @@ class MyFollowerVm extends _$MyFollowerVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_sale加载listData数据---------------start--${state.page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-    //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
-    //     Log.d("请求完成结果------${result.data}");
-    //     //校验成功失败
-    //     if (result.isSuccess) {
-    //       // state = state.copyWith(serverTime: result.data);
-    //       state = state;
-    //   handleList(listResult.data?.rows);
-    //       ToastEngine.show("获取数据成功");
-    //     } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    //       ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //     }
-    //   } catch (e) {
-    //     ToastEngine.show("Error: $e");
-    //   }
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-    final List<Map<String, dynamic>> listData = [
-      {
-        'id':1,
-        'avator': 'https://iknow-pic.cdn.bcebos.com/4afbfbedab64034f6c21389bbdc379310b551dba',
-        'title': 'Steve Jobs',
-        'isFollow': false,
-      },
-      {
-        'id':2,
-        'avator': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'William Jefferson',
-        'isFollow': true,
-      },
-    ];
-
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
-    } else {
-      //加载更多
-      final allList = state.list;
-      allList.addAll(listData);
-      state = state.copyWith(list: allList);
-      refreshController.finishLoad();
-
+    Log.d("for_sale加载listData数据---------------start--${_page}---");
+
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    // final List<Map<String, dynamic>> listData = [
+    //   {
+    //     'id':1,
+    //     'avator': 'https://iknow-pic.cdn.bcebos.com/4afbfbedab64034f6c21389bbdc379310b551dba',
+    //     'title': 'Steve Jobs',
+    //     'isFollow': false,
+    //   },
+    //   {
+    //     'id':2,
+    //     'avator': 'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'William Jefferson',
+    //     'isFollow': true,
+    //   },
+    // ];
+
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "keyword": "",
+        "page": _page,
+        "limit": _limit,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonNewsFeedRespositoryInstance.fetchMyFlowerList(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        handlerResultList(result.list as List<MyfollowingListEntity>);
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
     }
 
-    // 最后赋值
-    _needShowPlaceholder = false;
+    // 更新 my_posts_tabs 里面的数字
+    updateMyFollowingTabsNum(tabsNamesData['Follower'], state.list!.length, 1);
+  }
+
+  void handlerResultList(List<MyfollowingListEntity>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        allList!.addAll(list.map((item) => item.toJson()).toList());
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+      }
+    } else {
+      if (_page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if(state.list!.length == 0){
+          changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishLoad();
+        }else {
+          if(_needShowPlaceholder){
+            changeLoadingState(LoadState.State_Success, null);
+          }
+        }
+        //更新展示的状态
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
+    }
+  }
 
+  // 更新 my_posts_tabs 里面的数字
+  updateMyFollowingTabsNum(String key, int num, int activeTabIdx){
     WidgetsBinding.instance.addPostFrameCallback((_) {
       // 需要更新 my_posts_tabs 里面的数字
       ref.read(myFollowingVmProvider.notifier)
-          .updateMyFollowingTabsNum( 'followerCount', state.list!.length, 1);
+          .updateMyFollowingTabsNum(key, num, activeTabIdx );
     });
-
   }
 
   handlerSearchChange(String value){}

+ 1 - 1
packages/cpt_community/lib/modules/my_following/my_follower/my_follower_vm.g.dart

@@ -6,7 +6,7 @@ part of 'my_follower_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$myFollowerVmHash() => r'94dbe2b359863bd7ea8bc90efc0b273d05aa9613';
+String _$myFollowerVmHash() => r'5587cec27d5bbd560823f5066e743168729f2044';
 
 /// See also [MyFollowerVm].
 @ProviderFor(MyFollowerVm)

+ 4 - 2
packages/cpt_community/lib/modules/my_following/my_following_state.dart

@@ -1,3 +1,5 @@
+import 'package:cpt_community/modules/my_following/tabs_data.dart';
+
 class MyFollowingState {
   List<String>? tabsList;
   int? currentPageViewIdx = 0;
@@ -14,8 +16,8 @@ class MyFollowingState {
     this.followPageIsSearchBarStatus = false,
     this.followerPageIsSearchBarStatus = false,
   }) : tabsList = tabsList ?? [
-    'Follow',
-    'Follower',
+    tabsNamesData['Follow'],
+    tabsNamesData['Follower'],
   ];
 
   MyFollowingState copyWith({

+ 6 - 3
packages/cpt_community/lib/modules/my_following/my_following_vm.dart

@@ -1,3 +1,4 @@
+import 'package:cpt_community/modules/my_following/tabs_data.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
@@ -39,11 +40,13 @@ class MyFollowingVm extends _$MyFollowingVm {
     tabsRouter.setActiveIndex(tabIndex);
   }
 
+  // 设置当前tab
   setCurrentTabIndex(int activeTabIdx){
     state = state.copyWith(
       activeTabIdx: activeTabIdx,
     );
   }
+
   // 改变 follow 页面navigatorbar
   handlerChangeFollowPageNavbar(bool showSearchBar){
     WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
@@ -73,14 +76,14 @@ class MyFollowingVm extends _$MyFollowingVm {
     });
   }
 
-
+  // 更新 tab 的数字
   updateMyFollowingTabsNum(String code, int num, int activeTabIdx){
-    if(code == 'followerCount'){
+    if(code == tabsNamesData['Follower']){
       state = state.copyWith(
         followerCount: num,
         activeTabIdx: activeTabIdx,
       );
-    } else if(code == 'followCount'){
+    } else if(code == tabsNamesData['Follow']){
       state = state.copyWith(
         followCount: num,
         activeTabIdx: activeTabIdx,

+ 1 - 1
packages/cpt_community/lib/modules/my_following/my_following_vm.g.dart

@@ -6,7 +6,7 @@ part of 'my_following_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$myFollowingVmHash() => r'062ebd721a307fa49519a8aedffa645d04a4ce68';
+String _$myFollowingVmHash() => r'a547759c6d6dbd425d1573adc47494172a707e54';
 
 /// See also [MyFollowingVm].
 @ProviderFor(MyFollowingVm)

+ 4 - 0
packages/cpt_community/lib/modules/my_following/tabs_data.dart

@@ -0,0 +1,4 @@
+Map<String, dynamic> tabsNamesData = {
+  'Follow': 'Follow',
+  'Follower': 'Follower',
+};

+ 59 - 0
packages/cpt_community/lib/modules/my_posts/components/my_posts_sale_rent_item.dart

@@ -0,0 +1,59 @@
+import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:hooks_riverpod/hooks_riverpod.dart';
+import 'package:shared/utils/color_utils.dart';
+import 'package:shared/utils/log_utils.dart';
+
+import '../../../components/garage_card.dart';
+import 'my_posts_sale_rent_item_vm.dart';
+
+class MyPostsSaleRentItem extends HookConsumerWidget {
+  MyPostsSaleRentItem({Key? key, required this.item, required this.garageSaleType}) : super(key: key);
+
+  String garageSaleType = 'forSale';
+  final Map<String, dynamic> item;
+
+  @override
+  Widget build(BuildContext context, WidgetRef ref) {
+    final vm = ref.read(myPostsSaleRentItemVmProvider.notifier);
+    return SizedBox(
+      width: double.infinity,
+      child: Container(
+        decoration: BoxDecoration(
+          color: context.appColors.whiteBG,
+          borderRadius: BorderRadius.circular(8),
+          boxShadow: [
+            BoxShadow(
+              color: ColorUtils.string2Color('#E5E5E5'),
+              offset: const Offset(0, 2),
+              blurRadius: 8,
+            ),
+          ],
+        ),
+        child: Column(
+            mainAxisAlignment: MainAxisAlignment.start,
+            crossAxisAlignment: CrossAxisAlignment.start,
+            mainAxisSize: MainAxisSize.max,
+            children: [
+              Expanded(
+                child: GarageCard(
+                    key: UniqueKey(),
+                    useType: GarageCardUseType.myPostsForRent,
+                    itemObj: item,
+                    onClickColleciotn: (dynamic collectionValue) async {
+                      Log.d("my_posts_sale_rent_item 点击了喜欢按钮  --${item['id']}-$collectionValue");
+                      bool asyncResult = await vm.handlerGarageClickLike(item['id'], collectionValue);
+                      if(asyncResult){
+                        return true;
+                      }else {
+                        return false;
+                      }
+                    }
+                ),
+              ),
+            ]
+        ),
+      ),
+    );
+  }
+}

+ 37 - 0
packages/cpt_community/lib/modules/my_posts/components/my_posts_sale_rent_item_vm.dart

@@ -0,0 +1,37 @@
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:shared/utils/log_utils.dart';
+
+import '../../../respository/common_garage.dart';
+
+part 'my_posts_sale_rent_item_vm.g.dart';
+
+@riverpod
+class MyPostsSaleRentItemVm extends _$MyPostsSaleRentItemVm {
+  late CommonGarageRespository commonGarageRespositoryInstance;
+  @override
+  build(){
+    // 引入数据仓库
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
+    final state = {};
+    Log.d("--------------------------build---------------------");
+
+    return state;
+  }
+
+  Future<bool> handlerGarageClickLike(int garageId, bool isLike) async{
+    // 调用 fetchGarageColleciton
+    try{
+      Map<String, dynamic> params = {
+        "id": garageId,
+      };
+      final result = await commonGarageRespositoryInstance.fetchGarageColleciton(params);
+      if(result.isSuccess){
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      return false;
+    }
+  }
+}

+ 27 - 0
packages/cpt_community/lib/modules/my_posts/components/my_posts_sale_rent_item_vm.g.dart

@@ -0,0 +1,27 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'my_posts_sale_rent_item_vm.dart';
+
+// **************************************************************************
+// RiverpodGenerator
+// **************************************************************************
+
+String _$myPostsSaleRentItemVmHash() =>
+    r'0c2db008cc9f0151beaaa257c259f8a104c4ac09';
+
+/// See also [MyPostsSaleRentItemVm].
+@ProviderFor(MyPostsSaleRentItemVm)
+final myPostsSaleRentItemVmProvider =
+    AutoDisposeNotifierProvider<MyPostsSaleRentItemVm, Object?>.internal(
+  MyPostsSaleRentItemVm.new,
+  name: r'myPostsSaleRentItemVmProvider',
+  debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
+      ? null
+      : _$myPostsSaleRentItemVmHash,
+  dependencies: null,
+  allTransitiveDependencies: null,
+);
+
+typedef _$MyPostsSaleRentItemVm = AutoDisposeNotifier<Object?>;
+// ignore_for_file: type=lint
+// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 4 - 41
packages/cpt_community/lib/modules/my_posts/my_posts_forrent/my_posts_forrent_page.dart

@@ -19,6 +19,7 @@ import 'package:widgets/widget_export.dart';
 import '../../../components/garage_card.dart';
 import '../../../components/newfeed_card_header.dart';
 import '../../../router/page/community_page_router.dart';
+import '../components/my_posts_sale_rent_item.dart';
 import 'my_posts_forrent_vm.dart';
 
 @RoutePage()
@@ -85,9 +86,9 @@ class MyPostsForRentPage extends HookConsumerWidget {
                   ),
                   delegate: SliverChildBuilderDelegate(
                         (context, index) {
-                      return  _buildMyPostsForRentItem(context, ref, state.list[index], vm).onTap((){
-                        vm.handlerGotoDetail(state.list[index]['id']);
-                      });
+                          return MyPostsSaleRentItem(item: state.list[index],garageSaleType: 'forRent').onTap((){
+                            vm.handlerGotoDetail(state.list[index]['id']);
+                          });
                     },
                     childCount: state.list.length,
                   ),
@@ -98,42 +99,4 @@ class MyPostsForRentPage extends HookConsumerWidget {
       ),
     );
   }
-
-  Widget _buildMyPostsForRentItem(BuildContext context, WidgetRef ref, item, vm){
-    return SizedBox(
-      width: double.infinity,
-      child: Container(
-        decoration: BoxDecoration(
-          color: context.appColors.whiteBG,
-          borderRadius: BorderRadius.circular(8),
-          boxShadow: [
-            BoxShadow(
-              color: ColorUtils.string2Color('#E5E5E5'),
-              offset: const Offset(0, 2),
-              blurRadius: 8,
-            ),
-          ],
-        ),
-        child: Column(
-            mainAxisAlignment: MainAxisAlignment.start,
-            crossAxisAlignment: CrossAxisAlignment.start,
-            mainAxisSize: MainAxisSize.max,
-            children: [
-              // 卡片头部(头像 标题 时间)
-              Expanded(
-                child: GarageCard(
-                    key: UniqueKey(),
-                    useType: GarageCardUseType.myPostsForRent,
-                    itemObj: item,
-                    onClickColleciotn: (dynamic collectionValue){
-                      Log.d("点击了收藏按钮  --${item['id']}-$collectionValue");
-                      return true;
-                    }
-                ),
-              ),
-            ]
-        ),
-      ),
-    );
-  }
 }

+ 134 - 117
packages/cpt_community/lib/modules/my_posts/my_posts_forrent/my_posts_forrent_vm.dart

@@ -1,5 +1,6 @@
 import 'package:cpt_community/modules/my_posts/my_posts_vm.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/myposts_sale_rent_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -8,6 +9,7 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
+import '../../../respository/common_garage.dart';
 import '../../../router/page/community_page_router.dart';
 import 'my_posts_forrent_respository.dart';
 import 'my_posts_forrent_state.dart';
@@ -16,8 +18,12 @@ part 'my_posts_forrent_vm.g.dart';
 
 @riverpod
 class MyPostsForRentVm extends _$MyPostsForRentVm {
-  // late MyPostsForRentRepository MyPostsForRentRepositoryInstance;
+  late CommonGarageRespository commonGarageRespositoryInstance;
   bool _needShowPlaceholder = false; //是否展示LoadingView
+  late BuildContext _currentPageContext;
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
 
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
@@ -31,10 +37,14 @@ class MyPostsForRentVm extends _$MyPostsForRentVm {
     );
   }
 
+  setCurrentPageContext(BuildContext context){
+    _currentPageContext = context;
+  }
+
   @override
   MyPostsForRentState build(){
     // 引入数据仓库
-    // MyPostsForRentRepositoryInstance = ref.read(newsRepositoryProvider);
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -59,17 +69,7 @@ class MyPostsForRentVm extends _$MyPostsForRentVm {
   // 上拉加载 更多
   Future loadMore() async {
     Log.d("----for_sale_vm-----loadMore");
-    // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.count){
-    //   return;
-    // }else {
-    //   int page = state.page + 1;
-    //   state = state.copyWith(page: page,);
-    //   getListData();
-    // }
-    // 检查 page 是否为 null,并初始化为 1
-    int newCurPage = state.page ?? 1;
-    state = state.copyWith(page: ++newCurPage);
+    _page++;
     getListData();
   }
 
@@ -77,15 +77,13 @@ class MyPostsForRentVm extends _$MyPostsForRentVm {
   // 下拉刷新
   Future onRefresh() async {
     Log.d("----forrent_vm-----onRefresh ");
-
-    // await Future.delayed(const Duration(seconds: 2));
-    state = state.copyWith(page: 1);
+    _page = 1;
     getListData();
   }
 
   // 重试请求
   Future retryRequest() async {
-    state = state.copyWith(page: 1);
+    _page = 1;
     _needShowPlaceholder = true;
     getListData();
   }
@@ -97,115 +95,134 @@ class MyPostsForRentVm extends _$MyPostsForRentVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_sale加载listData数据---------------start--${state.page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-    //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
-    //     Log.d("请求完成结果------${result.data}");
-    //     //校验成功失败
-    //     if (result.isSuccess) {
-    //       // state = state.copyWith(serverTime: result.data);
-    //       state = state;
-    //   handleList(listResult.data?.rows);
-    //       ToastEngine.show("获取数据成功");
-    //     } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    //       ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //     }
-    //   } catch (e) {
-    //     ToastEngine.show("Error: $e");
-    //   }
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-    final List<Map<String, dynamic>> listData = [
-      {
-        'id':1,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':2,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':3,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-    ];
-
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
-    } else {
-      //加载更多
-      final allList = state.list;
-      allList.addAll(listData);
-      state = state.copyWith(list: allList,);
-      refreshController.finishLoad();
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    // final List<Map<String, dynamic>> listData = [
+    //   {
+    //     'id':1,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':2,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':3,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    // ];
+    //
+    // if (_page == 1) {
+    //   //刷新的方式
+    //   state = state.copyWith(list: listData);
+    //   refreshController.finishRefresh();
+    //   // //更新展示的状态
+    //   changeLoadingState(LoadState.State_Success, null);
+    // } else {
+    //   //加载更多
+    //   final allList = state.list;
+    //   allList.addAll(listData);
+    //   state = state.copyWith(list: allList,);
+    //   refreshController.finishLoad();
+    // }
+
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "type": 2,  // 类型(1=Sale,2=Rent)
+        "page": _page,
+        "limit": _limit,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonGarageRespositoryInstance.fetchMyPostsGarageDataList(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        handlerResultList((result.list as List<MypostsSaleRentEntity>));
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
     }
 
-    WidgetsBinding.instance.addPostFrameCallback((_) {
-      // 需要更新 my_posts_tabs 里面的数字
-      ref.read(myPostsVmProvider.notifier).updateMyPostsTabsNum( 'forRent', state.list.length, 2);
-    });
+    // 需要更新 my_posts_tabs 里面的数字
+    updateMyFollowingTabsNum('forRent', state.list.length, 2);
 
-    // 最后赋值
-    _needShowPlaceholder = false;
   }
 
-
-  // 点击 like comments  share
-  void handlerClickActionBtn(String? actionStr, item){
-    final id = item['id'];
-    switch (actionStr) {
-      case 'like':
-        Log.d("点击了 点赞");
-        handlerGotoDetail(id);
-        break;
-      case 'comments':
-        Log.d("点击了 评论");
-        handlerGotoDetail(id);
-        break;
-      case 'share':
-        Log.d("点击了 分享");
-        handlerGotoDetail(id);
-        break;
-      default:
-        break;
+  void handlerResultList(List<MypostsSaleRentEntity>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
+
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+      }
+    } else {
+      if (_page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if(state.list!.length == 0){
+          changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishLoad();
+        }else {
+          if(_needShowPlaceholder){
+            changeLoadingState(LoadState.State_Success, null);
+          }
+        }
+        //更新展示的状态
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
     }
   }
+
+
+  // 更新 my_posts_tabs 里面的数字
+  updateMyFollowingTabsNum(String key, int num, int activeTabIdx){
+    WidgetsBinding.instance.addPostFrameCallback((_) {
+      // 需要更新 my_posts_tabs 里面的数字
+      ref.read(myPostsVmProvider.notifier)
+          .updateMyPostsTabsNum(key, num, activeTabIdx );
+    });
+  }
   // 去详情页面
   void handlerGotoDetail(id){
     Log.d("去详情页面");
-    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forrent'));
+    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forRent'));
   }
 }

+ 1 - 1
packages/cpt_community/lib/modules/my_posts/my_posts_forrent/my_posts_forrent_vm.g.dart

@@ -6,7 +6,7 @@ part of 'my_posts_forrent_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$myPostsForRentVmHash() => r'ee3f8fee8a2c0b11102959d0c9800622a8957b75';
+String _$myPostsForRentVmHash() => r'272c5370f64f4ecc7ca4544a3ee819518b62b06e';
 
 /// See also [MyPostsForRentVm].
 @ProviderFor(MyPostsForRentVm)

+ 3 - 40
packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_page.dart

@@ -19,6 +19,7 @@ import 'package:widgets/widget_export.dart';
 import '../../../components/garage_card.dart';
 import '../../../components/newfeed_card_header.dart';
 import '../../../router/page/community_page_router.dart';
+import '../components/my_posts_sale_rent_item.dart';
 import 'my_posts_forsale_vm.dart';
 
 @RoutePage()
@@ -86,8 +87,8 @@ class MyPostsForSalePage extends HookConsumerWidget {
                   ),
                   delegate: SliverChildBuilderDelegate(
                         (context, index) {
-                      return  _buildMyPostsForSaleItem(context, ref, state.list[index], vm).onTap((){
-                        vm.handlerGotoDetail(state.list[index]['id']);
+                      return MyPostsSaleRentItem(item: state.list[index], garageSaleType: 'forSale').onTap((){
+                        vm.handlerGotoDetail(state.list[index]['id'], );
                       });
                     },
                     childCount: state.list.length,
@@ -99,42 +100,4 @@ class MyPostsForSalePage extends HookConsumerWidget {
       ),
     );
   }
-
-  Widget _buildMyPostsForSaleItem(BuildContext context, WidgetRef ref, item, vm){
-    return SizedBox(
-      width: double.infinity,
-      child: Container(
-        decoration: BoxDecoration(
-          color: context.appColors.whiteBG,
-          borderRadius: BorderRadius.circular(8),
-          boxShadow: [
-            BoxShadow(
-              color: ColorUtils.string2Color('#E5E5E5'),
-              offset: const Offset(0, 2),
-              blurRadius: 8,
-            ),
-          ],
-        ),
-        child: Column(
-            mainAxisAlignment: MainAxisAlignment.start,
-            crossAxisAlignment: CrossAxisAlignment.start,
-            mainAxisSize: MainAxisSize.max,
-            children: [
-              // 卡片头部(头像 标题 时间)
-              Expanded(
-                child: GarageCard(
-                    key: UniqueKey(),
-                    useType: GarageCardUseType.myPostsForSale,
-                    itemObj: item,
-                    onClickColleciotn: (dynamic collectionValue){
-                      Log.d("点击了收藏按钮  --${item['id']}-$collectionValue");
-                      return true;
-                    }
-                ),
-              ),
-            ]
-        ),
-      ),
-    );
-  }
 }

+ 0 - 18
packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_state.dart

@@ -6,9 +6,6 @@ class MyPostsForSaleState {
   LoadState loadingState;
   String? errorMessage;
 
-  int? page;
-  int? limit = 10;
-  int? count = 0;
   List<Map<String, dynamic>> list;
 
   List<String>? tabsList = ['For Sale', 'For Rent'];
@@ -17,9 +14,6 @@ class MyPostsForSaleState {
     this.activeTabIndex,
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
-    this.page = 1,
-    this.limit = 10,
-    this.count = 0,
     required this.list,
     this.tabsList,
   });
@@ -28,9 +22,6 @@ class MyPostsForSaleState {
     int? activeTabIndex,
     LoadState? loadingState,
     String? errorMessage,
-    int? page,
-    int? limit,
-    int? count,
     List<Map<String, dynamic>>? list,
     List<String>? tabsList,
   }) {
@@ -38,9 +29,6 @@ class MyPostsForSaleState {
       activeTabIndex: activeTabIndex ?? this.activeTabIndex,
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       tabsList: tabsList ?? this.tabsList,
       list: list ?? this.list,
     );
@@ -51,9 +39,6 @@ class MyPostsForSaleState {
       'activeTabIndex': this.activeTabIndex,
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'list': this.list,
       'tabsList': this.tabsList,
     };
@@ -64,9 +49,6 @@ class MyPostsForSaleState {
       activeTabIndex: map['activeTabIndex'] as int,
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       list: map['list'] as List<Map<String, dynamic>>,
       tabsList: map['tabsList'] as List<String>,
     );

+ 166 - 149
packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_vm.dart

@@ -1,5 +1,7 @@
 import 'package:cpt_community/modules/my_posts/my_posts_vm.dart';
+import 'package:cpt_community/respository/common_garage.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/myposts_sale_rent_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -17,8 +19,11 @@ part 'my_posts_forsale_vm.g.dart';
 
 @riverpod
 class MyPostsForSaleVm extends _$MyPostsForSaleVm {
-  // late MyPostsForSaleRepository MyPostsForSaleRepositoryInstance;
+  late CommonGarageRespository commonGarageRespositoryInstance;
   late BuildContext _currentPageContext;
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
 
   bool _needShowPlaceholder = false; //是否展示LoadingView
 
@@ -37,7 +42,7 @@ class MyPostsForSaleVm extends _$MyPostsForSaleVm {
   @override
   MyPostsForSaleState build(){
     // 引入数据仓库
-    // MyPostsForSaleRepositoryInstance = ref.read(newsRepositoryProvider);
+    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -65,17 +70,7 @@ class MyPostsForSaleVm extends _$MyPostsForSaleVm {
   // 上拉加载 更多
   Future loadMore() async {
     Log.d("----for_sale_vm-----loadMore");
-    // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.count){
-    //   return;
-    // }else {
-    //   int page = state.page + 1;
-    //   state = state.copyWith(page: page,);
-    //   getListData();
-    // }
-    // 检查 page 是否为 null,并初始化为 1
-    int newCurPage = state.page ?? 1;
-    state = state.copyWith(page: ++newCurPage);
+    _page++;
     getListData();
   }
 
@@ -84,14 +79,13 @@ class MyPostsForSaleVm extends _$MyPostsForSaleVm {
   Future onRefresh() async {
     Log.d("----forsale_vm-----onRefresh ");
 
-    // await Future.delayed(const Duration(seconds: 2));
-    state = state.copyWith(page: 1);
+    _page = 1;
     getListData();
   }
 
   // 重试请求
   Future retryRequest() async {
-    state = state.copyWith(page: 1);
+    _page = 1;
     _needShowPlaceholder = true;
     getListData();
   }
@@ -103,150 +97,173 @@ class MyPostsForSaleVm extends _$MyPostsForSaleVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_sale加载listData数据---------------start--${state.page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-    //     final result = await propertyNewsRepository.fetchPropertyNewsList(params);
-    //     Log.d("请求完成结果------${result.data}");
-    //     //校验成功失败
-    //     if (result.isSuccess) {
-    //       // state = state.copyWith(serverTime: result.data);
-    //       state = state;
-    //   handleList(listResult.data?.rows);
-    //       ToastEngine.show("获取数据成功");
-    //     } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    //       ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    //     }
-    //   } catch (e) {
-    //     ToastEngine.show("Error: $e");
-    //   }
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-    final List<Map<String, dynamic>> listData = [
-      {
-        'id':1,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':2,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':3,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':4,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':5,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$66',
-        'isCollection': true,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-      {
-        'id':6,
-        'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
-        'title': 'Electronic keyboard',
-        'price': '\$88',
-        'isCollection': false,
-        'collection_num': 12,
-        'publisher': 'William Jefferson',
-        'publish_time': 'June 17,2016 at 7:23 p.m.',
-        'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
-      },
-    ];
-
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
-    } else {
-      //加载更多
-      final allList = state.list;
-      allList.addAll(listData);
-      state = state.copyWith(list: allList,);
-      refreshController.finishLoad();
+
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    // final List<Map<String, dynamic>> listData = [
+    //   {
+    //     'id':1,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':2,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':3,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':4,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':5,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$66',
+    //     'isCollection': true,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    //   {
+    //     'id':6,
+    //     'goods_img':  'https://img2.baidu.com/it/u=3489233687,2364672159&fm=253&fmt=auto&app=120&f=JPEG?w=507&h=500',
+    //     'title': 'Electronic keyboard',
+    //     'price': '\$88',
+    //     'isCollection': false,
+    //     'collection_num': 12,
+    //     'publisher': 'William Jefferson',
+    //     'publish_time': 'June 17,2016 at 7:23 p.m.',
+    //     'publisher_avator': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500'
+    //   },
+    // ];
+    //
+    // if (_page == 1) {
+    //   //刷新的方式
+    //   state = state.copyWith(list: listData);
+    //   refreshController.finishRefresh();
+    //   // //更新展示的状态
+    //   changeLoadingState(LoadState.State_Success, null);
+    // } else {
+    //   //加载更多
+    //   final allList = state.list;
+    //   allList.addAll(listData);
+    //   state = state.copyWith(list: allList,);
+    //   refreshController.finishLoad();
+    // }
+    // // 最后赋值
+    // _needShowPlaceholder = false;
+
+    try {
+      //请求网络
+      Map<String, dynamic>  params = {
+        "type": 1,  // 类型(1=Sale,2=Rent)
+        "page": _page,
+        "limit": _limit,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonGarageRespositoryInstance.fetchMyPostsGarageDataList(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        handlerResultList((result.list as List<MypostsSaleRentEntity>));
+      } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
+        ToastEngine.show(result.errorMsg ?? "Network Load Error");
+      }
+    } catch (e) {
+      ToastEngine.show("Error: $e");
     }
 
 
-    WidgetsBinding.instance.addPostFrameCallback((_) {
-        // 需要更新 my_posts_tabs 里面的数字
-      ref.read(myPostsVmProvider.notifier)
-          .updateMyPostsTabsNum( 'forSale', state.list.length, 1);
-    });
+    // 需要更新 my_posts_tabs 里面的数字
+    updateMyFollowingTabsNum('forSale', state.list.length, 1);
 
-    // 最后赋值
-    _needShowPlaceholder = false;
   }
 
 
-  // 点击 like comments  share
-  void handlerClickActionBtn(String? actionStr, item){
-    final id = item['id'];
-    switch (actionStr) {
-      case 'like':
-        Log.d("点击了 点赞");
-        handlerGotoDetail(id);
-        break;
-      case 'comments':
-        Log.d("点击了 评论");
-        handlerGotoDetail(id);
-        break;
-      case 'share':
-        Log.d("点击了 分享");
-        handlerGotoDetail(id);
-        break;
-      default:
-        break;
+  void handlerResultList(List<MypostsSaleRentEntity>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
+
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+      }
+    } else {
+      if (_page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if(state.list!.length == 0){
+          changeLoadingState(LoadState.State_Empty, null);
+          refreshController.finishLoad();
+        }else {
+          if(_needShowPlaceholder){
+            changeLoadingState(LoadState.State_Success, null);
+          }
+        }
+        //更新展示的状态
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
     }
   }
+
+
+  // 更新 my_posts_tabs 里面的数字
+  updateMyFollowingTabsNum(String key, int num, int activeTabIdx){
+    WidgetsBinding.instance.addPostFrameCallback((_) {
+      // 需要更新 my_posts_tabs 里面的数字
+      ref.read(myPostsVmProvider.notifier)
+          .updateMyPostsTabsNum(key, num, activeTabIdx );
+    });
+  }
+
   // 去详情页面
   void handlerGotoDetail(id){
     Log.d("去详情页面");
-    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forsale'));
+    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forSale'));
   }
 }

+ 1 - 1
packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_vm.g.dart

@@ -6,7 +6,7 @@ part of 'my_posts_forsale_vm.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$myPostsForSaleVmHash() => r'e5d86704c4d68a8ba887e740bd37ffa1ff816b6a';
+String _$myPostsForSaleVmHash() => r'd2200e3a70ccfc082e46550e378d2df9ea437296';
 
 /// See also [MyPostsForSaleVm].
 @ProviderFor(MyPostsForSaleVm)

+ 259 - 0
packages/cpt_community/lib/respository/common_garage.dart

@@ -0,0 +1,259 @@
+import 'package:domain/constants/api_constants.dart';
+import 'package:domain/entity/garage_sale_rent_detail_entity.dart';
+import 'package:domain/entity/garage_sale_rent_entity.dart';
+import 'package:domain/entity/myposts_sale_rent_entity.dart';
+import 'package:domain/entity/newsfeed_foryou_entity.dart';
+import 'package:domain/entity/newsfeed_news_entity.dart';
+import 'package:domain/entity/server_time.dart';
+import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:plugin_platform/platform_export.dart';
+import 'package:plugin_platform/http/dio_engine.dart';
+import 'package:plugin_platform/http/http_result.dart';
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:shared/utils/log_utils.dart';
+import 'package:shared/utils/util.dart';
+
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:plugin_basic/provider/http_provider/http_provider.dart';
+
+
+part 'common_garage.g.dart';
+
+@Riverpod(keepAlive: true)
+CommonGarageRespository commonGarageRespository(Ref ref) {
+  final dioEngine = ref.watch(dioEngineProvider);
+  return CommonGarageRespository(dioEngine: dioEngine);
+}
+
+/*
+ * 数据仓库
+ */
+class CommonGarageRespository {
+  DioEngine dioEngine;
+
+  CommonGarageRespository({required this.dioEngine});
+
+  // garage 获取 分类 字典
+  Future<HttpResult<Object>> fetchGarageCateGoryList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/garage-sale/category/index', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: json);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // garage 获取 列表
+  Future<HttpResult<Object>> fetchGarageDataList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/garage-sale/index/type', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getListJson();
+      List<GarageSaleRentEntity> data = json?.map((item) => GarageSaleRentEntity.fromJson(item)).toList() ?? [];
+      //重新赋值data或list
+      return result.convert(list: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // myposts 中 garage 获取 列表
+  Future<HttpResult<Object>> fetchMyPostsGarageDataList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/me/post/garage-sale', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getListJson();
+      List<MypostsSaleRentEntity> data = json?.map((item) => MypostsSaleRentEntity.fromJson(item)).toList() ?? [];
+      //重新赋值data或list
+      return result.convert(list: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+
+  // garage 点赞/取消点赞
+  Future<HttpResult<Object>> fetchGarageColleciton(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/garage-sale/like/click', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataDynamic();
+      // var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: json);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+
+  // 发布 garage
+  Future<HttpResult<Object>> fetchPublishGarage(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/garage-sale/index/publish', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: json);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 获取 详情信息
+  Future<HttpResult<Object>> fetchGarageDetailInfo(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/garage-sale/index/detail', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      var data = GarageSaleRentDetailEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+
+}

+ 11 - 11
packages/cpt_community/lib/respository/newsfeed_news_repository.g.dart

@@ -1,29 +1,29 @@
 // GENERATED CODE - DO NOT MODIFY BY HAND
 
-part of 'newsfeed_news_repository.dart';
+part of 'common_garage.dart';
 
 // **************************************************************************
 // RiverpodGenerator
 // **************************************************************************
 
-String _$newsFeedNewsRepositoryHash() =>
-    r'97db5621bdc5be4656b3347b7f32fde23584c0a0';
+String _$commonGarageRespositoryHash() =>
+    r'116b7b036198559326ab4561acbca6d657a261ab';
 
-/// See also [newsFeedNewsRepository].
-@ProviderFor(newsFeedNewsRepository)
-final newsFeedNewsRepositoryProvider =
-    Provider<NewsFeedNewsRepository>.internal(
-  newsFeedNewsRepository,
-  name: r'newsFeedNewsRepositoryProvider',
+/// See also [commonGarageRespository].
+@ProviderFor(commonGarageRespository)
+final commonGarageRespositoryProvider =
+    Provider<CommonGarageRespository>.internal(
+  commonGarageRespository,
+  name: r'commonGarageRespositoryProvider',
   debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
       ? null
-      : _$newsFeedNewsRepositoryHash,
+      : _$commonGarageRespositoryHash,
   dependencies: null,
   allTransitiveDependencies: null,
 );
 
 @Deprecated('Will be removed in 3.0. Use Ref instead')
 // ignore: unused_element
-typedef NewsFeedNewsRepositoryRef = ProviderRef<NewsFeedNewsRepository>;
+typedef CommonGarageRespositoryRef = ProviderRef<CommonGarageRespository>;
 // ignore_for_file: type=lint
 // ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 478 - 0
packages/cpt_community/lib/respository/common_newsfeed.dart

@@ -0,0 +1,478 @@
+import 'package:domain/constants/api_constants.dart';
+import 'package:domain/entity/myfollowing_list_entity.dart';
+import 'package:domain/entity/newsfeed_comment_publish_entity.dart';
+import 'package:domain/entity/newsfeed_detail_entity.dart';
+import 'package:domain/entity/newsfeed_following_entity.dart';
+import 'package:domain/entity/newsfeed_foryou_entity.dart';
+import 'package:domain/entity/newsfeed_news_entity.dart';
+import 'package:domain/entity/server_time.dart';
+import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:plugin_platform/platform_export.dart';
+import 'package:plugin_platform/http/dio_engine.dart';
+import 'package:plugin_platform/http/http_result.dart';
+import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:shared/utils/log_utils.dart';
+import 'package:shared/utils/util.dart';
+
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:plugin_basic/provider/http_provider/http_provider.dart';
+
+
+part 'common_newsfeed.g.dart';
+
+@Riverpod(keepAlive: true)
+CommonNewsFeedRespository commonNewsFeedRespository(Ref ref) {
+  final dioEngine = ref.watch(dioEngineProvider);
+  return CommonNewsFeedRespository(dioEngine: dioEngine);
+}
+
+/*
+ * 数据仓库
+ */
+class CommonNewsFeedRespository {
+  DioEngine dioEngine;
+
+  CommonNewsFeedRespository({required this.dioEngine});
+
+  // news feed - news 列表
+  Future<HttpResult<Object>> fetchNewsList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/news-feed/feed/news', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      var data = NewsfeedNewsEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // news feed - following 列表
+  Future<HttpResult<Object>> fetchFollowingList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/news-feed/feed/following', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      var data = NewsfeedFollowingEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // news feed - foryou 列表
+  Future<HttpResult<Object>> fetchForyouList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/news-feed/feed/for-you', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 获取 详情信息
+  Future<HttpResult<Object>> fetchNewsFeedDetailInfo(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/news-feed/feed/detail', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      var data = NewsfeedDetailEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 提交评论
+  Future<HttpResult<Object>> fetchNewsfeedCommentSubmit(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/news-feed/comment/publish', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      var data = NewsfeedCommentPublishEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // news feed - post 发布newsfeed
+  Future<HttpResult<Object>> fetchNewsfeedPublish(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/news-feed/index/publish', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedCommentPublishEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: json);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+
+  // 获取 我关注的人
+  Future<HttpResult<Object>> fetchMyFollowList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/me/index/follows', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final ListJson = result.getListJson();
+      var data = ListJson!.map((e) => MyfollowingListEntity.fromJson(e!)).toList();
+      //重新赋值data或list
+      return result.convert(list: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 获取 关注我的人
+  Future<HttpResult<Object>> fetchMyFlowerList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/me/index/flowers', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final ListJson = result.getListJson();
+      var data = ListJson!.map((e) => MyfollowingListEntity.fromJson(e!)).toList();
+      //重新赋值data或list
+      return result.convert(list: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // news feed 点赞/取消点赞
+  Future<HttpResult<Object>> fetchLikeClick(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/news-feed/like/click', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final boolData = result.getDataDynamic();
+      // var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: boolData);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 关注/取消关注
+  Future<HttpResult<Object>> handlerFollowOrCancel(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/me/index/follow', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: json);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 获取 我发布的newsfeed
+  Future<HttpResult<Object>> fetchMyPostNewsfeedList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/me/post/news-feed', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedDetailEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 获取 我发布的 garage
+  Future<HttpResult<Object>> fetchMyPostGarageList(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/me/post/garage-sale', // api 地址
+      params: params,
+      headers: headers,
+      method: HttpMethod.GET,
+      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedDetailEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: data);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+}

+ 29 - 0
packages/cpt_community/lib/respository/common_newsfeed.g.dart

@@ -0,0 +1,29 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'common_newsfeed.dart';
+
+// **************************************************************************
+// RiverpodGenerator
+// **************************************************************************
+
+String _$commonNewsFeedRespositoryHash() =>
+    r'c21dbbacfe42a102f5addcb11433a2398e7301d4';
+
+/// See also [commonNewsFeedRespository].
+@ProviderFor(commonNewsFeedRespository)
+final commonNewsFeedRespositoryProvider =
+    Provider<CommonNewsFeedRespository>.internal(
+  commonNewsFeedRespository,
+  name: r'commonNewsFeedRespositoryProvider',
+  debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
+      ? null
+      : _$commonNewsFeedRespositoryHash,
+  dependencies: null,
+  allTransitiveDependencies: null,
+);
+
+@Deprecated('Will be removed in 3.0. Use Ref instead')
+// ignore: unused_element
+typedef CommonNewsFeedRespositoryRef = ProviderRef<CommonNewsFeedRespository>;
+// ignore_for_file: type=lint
+// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 0 - 65
packages/cpt_community/lib/respository/newsfeed_comment_repository.dart

@@ -1,65 +0,0 @@
-import 'package:domain/constants/api_constants.dart';
-import 'package:domain/entity/newsfeed_comment_publish_entity.dart';
-import 'package:domain/entity/newsfeed_news_entity.dart';
-import 'package:domain/entity/server_time.dart';
-import 'package:plugin_platform/platform_export.dart';
-import 'package:plugin_platform/http/dio_engine.dart';
-import 'package:plugin_platform/http/http_result.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:shared/utils/util.dart';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:plugin_basic/provider/http_provider/http_provider.dart';
-
-
-part 'newsfeed_comment_repository.g.dart';
-
-@Riverpod(keepAlive: true)
-NewsFeedCommentRepository newsFeedCommentRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
-  return NewsFeedCommentRepository(dioEngine: dioEngine);
-}
-
-/*
- * 数据仓库
- */
-class NewsFeedCommentRepository {
-  DioEngine dioEngine;
-
-  NewsFeedCommentRepository({required this.dioEngine});
-  
-  // news feed -news 点赞/取消点赞
-  Future<HttpResult<Object>> fetchNewsfeedCommentSubmit(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/comment/publish', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.POST,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = NewsfeedCommentPublishEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: data);
-    }
-    return result.convert();
-  }
-
-  
-}

+ 0 - 29
packages/cpt_community/lib/respository/newsfeed_comment_repository.g.dart

@@ -1,29 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of 'newsfeed_comment_repository.dart';
-
-// **************************************************************************
-// RiverpodGenerator
-// **************************************************************************
-
-String _$newsFeedCommentRepositoryHash() =>
-    r'd4e82743b8c627b06d404d2a3218fe8980ae505b';
-
-/// See also [newsFeedCommentRepository].
-@ProviderFor(newsFeedCommentRepository)
-final newsFeedCommentRepositoryProvider =
-    Provider<NewsFeedCommentRepository>.internal(
-  newsFeedCommentRepository,
-  name: r'newsFeedCommentRepositoryProvider',
-  debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
-      ? null
-      : _$newsFeedCommentRepositoryHash,
-  dependencies: null,
-  allTransitiveDependencies: null,
-);
-
-@Deprecated('Will be removed in 3.0. Use Ref instead')
-// ignore: unused_element
-typedef NewsFeedCommentRepositoryRef = ProviderRef<NewsFeedCommentRepository>;
-// ignore_for_file: type=lint
-// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 0 - 99
packages/cpt_community/lib/respository/newsfeed_following_repository.dart

@@ -1,99 +0,0 @@
-import 'package:domain/constants/api_constants.dart';
-import 'package:domain/entity/newsfeed_following_entity.dart';
-import 'package:domain/entity/newsfeed_news_entity.dart';
-import 'package:domain/entity/server_time.dart';
-import 'package:plugin_platform/platform_export.dart';
-import 'package:plugin_platform/http/dio_engine.dart';
-import 'package:plugin_platform/http/http_result.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:shared/utils/util.dart';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:plugin_basic/provider/http_provider/http_provider.dart';
-
-
-part 'newsfeed_following_repository.g.dart';
-
-@Riverpod(keepAlive: true)
-NewsFeedFollowingRepository newsFeedFollowingRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
-  return NewsFeedFollowingRepository(dioEngine: dioEngine);
-}
-
-/*
- * 数据仓库
- */
-class NewsFeedFollowingRepository {
-  DioEngine dioEngine;
-
-  NewsFeedFollowingRepository({required this.dioEngine});
-
-  // news feed - news 列表
-  Future<HttpResult<Object>> fetchFollowingList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/feed/following', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.GET,
-      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = NewsfeedFollowingEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: data);
-    }
-    return result.convert();
-  }
-
-  // news feed -news 点赞/取消点赞
-  Future<HttpResult<Object>> fetchLikeClick(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/like/click', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.POST,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final boolData = result.getDataDynamic();
-      // var data = NewsfeedFollowingEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: boolData);
-    }
-    return result.convert();
-  }
-
-
-
-}

+ 0 - 30
packages/cpt_community/lib/respository/newsfeed_following_repository.g.dart

@@ -1,30 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of 'newsfeed_following_repository.dart';
-
-// **************************************************************************
-// RiverpodGenerator
-// **************************************************************************
-
-String _$newsFeedFollowingRepositoryHash() =>
-    r'5104ae97a6afb5f318af1a102e5ed3c8f85523d2';
-
-/// See also [newsFeedFollowingRepository].
-@ProviderFor(newsFeedFollowingRepository)
-final newsFeedFollowingRepositoryProvider =
-    Provider<NewsFeedFollowingRepository>.internal(
-  newsFeedFollowingRepository,
-  name: r'newsFeedFollowingRepositoryProvider',
-  debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
-      ? null
-      : _$newsFeedFollowingRepositoryHash,
-  dependencies: null,
-  allTransitiveDependencies: null,
-);
-
-@Deprecated('Will be removed in 3.0. Use Ref instead')
-// ignore: unused_element
-typedef NewsFeedFollowingRepositoryRef
-    = ProviderRef<NewsFeedFollowingRepository>;
-// ignore_for_file: type=lint
-// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 0 - 99
packages/cpt_community/lib/respository/newsfeed_foryou_repository.dart

@@ -1,99 +0,0 @@
-import 'package:domain/constants/api_constants.dart';
-import 'package:domain/entity/newsfeed_foryou_entity.dart';
-import 'package:domain/entity/newsfeed_news_entity.dart';
-import 'package:domain/entity/server_time.dart';
-import 'package:plugin_platform/platform_export.dart';
-import 'package:plugin_platform/http/dio_engine.dart';
-import 'package:plugin_platform/http/http_result.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:shared/utils/util.dart';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:plugin_basic/provider/http_provider/http_provider.dart';
-
-
-part 'newsfeed_foryou_repository.g.dart';
-
-@Riverpod(keepAlive: true)
-NewsFeedForyouRepository newsFeedForyouRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
-  return NewsFeedForyouRepository(dioEngine: dioEngine);
-}
-
-/*
- * 数据仓库
- */
-class NewsFeedForyouRepository {
-  DioEngine dioEngine;
-
-  NewsFeedForyouRepository({required this.dioEngine});
-
-  // news feed - news 列表
-  Future<HttpResult<Object>> fetchForyouList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/feed/for-you', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.GET,
-      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = NewsfeedForyouEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: data);
-    }
-    return result.convert();
-  }
-
-  // news feed -news 点赞/取消点赞
-  Future<HttpResult<Object>> fetchLikeClick(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/like/click', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.POST,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final boolData = result.getDataDynamic();
-      // var data = NewsfeedForyouEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: boolData);
-    }
-    return result.convert();
-  }
-
-
-
-}

+ 0 - 29
packages/cpt_community/lib/respository/newsfeed_foryou_repository.g.dart

@@ -1,29 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of 'newsfeed_foryou_repository.dart';
-
-// **************************************************************************
-// RiverpodGenerator
-// **************************************************************************
-
-String _$newsFeedForyouRepositoryHash() =>
-    r'71ac847dc2c3d53094e7198d1c329a011b3ae8aa';
-
-/// See also [newsFeedForyouRepository].
-@ProviderFor(newsFeedForyouRepository)
-final newsFeedForyouRepositoryProvider =
-    Provider<NewsFeedForyouRepository>.internal(
-  newsFeedForyouRepository,
-  name: r'newsFeedForyouRepositoryProvider',
-  debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
-      ? null
-      : _$newsFeedForyouRepositoryHash,
-  dependencies: null,
-  allTransitiveDependencies: null,
-);
-
-@Deprecated('Will be removed in 3.0. Use Ref instead')
-// ignore: unused_element
-typedef NewsFeedForyouRepositoryRef = ProviderRef<NewsFeedForyouRepository>;
-// ignore_for_file: type=lint
-// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 0 - 98
packages/cpt_community/lib/respository/newsfeed_news_repository.dart

@@ -1,98 +0,0 @@
-import 'package:domain/constants/api_constants.dart';
-import 'package:domain/entity/newsfeed_news_entity.dart';
-import 'package:domain/entity/server_time.dart';
-import 'package:plugin_platform/platform_export.dart';
-import 'package:plugin_platform/http/dio_engine.dart';
-import 'package:plugin_platform/http/http_result.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:shared/utils/util.dart';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:plugin_basic/provider/http_provider/http_provider.dart';
-
-
-part 'newsfeed_news_repository.g.dart';
-
-@Riverpod(keepAlive: true)
-NewsFeedNewsRepository newsFeedNewsRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
-  return NewsFeedNewsRepository(dioEngine: dioEngine);
-}
-
-/*
- * 数据仓库
- */
-class NewsFeedNewsRepository {
-  DioEngine dioEngine;
-
-  NewsFeedNewsRepository({required this.dioEngine});
-
-  // news feed - news 列表
-  Future<HttpResult<Object>> fetchNewsList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/feed/news', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.GET,
-      isShowLoadingDialog: false,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = NewsfeedNewsEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: data);
-    }
-    return result.convert();
-  }
-
-  // news feed -news 点赞/取消点赞
-  Future<HttpResult<Object>> fetchLikeClick(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/like/click', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.POST,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final boolData = result.getDataDynamic();
-      // var data = NewsfeedNewsEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: boolData);
-    }
-    return result.convert();
-  }
-
-
-
-}

+ 0 - 65
packages/cpt_community/lib/respository/newsfeed_publish_repository.dart

@@ -1,65 +0,0 @@
-import 'package:domain/constants/api_constants.dart';
-import 'package:domain/entity/newsfeed_comment_publish_entity.dart';
-import 'package:domain/entity/newsfeed_news_entity.dart';
-import 'package:domain/entity/server_time.dart';
-import 'package:plugin_platform/platform_export.dart';
-import 'package:plugin_platform/http/dio_engine.dart';
-import 'package:plugin_platform/http/http_result.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:shared/utils/util.dart';
-
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:plugin_basic/provider/http_provider/http_provider.dart';
-
-
-part 'newsfeed_publish_repository.g.dart';
-
-@Riverpod(keepAlive: true)
-NewsFeedPublishRepository newsFeedPublishRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
-  return NewsFeedPublishRepository(dioEngine: dioEngine);
-}
-
-/*
- * 数据仓库
- */
-class NewsFeedPublishRepository {
-  DioEngine dioEngine;
-
-  NewsFeedPublishRepository({required this.dioEngine});
-
-  // news feed -news 点赞/取消点赞
-  Future<HttpResult<Object>> fetchNewsfeedPublish(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
-    Map<String, dynamic> params = {};
-    params = data!;
-    Map<String, String> headers = {};
-    headers["Content-Type"] = "application/x-www-form-urlencoded";
-    headers["Accept"] = "application/x.yyjobs-api.v1+json";
-
-    final result = await dioEngine.requestNetResult(
-      // ApiConstants.apiServerTime, // api 地址
-      '/api/v1/user/news-feed/index/publish', // api 地址
-      params: params,
-      headers: headers,
-      method: HttpMethod.POST,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
-      cancelToken: cancelToken,
-    );
-    //根据返回的结果,封装原始数据为Bean/Entity对象
-    if (result.isSuccess) {
-      //重新赋值data或list
-      final json = result.getDataJson();
-      var data = NewsfeedCommentPublishEntity.fromJson(json!);
-      //重新赋值data或list
-      return result.convert(data: data);
-    }
-    return result.convert();
-  }
-
-
-}

+ 0 - 29
packages/cpt_community/lib/respository/newsfeed_publish_repository.g.dart

@@ -1,29 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of 'newsfeed_publish_repository.dart';
-
-// **************************************************************************
-// RiverpodGenerator
-// **************************************************************************
-
-String _$newsFeedPublishRepositoryHash() =>
-    r'c7233b4abdd852c7a3749a62671192b0740c4295';
-
-/// See also [newsFeedPublishRepository].
-@ProviderFor(newsFeedPublishRepository)
-final newsFeedPublishRepositoryProvider =
-    Provider<NewsFeedPublishRepository>.internal(
-  newsFeedPublishRepository,
-  name: r'newsFeedPublishRepositoryProvider',
-  debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
-      ? null
-      : _$newsFeedPublishRepositoryHash,
-  dependencies: null,
-  allTransitiveDependencies: null,
-);
-
-@Deprecated('Will be removed in 3.0. Use Ref instead')
-// ignore: unused_element
-typedef NewsFeedPublishRepositoryRef = ProviderRef<NewsFeedPublishRepository>;
-// ignore_for_file: type=lint
-// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package

+ 1 - 1
packages/cpt_community/lib/router/page/community_page_router.dart

@@ -82,7 +82,7 @@ class CommunityPageRouter extends _$CommunityPageRouter {
     ),
     CustomRoute(
       page: NewsfeedDetailPageRoute.page,
-      path: RouterPath.newsFeedDetail,
+      path: "${RouterPath.newsFeedDetail}:id/:type",
       transitionsBuilder: applySlideTransition,
     ),
     // Garage

+ 100 - 15
packages/cpt_community/lib/router/page/community_page_router.gr.dart

@@ -57,9 +57,15 @@ abstract class _$CommunityPageRouter extends RootStackRouter {
       );
     },
     GaragesalePostPageRoute.name: (routeData) {
+      final args = routeData.argsAs<GaragesalePostPageRouteArgs>();
       return AutoRoutePage<dynamic>(
         routeData: routeData,
-        child: const GaragesalePostPage(),
+        child: GaragesalePostPage(
+          key: args.key,
+          type: args.type,
+          sCallback: args.sCallback,
+          fCallback: args.fCallback,
+        ),
       );
     },
     MyFollowPageRoute.name: (routeData) {
@@ -111,7 +117,12 @@ abstract class _$CommunityPageRouter extends RootStackRouter {
       );
     },
     NewsfeedDetailPageRoute.name: (routeData) {
-      final args = routeData.argsAs<NewsfeedDetailPageRouteArgs>();
+      final pathParams = routeData.inheritedPathParams;
+      final args = routeData.argsAs<NewsfeedDetailPageRouteArgs>(
+          orElse: () => NewsfeedDetailPageRouteArgs(
+                id: pathParams.optInt('id'),
+                type: pathParams.optString('type'),
+              ));
       return AutoRoutePage<dynamic>(
         routeData: routeData,
         child: NewsfeedDetailPage(
@@ -122,9 +133,15 @@ abstract class _$CommunityPageRouter extends RootStackRouter {
       );
     },
     NewsfeedPostPageRoute.name: (routeData) {
+      final args = routeData.argsAs<NewsfeedPostPageRouteArgs>(
+          orElse: () => const NewsfeedPostPageRouteArgs());
       return AutoRoutePage<dynamic>(
         routeData: routeData,
-        child: const NewsfeedPostPage(),
+        child: NewsfeedPostPage(
+          key: args.key,
+          sCallback: args.sCallback,
+          fCallback: args.fCallback,
+        ),
       );
     },
   };
@@ -206,8 +223,8 @@ class GaragesaleDetailPageRoute
     extends PageRouteInfo<GaragesaleDetailPageRouteArgs> {
   GaragesaleDetailPageRoute({
     Key? key,
-    required int? id,
-    required String? type,
+    required int id,
+    required String type,
     List<PageRouteInfo>? children,
   }) : super(
           GaragesaleDetailPageRoute.name,
@@ -234,9 +251,9 @@ class GaragesaleDetailPageRouteArgs {
 
   final Key? key;
 
-  final int? id;
+  final int id;
 
-  final String? type;
+  final String type;
 
   @override
   String toString() {
@@ -246,16 +263,51 @@ class GaragesaleDetailPageRouteArgs {
 
 /// generated route for
 /// [GaragesalePostPage]
-class GaragesalePostPageRoute extends PageRouteInfo<void> {
-  const GaragesalePostPageRoute({List<PageRouteInfo>? children})
-      : super(
+class GaragesalePostPageRoute
+    extends PageRouteInfo<GaragesalePostPageRouteArgs> {
+  GaragesalePostPageRoute({
+    Key? key,
+    required int type,
+    void Function()? sCallback,
+    void Function()? fCallback,
+    List<PageRouteInfo>? children,
+  }) : super(
           GaragesalePostPageRoute.name,
+          args: GaragesalePostPageRouteArgs(
+            key: key,
+            type: type,
+            sCallback: sCallback,
+            fCallback: fCallback,
+          ),
           initialChildren: children,
         );
 
   static const String name = 'GaragesalePostPageRoute';
 
-  static const PageInfo<void> page = PageInfo<void>(name);
+  static const PageInfo<GaragesalePostPageRouteArgs> page =
+      PageInfo<GaragesalePostPageRouteArgs>(name);
+}
+
+class GaragesalePostPageRouteArgs {
+  const GaragesalePostPageRouteArgs({
+    this.key,
+    required this.type,
+    this.sCallback,
+    this.fCallback,
+  });
+
+  final Key? key;
+
+  final int type;
+
+  final void Function()? sCallback;
+
+  final void Function()? fCallback;
+
+  @override
+  String toString() {
+    return 'GaragesalePostPageRouteArgs{key: $key, type: $type, sCallback: $sCallback, fCallback: $fCallback}';
+  }
 }
 
 /// generated route for
@@ -386,6 +438,10 @@ class NewsfeedDetailPageRoute
             id: id,
             type: type,
           ),
+          rawPathParams: {
+            'id': id,
+            'type': type,
+          },
           initialChildren: children,
         );
 
@@ -416,14 +472,43 @@ class NewsfeedDetailPageRouteArgs {
 
 /// generated route for
 /// [NewsfeedPostPage]
-class NewsfeedPostPageRoute extends PageRouteInfo<void> {
-  const NewsfeedPostPageRoute({List<PageRouteInfo>? children})
-      : super(
+class NewsfeedPostPageRoute extends PageRouteInfo<NewsfeedPostPageRouteArgs> {
+  NewsfeedPostPageRoute({
+    Key? key,
+    void Function()? sCallback,
+    void Function()? fCallback,
+    List<PageRouteInfo>? children,
+  }) : super(
           NewsfeedPostPageRoute.name,
+          args: NewsfeedPostPageRouteArgs(
+            key: key,
+            sCallback: sCallback,
+            fCallback: fCallback,
+          ),
           initialChildren: children,
         );
 
   static const String name = 'NewsfeedPostPageRoute';
 
-  static const PageInfo<void> page = PageInfo<void>(name);
+  static const PageInfo<NewsfeedPostPageRouteArgs> page =
+      PageInfo<NewsfeedPostPageRouteArgs>(name);
+}
+
+class NewsfeedPostPageRouteArgs {
+  const NewsfeedPostPageRouteArgs({
+    this.key,
+    this.sCallback,
+    this.fCallback,
+  });
+
+  final Key? key;
+
+  final void Function()? sCallback;
+
+  final void Function()? fCallback;
+
+  @override
+  String toString() {
+    return 'NewsfeedPostPageRouteArgs{key: $key, sCallback: $sCallback, fCallback: $fCallback}';
+  }
 }

+ 17 - 17
packages/cpt_facility/lib/modules/book_confirm/book_confirm_page.dart

@@ -1,17 +1,19 @@
 import 'package:cs_resources/generated/assets.dart';
 import 'package:cs_resources/generated/l10n.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/facility_book_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:router/ext/auto_router_extensions.dart';
+import 'package:shared/utils/date_time_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_appbar.dart';
 import 'package:widgets/my_button.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/my_text_view.dart';
 import '../../router/page/facility_page_router.dart';
-import 'book_confirm_view_model.dart';
+import '../booking/facility_booking_view_model.dart';
 
 @RoutePage()
 class BookConfirmPage extends HookConsumerWidget {
@@ -28,13 +30,13 @@ class BookConfirmPage extends HookConsumerWidget {
 
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final viewModel = ref.watch(bookConfirmViewModelProvider.notifier);
-    final state = ref.watch(bookConfirmViewModelProvider);
+    final viewModel = ref.watch(facilityBookingViewModelProvider.notifier);
+    final state = ref.watch(facilityBookingViewModelProvider);
 
     return Scaffold(
       appBar: MyAppBar.appBar(
         context,
-        "Function Room",
+        state.facilityName ?? "",
         showBackButton: true,
         backgroundColor: context.appColors.backgroundWhite,
       ),
@@ -59,9 +61,9 @@ class BookConfirmPage extends HookConsumerWidget {
                     Assets.facilityConfirmDateIcon,
                     28.5,
                     29,
-                    "Tue,24 Oct 2023",
+                    "${DateTimeUtils.getWeekday(state.selectedDate, languageCode: 'en', short: true)}, ${DateTimeUtils.formatDate(state.selectedDate, format: 'dd MMM yyyy')}",
                     null,
-                    "05:00 PM-10:00 PM",
+                    "${state.data?.facilities?[state.index].periods?[state.innerIndex].start}-${state.data?.facilities?[state.index].periods?[state.innerIndex].end}",
                     null,
                   ),
 
@@ -73,9 +75,9 @@ class BookConfirmPage extends HookConsumerWidget {
                     Assets.facilityConfirmFacilityIcon,
                     25.0,
                     30.5,
-                    "Kids party room",
+                    state.facilityName ?? "",
                     null,
-                    "Blue room",
+                    state.data?.facilities?[state.index].name ?? "",
                     null,
                   ),
 
@@ -88,9 +90,9 @@ class BookConfirmPage extends HookConsumerWidget {
                     27.0,
                     22.0,
                     S.current.booking_fee,
-                    "10.80",
+                    state.data?.facilities?[state.index].periods?[state.innerIndex].price,
                     S.current.total,
-                    "\$10.80",
+                    "\$${state.data?.facilities?[state.index].periods?[state.innerIndex].price}",
                   ),
 
                   // 押金
@@ -102,25 +104,24 @@ class BookConfirmPage extends HookConsumerWidget {
                     28.0,
                     26.5,
                     S.current.deposit_hold,
-                    "\$100.00",
+                    "\$${state.data?.facilities?[state.index].periods?[state.innerIndex].deposit}",
                     null,
                     null,
                   ),
 
                   // 添加间隔
                   const SizedBox(height: 7.5),
-
                 ],
               ),
             ),
           ),
 
           // 显示支付信息
-          _paymentInfo(context,ref),
+          _paymentInfo(context, ref),
 
           // 底部按钮
           MyButton(
-            onPressed:viewModel.doPayment,
+            onPressed: viewModel.doPayment,
             text: S.current.proceed_with_payment,
             textColor: Colors.white,
             backgroundColor: context.appColors.btnBgDefault,
@@ -135,7 +136,6 @@ class BookConfirmPage extends HookConsumerWidget {
     );
   }
 
-
   //展示的Item
   Widget _buildConfirmItem(
     BuildContext context,
@@ -235,8 +235,8 @@ class BookConfirmPage extends HookConsumerWidget {
   }
 
   //底部的支付信息
-  Widget _paymentInfo(BuildContext context,WidgetRef ref) {
-    final viewModel = ref.watch(bookConfirmViewModelProvider.notifier);
+  Widget _paymentInfo(BuildContext context, WidgetRef ref) {
+    final viewModel = ref.watch(facilityBookingViewModelProvider.notifier);
 
     return Container(
       padding: const EdgeInsets.symmetric(vertical: 17.5, horizontal: 23),

+ 0 - 3
packages/cpt_facility/lib/modules/book_confirm/book_confirm_state.dart

@@ -1,3 +0,0 @@
-class BookConfirmState{
-
-}

+ 0 - 29
packages/cpt_facility/lib/modules/book_confirm/book_confirm_view_model.dart

@@ -1,29 +0,0 @@
-import 'package:cpt_facility/modules/detail/facility_detail_page.dart';
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:router/componentRouter/component_service_manager.dart';
-
-import 'book_confirm_state.dart';
-import 'package:plugin_platform/engine/toast/toast_engine.dart';
-
-part 'book_confirm_view_model.g.dart';
-
-@riverpod
-class BookConfirmViewModel extends _$BookConfirmViewModel {
-  @override
-  BookConfirmState build() {
-    return BookConfirmState();
-  }
-
-  //执行支付
-  void doPayment() {
-    ToastEngine.show("点击了确定");
-
-    FacilityDetailPage.startWithPop2Main();
-  }
-
-  //选择银行卡页面
-  void gotoChooseCardPage() {
-    ComponentServiceManager().paymentService.startChooseCardPage();
-  }
-
-}

+ 54 - 33
packages/cpt_facility/lib/modules/booking/facility_booking_page.dart

@@ -4,6 +4,7 @@ import 'package:cpt_facility/modules/location/facility_location_page.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:cs_resources/generated/l10n.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/facility_book_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:flutter_hooks/flutter_hooks.dart';
@@ -25,14 +26,17 @@ import 'facility_booking_view_model.dart';
 
 @RoutePage()
 class FacilityBookingPage extends HookConsumerWidget {
-  const FacilityBookingPage({Key? key}) : super(key: key);
+  final String facilityId;
+  final String facilityName;
+
+  const FacilityBookingPage({Key? key, required this.facilityId, required this.facilityName}) : super(key: key);
 
   //启动当前页面
-  static void startInstance({BuildContext? context}) {
+  static void startInstance({BuildContext? context, required String facilityId, required String facilityName}) {
     if (context != null) {
-      context.router.push(const FacilityBookingPageRoute());
+      context.router.push(FacilityBookingPageRoute(facilityId: facilityId, facilityName: facilityName));
     } else {
-      appRouter.push(const FacilityBookingPageRoute());
+      appRouter.push(FacilityBookingPageRoute(facilityId: facilityId, facilityName: facilityName));
     }
   }
 
@@ -43,27 +47,35 @@ class FacilityBookingPage extends HookConsumerWidget {
 
     useEffect(() {
       // 组件挂载时执行 - 执行接口请求
-      Future.microtask(() => viewModel.fetchListByDate());
+      Future.microtask(() {
+        viewModel.setFacilityId(facilityId, facilityName);
+        viewModel.fetchListByDate();
+      });
       return () {
         // 组件卸载时执行
       };
     }, []);
 
     return Scaffold(
-      appBar: MyAppBar.appBar(context, "Kids party room", backgroundColor: context.appColors.backgroundWhite, actions: [
-        //去设施小区的定位图片
-        const MyAssetImage(
-          Assets.facilityTitleLocationIcon,
-          width: 44,
-          height: 44,
-        ).marginOnly(right: 3).onTap(() {
-          FacilityLocationPage.startInstance(context: context, imageUrls: [
-            "https://mz.eastday.com/63074197.jpeg",
-            "https://t10.baidu.com/it/u=3562774827,189123978&fm=30&app=106&f=PNG?w=640&h=479&s=DFBA6EC80A72B7CC02FC011F0300D0C2",
-            "https://img1.baidu.com/it/u=4090167392,148087489&fm=253&fmt=auto&app=138&f=JPEG?w=484&h=300"
-          ]);
-        }),
-      ]),
+      appBar: MyAppBar.appBar(
+        context,
+        facilityName,
+        backgroundColor: context.appColors.backgroundWhite,
+        actions: [
+          //去设施小区的定位图片
+          const MyAssetImage(
+            Assets.facilityTitleLocationIcon,
+            width: 44,
+            height: 44,
+          ).marginOnly(right: 3).onTap(() {
+            FacilityLocationPage.startInstance(context: context, imageUrls: [
+              "https://mz.eastday.com/63074197.jpeg",
+              "https://t10.baidu.com/it/u=3562774827,189123978&fm=30&app=106&f=PNG?w=640&h=479&s=DFBA6EC80A72B7CC02FC011F0300D0C2",
+              "https://img1.baidu.com/it/u=4090167392,148087489&fm=253&fmt=auto&app=138&f=JPEG?w=484&h=300"
+            ]);
+          }),
+        ],
+      ),
       backgroundColor: context.appColors.backgroundDark,
       body: Column(
         mainAxisSize: MainAxisSize.max,
@@ -93,7 +105,6 @@ class FacilityBookingPage extends HookConsumerWidget {
           WeeklyCalendar(
             selectedDate: state.selectedDate,
             onChangedSelectedDate: (dateTime) {
-              Log.d("onChangedSelectedDate选中 - ${dateTime}}");
               viewModel.changeSelectedDate(dateTime);
             },
           ),
@@ -108,7 +119,7 @@ class FacilityBookingPage extends HookConsumerWidget {
             successSliverWidget: [
               SliverToBoxAdapter(
                 child: MyTextView(
-                  S.current.quota_left_msg(1, DateTimeUtils.formatDate(state.selectedDate, format: 'dd MMM yyyy')),
+                  S.current.quota_left_msg(state.data?.remainQuota ?? 0, state.data?.quotaResetOn ?? "-"),
                   marginTop: 7,
                   marginBottom: 15,
                   textColor: context.appColors.textBlack,
@@ -119,9 +130,9 @@ class FacilityBookingPage extends HookConsumerWidget {
               SliverList(
                   delegate: SliverChildBuilderDelegate(
                 (context, index) {
-                  return _buildFacilityOption(context, state.datas[index]);
+                  return _buildFacilityOption(context, ref, state.data?.facilities?[index], index);
                 },
-                childCount: state.datas.length,
+                childCount: state.data?.facilities?.length,
               ))
             ],
           ).marginOnly(top: 5).expanded(),
@@ -170,7 +181,8 @@ class FacilityBookingPage extends HookConsumerWidget {
   }
 
   //生产当前设施的选项
-  Widget _buildFacilityOption(BuildContext context, String item) {
+  Widget _buildFacilityOption(BuildContext context, WidgetRef ref, FacilityBookFacilities? item, int index) {
+    final viewModel = ref.watch(facilityBookingViewModelProvider.notifier);
     return Column(
       children: [
         Container(
@@ -179,7 +191,7 @@ class FacilityBookingPage extends HookConsumerWidget {
           color: context.appColors.btnBgDefault,
           child: Center(
             child: MyTextView(
-              item,
+              item?.name ?? "",
               fontSize: 16,
               textColor: Colors.white,
               textAlign: TextAlign.center,
@@ -196,11 +208,15 @@ class FacilityBookingPage extends HookConsumerWidget {
             mainAxisSpacing: 6.5,
             crossAxisSpacing: 6.5,
           ),
-          itemCount: 4,
-          itemBuilder: (context, index) {
+          itemCount: item?.periods?.length,
+          itemBuilder: (context, innerIndex) {
             return Container(
               decoration: BoxDecoration(
-                color: context.appColors.whiteBG,
+                color: item?.periods?[innerIndex].selected == true
+                    ? context.appColors.orangeBG
+                    : item?.periods?[innerIndex].enable == true
+                        ? context.appColors.whiteBG
+                        : context.appColors.disEnableGray,
                 borderRadius: BorderRadius.circular(5.0),
               ),
               child: Column(
@@ -208,20 +224,25 @@ class FacilityBookingPage extends HookConsumerWidget {
                 mainAxisAlignment: MainAxisAlignment.center, // 垂直居中
                 children: [
                   MyTextView(
-                    "10.00 AM",
+                    item?.periods?[innerIndex].start ?? "",
                     fontSize: 12,
-                    textColor: context.appColors.textBlack,
+                    textColor: item?.periods?[innerIndex].selected == true ? context.appColors.textWhite : context.appColors.textBlack,
                     isFontMedium: true,
                   ),
                   MyTextView(
-                    "04.00 PM",
+                    item?.periods?[innerIndex].end ?? "",
                     fontSize: 12,
-                    textColor: context.appColors.textBlack,
+                    textColor: item?.periods?[innerIndex].selected == true ? context.appColors.textWhite : context.appColors.textBlack,
                     isFontMedium: true,
                   ),
                 ],
               ),
-            );
+            ).onTap(() {
+              //点击选中,可用并且未选中的情况下点击选中
+              if (item?.periods?[innerIndex].enable == true && item?.periods?[innerIndex].selected == false) {
+                viewModel.selectPeriods(index, innerIndex);
+              }
+            });
           },
         ).marginSymmetric(horizontal: 10, vertical: 17),
       ],

+ 24 - 4
packages/cpt_facility/lib/modules/booking/facility_booking_state.dart

@@ -1,3 +1,4 @@
+import 'package:domain/entity/facility_book_entity.dart';
 import 'package:widgets/load_state_layout.dart';
 
 class FacilityBookingState {
@@ -8,28 +9,47 @@ class FacilityBookingState {
   LoadState loadingState;
   String? errorMessage;
 
-  List<String> datas;
+  //网络请求数据
+  FacilityBookEntity? data;
+
+  String? facilityId;
+  String? facilityName;
+
+  int index;
+  int innerIndex;
 
   // ===================================  Begin  ↓  ===================================
 
   FacilityBookingState({
     required this.selectedDate,
     this.loadingState = LoadState.State_Loading,
-    required this.datas,
+    this.data,
     this.errorMessage,
+    this.facilityId,
+    this.facilityName,
+    this.index = 0,
+    this.innerIndex = 0,
   });
 
   FacilityBookingState copyWith({
     DateTime? selectedDate,
     LoadState? loadingState,
     String? errorMessage,
-    List<String>? datas,
+    String? facilityId,
+    String? facilityName,
+    FacilityBookEntity? data,
+    int? index,
+    int? innerIndex,
   }) {
     return FacilityBookingState(
       selectedDate: selectedDate ?? this.selectedDate,
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
-      datas: datas ?? this.datas,
+      data: data,
+      facilityId: facilityId ?? this.facilityId,
+      facilityName: facilityName ?? this.facilityName,
+      index: index ?? this.index,
+      innerIndex: innerIndex ?? this.innerIndex,
     );
   }
 }

+ 111 - 15
packages/cpt_facility/lib/modules/booking/facility_booking_view_model.dart

@@ -1,29 +1,41 @@
-import 'package:cs_resources/generated/l10n.dart';
+import 'package:domain/entity/facility_book_entity.dart';
+import 'package:domain/repository/facility_repository.dart';
+import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:router/componentRouter/component_service_manager.dart';
 import 'package:shared/utils/log_utils.dart';
-import 'package:shared/utils/util.dart';
 import 'package:widgets/load_state_layout.dart';
 import '../book_confirm/book_confirm_page.dart';
+import '../detail/facility_detail_page.dart';
 import 'facility_booking_state.dart';
 
 part 'facility_booking_view_model.g.dart';
 
 @riverpod
-class FacilityBookingViewModel extends _$FacilityBookingViewModel {
+class FacilityBookingViewModel extends _$FacilityBookingViewModel with DioCancelableMixin {
+  late final FacilityRepository _facilityRepository;
+
   @override
   FacilityBookingState build() {
+    _facilityRepository = ref.read(facilityRepositoryProvider);
+
     final state = FacilityBookingState(
       selectedDate: DateTime.now(),
-      datas: [],
     );
     initListener(state);
-    ref.onDispose(() {
+    registerCancellation(callback: () {
       onDispose(state);
     });
 
     return state;
   }
 
+  //设置设施的ID
+  void setFacilityId(String facilityId, String facilityName) {
+    state = state.copyWith(facilityId: facilityId, facilityName: facilityName);
+  }
+
   //修改选中的时间
   void changeSelectedDate(DateTime dateTime) {
     state = state.copyWith(selectedDate: dateTime);
@@ -40,20 +52,30 @@ class FacilityBookingViewModel extends _$FacilityBookingViewModel {
   Future fetchListByDate() async {
     state = state.copyWith(loadingState: LoadState.State_Loading);
 
-    await Future.delayed(const Duration(milliseconds: 1500));
-
-    List<String> list = ["Orange Room", "Purple Room", "Red Room"];
+    // 获取列表
+    var result = await _facilityRepository.fetchFacilityDateDetail(
+      id: state.facilityId,
+      date: state.selectedDate,
+      cancelToken: cancelToken,
+    );
 
-    if (list.isNotEmpty) {
-      //加载成功
-      state = state.copyWith(datas: list, loadingState: LoadState.State_Success);
+    // 处理数据
+    if (result.isSuccess) {
+      if (result.data != null) {
+        //有数据
+        state = state.copyWith(data: result.data, loadingState: LoadState.State_Success);
+      } else {
+        //展示无数据的布局
+        state = state.copyWith(data: null, loadingState: LoadState.State_Empty, errorMessage: null);
+      }
     } else {
-      //无数据
-      state = state.copyWith(datas: [], loadingState: LoadState.State_Empty);
+      state = state.copyWith(data: null, loadingState: LoadState.State_Error, errorMessage: result.errorMsg);
     }
   }
 
-  void initListener(FacilityBookingState state) {}
+  void initListener(FacilityBookingState state) {
+    Log.d("FacilityBookingViewModel - initListener");
+  }
 
   void onDispose(FacilityBookingState state) {
     Log.d("FacilityBookingViewModel - onDispose");
@@ -61,6 +83,80 @@ class FacilityBookingViewModel extends _$FacilityBookingViewModel {
 
   //去付款确认页面
   void gotoConfirmPage() {
-    BookConfirmPage.startInstance();
+    if (state.data == null) return;
+
+    //找到数据中的已选中数据
+    final selectedPeriods = <FacilityBookFacilitiesPeriods>[];
+    for (var facility in state.data!.facilities!) {
+      final periods = facility.periods ?? [];
+
+      // 筛选出已选中的 periods,并添加到结果列表
+      selectedPeriods.addAll(
+        periods.where((period) => period.selected).toList(),
+      );
+    }
+
+    if (selectedPeriods.isEmpty) {
+      ToastEngine.show("Select Facility And Date");
+    } else {
+      BookConfirmPage.startInstance();
+    }
+  }
+
+  //选中指定的Task
+  void selectPeriods(int index, int innerIndex) {
+    // 创建新的 periods 列表来更新状态
+    final updatedFacilities = state.data!.facilities!.map((facility) {
+      // 创建新的 periods 列表
+      final updatedPeriods = facility.periods!.map((period) {
+        return FacilityBookFacilitiesPeriods()
+          ..id = period.id
+          ..start = period.start
+          ..end = period.end
+          ..price = period.price
+          ..deposit = period.deposit
+          ..enable = period.enable
+          ..selected = false; // 设置默认未选中
+      }).toList();
+
+      return FacilityBookFacilities()
+        ..id = facility.id
+        ..name = facility.name
+        ..periods = updatedPeriods;
+    }).toList();
+
+    // 设置指定索引的 selected 为 true
+    updatedFacilities[index].periods?[innerIndex].selected = true;
+
+    // 更新 FacilityBookEntity 的状态
+    state = state.copyWith(
+      data: FacilityBookEntity()
+        ..remainQuota = state.data!.remainQuota
+        ..quotaResetOn = state.data!.quotaResetOn
+        ..facilityType = state.data!.facilityType
+        ..facilities = updatedFacilities, //只更新了facilities对象
+      index: index,
+      innerIndex: innerIndex,
+    );
+  }
+
+  //确认页面执行支付
+  void doPayment() async {
+    final result = await _facilityRepository.submitBooking(
+      periodId: state.data?.facilities?[state.index].periods?[state.innerIndex].id,
+      date: state.selectedDate,
+      cancelToken: cancelToken,
+    );
+
+    if (result.isSuccess) {
+      FacilityDetailPage.startWithPop2Main();
+    } else {
+      ToastEngine.show(result.errorMsg ?? "UnKnow Error");
+    }
+  }
+
+  //确认页面选择银行卡页面
+  void gotoChooseCardPage() {
+    ComponentServiceManager().paymentService.startChooseCardPage();
   }
 }

+ 1 - 1
packages/cpt_facility/lib/modules/booking/facility_booking_view_model.g.dart

@@ -7,7 +7,7 @@ part of 'facility_booking_view_model.dart';
 // **************************************************************************
 
 String _$facilityBookingViewModelHash() =>
-    r'c9a681e01791881d17dc58b3a8e45153e6fe62ad';
+    r'5bfb55d67994d66800bb220385e48954d6aec449';
 
 /// See also [FacilityBookingViewModel].
 @ProviderFor(FacilityBookingViewModel)

+ 1 - 1
packages/cpt_facility/lib/modules/facility/active/facility_active_screen.dart

@@ -44,7 +44,7 @@ class FacilityActiveScreen extends HookConsumerWidget {
                 delegate: SliverChildBuilderDelegate(
                       (context, index) {
                     return FacilityActiveItem(index: index, item: state.datas[index]).onTap((){
-                      FacilityDetailPage.startInstance(context: context);
+                      // FacilityDetailPage.startInstance(context: context);
                     });
                   },
                   childCount: state.datas.length,

+ 3 - 2
packages/cpt_facility/lib/modules/facility/active/facility_active_state.dart

@@ -1,3 +1,4 @@
+import 'package:domain/entity/facility_page_entity.dart';
 import 'package:widgets/load_state_layout.dart';
 
 class FacilityActiveState {
@@ -6,7 +7,7 @@ class FacilityActiveState {
   LoadState loadingState;
   String? errorMessage;
 
-  List<String> datas; //页面列表数据
+  List<FacilityPageList> datas; //页面列表数据
 
   // ===================================  Begin  ↓  ===================================
 
@@ -20,7 +21,7 @@ class FacilityActiveState {
     LoadState? loadingState,
     String? errorMessage,
     bool? needShowPlaceholder,
-    List<String>? datas,
+    List<FacilityPageList>? datas,
   }) {
     return FacilityActiveState(
       errorMessage: errorMessage ?? this.errorMessage,

+ 48 - 70
packages/cpt_facility/lib/modules/facility/active/facility_active_view_model.dart

@@ -1,3 +1,6 @@
+import 'package:domain/entity/facility_page_entity.dart';
+import 'package:domain/repository/facility_repository.dart';
+import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
@@ -8,19 +11,23 @@ import 'facility_active_state.dart';
 part 'facility_active_view_model.g.dart';
 
 @riverpod
-class FacilityActiveViewModel extends _$FacilityActiveViewModel {
+class FacilityActiveViewModel extends _$FacilityActiveViewModel with DioCancelableMixin {
+  late final FacilityRepository _facilityRepository;
   var _curPage = 1; //请求参数当前的页面
   var _needShowPlaceholder = true; //是否展示LoadingView
 
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
-    controlFinishRefresh: true,  //允许刷新
-    controlFinishLoad: true,   //允许加载
+    controlFinishRefresh: true, //允许刷新
+    controlFinishLoad: true, //允许加载
   );
 
   @override
   FacilityActiveState build() {
-    return FacilityActiveState(datas: []);
+    _facilityRepository = ref.read(facilityRepositoryProvider);
+    final state = FacilityActiveState(datas: []);
+    registerCancellation();
+    return state;
   }
 
   //刷新页面状态
@@ -53,78 +60,49 @@ class FacilityActiveViewModel extends _$FacilityActiveViewModel {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    // 获取 Applied 列表
-    // var listResult = await _jobRepository.fetchJobAppliedList(
-    //   state.jobId,
-    //   state.selectedStatusId,
-    //   state.keyword,
-    //   curPage: _curPage,
-    //   cancelToken: cancelToken,
-    // );
-    //
-    // // 处理数据
-    // if (listResult.isSuccess) {
-    //   handleList(listResult.data?.rows);
-    // } else {
-    //   errorMessage = listResult.errorMsg;
-    //   changeLoadingState(LoadState.State_Error);
-    // }
+    // 获取列表
+    var listResult = await _facilityRepository.fetchFacilityActiveList(
+      curPage: _curPage,
+      cancelToken: cancelToken,
+    );
 
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-
-    final List<String> list = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"];
-
-    if (_curPage == 1) {
-      //刷新的方式
-      state = state.copyWith(datas: list);
-      refreshController.finishRefresh();
-
-      //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
+    // 处理数据
+    if (listResult.isSuccess) {
+      handleList(listResult.data?.list);
     } else {
-      //加载更多
-      final allList = state.datas;
-      allList.addAll(list);
-      state.datas.addAll(list);
-
-      refreshController.finishLoad();
-
-      state = state.copyWith(datas: allList);
+      changeLoadingState(LoadState.State_Error, listResult.errorMsg);
     }
 
     // 最后赋值
     _needShowPlaceholder = false;
   }
 
-// 处理数据与展示的逻辑
-// void handleList(List<JobAppliedListSGRows>? list) {
-//   if (list != null && list.isNotEmpty) {
-//     //有数据,判断是刷新还是加载更多的数据
-//     if (_curPage == 1) {
-//       //刷新的方式
-//       state.datas.clear();
-//       state.datas.addAll(list);
-//       refreshController.finishRefresh();
-//
-//       //更新展示的状态
-//       changeLoadingState(LoadState.State_Success);
-//     } else {
-//       //加载更多
-//       state.datas.addAll(list);
-//       refreshController.finishLoad();
-//       update();
-//     }
-//   } else {
-//     if (_curPage == 1) {
-//       //展示无数据的布局
-//       state.datas.clear();
-//       changeLoadingState(LoadState.State_Empty);
-//       refreshController.finishRefresh();
-//     } else {
-//       //展示加载完成,没有更多数据了
-//       refreshController.finishLoad(IndicatorResult.noMore);
-//     }
-//   }
-// }
+  // 处理数据与展示的逻辑
+  void handleList(List<FacilityPageList>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_curPage == 1) {
+        //刷新的方式
+        state = state.copyWith(datas: list);
+        refreshController.finishRefresh();
+
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        state.datas.addAll(List<FacilityPageList>.from(state.datas)..addAll(list));
+        refreshController.finishLoad();
+      }
+    } else {
+      if (_curPage == 1) {
+        //展示无数据的布局
+        state = state.copyWith(datas: []);
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
+    }
+  }
 }

+ 8 - 7
packages/cpt_facility/lib/modules/facility/active/item_facility_active.dart

@@ -1,6 +1,7 @@
 import 'package:cpt_facility/modules/facility/active/facility_active_screen.dart';
 import 'package:cs_resources/generated/l10n.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/facility_page_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_text_view.dart';
@@ -8,7 +9,7 @@ import 'package:widgets/my_text_view.dart';
 ///  设施的Active的Item
 class FacilityActiveItem extends StatelessWidget {
   final int index;
-  final String item;
+  final FacilityPageList item;
 
   const FacilityActiveItem({
     required this.index,
@@ -34,7 +35,7 @@ class FacilityActiveItem extends StatelessWidget {
             children: [
               //设施
               MyTextView(
-                "Kids party room",
+                item.facility?.type?.name ?? "",
                 fontSize: 16,
                 maxLines: 3,
                 textColor: context.appColors.textBlack,
@@ -43,7 +44,7 @@ class FacilityActiveItem extends StatelessWidget {
 
               //分类
               MyTextView(
-                "Blue room",
+                item.facility?.name ?? "",
                 fontSize: 14,
                 marginTop: 3,
                 textColor: context.appColors.textBlack,
@@ -52,7 +53,7 @@ class FacilityActiveItem extends StatelessWidget {
 
               //预订人
               MyTextView(
-                S.current.booked_by_someone("Wu Bing Bing"),
+                S.current.booked_by_someone(item.account?.name ?? ""),
                 fontSize: 14,
                 marginTop: 3,
                 textColor: context.appColors.textBlack,
@@ -61,7 +62,7 @@ class FacilityActiveItem extends StatelessWidget {
 
               //日期
               MyTextView(
-                "Tue,24 Oct 2023",
+                item.booking?.date ?? "",
                 fontSize: 14,
                 marginTop: 16,
                 textColor: context.appColors.textBlack,
@@ -70,7 +71,7 @@ class FacilityActiveItem extends StatelessWidget {
 
               //时间
               MyTextView(
-                "05:00 PM-10:00 PM",
+                "${item.booking?.start ?? ""}-${item.booking?.end ?? ""}",
                 fontSize: 14,
                 marginBottom: 7,
                 marginTop: 3,
@@ -113,7 +114,7 @@ class FacilityActiveItem extends StatelessWidget {
           ).expanded(),
           Column(
             mainAxisSize: MainAxisSize.min,
-            mainAxisAlignment:MainAxisAlignment.start,
+            mainAxisAlignment: MainAxisAlignment.start,
             crossAxisAlignment: CrossAxisAlignment.start,
             children: [
               //查看按钮

+ 6 - 3
packages/cpt_facility/lib/modules/facility/book/facility_book_screen.dart

@@ -25,13 +25,12 @@ class FacilityBookScreen extends HookConsumerWidget {
       };
     }, []);
 
-    return Container(
+    return SizedBox(
       width: double.infinity,
       height: double.infinity,
       child: EasyRefresh(
         controller: viewModel.refreshController,
         onRefresh: viewModel.onRefresh,
-        onLoad: viewModel.loadMore,
         child: LoadStateLayout(
           state: state.loadingState,
           errorMessage: state.errorMessage,
@@ -43,7 +42,11 @@ class FacilityBookScreen extends HookConsumerWidget {
                 delegate: SliverChildBuilderDelegate(
               (context, index) {
                 return FacilityBookItem(index: index, item: state.datas[index]).onTap(() {
-                  FacilityBookingPage.startInstance(context: context);
+                  FacilityBookingPage.startInstance(
+                    context: context,
+                    facilityId: state.datas[index].id ?? "",
+                    facilityName: state.datas[index].name ?? "",
+                  );
                 });
               },
               childCount: state.datas.length,

+ 0 - 0
packages/cpt_facility/lib/modules/facility/book/facility_book_state.dart


Some files were not shown because too many files changed in this diff