Browse Source

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

“shanwenxin” 2 months ago
parent
commit
4a99b84abc
100 changed files with 1917 additions and 2009 deletions
  1. 8 8
      packages/cpt_community/lib/components/garage_card.dart
  2. 36 29
      packages/cpt_community/lib/components/newsfeed_card_content.dart
  3. 112 80
      packages/cpt_community/lib/modules/community/community_page.dart
  4. 1 1
      packages/cpt_community/lib/modules/community/community_state.dart
  5. 227 91
      packages/cpt_community/lib/modules/community/community_vm.dart
  6. 5 3
      packages/cpt_community/lib/modules/community/customSilverHeaderTabs.dart
  7. 6 13
      packages/cpt_community/lib/modules/community/following/following_page.dart
  8. 43 29
      packages/cpt_community/lib/modules/community/following/following_vm.dart
  9. 3 3
      packages/cpt_community/lib/modules/community/foryou/foryou_page.dart
  10. 47 151
      packages/cpt_community/lib/modules/community/foryou/foryou_vm.dart
  11. 7 3
      packages/cpt_community/lib/modules/community/news/news_page.dart
  12. 48 26
      packages/cpt_community/lib/modules/community/news/news_vm.dart
  13. 1 1
      packages/cpt_community/lib/modules/community/newsfeed_detail/comments_input.dart
  14. 2 6
      packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_page.dart
  15. 14 3
      packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_vm.dart
  16. 1 4
      packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_page.dart
  17. 23 8
      packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_vm.dart
  18. 5 6
      packages/cpt_community/lib/modules/community/newsfeed_tabs.dart
  19. 1 0
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_page.dart
  20. 13 0
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_state.dart
  21. 87 97
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.dart
  22. 3 1
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_page.dart
  23. 13 1
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_state.dart
  24. 57 119
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart
  25. 133 60
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_page.dart
  26. 170 60
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_vm.dart
  27. 6 4
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_page.dart
  28. 1 1
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_state.dart
  29. 53 37
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.dart
  30. 1 1
      packages/cpt_community/lib/modules/my_following/components/item_following.dart
  31. 3 3
      packages/cpt_community/lib/modules/my_following/my_follow/my_follow_page.dart
  32. 3 3
      packages/cpt_community/lib/modules/my_following/my_follower/my_follower_page.dart
  33. 1 1
      packages/cpt_community/lib/modules/my_following/my_following_page.dart
  34. 5 3
      packages/cpt_community/lib/modules/my_following/my_following_tabs.dart
  35. 2 2
      packages/cpt_community/lib/modules/my_posts/my_posts_forrent/my_posts_forrent_vm.dart
  36. 3 2
      packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_vm.dart
  37. 32 14
      packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_page.dart
  38. 0 18
      packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_state.dart
  39. 247 76
      packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_vm.dart
  40. 5 1
      packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/newsfeed_itemgroup_state.dart
  41. 21 8
      packages/cpt_community/lib/respository/common_garage.dart
  42. 15 1
      packages/cpt_community/lib/respository/common_newsfeed.dart
  43. 1 1
      packages/cpt_community/lib/router/page/community_page_router.gr.dart
  44. 2 1
      packages/cpt_facility/lib/modules/booking/facility_booking_view_model.dart
  45. 1 1
      packages/cpt_facility/lib/modules/booking/facility_booking_view_model.g.dart
  46. 91 30
      packages/cpt_facility/lib/modules/detail/facility_detail_page.dart
  47. 16 2
      packages/cpt_facility/lib/modules/detail/facility_detail_state.dart
  48. 22 2
      packages/cpt_facility/lib/modules/detail/facility_detail_view_model.dart
  49. 1 1
      packages/cpt_facility/lib/modules/detail/facility_detail_view_model.g.dart
  50. 7 8
      packages/cpt_facility/lib/modules/facility/active/facility_active_screen.dart
  51. 2 2
      packages/cpt_facility/lib/modules/facility/active/facility_active_state.dart
  52. 2 2
      packages/cpt_facility/lib/modules/facility/active/facility_active_view_model.dart
  53. 1 1
      packages/cpt_facility/lib/modules/facility/active/facility_active_view_model.g.dart
  54. 1 1
      packages/cpt_facility/lib/modules/facility/active/item_facility_active.dart
  55. 3 2
      packages/cpt_facility/lib/modules/facility/book/facility_book_state.dart
  56. 2 1
      packages/cpt_facility/lib/modules/facility/book/facility_book_view_model.dart
  57. 9 6
      packages/cpt_facility/lib/modules/facility/book/item_facility_book.dart
  58. 11 2
      packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_screen.dart
  59. 2 2
      packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_state.dart
  60. 2 2
      packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_view_model.dart
  61. 1 1
      packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_view_model.g.dart
  62. 1 1
      packages/cpt_facility/lib/modules/facility/deposit/item_facility_deposit.dart
  63. 0 52
      packages/cpt_facility/lib/modules/facility/facility_types.dart
  64. 1 1
      packages/cpt_facility/lib/modules/facility/history/facility_history_screen.dart
  65. 2 2
      packages/cpt_facility/lib/modules/facility/history/facility_history_state.dart
  66. 2 2
      packages/cpt_facility/lib/modules/facility/history/facility_history_view_model.dart
  67. 1 1
      packages/cpt_facility/lib/modules/facility/history/facility_history_view_model.g.dart
  68. 1 1
      packages/cpt_facility/lib/modules/facility/history/item_facility_history.dart
  69. 34 5
      packages/cpt_facility/lib/router/page/facility_page_router.gr.dart
  70. 1 1
      packages/cpt_main/lib/modules/feedback/create/feedback_create_view_model.dart
  71. 1 3
      packages/cpt_main/lib/modules/visitor/active/visitor_active.dart
  72. 3 2
      packages/cpt_main/lib/modules/visitor/active/visitor_active_state.dart
  73. 51 74
      packages/cpt_main/lib/modules/visitor/active/visitor_active_view_model.dart
  74. 0 3
      packages/cpt_main/lib/modules/visitor/history/visitor_history.dart
  75. 3 2
      packages/cpt_main/lib/modules/visitor/history/visitor_history_state.dart
  76. 47 70
      packages/cpt_main/lib/modules/visitor/history/visitor_history_view_model.dart
  77. 9 7
      packages/cpt_main/lib/modules/visitor/item_visitor.dart
  78. 3 5
      packages/cpt_main/lib/modules/visitor/register/visitor_register_page.dart
  79. 34 12
      packages/cpt_main/lib/modules/visitor/register/visitor_register_view_model.dart
  80. 0 18
      packages/cpt_main/lib/modules/visitor/visitor_view_model.dart
  81. 1 1
      packages/cpt_payment/lib/modules/add_card/add_card_view_model.g.dart
  82. 1 1
      packages/cpt_payment/lib/modules/choose_card/choose_card_view_model.g.dart
  83. 0 57
      packages/cpt_payment/lib/modules/payment/condo/active/condo_active_screen.dart
  84. 0 135
      packages/cpt_payment/lib/modules/payment/condo/active/item_condo_active.dart
  85. 0 31
      packages/cpt_payment/lib/modules/payment/condo/history/condo_history_state.dart
  86. 0 130
      packages/cpt_payment/lib/modules/payment/condo/history/condo_history_view_model.dart
  87. 0 27
      packages/cpt_payment/lib/modules/payment/condo/history/condo_history_view_model.g.dart
  88. 0 136
      packages/cpt_payment/lib/modules/payment/condo/history/item_condo_active.dart
  89. 0 130
      packages/cpt_payment/lib/modules/payment/condo/payment/condo_payment_view_model.dart
  90. 7 8
      packages/cpt_payment/lib/modules/payment/condo/history/condo_history_screen.dart
  91. 4 4
      packages/cpt_payment/lib/modules/payment/condo/active/condo_active_state.dart
  92. 5 6
      packages/cpt_payment/lib/modules/payment/condo/active/condo_active_view_model.dart
  93. 11 11
      packages/cpt_payment/lib/modules/payment/condo/active/condo_active_view_model.g.dart
  94. 2 2
      packages/cpt_payment/lib/modules/payment/condo/history/item_condo_history.dart
  95. 1 1
      packages/cpt_payment/lib/modules/payment/manage/manage_view_model.g.dart
  96. 11 7
      packages/cpt_payment/lib/modules/payment/condo/payment/item_condo_payment.dart
  97. 7 8
      packages/cpt_payment/lib/modules/payment/condo/payment/condo_payment_screen.dart
  98. 7 6
      packages/cpt_payment/lib/modules/payment/condo/payment/condo_payment_state.dart
  99. 25 0
      packages/cpt_payment/lib/modules/payment/payment/payment_list_types.dart
  100. 0 0
      packages/cpt_payment/lib/modules/payment/payment/payment_list_view_model.dart

+ 8 - 8
packages/cpt_community/lib/components/garage_card.dart

@@ -56,10 +56,10 @@ class GarageCard extends StatelessWidget {
     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", "");
+    int 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_avatar = card_account?['avatar']?? "";
     String card_publish_name = card_account?['name']?? "";
     bool card_liked = itemObj.getValue("liked", false);
     int card_likes_count = itemObj.getValue("likes_count", 0);
@@ -116,7 +116,7 @@ class GarageCard extends StatelessWidget {
             children: [
               Expanded(
                 child: MyTextView(
-                  card_price,
+                  '$card_price',
                   maxLines: 1,
                   isTextEllipsis: true,
                   textAlign: TextAlign.start,
@@ -144,7 +144,7 @@ class GarageCard extends StatelessWidget {
               children: [
                 if (useType == GarageCardUseType.forSale || useType == GarageCardUseType.forRent)
                   MyLoadImage(
-                    card_avator,
+                    card_avatar,
                     width: 30,
                     height: 30,
                     isCircle: true,
@@ -237,14 +237,14 @@ class CollectionWidget extends HookConsumerWidget {
     ).onTap(() async{
         // Log.d("点击了收藏按钮  ${isCollectionState.value}");
         // ToastEngine.show("点击了收藏按钮 ${isCollectionState.value}");
-        bool result = await onClickColleciotn?.call(isCollectionState.value);
-        if(result){
+        final result = await onClickColleciotn?.call(isCollectionState.value);
+        if(result !=null && 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");
+            // ToastEngine.show("Collect Success");
           }else {
-            ToastEngine.show("Cancel Collect Success");
+            // ToastEngine.show("Cancel Collect Success");
           }
         }
       })

+ 36 - 29
packages/cpt_community/lib/components/newsfeed_card_content.dart

@@ -9,23 +9,16 @@ 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:plugin_platform/engine/image/image_preview.dart';
 import 'package:router/componentRouter/component_service_manager.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/color_utils.dart';
+import 'package:shared/utils/goto_page.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/my_text_view.dart';
 
-// 'id':1,
-// 'avator': Assets.communityCamera,
-// '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.',
-// 'likeno': 12
-
 class NewsFeedCardContent extends StatelessWidget {
   final String content;
   final List<dynamic>? imageUrls;
@@ -57,7 +50,7 @@ class NewsFeedCardContent extends StatelessWidget {
           final maxHeight = constraints.maxHeight;
           final minHeight = constraints.minHeight;
           final maxWidth = constraints.maxWidth;
-          Log.d("---maxHeight-----$maxHeight-- $minHeight  $maxWidth--");
+          // Log.d("---maxHeight-----$maxHeight-- $minHeight  $maxWidth--");
           return Container(
             width: double.infinity,
             // color: Colors.red,
@@ -104,28 +97,42 @@ class NewsFeedCardContent extends StatelessWidget {
               imageUrls.length,
               (index) => Container(
                 height: 87,
-                width: maxWidth/imageCount - 16,
+                  width: (totalImageCount < rowMaxImageNum)? maxWidth/rowMaxImageNum - 16 : maxWidth/imageCount - 16,
                 margin: EdgeInsets.only(right: (index!=imageCount-1) ? 16 : 0 ),
-                // color: ColorUtils.string2Color("#F2F3F6"),
+                color: ColorUtils.string2Color("#F2F3F6"),
                 child:Stack(
                     children: [
-                      MyLoadImage(
-                        imageUrls[index],
-                        height: 87,
-                        // width: maxWidth/imageCount - 16,
-                        width: (totalImageCount < rowMaxImageNum)? maxWidth/rowMaxImageNum - 16 : maxWidth/imageCount - 16,
-                        fit: BoxFit.cover,
-                        // fit:BoxFit.fitWidth,
-                        cornerRadius: 5,
-                        onClick: (){
-                          if(isPreviewImage){
-                            // 点击图片预览
-                            // 过滤掉非字符串类型的元素
-                            List<String> filteredImages = totalImageUrls?.whereType<String>().toList() ?? [];
-                            // PreviewPhotoPage.startInstance(context: context, images: filteredImages, position: index);
-                            context.appRouter.push(PreviewPhotoPageRoute(images: filteredImages, position: index));
-                          }
-                        },
+                      Hero(
+                        tag: imageUrls[index],
+                        child: MyLoadImage(
+                          imageUrls[index],
+                          height: 87,
+                          // width: maxWidth/imageCount - 16,
+                          width: (totalImageCount < rowMaxImageNum)? maxWidth/rowMaxImageNum - 16 : maxWidth/imageCount - 16,
+                          fit: BoxFit.cover,
+                          // fit:BoxFit.fitWidth,
+                          cornerRadius: 5,
+                          onClick: (){
+                            if(isPreviewImage){
+                              // 点击图片预览
+                              // 过滤掉非字符串类型的元素
+                              List<String> filteredImages = totalImageUrls?.whereType<String>().toList() ?? [];
+                              // PreviewPhotoPage.startInstance(context: context, images: filteredImages, position: index);
+                              // context.appRouter.push(PreviewPhotoPageRoute(images: filteredImages, position: index));
+                              // ImagePreviewEngine.multipleImagePreview(
+                              //     context,
+                              //     filteredImages,
+                              //     heroes: List.generate(filteredImages.length, (index) => filteredImages[index]),
+                              //     onLongPressAction: (url) {}
+                              // );
+                              GotoPage.pushPageByFade(
+                                  context: context,
+                                  targetPage:
+                                  PreviewPhotoPage(images: filteredImages, position: index),
+                              );
+                            }
+                          },
+                        ),
                       ),
                       otherImageCount > 0 && index == imageCount-1 ?
                         Positioned(

+ 112 - 80
packages/cpt_community/lib/modules/community/community_page.dart

@@ -5,6 +5,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/provider/user_config/user_config_service.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:shared/utils/log_utils.dart';
@@ -22,11 +23,11 @@ import 'community_vm.dart';
 import 'customSilverHeaderTabs.dart';
 
 final tabsRouterKey = GlobalKey<AutoTabsRouterState>();
-
-
+final GlobalKey<ExtendedNestedScrollViewState> extendedNestedScrollViewKey =
+GlobalKey<ExtendedNestedScrollViewState>();
 @RoutePage()
-class CommunityPage extends HookConsumerWidget {
-    const CommunityPage({Key? key}) : super(key: key);
+class CommunityPage extends HookConsumerWidget with WidgetsBindingObserver {
+    CommunityPage({Key? key}) : super(key: key);
 
     //启动当前页面
     static void startInstance({BuildContext? context}) {
@@ -37,11 +38,62 @@ class CommunityPage extends HookConsumerWidget {
       }
     }
 
+    bool _isKeyboardVisible = false;
+
+    void handlerNestedScrollViewScroll({double? outerOffset, double? innerOffset, bool? isOuterScrollAnimated=false, bool? isInnerScrollAnimated=false}){
+
+      if(outerOffset !=null){
+        if(isOuterScrollAnimated!){
+          extendedNestedScrollViewKey.currentState?.outerController.animateTo(
+            outerOffset,
+            duration: const Duration(seconds: 1),
+            curve: Curves.easeIn,
+          );
+        }else {
+          extendedNestedScrollViewKey.currentState?.outerController.jumpTo(
+            outerOffset,
+          );
+        }
+      }
+
+      if(innerOffset !=null){
+        extendedNestedScrollViewKey.currentState?.innerPositions.forEach((position) {
+          if(isInnerScrollAnimated!){
+            position.animateTo(innerOffset,
+                duration: Duration(seconds: 1), curve: Curves.easeIn);
+          }else {
+            position.jumpTo(innerOffset);
+          }
+        });
+      }
+    }
+
+    @override
+    void didChangeMetrics() {
+      final bottomInset = WidgetsBinding.instance.window.viewInsets.bottom;
+      final newValue = bottomInset > 0.0;
+      if (_isKeyboardVisible != newValue) {
+          _isKeyboardVisible = newValue;
+        if (_isKeyboardVisible) {
+          handlerNestedScrollViewScroll(innerOffset: 0.0,);
+          print("键盘已显示");
+        } else {
+          WidgetsBinding.instance.removeObserver(this);
+          print("键盘已隐藏");
+        }
+      }
+    }
+
     @override
     Widget build(BuildContext context, WidgetRef ref) {
         final vm = ref.read(communityVmProvider.notifier);
         final state = ref.watch(communityVmProvider);
 
+        useEffect(() {
+          // 监听窗口
+          WidgetsBinding.instance.addObserver(this);
+        }, []);
+
         useEffect((){
           Log.d("CommunityPage initState");
           // 延迟监听
@@ -55,6 +107,7 @@ class CommunityPage extends HookConsumerWidget {
 
           return (){
             Log.d("CommunityPage dispose");
+            WidgetsBinding.instance.removeObserver(this);
             tabsRouterKey.currentState?.controller?.removeListener(vm.tabsRouterChange);
           };
         },[]);
@@ -62,6 +115,7 @@ class CommunityPage extends HookConsumerWidget {
         return Scaffold(
             appBar: MyAppBar.searchAppBar(
               context,
+              value: vm.getCurrentQueryParams('keyword'),
               actions: [
                  const MyAssetImage(
                   Assets.communityLikeActive,
@@ -82,25 +136,28 @@ class CommunityPage extends HookConsumerWidget {
                 const SizedBox(width: 15),
               ],
               backgroundColor: context.appColors.backgroundWhite,
+              onSearch: (value) {
+                vm.handlerSearch(value);
+              }
             ),
           backgroundColor: context.appColors.backgroundDefault,
-          body:  NestedScrollView(
+          body:  ExtendedNestedScrollView(
+            key: extendedNestedScrollViewKey,
+              onlyOneScrollInBody: true,
             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),
-              // ),
+                // SliverPersistentHeader(
+                //   delegate: CustomSliverPersistentHeaderDelegate(
+                //     maxHeight: 180,
+                //     minHeight: 180,
+                //     child: _buildTopSection(context, ref, vm, state),
+                //   ),
+                //   pinned: false,
+                // ),
+                // top 组件,转换为 Sliver 组件
+                SliverToBoxAdapter(
+                  child: _buildTopSection(context, ref, vm, state),
+                ),
               ];
             },
             body: Column(
@@ -122,7 +179,9 @@ class CommunityPage extends HookConsumerWidget {
                           children: [
                             _buildTabsSection(context, ref, tabsRouter, vm, state),
                             _buildPostSection(context, ref, vm, state),
-                            Expanded(child: child),
+                            Expanded(
+                                child: child
+                            ),
                           ],
                         );
                       },
@@ -131,52 +190,6 @@ class CommunityPage extends HookConsumerWidget {
               ]
             )
           )
-
-          // 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 组件和其他内容
-          //     );
-          //   },
-          // ),
         );
     }
 
@@ -209,6 +222,7 @@ class CommunityPage extends HookConsumerWidget {
                       height: 70,
                       decoration: BoxDecoration(
                         shape: BoxShape.circle, // 设置为圆形
+                        color: ColorUtils.string2Color("#F0F8FF"),
                         boxShadow: index == curTagIdx ? [
                           BoxShadow(
                             color: context.appColors.tabLightBlueShadow, // 设置阴影颜色
@@ -220,6 +234,7 @@ class CommunityPage extends HookConsumerWidget {
                       child: MyAssetImage(
                         item['icon'],
                         width: MediaQuery.of(context).size.width / topSectionsData.length - 36,
+                        // width: 70,
                         height: 70,
                       ).onTap(() {
                           vm.handlerSwitchNewsfeedOrGaragesale(index, context, null);
@@ -256,20 +271,22 @@ class CommunityPage extends HookConsumerWidget {
        }
        return Container(
         width: double.infinity,
-        padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 12),
         color: ColorUtils.string2Color('#F2F3F6'),
-        child: NewsfeedTabs(
-          key: UniqueKey(),
-          tabsList: tabsList,
-            tabsRouter: tabsRouter,
-          onClickAction:(Map<String, dynamic>? params){
-            if (params != null) {
-              // 解构 params
-              final int? currentCatgoryIdx = params['currentCatgoryIdx'] as int?;
-              final int? tabIdx = params['tabIdx'] as int?;
-              vm.handlerChangeTab(tabIdx, tabsRouter, currentCatgoryIdx);
+        child: Center(
+          child: NewsfeedTabs(
+            key: UniqueKey(),
+            tabsList: tabsList,
+              tabsRouter: tabsRouter,
+            margin: EdgeInsets.only(top: 14,bottom: 12, left: 20, right: 20),
+            onClickAction:(Map<String, dynamic>? params){
+              if (params != null) {
+                // 解构 params
+                final int? currentCatgoryIdx = params['currentCatgoryIdx'] as int?;
+                final int? tabIdx = params['tabIdx'] as int?;
+                vm.handlerChangeTab(tabIdx, tabsRouter, currentCatgoryIdx);
+              }
             }
-          }
+          ),
         ),
       );
     }
@@ -287,6 +304,7 @@ class CommunityPage extends HookConsumerWidget {
       }
 
       Widget _buildNewsFeedPost(BuildContext context, WidgetRef ref, vm, state){
+        final userConfig = UserConfigService.getState(ref: ref);
         return Container(
           height: 65.5,
           width: double.infinity,
@@ -294,7 +312,14 @@ class CommunityPage extends HookConsumerWidget {
           color: Colors.white,
           child: Row(
             children: [
-              const MyAssetImage(Assets.communityNesFeed, width: 45,height: 45,),
+              // const MyAssetImage(Assets.communityNewsFeed, width: 45,height: 45,),
+              MyLoadImage(
+                userConfig.user?.avatar,
+                width: 45,
+                height: 45,
+                isCircle: true,
+                fit: BoxFit.fill,
+              ),
               Expanded(
                 child: MyTextView(
                   "What’s on your mind?",
@@ -321,6 +346,7 @@ class CommunityPage extends HookConsumerWidget {
       }
 
       Widget _buildGarageSalePost(BuildContext context, WidgetRef ref, vm, state){
+        final userConfig = UserConfigService.getState(ref: ref);
         return Container(
           height: 65.5,
           width: double.infinity,
@@ -328,7 +354,13 @@ class CommunityPage extends HookConsumerWidget {
           color: Colors.white,
           child: Row(
             children: [
-              const MyAssetImage(Assets.communityNesFeed, width: 45,height: 45,),
+              MyLoadImage(
+                userConfig.user?.avatar,
+                width: 45,
+                height: 45,
+                isCircle: true,
+                fit: BoxFit.fill,
+              ),
               Expanded(
                 child: MyTextView(
                   "Sell Item",

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

@@ -29,7 +29,7 @@ class CommunityVmState {
   }) : topSectionsData = topSectionsData?? [
     {
       "title": "News Feed",
-      "icon": Assets.communityNesFeed,
+      "icon": Assets.communityNews,
     },
     {
       "title": "Garage Sale",

+ 227 - 91
packages/cpt_community/lib/modules/community/community_vm.dart

@@ -10,10 +10,11 @@ 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_basic/constants/app_constant.dart';
 import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
+import 'package:plugin_platform/engine/sp/sp_util.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:router/path/router_path.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:widgets/dialog/app_custom_dialog.dart';
@@ -22,13 +23,10 @@ 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';
@@ -38,39 +36,84 @@ class CommunityVm extends _$CommunityVm {
   get topSectionsData => state.topSectionsData;
   late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
   late CommonGarageRespository commonGarageRespositoryInstance;
+  late Map<int, dynamic> providerMap = {};
 
-  final Map<int, dynamic> providerMap = {};
+  bool _isSingleSelect = true;
+  List<Map<String, dynamic>> _currentSelectedGarageCategory = [];
 
-// 根据索引获取 Provider
+  Map<int, Map<String, dynamic>> _queryParams = {};
+
+  // 获取当前的查询参数
+  getCurrentQueryParams(String key) {
+    return _queryParams[state.currentPageViewIdx]?[key];
+  }
+
+  // 根据索引获取 Provider
   ProviderBase getProvider(int index) {
     return providerMap[index]!;
   }
 
   CommunityVmState initState() {
+    List<String> newsFeedTabsList = [
+      "News",
+      "Following",
+      "For You",
+    ];
+    List<String> garageSaleTabsList = [
+      "For Sale",
+      "For Rent",
+    ];
+
+    List<String> COMMUNITY_TABS_LIST = [...newsFeedTabsList];
+    COMMUNITY_TABS_LIST.addAll(garageSaleTabsList);
+
+
+    // s.add(garageSaleTabsList);
+    Log.d("COMMUNITY_TABS_LIST   $COMMUNITY_TABS_LIST");
+    // Log.d("s   $newsFeedTabsList");
+    COMMUNITY_TABS_LIST.asMap().forEach((index, value) {
+      _queryParams[index] = {
+        'keyword': null,
+        'is_liked': null,
+        'category_id': null,
+        'category_name': null,
+        'page_view_idx': index,
+        'page_view_name': value,
+      };
+    });
+
     return CommunityVmState(
       currentCategoryIdx: 0,
       currentPageViewIdx: 0,
       lastGarageTabIdx: 0,
       lastNewsfeedTabIdx: 0,
-      newsFeedTabsList: [
-        "News",
-        "Following",
-        "For You",
-      ],
-      garageSaleTabsList: [
-        "For Sale",
-        "For Rent",
-      ],
+      newsFeedTabsList: newsFeedTabsList,
+      garageSaleTabsList: garageSaleTabsList,
     );
   }
 
   @override
   CommunityVmState build(){
+
     // 引入数据仓库
     commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
     final state = initState();
-    // 第一帧渲染完成
+
+    setCurrentPageViewIconStatus();
+    getPageViewVm();
+
+    Log.d("-------------community vm-------------build---------------------");
+    ref.onDispose((){
+      providerMap = {};
+      Log.d("-------------community vm-------------dispose---------------------");
+    });
+    return state;
+  }
+
+  // 搜集pageView 对应的vm
+  void getPageViewVm(){
+    // 每次切换后需要重新获取 一组 pageView的 vm
     WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
       // 存入 一组 pageView的 vm
       CommunityPageViewIdxData.values.forEach((key, value) {
@@ -91,23 +134,26 @@ class CommunityVm extends _$CommunityVm {
             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---------------------");
+  }
+
+  // 设置当前导航栏的 图标 等状态
+  void setCurrentPageViewIconStatus(){
+    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
+      Log.d("获取当前的导航栏 相关状态resMap444 ${providerMap[state.currentPageViewIdx]} ");
+      Map<String, dynamic> resMap = providerMap[state.currentPageViewIdx]?.getCurrentQueryParams(null)??{};
+      Log.d("获取当前的导航栏 相关状态resMap $resMap ");
+      _queryParams[state.currentPageViewIdx] = resMap;
     });
-    return state;
   }
 
   tabsRouterChange(){
+    // 设置当前导航栏的 图标 等状态
     Log.d("----tabsRouterChange---${tabsRouterKey.currentState?.controller?.activeIndex}-");
-    
     state = state.copyWith(currentPageViewIdx: tabsRouterKey.currentState?.controller?.activeIndex ?? 0);
+
+    setCurrentPageViewIconStatus();
+    getPageViewVm();
   }
 
   // 点击tab 切换tab
@@ -119,6 +165,7 @@ class CommunityVm extends _$CommunityVm {
     }else {
       tabsRouter.setActiveIndex(state.newsFeedTabsList!.length + tabIndex);
     }
+
   }
 
   // 获取当前pageView 的vm
@@ -162,13 +209,7 @@ class CommunityVm extends _$CommunityVm {
   }
 
   // 获取garage sale 分类选项
-  Future getGarageSaleCategoryOptions() async{
-    final Map<String, dynamic> params = {};
-    final result = await commonGarageRespositoryInstance.fetchGarageCateGoryList(params);
-    return result;
-  }
-  // 选择 garage sale 导航栏点击 选择分类
-  handlerChooseGarageCategory(BuildContext context) async {
+  Future<List<Map<String, dynamic>>> getGarageSaleCategoryOptions() async{
     List<Map<String, dynamic>> garageCategoryList = [
       // {
       //   'id': '1',
@@ -199,79 +240,173 @@ class CommunityVm extends _$CommunityVm {
       //   'name': 'Others',
       // },
     ];
-
     // 获取分类列表
     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
-        );
+      // 加入有缓存 就取缓存
+      List<Map<String, dynamic>>? StorageCategoryList = SPUtil.getObjectList(
+          AppConstant.storageGarageCategoryList)?.cast<Map<String, dynamic>>();
 
-        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: (){
-
-              },
-            )
-        );
+      if (StorageCategoryList != null && StorageCategoryList.isNotEmpty) {
+        Log.d("取StorageCategoryList 缓存: $StorageCategoryList ");
+        garageCategoryList = StorageCategoryList;
+      } else {
+        Map<String, dynamic> params = {};
+        final result = await commonGarageRespositoryInstance
+            .fetchGarageCateGoryList(params);
+        if (result.isSuccess) {
+          final listJson = result.getListJson();
+          // 将 listJson 转换为 List<Map<String, dynamic>>
+          garageCategoryList = (listJson as List?)
+              ?.map((item) => item as Map<String, dynamic>)
+              .toList() ?? [];
+          // 将 garageCategoryList 存入缓存
+          Log.d("设置StorageCategoryList 缓存");
+          SPUtil.putObjectList(
+              AppConstant.storageGarageCategoryList, garageCategoryList);
+        }
       }
-    }catch(error){
-      Log.d("---------------- $error");
+    } catch(error){
+
     }
+    return garageCategoryList;
+  }
+  // 选择 garage sale 导航栏点击 选择分类
+  handlerChooseGarageCategory(BuildContext context) async {
+      List<Map<String, dynamic>> garageCategoryList = await getGarageSaleCategoryOptions();
+      // 显示弹框
+      handlerShowChooseGarageCategoryDialog(context, garageCategoryList);
 
+      state = state.copyWith(
+          garageCategoryList: garageCategoryList
+      );
+  }
+
+  Future<void> handlerShowChooseGarageCategoryDialog(BuildContext context, List<Map<String, dynamic>> garageCategoryList) async{
+    await DialogEngine.show(
+        tag: "chooseGarageSaleCategory",
+        position: DialogPosition.center,
+        widget: AppCustomDialog(
+          message: '',
+          dialogWidth: MediaQuery.of(context).size.width * 0.8,
+          // contentBoxMaxHeight: 350,
+          // contentBoxMinHeight: 300,
+          isShowConfirmBtn: 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: garageCategoryList!.length > 0 ? [
+                  MyCheckboxGroup(
+                      isSingleSelect: _isSingleSelect,
+                      labelStyle: const TextStyle(
+                        fontSize: 16,
+                        fontWeight: FontWeight.w500,
+                      ),
+                      items: garageCategoryList!,
+                      defaultSelectedItems: [],
+                      onChanged: (List<Map<String, dynamic>> selectedItems){
+                        Log.d("----MyCheckboxGroup onChanged  $selectedItems");
+                        _currentSelectedGarageCategory = selectedItems;
+                      }
+                  )
+                ]: [
+                  Container(
+                    child: CircularProgressIndicator(
+                      strokeWidth: 3,
+                      valueColor: AlwaysStoppedAnimation(context.appColors.textDarkGray),
+                    ),
+                  )
+                ],
+              ),
+            );
+          },
+          isShowCancelBtn:false,
+          confirmAction: (){
+            // 点击了确定
+            Log.d("----点击了确定按钮");
+            int? categoryId;
+            if(_isSingleSelect){
+              if(_currentSelectedGarageCategory.length > 0){
+                categoryId = _currentSelectedGarageCategory[0]['id'];
+              }
+            }
+
+            providerMap[state.currentPageViewIdx]
+              ..setCurrentQueryParams({
+                "category_id": _queryParams?[state.currentPageViewIdx]?['categoryId'],
+              })
+              ..directRefresh();
+          },
+        )
+    );
+  }
+
+  // 搜索
+  handlerSearch(String value){
+    Log.d("community_vm 中 搜索 value: $value");
+    _queryParams?[state.currentPageViewIdx]?['keyword'] = value;
+    providerMap[state.currentPageViewIdx]
+      ..setCurrentQueryParams({
+        "keyword": _queryParams?[state.currentPageViewIdx]?['keyword'],
+      })
+      ..directRefresh();
   }
 
   // 点击了导航栏的 like btn
   handlerClickNavbarLikeBtn(BuildContext? context){
     if(state.currentCategoryIdx ==0){
       //
-      ToastEngine.show("点击了 newsfeed like");
+      // ToastEngine.show("点击了 newsfeed like");
+
     }else if(state.currentCategoryIdx == 1){
       //
-      ToastEngine.show("点击了 garagesale like");
+      // ToastEngine.show("点击了 garagesale like");
+
+    }
+
+    _queryParams[state.currentPageViewIdx]?['is_liked'] = !(_queryParams?[state.currentPageViewIdx]?['is_liked']??false);
+
+
+    // 控制外层滚动和内层滚动
+    handlerNestedScrollViewScroll();
+
+    providerMap[state.currentPageViewIdx]
+      ..setCurrentQueryParams({
+        "is_liked": _queryParams?[state.currentPageViewIdx]?['is_liked'],
+      })
+      ..directRefresh();
 
+    // providerMap[state.currentPageViewIdx].directRefresh();
+  }
+
+  handlerNestedScrollViewScroll({double? outerOffset, double? innerOffset=0.0, bool? isOuterScrollAnimated=false, bool? isInnerScrollAnimated=false}){
+
+    if(outerOffset !=null){
+      if(isOuterScrollAnimated!){
+        extendedNestedScrollViewKey.currentState?.outerController.animateTo(
+          outerOffset,
+          duration: const Duration(seconds: 1),
+          curve: Curves.easeIn,
+        );
+      }else {
+        extendedNestedScrollViewKey.currentState?.outerController.jumpTo(
+          outerOffset,
+        );
+      }
+    }
+
+    if(innerOffset !=null){
+      extendedNestedScrollViewKey.currentState?.innerPositions.forEach((position) {
+        if(isInnerScrollAnimated!){
+          position.animateTo(innerOffset,
+              duration: Duration(seconds: 1), curve: Curves.easeIn);
+        }else {
+          position.jumpTo(innerOffset);
+        }
+      });
     }
   }
 
@@ -302,6 +437,7 @@ class CommunityVm extends _$CommunityVm {
           }
         }
     });
+
     GaragesalePostPage.startInstance(type: type);
   }
 

+ 5 - 3
packages/cpt_community/lib/modules/community/customSilverHeaderTabs.dart

@@ -2,14 +2,16 @@ import 'package:flutter/cupertino.dart';
 
 class CustomSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
    final Widget child;
+   double maxHeight = 100.0;
+   double minHeight = 100.0;
 
-   CustomSliverPersistentHeaderDelegate({required this.child});
+   CustomSliverPersistentHeaderDelegate({required this.child, required this.maxHeight, required this.minHeight});
 
    @override
-   double get minExtent => 100.0; // 最小高度
+   double get maxExtent => maxHeight; // 最大高度
 
    @override
-   double get maxExtent => 100.0; // 最大高度
+   double get minExtent => minHeight; // 最小高度
 
    @override
    Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {

+ 6 - 13
packages/cpt_community/lib/modules/community/following/following_page.dart

@@ -7,7 +7,6 @@ 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';
-import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/my_button.dart';
 import 'package:widgets/my_load_image.dart';
@@ -40,7 +39,7 @@ class FollowingPage extends HookConsumerWidget {
 
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final vm = ref.read(followingVmProvider.notifier);
+    final vm = ref.watch(followingVmProvider.notifier);
     final state = ref.watch(followingVmProvider);
     bool isVisible = false;
     useEffect((){
@@ -63,15 +62,9 @@ class FollowingPage extends HookConsumerWidget {
             Expanded(
               child:  EasyRefresh(
                 controller: vm.refreshController,
-                key: UniqueKey(),
-                onLoad: () async{
-                  Log.d("--following--onLoad");
-                  vm.loadMore();
-                },
-                onRefresh: () async{
-                  Log.d("--following--onRefresh");
-                  vm.onRefresh();
-                },
+                key: const PageStorageKey<String>('news'),
+                onLoad: vm.loadMore,
+                onRefresh: vm.onRefresh,
                 child: LoadStateLayout(
                   state: state.loadingState,
                   errorMessage: state.errorMessage,
@@ -100,7 +93,7 @@ class FollowingPage extends HookConsumerWidget {
     String card_title = item.getValue("title", "");
     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_avatar = card_account?['avatar']?? "";
     String card_count_name = card_account?['name']?? "";
     bool card_followed = card_account?['followed']??false;
     String card_content = item.getValue("content", "");
@@ -134,7 +127,7 @@ class FollowingPage extends HookConsumerWidget {
                   child: NewsFeedCardHeader(
                     key: UniqueKey(),
                     title: card_count_name,
-                    avator: card_avator,
+                    avator: card_avatar,
                     time: card_created_at,
                   ),
                 ),

+ 43 - 29
packages/cpt_community/lib/modules/community/following/following_vm.dart

@@ -23,6 +23,11 @@ class FollowingVm extends _$FollowingVm {
   int _page = 1;  // 当前页
   int _limit = 10; // 每页数量
   int _count = 0; // 总条数
+
+  Map<String, dynamic> _queryParams = {
+    'keyword': null,
+    'is_liked': null,
+  };
   
   bool _needShowPlaceholder = false; //是否展示LoadingView
   // Refresh 控制器
@@ -63,59 +68,55 @@ class FollowingVm extends _$FollowingVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.following);
-    if(isShowing){
       Log.d("----following_vm-----loadMore");
-      // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= _count){
-      //   return;
-      // }else {
-      //   int page = _page + 1;
-      //   state = state.copyWith(page: page,);
-      //   getListData();
-      // }
       _page++;
       getListData();
-    }else {
-      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));
       _page = 1;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
+  }
+
+  // 手动进行刷新
+  Future triggerRefresh() async {
+    Log.d("trggerRefresh");
+    refreshController.callRefresh();
+  }
+
+  // 手动进行刷新
+  Future directRefresh() async {
+    state = state.copyWith(list:[]);
+    // 注意:由于 nestedscrollview 嵌套easyfresh 组件  refreshController.callRefresh() 自动刷新只能滚动顶部但是不会触发下拉刷新,这里调用是 用到了将其滚动到顶部的作用,进而刷新操作主动掉接口
+    // https://github.com/xuelongqy/flutter_easy_refresh/issues/692
+    refreshController.callRefresh();
+    refreshController.resetFooter();
+    _page = 1;
+    _needShowPlaceholder = true;
+    getListData();
   }
 
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.following);
-    if(isShowing){
+      Log.d("重新加载数据---9999-----");
       _page = 1;
-      _needShowPlaceholder = true;
+      refreshController.resetFooter();
+      _needShowPlaceholder = false;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
 
   // 获取list 列表数据
   Future getListData<T>() async {
     if (_needShowPlaceholder) {
+      Log.d("修改加载状态---LoadState.State_Loading-----");
       changeLoadingState(LoadState.State_Loading, null);
     }
-    Log.d("加载listData数据---------------start--${_page}---");
 
     try {
       //请求网络
@@ -136,8 +137,8 @@ class FollowingVm extends _$FollowingVm {
     } catch (e) {
       ToastEngine.show("Error: $e");
     }
-    // // 最后赋值
-    // _needShowPlaceholder = false;
+    // 最后赋值
+    _needShowPlaceholder = false;
   }
 
 
@@ -149,12 +150,12 @@ class FollowingVm extends _$FollowingVm {
         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();
       }
@@ -280,6 +281,19 @@ class FollowingVm extends _$FollowingVm {
     }
   }
 
+  // 设置当前的 _queryParams
+  setCurrentQueryParams(Map<String, dynamic> params){
+    _queryParams.addAll(params);
+  }
+
+  // 获取当前的 _queryParams
+  Map<String, dynamic> getCurrentQueryParams(String? key){
+    if(key!=null && key!.isNotEmpty){
+      return _queryParams[key];
+    }
+    return _queryParams;
+  }
+
   // 去详情页面
   void handlerGotoDetail(BuildContext? context, int id){
     Log.d("去详情页面");

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

@@ -63,7 +63,7 @@ class ForyouPage extends HookConsumerWidget {
             Expanded(
               child: EasyRefresh(
                 controller: vm.refreshController,
-                key: UniqueKey(),
+                key: const PageStorageKey<String>('news'),
                 onLoad: () async{
                   Log.d("--foryou--onLoad");
                   vm.loadMore();
@@ -100,7 +100,7 @@ class ForyouPage extends HookConsumerWidget {
     String card_title = item.getValue("title", "");
     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_avatar = card_account?['avatar']?? "";
     String card_count_name = card_account?['name']?? "";
     bool card_followed = card_account?['followed']??false;
     String card_content = item.getValue("content", "");
@@ -134,7 +134,7 @@ class ForyouPage extends HookConsumerWidget {
                   child: NewsFeedCardHeader(
                     key: UniqueKey(),
                     title: card_count_name,
-                    avator: card_avator,
+                    avator: card_avatar,
                     time: card_created_at,
                   ),
                 ),

+ 47 - 151
packages/cpt_community/lib/modules/community/foryou/foryou_vm.dart

@@ -25,6 +25,12 @@ class ForyouVm extends _$ForyouVm {
   int _page = 1;  // 当前页
   int _limit = 10; // 每页数量
   int _count = 0; // 总条数
+
+  Map<String, dynamic> _queryParams = {
+    'keyword': null,
+    'is_liked': null,
+  };
+
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -64,38 +70,37 @@ class ForyouVm extends _$ForyouVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forYou);
-    if(isShowing){
-      Log.d("----foryou_vm-----loadMore");
-      // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= _count){
-      //   return;
-      // }else {
-      //   int page = _page + 1;
-      //   state = state.copyWith(page: page,);
-      //   getListData();
-      // }
-      // 检查 page 是否为 null,并初始化为 1
-      _page++;
-      getListData();
-    }else {
-      refreshController.finishLoad();
-    }
+    Log.d("----foryou_vm-----loadMore");
+    _page++;
+    getListData();
+  }
+
+  // 手动进行刷新
+  Future triggerRefresh() async {
+    Log.d("trggerRefresh");
+    refreshController.callRefresh();
   }
 
 
   // 下拉刷新
   Future onRefresh() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forYou);
-    if(isShowing){
-      // 当前pageView 页面正处于显示状态
-      Log.d("----forsale_vm-----onRefresh ");
-      // await Future.delayed(const Duration(seconds: 2));
-      _page = 1;
-      getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
+    // 当前pageView 页面正处于显示状态
+    Log.d("----forsale_vm-----onRefresh ");
+    // await Future.delayed(const Duration(seconds: 2));
+    _page = 1;
+    getListData();
+  }
+
+  // 手动进行刷新
+  Future directRefresh() async {
+    state = state.copyWith(list:[]);
+    // 注意:由于 nestedscrollview 嵌套easyfresh 组件  refreshController.callRefresh() 自动刷新只能滚动顶部但是不会触发下拉刷新,这里调用是 用到了将其滚动到顶部的作用,进而刷新操作主动掉接口
+    // https://github.com/xuelongqy/flutter_easy_refresh/issues/692
+    refreshController.callRefresh();
+    refreshController.resetFooter();
+    _page = 1;
+    _needShowPlaceholder = true;
+    getListData();
   }
 
   // 重试请求
@@ -115,130 +120,6 @@ class ForyouVm extends _$ForyouVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("加载listData数据---------------start--${_page}---");
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": _page,
-    //       "limit": _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 (_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 = {
@@ -258,6 +139,8 @@ class ForyouVm extends _$ForyouVm {
     } catch (e) {
       ToastEngine.show("Error: $e");
     }
+    // 最后赋值
+    _needShowPlaceholder = false;
   }
 
 
@@ -401,6 +284,19 @@ class ForyouVm extends _$ForyouVm {
     }
   }
 
+  // 设置当前的 _queryParams
+  setCurrentQueryParams(Map<String, dynamic> params){
+    _queryParams.addAll(params);
+  }
+
+  // 获取当前的 _queryParams
+  Map<String, dynamic> getCurrentQueryParams(String? key){
+    if(key!=null && key!.isNotEmpty){
+      return _queryParams[key];
+    }
+    return _queryParams;
+  }
+
   // 去详情页面
   void handlerGotoDetail(BuildContext? context, int id){
     Log.d("去详情页面");

+ 7 - 3
packages/cpt_community/lib/modules/community/news/news_page.dart

@@ -1,4 +1,5 @@
 import 'package:cs_resources/generated/assets.dart';
+import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:flutter/rendering.dart';
@@ -16,6 +17,7 @@ import 'package:widgets/my_text_view.dart';
 import 'package:widgets/my_appbar.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
 import 'package:widgets/widget_export.dart';
+import 'package:easy_refresh/easy_refresh.dart';
 
 import '../../../components/newfeed_card_header.dart';
 import '../../../components/newsfeed_card_content.dart';
@@ -63,12 +65,13 @@ class NewsPage extends HookConsumerWidget {
         children: [
           Expanded(
             child: EasyRefresh(
+              key: const PageStorageKey<String>('news'),
               controller: vm.refreshController,
-              key: UniqueKey(),
               onLoad: () async{
                 Log.d("--news--onLoad");
                 vm.loadMore();
               },
+
               onRefresh: () async{
                 Log.d("--news--onRefresh");
                 vm.onRefresh();
@@ -79,6 +82,7 @@ class NewsPage extends HookConsumerWidget {
                 errorRetry: () {
                   vm.retryRequest();
                 },
+                  // sliverScrollController: vm.scrollController,
                 successSliverWidget: [
                   SliverList(
                     delegate: SliverChildBuilderDelegate(
@@ -102,7 +106,7 @@ class NewsPage extends HookConsumerWidget {
     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", null);
-    String card_avator = card_account?['avator']?? "";
+    String card_avatar = card_account?['avatar']?? "";
     String card_count_name = card_account?['name']?? "";
     bool card_followed = card_account?['followed']??false;
     int card_count_id = card_account?['id']?? null;
@@ -139,7 +143,7 @@ class NewsPage extends HookConsumerWidget {
                     child: NewsFeedCardHeader(
                       key: UniqueKey(),
                       title: card_count_name,
-                      avator: card_avator,
+                      avator: card_avatar,
                       time: card_created_at,
                     ),
                   ),

+ 48 - 26
packages/cpt_community/lib/modules/community/news/news_vm.dart

@@ -9,6 +9,7 @@ import 'package:shared/utils/ext_dart.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
+import 'package:easy_refresh/easy_paging.dart';
 
 import '../../../router/page/community_page_router.dart';
 import '../community_pageview_idx_data.dart';
@@ -26,9 +27,18 @@ class NewsVm extends _$NewsVm {
   int _page = 1;  // 当前页
   int _limit = 10; // 每页数量
   int _count = 0; // 总条数
+
+  Map<String, dynamic> _queryParams = {
+    'keyword': null,
+    'is_liked': null,
+  };
   
   bool _needShowPlaceholder = false; //是否展示LoadingView
 
+  // Scroll 控制器
+  final ScrollController scrollController = ScrollController();
+
+
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -67,60 +77,55 @@ class NewsVm extends _$NewsVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.news);
-    if(isShowing){
       Log.d("----news_vm-----loadMore");
-      // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= _count){
-      //   return;
-      // }else {
-      //   int page = _page + 1;
-      //   state = state.copyWith(page: page,);
-      //   getListData();
-      // }
       _page++;
       getListData(isLoadMore: true);
-    }else {
-      refreshController.finishLoad();
-    }
   }
 
 
   // 下拉刷新
   Future onRefresh() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.news);
-    if(isShowing){
       // 当前pageView 页面正处于显示状态
-      Log.d("----forsale_vm-----onRefresh ");
+      Log.d("----news_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
       _page = 1;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
+  }
+
+  // 手动进行刷新
+  Future triggerRefresh() async {
+    Log.d("trggerRefresh");
+    refreshController.callRefresh();
   }
 
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.news);
-    if(isShowing){
       _page = 1;
       _needShowPlaceholder = true;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
+      Log.d("99999999");
+      // refreshController.callRefresh();
   }
 
+  // 手动进行刷新
+  Future directRefresh() async {
+    state = state.copyWith(list:[]);
+    // 注意:由于 nestedscrollview 嵌套easyfresh 组件  refreshController.callRefresh() 自动刷新只能滚动顶部但是不会触发下拉刷新,这里调用是 用到了将其滚动到顶部的作用,进而刷新操作主动掉接口
+    // https://github.com/xuelongqy/flutter_easy_refresh/issues/692
+    // refreshController.callRefresh();
+    refreshController.resetFooter();
+    _page = 1;
+    _needShowPlaceholder = true;
+    getListData();
+  }
 
   // 获取list 列表数据
   Future getListData<T>({bool? isLoadMore}) async {
+    Log.d("getListData   _needShowPlaceholder: $_needShowPlaceholder");
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("加载listData数据---------------start--${_page}---");
-
     try {
       //请求网络
       Map<String, dynamic>  params = {
@@ -140,6 +145,8 @@ class NewsVm extends _$NewsVm {
     } catch (e) {
       ToastEngine.show("Error: $e");
     }
+
+    _needShowPlaceholder = false;
   }
 
 
@@ -147,6 +154,7 @@ class NewsVm extends _$NewsVm {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_page == 1) {
+        refreshController.resetFooter();
         //刷新的方式
         state.list!.clear();
         state.list!.addAll(list.map((item) => item.toJson()).toList());
@@ -283,6 +291,20 @@ class NewsVm extends _$NewsVm {
     }
   }
 
+
+  // 设置当前的 _queryParams
+  setCurrentQueryParams(Map<String, dynamic> params){
+    _queryParams.addAll(params);
+  }
+
+  // 获取当前的 _queryParams
+  Map<String, dynamic> getCurrentQueryParams(String? key){
+    if(key!=null && key!.isNotEmpty){
+      return _queryParams[key]??{};
+    }
+    return _queryParams;
+  }
+
   // 去详情页面
   void handlerGotoDetail(BuildContext? context, int id){
     Log.d("去详情页面");

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

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

+ 2 - 6
packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_page.dart

@@ -30,7 +30,7 @@ import 'newsfeed_detail_vm.dart';
 @RoutePage()
 class NewsfeedDetailPage extends HookConsumerWidget {
   final int? id;
-  final String? type;  // news  following foryou
+  final String? type;  // news  following foryou  mypostsNews
 
   const NewsfeedDetailPage({Key? key, @PathParam('id') required this.id, @PathParam('type') required this.type}) : super(key: key);
   // 启动当前页面
@@ -463,11 +463,7 @@ class NewsfeedDetailPage extends HookConsumerWidget {
                                 customIconUnActiveAssets: Assets.communityNewsfeedDetailLike,
                                 onLike: () async {
                                   Log.d('点击了like button');
-                                  bool asyncResult = await vm.handlerLikeClick(context, detailInfo!.id as int, isLike);
-                                  if(asyncResult){
-                                    // 成功
-
-                                  }
+                                  final asyncResult = await vm.handlerLikeClick(context, detailInfo!.id as int, isLike);
                                 },
                               ),
                               const SizedBox(width: 10,),

+ 14 - 3
packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_vm.dart

@@ -1,6 +1,7 @@
 
 import 'package:cpt_community/modules/community/following/following_vm.dart';
 import 'package:cpt_community/modules/community/foryou/foryou_vm.dart';
+import 'package:cpt_community/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_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';
@@ -43,7 +44,7 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
   );
 
   int? _detailId;
-  String? _detailType = 'news';
+  String? _detailType = 'news';  // news  following foryou  mypostsNews
 
 
   NewsfeedDetailState initState() {
@@ -221,7 +222,7 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
 
   // 点击了 关注/取消关注按钮
   Future<bool> handlerFollow(BuildContext? context, int to_user_id,int cardId, bool isFollow) async{
-    Log.d("newsfeed_detail_vm 中 当前的 _detailType $_detailType 点击了 关注/取消关注");
+    Log.d("newsfeed_detail_vm 中 当前的 _detailType $_detailType to_user_id:$to_user_id cardId:$cardId isFollow:$isFollow  点击了 关注/取消关注");
     bool result = false;
     if(_detailType == 'news'){
       Log.d("调用 newvm 中的关注/取消关注方法");
@@ -238,6 +239,11 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
       // 调用列表中的 点赞方法
       final forYouVm = ref.read(foryouVmProvider.notifier);
       result = await forYouVm.handlerFollow(context, to_user_id, cardId, isFollow);
+    }else if(_detailType == 'mypostsNews'){
+      Log.d("调用 mypostsNews 中的关注/取消关注方法");
+      // 调用列表中的 点赞方法
+      final myPostsNewsVm = ref.read(myPostsNewsfeedVmProvider.notifier);
+      result = await myPostsNewsVm.handlerFollow(context, to_user_id, cardId, isFollow);
     }
 
     if(result){
@@ -276,7 +282,7 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
     BuildContext contextPage = context;
     // double height = MediaQuery.of(contextPage).size.height;
     double commentInputHeight = 150.0;
-        await DialogEngine.show(
+    await DialogEngine.show(
       tag: "newsFeedComments",
       position: DialogPosition.bottom,
       widget: CommentsDialog(
@@ -391,6 +397,11 @@ class NewsfeedDetailVm extends _$NewsfeedDetailVm {
       // 调用列表中的 点赞方法
       final forYouVm = ref.read(foryouVmProvider.notifier);
       result = await forYouVm.handlerLikeClick(id, isLike, null);
+    }else if(_detailType == 'mypostsNews'){
+      Log.d("调用 myPostsVm 中的点赞方法");
+      // 调用列表中的 点赞方法
+      final myPostsVm = ref.read(myPostsNewsfeedVmProvider.notifier);
+      result = await myPostsVm.handlerLikeClick(id, isLike, null, null);
     }
 
     if(result){

+ 1 - 4
packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_page.dart

@@ -109,11 +109,8 @@ class NewsfeedPostPage extends HookConsumerWidget {
                         textColor: Colors.white,
                         fontWeight: FontWeight.w500,
                         fontSize: 16,
-                        onPressed: (){
+                        onPressed: () {
                           vm.submitNewsfeedPost(context, sCallback: sCallback, fCallback: fCallback);
-                          // final communitVm = ref.read(communityVmProvider.notifier);
-                          // communitVm.getCurrentPageViewVm(null).initPageData();
-                          // Navigator.pop(context);
                         },
                       ),
                     ),

+ 23 - 8
packages/cpt_community/lib/modules/community/newsfeed_post/newsfeed_post_vm.dart

@@ -4,6 +4,7 @@ import 'package:cs_resources/generated/assets.dart';
 import 'package:flutter/material.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:router/ext/auto_router_extensions.dart';
 import 'package:router/path/router_path.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:shared/utils/log_utils.dart';
@@ -109,8 +110,8 @@ class NewsfeedPostVm extends _$NewsfeedPostVm {
     }
   }
 
-  ///提交反馈
-  void submitNewsfeedPost(BuildContext? context, {VoidCallback? sCallback, VoidCallback? fCallback}) {
+  ///newsfeed 发布提交
+  Future submitNewsfeedPost(BuildContext? context, {VoidCallback? sCallback, VoidCallback? fCallback}) async {
     state = state.copyWith(mindFieldErrorText: null);
 
     _dismissKeyboard(keyStr: 'mind');
@@ -124,26 +125,40 @@ class NewsfeedPostVm extends _$NewsfeedPostVm {
     if (Utils.isEmpty(mindValue)) {
       state = state.copyWith(mindFieldErrorText: "Mind cannot be empty!");
       ToastEngine.show("${state.mindFieldErrorText}");
-      return;
+      return false;
     }
 
-    handlerSubmitPostNewsfeed(sCallback: sCallback, fCallback: fCallback);
+    if(state.imgList.isEmpty){
+      ToastEngine.show("ImgList cannot be empty");
+      return false;
+    }
+
+    bool resResult = await handlerSubmitPostNewsfeed(mindValue, state.imgList,  sCallback: sCallback, fCallback: fCallback);
 
+    if(resResult){
+      final communitVm = ref.read(communityVmProvider.notifier);
+      communitVm.getCurrentPageViewVm(null).initPageData();
+      // Navigator.pop(context);
+      appRouter.maybePop();
+    }
   }
 
-  Future handlerSubmitPostNewsfeed({VoidCallback? sCallback, VoidCallback? fCallback}) async{
+  Future<bool> handlerSubmitPostNewsfeed(String mindValue,List<String> imgList,{VoidCallback? sCallback, VoidCallback? fCallback}) async{
     try {
       final result = await repositoryInstance.fetchNewsfeedPublish({
-        "content ": "test",
-        "resources": []
+        "content": mindValue,
+        "resources": imgList
       });
       if (result.isSuccess) {
         sCallback?.call();
+        return true;
       }else {
         fCallback?.call();
+        return false;
       }
     }catch(e){
-
+      Log.d("发布newsfeed 失败 $e");
+      return false;
     }
   }
 

+ 5 - 6
packages/cpt_community/lib/modules/community/newsfeed_tabs.dart

@@ -19,12 +19,14 @@ class NewsfeedTabs extends HookConsumerWidget {
   Widget? Function(BuildContext)? tabItemBuilder;
   dynamic? tabsRouter;
   void Function(Map<String, dynamic>)? onClickAction;
+  EdgeInsets? margin;
   NewsfeedTabs({
     Key? key,
     required this.tabsList,
     this.tabsRouter,
     this.onClickAction,
-    this.tabItemBuilder
+    this.tabItemBuilder,
+    this.margin = const EdgeInsets.only(top: 10, bottom: 10, left: 20, right: 20),
   }) : super(key: key);
 
   Widget _buildTabItem(BuildContext context, WidgetRef ref, vm, item, index) {
@@ -67,7 +69,6 @@ class NewsfeedTabs extends HookConsumerWidget {
           lastNewsFeedTabIdx = newValue;
           currentCatgoryIdx = 0;
           Log.d("-从garagesale  切换到 newsfeed---------------currentCatgoryIdx  $currentCatgoryIdx------lastNewsFeedTabIdx: $lastNewsFeedTabIdx, lastGarageTabIdx: $lastGarageTabIdx---------------");
-
         }else {
           lastGarageTabIdx = newValue - newsfeedTabCount;
           lastNewsFeedTabIdx = providerCommunityState.lastNewsfeedTabIdx;
@@ -91,9 +92,9 @@ class NewsfeedTabs extends HookConsumerWidget {
       curTabIdx = activePageIdx;
     }
     return Container(
-      width: MediaQuery.of(context).size.width / tabsList.length - 30,
+      width: MediaQuery.of(context).size.width / tabsList.length - margin!.left - margin!.right,
       height: 43,
-      padding: const EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10),
+      margin: margin,
       decoration: index==curTabIdx? BoxDecoration(
         color: index==curTabIdx? context.appColors.btnBgDefault: ColorUtils.string2Color("#F2F3F6"),
         borderRadius: BorderRadius.circular(20),
@@ -164,8 +165,6 @@ class NewsfeedTabs extends HookConsumerWidget {
         mainAxisAlignment: MainAxisAlignment.center,
         crossAxisAlignment: CrossAxisAlignment.center,
         children: _buildTabs(context, ref, vm),
-      ).constrained(
-          maxWidth:  MediaQuery.of(context).size.width
       ),
     );
   }

+ 1 - 0
packages/cpt_community/lib/modules/garage/for_rent/for_rent_page.dart

@@ -63,6 +63,7 @@ class ForrentPage extends HookConsumerWidget {
           width: double.infinity,
           height: double.infinity,
           child: EasyRefresh(
+            key: ValueKey('forrent'),
             controller: vm.refreshController,
             // 上拉加载
             onLoad: () async{

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

@@ -6,6 +6,9 @@ class ForrentState {
   LoadState loadingState;
   String? errorMessage;
 
+  String? keyword;
+  bool? isLiked;
+
   List<Map<String, dynamic>> list;
 
 
@@ -13,6 +16,8 @@ class ForrentState {
     this.activeTabIndex,
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
+    this.keyword,
+    this.isLiked,
     required this.list,
   });
 
@@ -20,12 +25,16 @@ class ForrentState {
     int? activeTabIndex,
     LoadState? loadingState,
     String? errorMessage,
+    String? keyword,
+    bool? isLiked,
     List<Map<String, dynamic>>? list,
   }) {
     return ForrentState(
       activeTabIndex: activeTabIndex ?? this.activeTabIndex,
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
+      keyword: keyword ?? this.keyword,
+      isLiked: isLiked ?? this.isLiked,
       list: list ?? this.list,
     );
   }
@@ -35,6 +44,8 @@ class ForrentState {
       'activeTabIndex': this.activeTabIndex,
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
+      'keyword': this.keyword,
+      'isLiked': this.isLiked,
       'list': this.list,
     };
   }
@@ -44,6 +55,8 @@ class ForrentState {
       activeTabIndex: map['activeTabIndex'] as int,
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
+      keyword: map['keyword'] as String,
+      isLiked: map['isLiked'] as bool,
       list: map['list'] as List<Map<String, dynamic>>,
     );
   }

+ 87 - 97
packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.dart

@@ -24,6 +24,13 @@ class ForrentVm extends _$ForrentVm {
   int _page = 1;  // 当前页
   int _limit = 10; // 每页数量
   int _count = 0; // 总条数
+
+  Map<String, dynamic> _queryParams = {
+    'category_id': null,
+    'keyword': null,
+    'is_liked': null,
+  };
+
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -33,39 +40,39 @@ class ForrentVm extends _$ForrentVm {
   ForrentState initState() {
     return ForrentState(
         list: [
-          {
-            '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.',
-            'publisrher_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':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.',
+          //   'publisrher_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'
+          // },
         ]
     );
   }
@@ -96,8 +103,6 @@ class ForrentVm extends _$ForrentVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forRent);
-    if(isShowing){
       Log.d("----for_sale_vm-----loadMore");
       // await Future.delayed(const Duration(seconds: 2));
       // if(state.list.length >= _count){
@@ -110,36 +115,41 @@ class ForrentVm extends _$ForrentVm {
       // 检查 page 是否为 null,并初始化为 1
       _page++;
       getListData();
-    }else {
-      refreshController.finishLoad();
-    }
   }
 
 
   // 下拉刷新
   Future onRefresh() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forRent);
-    if(isShowing){
       // 当前pageView 页面正处于显示状态
       Log.d("----forrent_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
       _page = 1;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
+  }
+
+  // 手动进行刷新
+  Future triggerRefresh() async {
+    Log.d("trggerRefresh");
+    refreshController.callRefresh();
+  }
+
+  // 手动进行刷新
+  Future directRefresh() async {
+    state = state.copyWith(list:[]);
+    // 注意:由于 nestedscrollview 嵌套easyfresh 组件  refreshController.callRefresh() 自动刷新只能滚动顶部但是不会触发下拉刷新,这里调用是 用到了将其滚动到顶部的作用,进而刷新操作主动掉接口
+    // https://github.com/xuelongqy/flutter_easy_refresh/issues/692
+    refreshController.callRefresh();
+    refreshController.resetFooter();
+    _page = 1;
+    _needShowPlaceholder = true;
+    getListData();
   }
 
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forRent);
-    if(isShowing){
       _page = 1;
       _needShowPlaceholder = true;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
 
@@ -149,49 +159,12 @@ class ForrentVm extends _$ForrentVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    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)
+        "category_id": _queryParams['category_id'],
+        "keyword": _queryParams['keyword'],
         "page": _page,
         "limit": _limit,
       };
@@ -199,7 +172,7 @@ class ForrentVm extends _$ForrentVm {
       final result = await commonGarageRespositoryInstance.fetchGarageDataList(params);
       //校验成功失败
       if (result.isSuccess) {
-        handlerResultList(result.list?.cast<GarageSaleRentEntity>(), isLoadMore ?? false);
+        handlerResultList((result.data as GarageSaleRentEntity).list as List<GarageSaleRentList>, isLoadMore ?? false);
       } else {
         String errorMessage = result.errorMsg!;
         changeLoadingState(LoadState.State_Error, errorMessage);
@@ -211,20 +184,17 @@ class ForrentVm extends _$ForrentVm {
 
     // 最后赋值
     _needShowPlaceholder = false;
+
   }
 
-  void handlerResultList(List<GarageSaleRentEntity>? list, bool isLoadMore) {
+
+  void handlerResultList(List<GarageSaleRentList>? 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);
@@ -279,10 +249,15 @@ class ForrentVm extends _$ForrentVm {
       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;
+          GarageSaleRentList elementEntity = GarageSaleRentList.fromJson(element);
+
+          if(elementEntity.id == id){
+            elementEntity.liked = !elementEntity.liked!;
+            elementEntity.likesCount = elementEntity.liked! ? (elementEntity.likesCount! + 1) : (elementEntity.likesCount! - 1);
           }
+
+          element = elementEntity.toJson();
+
         });
         return true;
       } else {
@@ -291,9 +266,24 @@ class ForrentVm extends _$ForrentVm {
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
     } catch (e) {
+      Log.e("Error: $e");
       ToastEngine.show("Error: $e");
     }
   }
+
+  // 设置当前的 _queryParams
+  setCurrentQueryParams(Map<String, dynamic> params){
+    _queryParams.addAll(params);
+  }
+
+  // 获取当前的 _queryParams
+  Map<String, dynamic> getCurrentQueryParams(String? key){
+    if(key!=null && key!.isNotEmpty){
+      return _queryParams[key];
+    }
+    return _queryParams;
+  }
+
   // 去详情页面
   void handlerGotoDetail({BuildContext? context, required int id, String type='forRent'}){
     Log.d("去详情页面");

+ 3 - 1
packages/cpt_community/lib/modules/garage/for_sale/for_sale_page.dart

@@ -1,5 +1,6 @@
 import 'package:cpt_community/modules/garage/for_rent/for_rent_page.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/garage_sale_rent_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:flutter/rendering.dart';
@@ -66,6 +67,7 @@ class ForsalePage extends HookConsumerWidget {
         width: double.infinity,
         height: double.infinity,
         child: EasyRefresh(
+          key: ValueKey('forsale'),
           controller: vm.refreshController,
           // 上拉加载
           onLoad: () async{
@@ -135,7 +137,7 @@ class ForsalePage extends HookConsumerWidget {
                   key: UniqueKey(),
                   itemObj: item.cast<String, dynamic>(),
                   onClickColleciotn: (dynamic collectionValue) async {
-                    Log.d("点击了收藏按钮  --id:${item['id']}- $collectionValue");
+                    Log.d("点击了喜欢按钮  --id:${item['id']}- $collectionValue");
                     int id = item['id'];
                     return await vm.handlerClickCollection(id, collectionValue);
                   }

+ 13 - 1
packages/cpt_community/lib/modules/garage/for_sale/for_sale_state.dart

@@ -5,6 +5,9 @@ class ForsaleState {
   //页面 LoadView 状态的展示
   LoadState loadingState;
   String? errorMessage;
+
+  String? keyword;
+  bool? isLiked;
   List<Map<String, dynamic>> list;
 
 
@@ -12,6 +15,8 @@ class ForsaleState {
     this.activeTabIndex,
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
+    this.keyword,
+    this.isLiked,
     required this.list,
   });
 
@@ -19,13 +24,16 @@ class ForsaleState {
     int? activeTabIndex,
     LoadState? loadingState,
     String? errorMessage,
+    String? keyword,
+    bool? isLiked,
     List<Map<String, dynamic>>? list,
-    List<String>? tabsList,
   }) {
     return ForsaleState(
       activeTabIndex: activeTabIndex ?? this.activeTabIndex,
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
+      keyword: keyword ?? this.keyword,
+      isLiked: isLiked ?? this.isLiked,
       list: list ?? this.list,
     );
   }
@@ -35,6 +43,8 @@ class ForsaleState {
       'activeTabIndex': this.activeTabIndex,
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
+      'keyword': this.keyword,
+      'isLiked': this.isLiked,
       'list': this.list,
     };
   }
@@ -44,6 +54,8 @@ class ForsaleState {
       activeTabIndex: map['activeTabIndex'] as int,
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
+      keyword: map['keyword'] as String,
+      isLiked: map['isLiked'] as bool,
       list: map['list'] as List<Map<String, dynamic>>,
     );
   }

+ 57 - 119
packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart

@@ -2,6 +2,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:domain/entity/newsfeed_detail_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
@@ -26,6 +27,12 @@ class ForsaleVm extends _$ForsaleVm {
   int _limit = 10; // 每页数量
   int _count = 0; // 总条数
 
+  Map<String, dynamic> _queryParams = {
+    'category_id': null,
+    'keyword': null,
+    'is_liked': null,
+  };
+
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -65,50 +72,46 @@ class ForsaleVm extends _$ForsaleVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forSale);
-    if(isShowing){
       Log.d("----for_sale_vm-----loadMore");
-      // await Future.delayed(const Duration(seconds: 2));
-      // if(state.list.length >= _count){
-      //   return;
-      // }else {
-      //   int page = _page + 1;
-      //   state = state.copyWith(page: page,);
-      //   getListData();
-      // }
-      // 检查 page 是否为 null,并初始化为 1
       _page++;
       getListData();
-    }else {
-      refreshController.finishLoad();
-    }
   }
 
 
   // 下拉刷新
   Future onRefresh() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forSale);
-    if(isShowing){
       // 当前pageView 页面正处于显示状态
       Log.d("----forsale_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
       _page = 1;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
+
+  // 手动进行刷新
+  Future triggerRefresh() async {
+    Log.d("trggerRefresh");
+    refreshController.callRefresh();
+  }
+
+  // 手动进行刷新
+  Future directRefresh() async {
+    state = state.copyWith(list:[]);
+    // 注意:由于 nestedscrollview 嵌套easyfresh 组件  refreshController.callRefresh() 自动刷新只能滚动顶部但是不会触发下拉刷新,这里调用是 用到了将其滚动到顶部的作用,进而刷新操作主动掉接口
+    // https://github.com/xuelongqy/flutter_easy_refresh/issues/692
+    refreshController.callRefresh();
+    refreshController.resetFooter();
+    _page = 1;
+    _needShowPlaceholder = true;
+    getListData();
+  }
+
+
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forSale);
-    if(isShowing){
       _page = 1;
       _needShowPlaceholder = true;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
 
@@ -118,100 +121,12 @@ class ForsaleVm extends _$ForsaleVm {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_sale_vm加载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'
-    //   },
-    //   {
-    //     '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)
+        "category_id": _queryParams['category_id'],
+        "keyword": _queryParams['keyword'],
         "page": _page,
         "limit": _limit,
       };
@@ -219,7 +134,7 @@ class ForsaleVm extends _$ForsaleVm {
       final result = await commonGarageRespositoryInstance.fetchGarageDataList(params);
       //校验成功失败
       if (result.isSuccess) {
-        handlerResultList(result.list?.cast<GarageSaleRentEntity>(), isLoadMore ?? false);
+        handlerResultList((result.data as GarageSaleRentEntity).list as List<GarageSaleRentList>, isLoadMore ?? false);
       } else {
         String errorMessage = result.errorMsg!;
         changeLoadingState(LoadState.State_Error, errorMessage);
@@ -229,10 +144,13 @@ class ForsaleVm extends _$ForsaleVm {
       ToastEngine.show("Error: $e");
     }
 
+    // 最后赋值
+    _needShowPlaceholder = false;
+
   }
 
 
-  void handlerResultList(List<GarageSaleRentEntity>? list, bool isLoadMore) {
+  void handlerResultList(List<GarageSaleRentList>? list, bool isLoadMore) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_page == 1) {
@@ -293,10 +211,15 @@ class ForsaleVm extends _$ForsaleVm {
       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;
+          GarageSaleRentList elementEntity = GarageSaleRentList.fromJson(element);
+
+          if(elementEntity.id == id){
+            elementEntity.liked = !elementEntity.liked!;
+            elementEntity.likesCount = elementEntity.liked! ? (elementEntity.likesCount! + 1) : (elementEntity.likesCount! - 1);
           }
+
+          element = elementEntity.toJson();
+
         });
         return true;
       } else {
@@ -305,9 +228,24 @@ class ForsaleVm extends _$ForsaleVm {
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
     } catch (e) {
+      Log.e("Error: $e");
       ToastEngine.show("Error: $e");
     }
   }
+
+  // 设置当前的 _queryParams
+  setCurrentQueryParams(Map<String, dynamic> params){
+    _queryParams.addAll(params);
+  }
+
+  // 获取当前的 _queryParams
+  Map<String, dynamic> getCurrentQueryParams(String? key){
+    if(key!=null && key!.isNotEmpty){
+      return _queryParams[key];
+    }
+    return _queryParams;
+  }
+
   // 去详情页面
   void handlerGotoDetail({BuildContext? context, required int id, String type='forSale'}){
     Log.d("去详情页面");

+ 133 - 60
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_page.dart

@@ -2,6 +2,8 @@ import 'package:cpt_community/modules/garage/garagesale_detail/garagesale_detail
 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/garage_sale_rent_detail_entity.dart';
+import 'package:domain/entity/garage_sale_rent_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:flutter_hooks/flutter_hooks.dart';
@@ -9,11 +11,13 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:shared/utils/log_utils.dart';
+import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/my_appbar.dart';
 import 'package:widgets/my_like_button.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/my_text_view.dart';
+import 'package:widgets/widget_export.dart';
 
 @RoutePage()
 class GaragesaleDetailPage extends HookConsumerWidget {
@@ -38,11 +42,15 @@ class GaragesaleDetailPage extends HookConsumerWidget {
     final String pageTitle = (type == 'forSale') ? 'For Sale' :'For Rent';
     GlobalKey _likeButtonKey = GlobalKey<MyLikeButtonState>();
 
-    String title =  '';
-    String price =  '';
-    String contactType = '';
+    GarageSaleRentDetailEntity detailInfo = state.datas?? GarageSaleRentDetailEntity();
+    String title =  detailInfo.title?? '';
+    int price =  detailInfo.price?? 0;
+
+    String contactType =  detailInfo.contact??'';
+
     String description = '';
 
+
     useEffect((){
       vm.setInitPageData(id: id!, type: type);
       // 组件挂载时执行 - 执行接口请求
@@ -62,36 +70,55 @@ class GaragesaleDetailPage extends HookConsumerWidget {
       body: Column(
         children: [
           Expanded(
-            child: Stack(
-              children:[
-                LoadStateLayout(
-                  state: state.loadingState,
-                  errorMessage: state.errorMessage,
-                  errorRetry: () {
-                    vm.retryRequest();
-                  },
-                  successWidget: SingleChildScrollView(
-                    scrollDirection: Axis.vertical,
-                    physics: const BouncingScrollPhysics(),
-                    clipBehavior: Clip.none,
-                    child: _buildContentBox(context, ref,
-                      title:title,
-                      price:price,
-                      contactType:contactType,
-                      description:description,
-                    ),
+            child: EasyRefresh(
+              controller: vm.refreshController,
+              // 上拉加载
+              onLoad: null,
+              // 下拉刷新
+              onRefresh: () async{
+                Log.d("----onRefresh");
+                vm.onRefresh();
+              },
+              // header: MaterialHeader(),
+              child: Stack(
+                children:[
+                  LoadStateLayout(
+                    state: state.loadingState,
+                    errorMessage: state.errorMessage,
+                    errorRetry: () {
+                      vm.retryRequest();
+                    },
+                    // successWidget: SingleChildScrollView(
+                    //   scrollDirection: Axis.vertical,
+                    //   physics: const BouncingScrollPhysics(),
+                    //   clipBehavior: Clip.none,
+                    //   child: _buildContentBox(context, ref, detailInfo,),
+                    // ),
+                    successSliverWidget: [
+                      SliverList(
+                        delegate: SliverChildBuilderDelegate(
+                                (context, index){
+                              return _buildContentBox(context, ref, detailInfo);
+                            },
+                            childCount: 1
+                        ),
+                      )
+                    ],
                   ),
-                ),
-                Visibility(
-                  visible: state.loadingState == LoadState.State_Success,
-                  child: _buildWhatsApp(context, ref,
-                    title:title,
-                    price:price,
-                    contactType:contactType,
-                    description:description,
+                  Visibility(
+                    visible: state.loadingState == LoadState.State_Success,
+                    child: Visibility(
+                      visible: vm.isContactWhatsApp(contactType),
+                      child: _buildWhatsApp(context, ref,
+                        title:title,
+                        price:price,
+                        contactType:contactType,
+                        description:description,
+                      ),
+                    ),
                   ),
-                ),
-              ]
+                ]
+              ),
             ),
           ),
           // 底部联系信息
@@ -102,6 +129,7 @@ class GaragesaleDetailPage extends HookConsumerWidget {
               price:price,
               contactType:contactType,
               description:description,
+              detailInfo:detailInfo,
             ),
           )
         ],
@@ -109,29 +137,29 @@ class GaragesaleDetailPage extends HookConsumerWidget {
     );
   }
 
-  Widget _buildWhatsApp(BuildContext context, WidgetRef ref, {required String title, required String price, required String contactType, required String description}) {
+  Widget _buildWhatsApp(BuildContext context, WidgetRef ref, {required String title, required int price, required String contactType, required String description}) {
     final vm = ref.read(garagesaleDetailVmProvider.notifier);
     return Positioned(
       right: 15.5,
       bottom: 42,
       child: InkWell(
         onTap: () {
-          // 跳转 WhatsApp
-          vm.gotoWhatsApp();
+          // 点击了whatsapp
+          vm.handlerClickWhatsapp(context, contactType, title, price);
         },
         child: const MyAssetImage(Assets.communityWhatsAPP, width: 57,height: 57,),
       ),
     );
   }
 
-  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 goods_img = '';
-    String title =  '';
-    String price = '';
+  Widget _buildContentBox(BuildContext context, WidgetRef ref, GarageSaleRentDetailEntity detailInfo) {
+    List<String> resources = detailInfo.resources??[];
+    String goods_img = resources[0]??'';
+    String title =  detailInfo.title??'';
+    int price = detailInfo.price??0;
     String contactType =  '';
-    String description = '';
+    String description = detailInfo.description??'';
+    CarouselSliderController buttonCarouselController = CarouselSliderController();
     return Column(
       crossAxisAlignment: CrossAxisAlignment.start,
       children: [
@@ -139,8 +167,17 @@ class GaragesaleDetailPage extends HookConsumerWidget {
         SizedBox(
           width: double.infinity,
           height: 173.5,
-          child: MyLoadImage(
-            goods_img,
+          child: CarouselSlider(
+            // items: [MyLoadImage(goods_img)] ,
+            items: resources.map((resource) => MyLoadImage(resource)).toList(),
+            carouselController: buttonCarouselController,
+            options: CarouselOptions(
+              autoPlay: true,
+              enlargeCenterPage: true,
+              viewportFraction: 0.9,
+              aspectRatio: 2.0,
+              initialPage: 0,
+            ),
           ),
         ),
         Column(
@@ -154,7 +191,7 @@ class GaragesaleDetailPage extends HookConsumerWidget {
             // 价格
             Padding(
               padding: const EdgeInsets.only(left: 16, right: 16, top: 10),
-              child: price.isNotEmpty? MyTextView( price, fontSize: 24, isFontMedium: true, textColor: context.appColors.textBlack,):const SizedBox.shrink(),
+              child: price!=null? MyTextView( '$price', fontSize: 24, isFontMedium: true, textColor: context.appColors.textBlack,):const SizedBox.shrink(),
             ),
            //  内容
             Padding(
@@ -168,15 +205,31 @@ class GaragesaleDetailPage extends HookConsumerWidget {
     );
   }
 
-  Widget _buildBottomConcatInfo(BuildContext context, WidgetRef ref, likeButtonKey, {required String title, required String price, required String contactType, required String description}) {
-    final state = ref.watch(garagesaleDetailVmProvider);
+  Widget _buildBottomConcatInfo(
+      BuildContext context,
+      WidgetRef ref,
+      likeButtonKey,
+      {
+        required String title,
+        required int price,
+        required String contactType,
+        required String description,
+        required GarageSaleRentDetailEntity detailInfo,
+      }
+      ) {
+    final vm = ref.read(garagesaleDetailVmProvider.notifier);
 
-    String publisher =  '';
-    String contactType =  '';
-    String contactInfo =  '';
-    String publisherAvatar = '';
-    String publisherTime =  '';
-    int collectionNum =  0;
+    GarageSaleRentDetailAccount  account = detailInfo.account?? GarageSaleRentDetailAccount();
+
+    String publisher =  account.name??'-';
+    String publisherAvatar = account.avatar??'-';
+
+    String contactType =  detailInfo.contact??'';
+    String publisherTime =  detailInfo.createdAt??'-';
+    int likes_count =  detailInfo!.likesCount??0;
+
+    final _likes_count = useState(likes_count);
+    final _isLiked = useState<bool>(false);
 
     return Container(
       height: 50,
@@ -220,18 +273,32 @@ class GaragesaleDetailPage extends HookConsumerWidget {
                     children: [
                       MyLikeButton(
                         key: likeButtonKey,
-                        isLiked: false,
+                        isLiked: _isLiked.value,
                         isCustomIcon: true,
                         customIconUnActiveAssets: Assets.communityCollection,
                         customIconActiveAssets: Assets.communityLikeActive,
                         // customIconWidth: 18,
                         // customIconHeight: 18,
-                        onLike: () {
+                        onLike: () async {
                           Log.d('点击了like button');
+                          int id = detailInfo!.id as int;
+                          final isSuccess = await vm.handlerClickCollection(context, id, true);
+                          if(isSuccess!=null && isSuccess){
+                            // 成功
+                            if(_isLiked.value){
+                              Log.d("取消点赞");
+                              _likes_count.value--;
+                              _isLiked.value = false;
+                            }else {
+                              Log.d("点赞");
+                              _likes_count.value++;
+                              _isLiked.value = true;
+                            }
+                          }
                         },
                       ),
                       MyTextView(
-                        "$collectionNum",
+                        "${_likes_count.value}",
                         fontSize: 18,
                         textColor: Colors.white,
                         isFontRegular: true,
@@ -247,12 +314,18 @@ class GaragesaleDetailPage extends HookConsumerWidget {
                 ),
                 // const MyAssetImage(Assets.communityCollection, width: 18,height: 18,),
                 Visibility(
-                  visible: contactType == 'Mobile Phone',
-                  child: const Row(
+                  visible: vm.isContactMobile(contactType),
+                  child:  Row(
                     children: [
-                      SizedBox(width: 4,),
-                      MyAssetImage(Assets.communityPhone, width: 21.5,height: 18,),
-                      SizedBox(width: 15,),
+                      const SizedBox(width: 4,),
+                      const MyAssetImage(
+                        Assets.communityPhone,
+                        width: 21.5,
+                        height: 18,
+                      ).onTap((){
+                        vm.handlerClickMobile(context, contactType);
+                      }),
+                      const SizedBox(width: 15,),
                     ],
                   ),
                 ),

+ 170 - 60
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_vm.dart

@@ -1,7 +1,10 @@
+import 'package:cpt_community/modules/garage/for_rent/for_rent_vm.dart';
+import 'package:cpt_community/modules/garage/garagesale_post/garagesale_post_vm.dart';
 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_basic/basic_export.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:router/ext/auto_router_extensions.dart';
@@ -11,6 +14,7 @@ import 'package:widgets/widget_export.dart';
 
 import '../../../router/page/community_page_router.dart';
 // import 'garagesale_detail_respository.dart';
+import '../for_sale/for_sale_vm.dart';
 import 'garagesale_detail_state.dart';
 
 part 'garagesale_detail_vm.g.dart';
@@ -18,10 +22,14 @@ part 'garagesale_detail_vm.g.dart';
 @riverpod
 class GaragesaleDetailVm extends _$GaragesaleDetailVm {
   late CommonGarageRespository commonGarageRespositoryInstance;
-  bool _needShowPlaceholder = false; //是否展示LoadingView
 
   int _detailId = 0;
-  String _detailType = "";
+  String _detailType = "forSale"; // forSale  forRent
+
+  bool _needShowPlaceholder = false; //是否展示LoadingView
+  int _page = 1;  // 当前页
+  int _limit = 10; // 每页数量
+  int _count = 0; // 总条数
 
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
@@ -54,88 +62,190 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
     );
   }
 
+  // 初始化页面数据
+  initPageData() {
+    Log.d("----for_sale_vm-----initPageData   ${state.loadingState}");
+    onRefresh();
+  }
+
+  // 上拉加载 更多
+  Future loadMore() async {
+    _page++;
+    getDetailData();
+  }
+
+
+  // 下拉刷新
+  Future onRefresh() async {
+    _page = 1;
+    getDetailData();
+  }
+
+
+  // 手动进行刷新
+  Future triggerRefresh() async {
+    Log.d("trggerRefresh");
+    refreshController.callRefresh();
+  }
+
+  // 手动进行刷新
+  Future directRefresh() async {
+    state = state.copyWith(datas:null);
+    // 注意:由于 nestedscrollview 嵌套easyfresh 组件  refreshController.callRefresh() 自动刷新只能滚动顶部但是不会触发下拉刷新,这里调用是 用到了将其滚动到顶部的作用,进而刷新操作主动掉接口
+    // https://github.com/xuelongqy/flutter_easy_refresh/issues/692
+    refreshController.callRefresh();
+    refreshController.resetFooter();
+    _page = 1;
+    _needShowPlaceholder = true;
+    getDetailData();
+  }
+
+
   // 重试请求
   Future retryRequest() async {
+    _page = 1;
     _needShowPlaceholder = true;
     getDetailData();
   }
 
+
   setInitPageData({required int id, required String type}){
     _detailId = id;
     _detailType = type;
   }
-  // 初始化页面数据
-  initPageData() {
-    Log.d("----property_news_vm-----initPageData   ${state.loadingState}");
-    getDetailData();
-  }
 
   Future getDetailData<T>() async {
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    //   try {
-    //     //请求网络
-    //     Map<String, dynamic>  params = {
-    //       "page": state.page,
-    //       "limit": state.limit,
-    //     };
-    //     Log.d("请求参数------$params");
-
-    await Future.delayed(const Duration(milliseconds: 1500));
-
-    final Map<String, dynamic> detailData = {
-      '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',
-      'description':'Electronic keyboards for sale. I will attend together with the booth.\$10 per day usage Negotiable usage',
-      'isCollection': true,
-      'contactType': 'WhatsApp',
-      'contactInfo': '+1 123456789',
-      'collection_num': 12,
-      'publisher': 'William Jefferson',
-      'publisher_avatar': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
-      'publisher_time': 'June 17,2024 at 7:23 PM'
-    };
-
-    state = state.copyWith(datas: GarageSaleRentDetailEntity(
-    ));
-
-    changeLoadingState(LoadState.State_Success, null);
-
-    refreshController.finishRefresh();
+
+    // await Future.delayed(const Duration(milliseconds: 1500));
+    //
+    // final Map<String, dynamic> detailData = {
+    //   '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',
+    //   'description':'Electronic keyboards for sale. I will attend together with the booth.\$10 per day usage Negotiable usage',
+    //   'isCollection': true,
+    //   'contactType': 'WhatsApp',
+    //   'contactInfo': '+1 123456789',
+    //   'collection_num': 12,
+    //   'publisher': 'William Jefferson',
+    //   'publisher_avatar': 'https://img1.baidu.com/it/u=3890726495,1572750319&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
+    //   'publisher_time': 'June 17,2024 at 7:23 PM'
+    // };
+
+    // state = state.copyWith(datas: GarageSaleRentDetailEntity(
+    // ));
+    //
+    // changeLoadingState(LoadState.State_Success, null);
+    //
+    // refreshController.finishRefresh();
+    //
+    // // 最后赋值
+    // _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;
+  }
+
 
+  // 点击了底部的收藏按钮
+  Future<bool?> handlerClickCollection(BuildContext? context, int id, bool isCollection) async{
+    var vm;
+    if(_detailType == "forSale"){
+      vm = ref.read(forsaleVmProvider.notifier);
+    }else if(_detailType == "forRent"){
+      vm = ref.read(forrentVmProvider.notifier);
+    }
+    try {
+      final isSuccess = await vm.handlerClickCollection(id, isCollection);
+      return isSuccess;
+    }catch(e){
 
-    // 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;
+  // 判断是whatsapp 还是 mobile  (通过 contact: whatsapp:+8617671757687)
+  String getContactType(String contactType){
+    // whatsapp:+8617671757687  截取:前面的字符串
+    String type = contactType.split(":")[0];
+    return type;
+  }
+
+  isContactWhatsApp(String contactType){
+    return contactType.contains("whatsapp");
+  }
+
+  isContactMobile(String contactType){
+    return contactType.contains("mobile");
+  }
+  String getContactNumber(String contactType){
+    // whatsapp:+8617671757687     mobile:+8617671757687  截取:后面的字符串
+    String number = contactType.split(":")[1];
+    return number;
+  }
+  // 点击 whatsapp
+  handlerClickWhatsapp(BuildContext? context,String contactType, String title, int price){
+    // 假设你有一个获取 WhatsApp 号码的方法
+    String whatsappNumber = getContactNumber(contactType); // 你需要实现这个方法
+    // 构建消息并进行编码
+    String message = Uri.encodeComponent("Hello, I am interested in your listing: $title for $price.");
+    // 打开WhatsApp
+    openWhatsApp(whatsappNumber, message);
+  }
+
+  // 打开whatsapp
+  openWhatsApp(String phoneNumber, String message) async {
+    final url = "https://wa.me/$phoneNumber/?text=${Uri.parse(message)}";
+    if (await  canLaunchUrl(Uri.parse(url))) {
+      await launchUrl(Uri.parse(url));
+    } else {
+      ToastEngine.show("Could not launch $url");
+      throw 'Could not launch $url';
+    }
+  }
+
+  // 点击 电话
+  handlerClickMobile(BuildContext? context,String contactType){
+    String mobileNumber = getContactNumber(contactType);
+    // 拨打电话
+    makePhoneCall(mobileNumber);
   }
 
+  // 拨打电话
+  Future<void> makePhoneCall(String phoneNumber) async {
+    final Uri launchUri = Uri(
+      scheme: 'tel',
+      path: phoneNumber,
+    );
 
-  // 去whatsapp
-  gotoWhatsApp(){
-    // 跳转 WhatsApp
+    if (await canLaunchUrl(launchUri)) {
+      await launchUrl(launchUri);
+    } else {
+      ToastEngine.show("Could not launch $launchUri");
+      throw 'Could not launch $launchUri';
+    }
   }
 }

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

@@ -42,9 +42,11 @@ class GaragesalePostPage extends HookConsumerWidget {
     final state = ref.watch(garagesalePostVmProvider);
 
     useEffect((){
-      vm.initData(
-        type:type
-      );
+      WidgetsBinding.instance!.addPostFrameCallback((_) {
+        vm.initData(
+            type:type
+        );
+      });
       return () => (){
 
       };
@@ -210,7 +212,7 @@ class GaragesalePostPage extends HookConsumerWidget {
                         textColor: Colors.white,
                         fontWeight: FontWeight.w500,
                         fontSize: 16,
-                        onPressed: (){
+                        onPressed: () {
                           // Navigator.pop(context);
                           vm.submitGaragesalePost(context, sCallback: sCallback, fCallback: fCallback);
                           // final communitVm = ref.read(communityVmProvider.notifier);

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

@@ -22,7 +22,7 @@ class GaragesalePostPageState {
   final String? description;
 
   // contact type 类型选项
-  final List<String> contactTypeOptionsList = ["Mobile Phone", "WhatsApp", "Email"];
+  final List<String> contactTypeOptionsList = ["Mobile Phone", "WhatsApp",];
   String? contactTypeSelectedOption;
 
   // contact information

+ 53 - 37
packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.dart

@@ -1,9 +1,15 @@
 
+import 'dart:async';
+
 import 'package:cpt_community/modules/community/community_vm.dart';
 import 'package:cs_resources/generated/assets.dart';
 import 'package:flutter/material.dart';
+import 'package:plugin_basic/constants/app_constant.dart';
+import 'package:plugin_platform/engine/sp/sp_util.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:plugin_platform/http/http_result.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:router/ext/auto_router_extensions.dart';
 import 'package:router/path/router_path.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:shared/utils/log_utils.dart';
@@ -129,33 +135,26 @@ class GaragesalePostVm extends _$GaragesalePostVm {
         }
       }
     });
-    // state = state.copyWith(
-    //     saleSelectedOption:_initialSaleSelectedItem,
-    // );
   }
 
-  Future getGarageCategoryList() async {
+  Future<List<String>> 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<Map<String, dynamic>> garageCategoryList = await communityVm.getGarageSaleCategoryOptions();
 
-      List<String> catList = (listJson as List)!.map((e) => (e['name'] as String)).toList()?? [];
+    // 获取分类列表
+    List<String> catNameResult = [];
 
+    _resCategoryOptionsList = garageCategoryList;
 
-      Log.d("--initialSelectedItem----$_initialSaleSelectedItem-");
+    // 将 listJson 转换为 List<String>
+    catNameResult = (garageCategoryList as List)!.map((e) => (e['name'] as String)).toList()?? [];
 
-       state = state.copyWith(
-         saleSelectedOption:_initialSaleSelectedItem,
-         categoryOptionsList: catList,
-       );
-    }
-    return result;
+    state = state.copyWith(
+      saleSelectedOption:_initialSaleSelectedItem,
+      categoryOptionsList: catNameResult,
+    );
+
+    return catNameResult;
   }
 
   //catogery 选择选项
@@ -253,7 +252,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
   }
 
   ///提交反馈
-  void submitGaragesalePost(BuildContext context, {VoidCallback? sCallback, VoidCallback? fCallback}) {
+  Future submitGaragesalePost(BuildContext context, {VoidCallback? sCallback, VoidCallback? fCallback}) async{
     Log.d("GaragesalePostPageState 提交表单");
     state = state.copyWith(titleErrorText: null, descriptionErrorText: null);
     _dismissKeyboard(keyStr: "");
@@ -261,6 +260,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     // 获取表单的值
     String  saleValue= state.saleSelectedOption ?? "";
     String  categoryValue= state.categorySelectedOption ?? "";
+    int categoryId;
     String  contactTypeValue= state.contactTypeSelectedOption ?? "";
 
     String  titleValue= _getFormFieldValue(keyStr: 'title');
@@ -278,6 +278,17 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     if (Utils.isEmpty(categoryValue)) {
       ToastEngine.show('Category is empty');
       return;
+    }else {
+      // 通过 categoryValue 值 来获取 categoryId
+      Log.d("_resCategoryOptionsList  $_resCategoryOptionsList");
+      try {
+        Map<String, dynamic>? categoryItem = _resCategoryOptionsList.firstWhere((element) => element['name'] == categoryValue, orElse: () => {'id': -1});
+        categoryId = categoryItem?['id'];
+      } catch (e) {
+        Log.d("未找到匹配的 categoryValue: $categoryValue");
+        ToastEngine.show('Category is invalid');
+        return;
+      }
     }
     if (Utils.isEmpty(contactTypeValue)) {
       ToastEngine.show('ContactType is empty');
@@ -325,18 +336,25 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     }
 
     // 提交数据
-    handlerSubmitPost(
+    final resResult = await handlerSubmitPost(
       type: saleValue == 'For Sale'? 1:2,
       titleValue: titleValue,
-      categoryId: 1,
+      categoryId: categoryId!,
       priceValue: priceValue,
       descriptionValue: descriptionValue,
       contactValue: totalContactStr,
       imgList: state.imgList,
     );
+
+    if(resResult.isSuccess){
+      final communitVm = ref.read(communityVmProvider.notifier);
+      communitVm.getCurrentPageViewVm(null).initPageData();
+      // Navigator.pop(context);
+      appRouter.maybePop();
+    }
   }
 
-  Future handlerSubmitPost({
+  Future<HttpResult<Object>> handlerSubmitPost({
     required int type,
     required String titleValue,
     required int categoryId,
@@ -345,17 +363,17 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     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;
+      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;
   }
 
 
@@ -402,6 +420,4 @@ class GaragesalePostVm extends _$GaragesalePostVm {
 
     Log.d("GaragesalePostPageState 销毁 onDispose");
   }
-
-
 }

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

@@ -30,7 +30,7 @@ class MyFollowingListItem extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
-    String avator = itemObj?['avator']??'';
+    String avator = itemObj?['avatar']??'';
     String name = itemObj?['name']??'';
     return Column(
       children: [

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

@@ -75,11 +75,11 @@ class MyFollowPage extends HookConsumerWidget {
                 final ScrollMetrics metrics = notification.metrics;
                 final double currentOffset = metrics.pixels;
                 final double prevOffset = previousOffset.value;
-                Log.d("---最大滚动距离-----${metrics.maxScrollExtent}-------");
+                // Log.d("---最大滚动距离-----${metrics.maxScrollExtent}-------");
                 if (currentOffset > prevOffset) {
                   // 向上滚动
                   // 日志输出当前滚动偏移量和前一次滚动偏移量
-                  Log.d('--向上滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
+                  // Log.d('--向上滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
                   if(useSearchBar.value == false && metrics.maxScrollExtent >=0 && currentOffset >= 110){
                     // 滚动到110 时 将 titlebar 换成 searchbar
                     useSearchBar.value = true;
@@ -87,7 +87,7 @@ class MyFollowPage extends HookConsumerWidget {
                 } else if (currentOffset < prevOffset) {
                   // 向下滚动
                   // 日志输出当前滚动偏移量和前一次滚动偏移量
-                  Log.d('--向下滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
+                  // Log.d('--向下滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
                   if(useSearchBar.value == true && metrics.maxScrollExtent >=0 && currentOffset <= 110){
                     // 滚动到110 时 将 searchbar 换成 titlebar
                     useSearchBar.value = false;

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

@@ -75,11 +75,11 @@ class MyFollowerPage extends HookConsumerWidget {
                 final ScrollMetrics metrics = notification.metrics;
                 final double currentOffset = metrics.pixels;
                 final double prevOffset = previousOffset.value;
-                Log.d("---最大滚动距离-----${metrics.maxScrollExtent}-------");
+                // Log.d("---最大滚动距离-----${metrics.maxScrollExtent}-------");
                 if (currentOffset > prevOffset) {
                   // 向上滚动
                   // 日志输出当前滚动偏移量和前一次滚动偏移量
-                  Log.d('--向上滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
+                  // Log.d('--向上滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
                   if(useSearchBar.value == false && metrics.maxScrollExtent >=0 && currentOffset >= 110){
                     // 滚动到110 时 将 titlebar 换成 searchbar
                     useSearchBar.value = true;
@@ -87,7 +87,7 @@ class MyFollowerPage extends HookConsumerWidget {
                 } else if (currentOffset < prevOffset) {
                   // 向下滚动
                   // 日志输出当前滚动偏移量和前一次滚动偏移量
-                  Log.d('--向下滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
+                  // Log.d('--向下滚动---当前currentOffset: $currentOffset, previousOffset: $prevOffset---------');
                   if(useSearchBar.value == true && metrics.maxScrollExtent >=0 && currentOffset <= 110){
                     // 滚动到110 时 将 searchbar 换成 titlebar
                     useSearchBar.value = false;

+ 1 - 1
packages/cpt_community/lib/modules/my_following/my_following_page.dart

@@ -46,11 +46,11 @@ class MyFollowingPage extends HookConsumerWidget {
     final vm = ref.read(myFollowingVmProvider.notifier);
     return Container(
       width: double.infinity,
-      padding: const EdgeInsets.only(left: 15, right: 15,top: 14,bottom: 14),
       child: MyFollowingTabs(
           key: UniqueKey(),
           tabsList: state.tabsList,
           tabsRouter: tabsRouter,
+          margin: EdgeInsets.only(top: 14,bottom: 12, left: 20, right: 20),
           onClickAction:(activeTabIdx){
             vm.handlerChangeTab.call(activeTabIdx, tabsRouter);
           }

+ 5 - 3
packages/cpt_community/lib/modules/my_following/my_following_tabs.dart

@@ -19,12 +19,14 @@ class MyFollowingTabs extends HookConsumerWidget {
   Widget? Function(BuildContext)? tabItemBuilder;
   dynamic? tabsRouter;
   void Function(int)? onClickAction;
+  EdgeInsets? margin;
   MyFollowingTabs({
     Key? key,
     required this.tabsList,
     this.tabsRouter,
     this.onClickAction,
-    this.tabItemBuilder
+    this.tabItemBuilder,
+    this.margin = const EdgeInsets.only(top: 10, bottom: 10, left: 20, right: 20),
   }) : super(key: key);
 
   Widget _buildTabItem(BuildContext context, WidgetRef ref, vm,state, item, index, int activeTabCounter) {
@@ -36,9 +38,9 @@ class MyFollowingTabs extends HookConsumerWidget {
 
 
     return Container(
-      width: MediaQuery.of(context).size.width / vm.state.tabsList.length - 30,
+      width: MediaQuery.of(context).size.width / tabsList.length - margin!.left - margin!.right,
       height: 43,
-      padding: const EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10),
+      margin: margin,
       decoration: index==activeTabIdx? BoxDecoration(
         color: index==activeTabIdx? context.appColors.btnBgDefault: ColorUtils.string2Color("#F2F3F6"),
         borderRadius: BorderRadius.circular(20),

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

@@ -157,7 +157,7 @@ class MyPostsForRentVm extends _$MyPostsForRentVm {
       final result = await commonGarageRespositoryInstance.fetchMyPostsGarageDataList(params);
       //校验成功失败
       if (result.isSuccess) {
-        handlerResultList((result.list as List<MypostsSaleRentEntity>));
+        handlerResultList((result.data! as MypostsSaleRentEntity).list as List<MypostsSaleRentList>);
       } else {
         String errorMessage = result.errorMsg!;
         changeLoadingState(LoadState.State_Error, errorMessage);
@@ -172,7 +172,7 @@ class MyPostsForRentVm extends _$MyPostsForRentVm {
 
   }
 
-  void handlerResultList(List<MypostsSaleRentEntity>? list) {
+  void handlerResultList(List<MypostsSaleRentList>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_page == 1) {

+ 3 - 2
packages/cpt_community/lib/modules/my_posts/my_posts_forsale/my_posts_forsale_vm.dart

@@ -193,9 +193,10 @@ class MyPostsForSaleVm extends _$MyPostsForSaleVm {
       };
       Log.d("请求参数------$params");
       final result = await commonGarageRespositoryInstance.fetchMyPostsGarageDataList(params);
+
       //校验成功失败
       if (result.isSuccess) {
-        handlerResultList((result.list as List<MypostsSaleRentEntity>));
+        handlerResultList((result.data! as MypostsSaleRentEntity).list as List<MypostsSaleRentList>);
       } else {
         String errorMessage = result.errorMsg!;
         changeLoadingState(LoadState.State_Error, errorMessage);
@@ -212,7 +213,7 @@ class MyPostsForSaleVm extends _$MyPostsForSaleVm {
   }
 
 
-  void handlerResultList(List<MypostsSaleRentEntity>? list) {
+  void handlerResultList(List<MypostsSaleRentList>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_page == 1) {

+ 32 - 14
packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_page.dart

@@ -2,6 +2,7 @@ import 'package:cpt_community/components/comments_dialog.dart';
 import 'package:cpt_community/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_vm.dart';
 import 'package:cpt_community/router/page/community_page_router.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/myposts_newsfeed_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
 import 'package:flutter_hooks/flutter_hooks.dart';
@@ -9,6 +10,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:plugin_basic/provider/app_config/app_config_service.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';
@@ -113,7 +115,7 @@ class MyPostsNewsfeedPage extends HookConsumerWidget {
                       return StickyHeader(
                         header: _buildHeaderContent(state.list![index], context),
                         content: Column(
-                          children: _buildGroupContent(state.list![index].itemgroupDatas , index, vm, context),
+                          children: _buildGroupItemContent((state.list![index] as NewsFeedItemGroupState).itemgroupDatas as List<MypostsNewsfeedList>, index, vm, context),
                         ),
                       );
                     },
@@ -136,10 +138,26 @@ class MyPostsNewsfeedPage extends HookConsumerWidget {
     );
   }
 
-  List<Widget> _buildGroupContent(List<Map<String, dynamic>> list, int groupIndex,  vm, BuildContext context) {
-    return list.asMap().entries.map((entry) {
+  List<Widget> _buildGroupItemContent(List<MypostsNewsfeedList> groupList, int groupIndex,  vm, BuildContext context) {
+    return groupList.asMap().entries.map((entry) {
       int childIndex = entry.key;
-      Map<String, dynamic> item = entry.value;
+      MypostsNewsfeedList item = entry.value;
+      Map<String, dynamic> itemJson = entry.value.toJson();
+
+      // String card_title = item.getValue("title", "");
+      int card_id = itemJson.getValue("id", null);
+      String card_created_at = itemJson.getValue("created_at", "");
+      // Map<String, dynamic>? card_account = itemJson.getValue<Map<String,dynamic>>("account", null);
+      // String card_avatar = card_account?['avatar']?? "";
+      // 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 = itemJson.getValue("content", "");
+      List? card_resources = itemJson.getValue<List>("resources", [])?? [];
+      bool card_liked = itemJson.getValue("liked", false);
+      int card_likes_count = itemJson.getValue("likes_count", 0);
+      int card_comments_count = itemJson.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),
@@ -160,7 +178,7 @@ class MyPostsNewsfeedPage extends HookConsumerWidget {
           crossAxisAlignment: CrossAxisAlignment.start,
           children: [
             MyTextView(
-              item['time'],
+              card_created_at,
               textColor: context.appColors.textDarkGray,
               fontSize: 12,
               paddingLeft: 15,
@@ -170,8 +188,8 @@ class MyPostsNewsfeedPage extends HookConsumerWidget {
             // 卡片中间 (文字和图片)
             NewsFeedCardContent(
               key: UniqueKey(),
-              content: item['content'],
-              imageUrls: item["imageUrls"],
+              content: card_content,
+              imageUrls: card_resources,
             ),
             const SizedBox(height: 16),
             // 卡片底部 (点赞 评论 分享)
@@ -185,17 +203,17 @@ class MyPostsNewsfeedPage extends HookConsumerWidget {
               ),
               child: NewsFeedCardFooter(
                 key: UniqueKey(),
-                isLike: true,
-                likes_count: item['likes_count']?? 0,
-                comments_count: item['comments_count']?? 0,
+                isLike: card_liked,
+                likes_count: card_likes_count,
+                comments_count: card_comments_count,
                 onLike: () {
-                  vm.handlerClickActionBtn('like', item);
+                  vm.handlerClickActionBtn('like', item.toJson(), groupIndex, childIndex);
                 },
                 onComment: () {
-                  vm.handlerClickActionBtn('comments', item);
+                  vm.handlerClickActionBtn('comments', item.toJson(), groupIndex, childIndex);
                 },
                 onShare: () {
-                  vm.handlerClickActionBtn('share', item);
+                  vm.handlerClickActionBtn('share', item.toJson(), groupIndex, childIndex);
                 },
               ),
             ),
@@ -203,7 +221,7 @@ class MyPostsNewsfeedPage extends HookConsumerWidget {
         ),
       ).onTap((){
         // 跳转到 详情页
-        vm.handlerGotoDetail(item['id']);
+        vm.handlerGotoDetail(context, card_id);
       });
     }).toList();
   }

+ 0 - 18
packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_state.dart

@@ -7,9 +7,6 @@ class MyPostsNewsfeedState {
   String? errorMessage;
 
   int? activeTabIndex =0;
-  int? page =0;
-  int? limit =10;
-  int? count =1;
   List<Map<String, dynamic>>? tabsList;
   List<NewsFeedItemGroupState>? list = [];
 
@@ -17,9 +14,6 @@ class MyPostsNewsfeedState {
     this.loadingState = LoadState.State_Loading,
     String? errorMessage,
     this.activeTabIndex,
-    this.page,
-    this.limit,
-    this.count = 1,
     List<Map<String, dynamic>>? tabsList,
     this.list,
   }): tabsList = tabsList ?? [
@@ -44,9 +38,6 @@ class MyPostsNewsfeedState {
     LoadState? loadingState,
     String? errorMessage,
     int? activeTabIndex,
-    int? page,
-    int? limit,
-    int? count,
     List<Map<String, dynamic>>? tabsList,
     List<NewsFeedItemGroupState>? list,
   }) {
@@ -54,9 +45,6 @@ class MyPostsNewsfeedState {
       loadingState: loadingState ?? this.loadingState,
       errorMessage: errorMessage ?? this.errorMessage,
       activeTabIndex: activeTabIndex ?? this.activeTabIndex,
-      page: page ?? this.page,
-      limit: limit ?? this.limit,
-      count: count ?? this.count,
       tabsList: tabsList ?? this.tabsList,
       list: list ?? this.list,
     );
@@ -67,9 +55,6 @@ class MyPostsNewsfeedState {
       'loadingState': this.loadingState,
       'errorMessage': this.errorMessage,
       'activeTabIndex': this.activeTabIndex,
-      'page': this.page,
-      'limit': this.limit,
-      'count': this.count,
       'tabsList': this.tabsList,
       'list': this.list,
     };
@@ -80,9 +65,6 @@ class MyPostsNewsfeedState {
       loadingState: map['loadingState'] as LoadState,
       errorMessage: map['errorMessage'] as String,
       activeTabIndex: map['activeTabIndex'] as int,
-      page: map['page'] as int,
-      limit: map['limit'] as int,
-      count: map['count'] as int,
       tabsList: map['tabsList'] as List<Map<String, dynamic>>,
       list: map['list'] as List<NewsFeedItemGroupState>,
     );

+ 247 - 76
packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/my_posts_newsfeed_vm.dart

@@ -1,13 +1,16 @@
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/myposts_newsfeed_entity.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:router/ext/auto_router_extensions.dart';
+import 'package:shared/utils/ext_dart.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 import 'package:auto_route/auto_route.dart';
 
+import '../../../respository/common_newsfeed.dart';
 import '../../../router/page/community_page_router.dart';
 
 import '../../community/newsfeed_detail/newsfeed_detail_page.dart';
@@ -19,9 +22,14 @@ part 'my_posts_newsfeed_vm.g.dart';
 
 @riverpod
 class MyPostsNewsfeedVm extends _$MyPostsNewsfeedVm {
-  // late MyPostsRepository MyPostsRepositoryInstance;
+  late CommonNewsFeedRespository commonNewsFeedRespositoryInstance;
 
   bool _needShowPlaceholder = false; //是否展示LoadingView
+
+  int _page = 1;
+  int _limit = 10;
+  int _count = 0;
+
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
@@ -37,7 +45,7 @@ class MyPostsNewsfeedVm extends _$MyPostsNewsfeedVm {
   @override
   MyPostsNewsfeedState build(){
     // 引入数据仓库
-    // MyPostsNewsfeedRepositoryInstance = ref.read(newsRepositoryProvider);
+    commonNewsFeedRespositoryInstance = ref.read(commonNewsFeedRespositoryProvider);
     final state = initState();
     Log.d("--------------------------build---------------------");
 
@@ -70,17 +78,7 @@ class MyPostsNewsfeedVm extends _$MyPostsNewsfeedVm {
   // 上拉加载 更多
   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();
   }
 
@@ -90,31 +88,31 @@ class MyPostsNewsfeedVm extends _$MyPostsNewsfeedVm {
     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();
   }
 
   // 获取list 列表数据
-  Future getListData<T>() async {
+  Future getListData<T>({bool? isLoadMore = false}) async {
     Log.d("加载listData数据---------------start-----");
 
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
 
-    Log.d("for_sale加载listData数据---------------start--${state.page}---");
+    Log.d("for_sale加载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);
@@ -136,91 +134,264 @@ class MyPostsNewsfeedVm extends _$MyPostsNewsfeedVm {
 
     await Future.delayed(const Duration(milliseconds: 1500));
 
-    final List<NewsFeedItemGroupState> listData = [];
-
-    listData.add(
-        NewsFeedItemGroupState(
-        groupId: "June 17,2024",
-        itemgroupDatas: [
-          {
-            '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 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
-          },
-        ]
-    ));
-
-
-
-
-    if (state.page == 1) {
-      //刷新的方式
-      state = state.copyWith(list: listData);
-      refreshController.finishRefresh();
-      // //更新展示的状态
-      changeLoadingState(LoadState.State_Success, null);
+    // final List<NewsFeedItemGroupState> listData = [];
+    //
+    // listData.add(
+    //     NewsFeedItemGroupState(
+    //     groupId: "June 17,2024",
+    //     itemgroupDatas: [
+    //       {
+    //         '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 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
+    //       },
+    //     ]
+    // ));
+
+
+
+
+    // 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 = {
+        "page": _page,
+        "limit": _limit,
+      };
+      Log.d("请求参数------$params");
+      final result = await commonNewsFeedRespositoryInstance.fetchMyPostNewsfeedList(params);
+      //校验成功失败
+      if (result.isSuccess) {
+        handlerResultList((result.data  as MypostsNewsfeedEntity).list as List<MypostsNewsfeedList>, 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");
+    }
+
+    updateMyPostsTabsNum('newsFeed', state.list!.length, 0);
+  }
+
+
+  void handlerResultList(List<MypostsNewsfeedList>? list, bool isLoadMore) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (_page == 1) {
+        //刷新的方式
+        state.list!.clear();
+
+        state.list!.addAll(groupList(list));
+        refreshController.finishRefresh();
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        allList!.addAll(groupList(list));
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+      }
     } else {
-      //加载更多
-      final allList = state.list;
-      allList?.addAll(listData);
-      state = state.copyWith(list: allList);
-      refreshController.finishLoad();
+      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);
+      }
+    }
+  }
+
+  // 根据created_at 将 list 进行分组
+  List<NewsFeedItemGroupState> groupList(List<MypostsNewsfeedList> list) {
+    if (list == null || list.isEmpty) {
+      return [];
     }
 
-    // 最后赋值
-    _needShowPlaceholder = false;
+    Map<String, List<MypostsNewsfeedList>> groupedMap = {};
 
+    for (var item in list) {
+      groupedMap.putIfAbsent(item.createdAt!, () => []).add(item);
+    }
+
+    return groupedMap.entries.map((entry) {
+      return NewsFeedItemGroupState(
+        groupId: entry.key,
+        itemgroupDatas: entry.value,
+      );
+    }).toList();
+  }
+
+
+
+  // 更新 my_posts_tabs 里面的数字
+  updateMyPostsTabsNum(String key, int num, int activeTabIdx){
     WidgetsBinding.instance.addPostFrameCallback((_) {
       // 需要更新 my_posts_tabs 里面的数字
       ref.read(myPostsVmProvider.notifier)
-          .updateMyPostsTabsNum( 'newsFeed', state.list!.length, 0);
+          .updateMyPostsTabsNum(key, num, activeTabIdx );
     });
   }
 
+  // 点赞/取消点赞
+  Future handlerLikeClick(int id, bool isLike, int? groupIndex, int? childIndex) async {
+    Log.d("99999   id:$id   isLike:$isLike groupIndex:$groupIndex  childIndex:$childIndex");
+    try {
+      final result = await commonNewsFeedRespositoryInstance.fetchLikeClick({
+        "id": id,
+      });
+      List<NewsFeedItemGroupState> listCopyDta =  List.from(state.list!);
+      if (result.isSuccess) {
+        if(groupIndex != null){
+          MypostsNewsfeedList currentGroupItem = listCopyDta[groupIndex!].itemgroupDatas[childIndex!];
+          Map<String, dynamic> currentGroupItemJson = currentGroupItem.toJson();
+          Log.d("77777  $currentGroupItemJson");
+          // 修改 listCopyDta[itemIdx] 中的 like 状态 和 likes_count
+          currentGroupItemJson['liked'] = !isLike;
+
+          if(isLike){
+            // 取消点赞
+            if(currentGroupItemJson['likes_count']>0){
+              currentGroupItemJson['likes_count'] = currentGroupItemJson['likes_count'] - 1;
+            }
+          }else {
+            currentGroupItemJson['likes_count'] = currentGroupItemJson['likes_count'] + 1;
+          }
+
+
+          listCopyDta[groupIndex!].itemgroupDatas[childIndex] = MypostsNewsfeedList.fromJson(currentGroupItemJson);
+        }else {
+          Log.d("88888");
+          // 详情中的点赞 需要找到对应的 item 进行 修改 like 和 likes_count
+          listCopyDta!.forEach((groupitem) {
+            List<MypostsNewsfeedList> groupItemGroupDatas = groupitem.itemgroupDatas;
+            if(groupItemGroupDatas!=null && groupItemGroupDatas.isNotEmpty){
+              for (var value in groupItemGroupDatas) {
+
+                if(value.id == id){
+                  value.liked = !isLike;
+                  if(isLike){
+                    // 取消点赞
+                    if(value.likesCount!>0){
+                      value.likesCount =value.likesCount! - 1;
+                    }
+                  }else {
+                    value.likesCount = value.likesCount! + 1;
+                  }
+                }
+              }
+            }
+
+          });
+        }
+
+        state = state.copyWith(list: listCopyDta);
+
+        final String toastMsg = isLike ? "Cancel successfully": "Liked successfully";
+        ToastEngine.show(toastMsg);
+
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error) {
+      Log.d("my_posts_newsfeed_vm handlerLikeClick 发生错误: $error");
+      return false;
+    }
+  }
 
 
   // 点击 like comments  share
-  void handlerClickActionBtn(String? actionStr, item){
+  Future<bool?> handlerClickActionBtn(String? actionStr, Map<String, dynamic> item, int? groupIndex, int? childIndex) async{
     final id = item['id'];
+    final liked = item.getValue('liked', false);
     switch (actionStr) {
       case 'like':
-        Log.d("点击了 点赞");
-        handlerGotoDetail(id);
-        break;
+        return await handlerLikeClick(id, liked, groupIndex, childIndex!);
       case 'comments':
         Log.d("点击了 评论");
-        handlerGotoDetail(id);
+        handlerGotoDetail(null, id);
         break;
       case 'share':
         Log.d("点击了 分享");
-        handlerGotoDetail(id);
+        handlerGotoDetail(null, id);
         break;
       default:
         Log.d("点击了卡片");
-        handlerGotoDetail(id);
+        handlerGotoDetail(null, id);
         break;
     }
   }
+
+
+  // 关注/取消关注
+  Future<bool> handlerFollow(BuildContext? context, int to_user_id, int cardId, bool isFollow) async{
+    Log.d("点击了 关注");
+    try {
+      final result = await commonNewsFeedRespositoryInstance.handlerFollowOrCancel({
+        "to_user_id": to_user_id,
+      });
+      if(result.isSuccess){
+        return true;
+      }else {
+        return false;
+      }
+    }catch(error){
+      Log.d("error: $error");
+      return false;
+    }
+  }
+
   // 去详情页面
-  void handlerGotoDetail(id){
+  void handlerGotoDetail(BuildContext? context, int id){
     Log.d("去详情页面");
-    appRouter.push(NewsfeedDetailPageRoute(id: id, type:'news'));
+    appRouter.push(NewsfeedDetailPageRoute(id: id, type: 'mypostsNews'));
   }
 }

+ 5 - 1
packages/cpt_community/lib/modules/my_posts/my_posts_newsfeed/newsfeed_itemgroup_state.dart

@@ -1,7 +1,11 @@
 
+import 'package:domain/entity/myposts_newsfeed_entity.dart';
+
 class NewsFeedItemGroupState {
   String groupId;  // 分组id
-  List<Map<String, dynamic>> itemgroupDatas;  // 组数据
+  List<MypostsNewsfeedList> itemgroupDatas;  // 组数据
 
   NewsFeedItemGroupState({required this.groupId, required this.itemgroupDatas});
+
+
 }

+ 21 - 8
packages/cpt_community/lib/respository/common_garage.dart

@@ -95,10 +95,10 @@ class CommonGarageRespository {
     //根据返回的结果,封装原始数据为Bean/Entity对象
     if (result.isSuccess) {
       //重新赋值data或list
-      final json = result.getListJson();
-      List<GarageSaleRentEntity> data = json?.map((item) => GarageSaleRentEntity.fromJson(item)).toList() ?? [];
+      final json = result.getDataJson();
+      var data = GarageSaleRentEntity.fromJson(json!);
       //重新赋值data或list
-      return result.convert(list: data);
+      return result.convert(data: data);
     }else {
       if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
         ToastEngine.show("${result.errorMsg}");
@@ -132,10 +132,11 @@ class CommonGarageRespository {
     //根据返回的结果,封装原始数据为Bean/Entity对象
     if (result.isSuccess) {
       //重新赋值data或list
-      final json = result.getListJson();
-      List<MypostsSaleRentEntity> data = json?.map((item) => MypostsSaleRentEntity.fromJson(item)).toList() ?? [];
+      final json = result.getDataJson();
+
+      var data = MypostsSaleRentEntity.fromJson(json!);
       //重新赋值data或list
-      return result.convert(list: data);
+      return result.convert(data: data);
     }else {
       if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
         ToastEngine.show("${result.errorMsg}");
@@ -193,10 +194,22 @@ class CommonGarageRespository {
     headers["Content-Type"] = "application/x-www-form-urlencoded";
     headers["Accept"] = "application/x.yyjobs-api.v1+json";
 
+    List<String> paths = data!["resources"] as List<String>;
+
+    Map<String, String> files = {};
+    if (paths != null && paths.isNotEmpty) {
+      paths.asMap().forEach((index, path) {
+        files["resources[$index]"] = path;
+      });
+    }
+    // 删除 resources 属性
+    params.remove("resources");
+
     final result = await dioEngine.requestNetResult(
       // ApiConstants.apiServerTime, // api 地址
       '/api/v1/user/garage-sale/index/publish', // api 地址
       params: params,
+      paths: files,
       headers: headers,
       method: HttpMethod.POST,
       isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
@@ -226,8 +239,8 @@ class CommonGarageRespository {
     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";
+    // headers["Content-Type"] = "application/x-www-form-urlencoded";
+    // headers["Accept"] = "application/x.yyjobs-api.v1+json";
 
     final result = await dioEngine.requestNetResult(
       // ApiConstants.apiServerTime, // api 地址

+ 15 - 1
packages/cpt_community/lib/respository/common_newsfeed.dart

@@ -1,5 +1,6 @@
 import 'package:domain/constants/api_constants.dart';
 import 'package:domain/entity/myfollowing_list_entity.dart';
+import 'package:domain/entity/myposts_newsfeed_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';
@@ -229,10 +230,23 @@ class CommonNewsFeedRespository {
     headers["Content-Type"] = "application/x-www-form-urlencoded";
     headers["Accept"] = "application/x.yyjobs-api.v1+json";
 
+    List<String> paths = data!["resources"] as List<String>;
+
+    Map<String, String> files = {};
+    if (paths != null && paths.isNotEmpty) {
+      paths.asMap().forEach((index, path) {
+        files["resources[$index]"] = path;
+      });
+    }
+
+    // 删除 resources 属性
+    params.remove("resources");
+
     final result = await dioEngine.requestNetResult(
       // ApiConstants.apiServerTime, // api 地址
       '/api/v1/user/news-feed/index/publish', // api 地址
       params: params,
+      paths: files,
       headers: headers,
       method: HttpMethod.POST,
       isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
@@ -427,7 +441,7 @@ class CommonNewsFeedRespository {
     if (result.isSuccess) {
       //重新赋值data或list
       final json = result.getDataJson();
-      // var data = NewsfeedDetailEntity.fromJson(json!);
+      var data = MypostsNewsfeedEntity.fromJson(json!);
       //重新赋值data或list
       return result.convert(data: data);
     }else {

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

@@ -18,7 +18,7 @@ abstract class _$CommunityPageRouter extends RootStackRouter {
     CommunityPageRoute.name: (routeData) {
       return AutoRoutePage<dynamic>(
         routeData: routeData,
-        child: const CommunityPage(),
+        child:  CommunityPage(),
       );
     },
     FollowingPageRoute.name: (routeData) {

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

@@ -149,7 +149,8 @@ class FacilityBookingViewModel extends _$FacilityBookingViewModel with DioCancel
     );
 
     if (result.isSuccess) {
-      FacilityDetailPage.startWithPop2Main();
+      final bookingId = result.data?.booking?.id;
+      FacilityDetailPage.startWithPop2Main(bookingId: bookingId);
     } else {
       ToastEngine.show(result.errorMsg ?? "UnKnow Error");
     }

+ 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'5bfb55d67994d66800bb220385e48954d6aec449';
+    r'564f4a008b169156b09e3c2325eb1e1cd02e1a47';
 
 /// See also [FacilityBookingViewModel].
 @ProviderFor(FacilityBookingViewModel)

+ 91 - 30
packages/cpt_facility/lib/modules/detail/facility_detail_page.dart

@@ -3,6 +3,7 @@ import 'package:cs_resources/generated/l10n.dart';
 import 'package:cs_resources/theme/app_colors_theme.dart';
 import 'package:flutter/material.dart';
 import 'package:auto_route/auto_route.dart';
+import 'package:flutter_hooks/flutter_hooks.dart';
 import 'package:hooks_riverpod/hooks_riverpod.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:widgets/ext/ex_widget.dart';
@@ -14,21 +15,23 @@ import 'facility_detail_view_model.dart';
 
 @RoutePage()
 class FacilityDetailPage extends HookConsumerWidget {
-  const FacilityDetailPage({Key? key}) : super(key: key);
+  final String? bookingId;
+
+  const FacilityDetailPage({Key? key, required this.bookingId}) : super(key: key);
 
   //启动当前页面
-  static void startInstance({BuildContext? context}) {
+  static void startInstance({BuildContext? context, required String? bookingId}) {
     if (context != null) {
-      context.router.push(const FacilityDetailPageRoute());
+      context.router.push(FacilityDetailPageRoute(bookingId: bookingId));
     } else {
-      appRouter.push(const FacilityDetailPageRoute());
+      appRouter.push(FacilityDetailPageRoute(bookingId: bookingId));
     }
   }
 
   //启动当前页面并回退至设施首页
-  static void startWithPop2Main() {
+  static void startWithPop2Main({required String? bookingId}) {
     appRouter.pushAndPopUntil(
-      const FacilityDetailPageRoute(),
+      FacilityDetailPageRoute(bookingId: bookingId),
       predicate: (route) {
         return route.settings.name == 'FacilityPageRoute';
       },
@@ -40,8 +43,16 @@ class FacilityDetailPage extends HookConsumerWidget {
     final viewModel = ref.watch(facilityDetailViewModelProvider.notifier);
     final state = ref.watch(facilityDetailViewModelProvider);
 
+    useEffect(() {
+      // 组件挂载时执行 - 执行接口请求
+      Future.microtask(() => viewModel.fetchFacilityDetail(bookingId));
+      return () {
+        // 组件卸载时执行
+      };
+    }, []);
+
     return Scaffold(
-      appBar: MyAppBar.appBar(context, "Kids party room", backgroundColor: context.appColors.backgroundWhite),
+      appBar: MyAppBar.appBar(context, state.detail?.facility?.type?.name ?? "", backgroundColor: context.appColors.backgroundWhite),
       backgroundColor: context.appColors.backgroundDark,
       body: SingleChildScrollView(
         scrollDirection: Axis.vertical,
@@ -61,9 +72,9 @@ class FacilityDetailPage extends HookConsumerWidget {
               Assets.facilityConfirmDateIcon,
               28.5,
               29,
-              "Tue,24 Oct 2023",
+              state.detail?.booking?.date ?? "",
               null,
-              "05:00 PM-10:00 PM",
+              "${state.detail?.booking?.start ?? ""}-${state.detail?.booking?.end ?? ""}",
               null,
             ),
 
@@ -75,9 +86,9 @@ class FacilityDetailPage extends HookConsumerWidget {
               Assets.facilityConfirmFacilityIcon,
               25.0,
               30.5,
-              "Kids party room",
+              state.detail?.facility?.type?.name ?? "",
               null,
-              "Blue room",
+              state.detail?.facility?.name ?? "",
               null,
             ),
 
@@ -90,9 +101,9 @@ class FacilityDetailPage extends HookConsumerWidget {
               27.0,
               22.0,
               S.current.booking_fee,
-              "10.80",
+              state.detail?.timePeriod?.price ?? "",
               S.current.total,
-              "\$10.80",
+              "\$${state.detail?.timePeriod?.price ?? ""}",
             ),
 
             // 押金
@@ -104,7 +115,7 @@ class FacilityDetailPage extends HookConsumerWidget {
               28.0,
               26.5,
               S.current.on_hold,
-              "\$100.00",
+              "\$${state.detail?.timePeriod?.deposit ?? ""}",
               null,
               null,
             ),
@@ -115,6 +126,7 @@ class FacilityDetailPage extends HookConsumerWidget {
   }
 
   Widget _buildHeaderWidget(BuildContext context, WidgetRef ref) {
+    final state = ref.watch(facilityDetailViewModelProvider);
     return Container(
       width: double.infinity,
       color: context.appColors.whiteBG,
@@ -152,7 +164,7 @@ class FacilityDetailPage extends HookConsumerWidget {
             textColor: context.appColors.textBlack,
           ),
           MyTextView(
-            "\$10.80",
+            "\$${state.detail?.timePeriod?.price ?? ""}",
             fontSize: 15,
             isFontRegular: true,
             textColor: context.appColors.textPrimary,
@@ -187,7 +199,7 @@ class FacilityDetailPage extends HookConsumerWidget {
                 textColor: context.appColors.textBlack,
               ),
               MyTextView(
-                "24 Oct 2023 at 02:19 PM",
+                " ${state.detail?.booking?.date ?? ""}",
                 fontSize: 15,
                 isFontMedium: true,
                 textColor: context.appColors.textBlack,
@@ -195,21 +207,70 @@ class FacilityDetailPage extends HookConsumerWidget {
             ],
           ).marginOnly(top: 5),
 
-          Divider(height: 0.5, color: context.appColors.dividerDefault).marginOnly(top: 14, bottom: 14),
+          //退还押金的布局展示
+          Visibility(
+            visible: state.detail?.booking?.depositRefund != "0.00",
+            child: Column(
+              children: [
+                Divider(height: 0.5, color: context.appColors.dividerDefault).marginOnly(top: 14, bottom: 14),
 
-          //押金
-          MyTextView(
-            S.current.deposit_released_caps,
-            fontSize: 15,
-            isFontRegular: true,
-            textColor: context.appColors.textBlack,
-          ),
-          MyTextView(
-            "\$100.00",
-            fontSize: 15,
-            marginTop: 5,
-            isFontRegular: true,
-            textColor: context.appColors.textPrimary,
+                //退还的押金
+                MyTextView(
+                  S.current.deposit_released_caps,
+                  fontSize: 15,
+                  isFontRegular: true,
+                  textColor: context.appColors.textBlack,
+                ),
+
+                MyTextView(
+                  "\$${state.detail?.booking?.depositRefund ?? ""}",
+                  fontSize: 15,
+                  marginTop: 5,
+                  isFontRegular: true,
+                  textColor: context.appColors.textPrimary,
+                ),
+
+                Divider(height: 0.5, color: context.appColors.dividerDefault).marginOnly(top: 14, bottom: 14),
+
+                //押金付款于时间
+                Row(
+                  mainAxisSize: MainAxisSize.min,
+                  children: [
+                    MyTextView(
+                      S.current.hold_started_on,
+                      fontSize: 15,
+                      isFontRegular: true,
+                      textColor: context.appColors.textBlack,
+                    ),
+                    MyTextView(
+                      " ${state.detail?.booking?.date ?? ""}",
+                      fontSize: 15,
+                      isFontMedium: true,
+                      textColor: context.appColors.textBlack,
+                    ),
+                  ],
+                ).marginOnly(top: 5),
+
+                //押金退款于时间
+                Row(
+                  mainAxisSize: MainAxisSize.min,
+                  children: [
+                    MyTextView(
+                      S.current.released_on,
+                      fontSize: 15,
+                      isFontRegular: true,
+                      textColor: context.appColors.textBlack,
+                    ),
+                    MyTextView(
+                      " ${state.detail?.booking?.depositRefundAt ?? ""}",
+                      fontSize: 15,
+                      isFontMedium: true,
+                      textColor: context.appColors.textBlack,
+                    ),
+                  ],
+                ).marginOnly(top: 5),
+              ],
+            ),
           ),
 
           const SizedBox(height: 23),

+ 16 - 2
packages/cpt_facility/lib/modules/detail/facility_detail_state.dart

@@ -1,3 +1,17 @@
-class FacilityDetailState{
+import 'package:domain/entity/facility_page_entity.dart';
 
-}
+class FacilityDetailState {
+  final FacilityDetail? detail;
+
+  FacilityDetailState({
+    this.detail,
+  });
+
+  FacilityDetailState copyWith({
+    FacilityDetail? detail,
+  }) {
+    return FacilityDetailState(
+      detail: detail ?? this.detail,
+    );
+  }
+}

+ 22 - 2
packages/cpt_facility/lib/modules/detail/facility_detail_view_model.dart

@@ -1,3 +1,6 @@
+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 'facility_detail_state.dart';
@@ -5,9 +8,26 @@ import 'facility_detail_state.dart';
 part 'facility_detail_view_model.g.dart';
 
 @riverpod
-class FacilityDetailViewModel extends _$FacilityDetailViewModel{
+class FacilityDetailViewModel extends _$FacilityDetailViewModel with DioCancelableMixin{
+  late final FacilityRepository _facilityRepository;
   @override
   FacilityDetailState build() {
-    return FacilityDetailState();
+    _facilityRepository = ref.read(facilityRepositoryProvider);
+    final state =  FacilityDetailState();
+    registerCancellation();
+    return state;
   }
+
+  /// 获取详情
+  Future fetchFacilityDetail(String? bookingId) async {
+    final result = await _facilityRepository.fetchFacilityBookingDetail(id: bookingId, cancelToken: cancelToken);
+
+    // 处理数据
+    if (result.isSuccess) {
+      state = state.copyWith(detail: result.data);
+    } else {
+      ToastEngine.show(result.errorMsg ?? "UnKnow Error");
+    }
+  }
+
 }

+ 1 - 1
packages/cpt_facility/lib/modules/detail/facility_detail_view_model.g.dart

@@ -7,7 +7,7 @@ part of 'facility_detail_view_model.dart';
 // **************************************************************************
 
 String _$facilityDetailViewModelHash() =>
-    r'fc7e226b3c796f8790a9715a13656c06d1b98b20';
+    r'8a361195ada0787beab9b28c38810c95acc51156';
 
 /// See also [FacilityDetailViewModel].
 @ProviderFor(FacilityDetailViewModel)

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

@@ -10,7 +10,6 @@ import '../../detail/facility_detail_page.dart';
 import 'facility_active_view_model.dart';
 import 'item_facility_active.dart';
 
-
 @RoutePage()
 class FacilityActiveScreen extends HookConsumerWidget {
   @override
@@ -42,13 +41,13 @@ class FacilityActiveScreen extends HookConsumerWidget {
           successSliverWidget: [
             SliverList(
                 delegate: SliverChildBuilderDelegate(
-                      (context, index) {
-                    return FacilityActiveItem(index: index, item: state.datas[index]).onTap((){
-                      // FacilityDetailPage.startInstance(context: context);
-                    });
-                  },
-                  childCount: state.datas.length,
-                ))
+              (context, index) {
+                return FacilityActiveItem(index: index, item: state.datas[index]).onTap(() {
+                  FacilityDetailPage.startInstance(context: context, bookingId: state.datas[index].booking?.id);
+                });
+              },
+              childCount: state.datas.length,
+            ))
           ],
         ),
       ).marginOnly(top: 5, bottom: 5),

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

@@ -7,7 +7,7 @@ class FacilityActiveState {
   LoadState loadingState;
   String? errorMessage;
 
-  List<FacilityPageList> datas; //页面列表数据
+  List<FacilityDetail> datas; //页面列表数据
 
   // ===================================  Begin  ↓  ===================================
 
@@ -21,7 +21,7 @@ class FacilityActiveState {
     LoadState? loadingState,
     String? errorMessage,
     bool? needShowPlaceholder,
-    List<FacilityPageList>? datas,
+    List<FacilityDetail>? datas,
   }) {
     return FacilityActiveState(
       errorMessage: errorMessage ?? this.errorMessage,

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

@@ -78,7 +78,7 @@ class FacilityActiveViewModel extends _$FacilityActiveViewModel with DioCancelab
   }
 
   // 处理数据与展示的逻辑
-  void handleList(List<FacilityPageList>? list) {
+  void handleList(List<FacilityDetail>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_curPage == 1) {
@@ -90,7 +90,7 @@ class FacilityActiveViewModel extends _$FacilityActiveViewModel with DioCancelab
         changeLoadingState(LoadState.State_Success, null);
       } else {
         //加载更多
-        state.datas.addAll(List<FacilityPageList>.from(state.datas)..addAll(list));
+        state.datas.addAll(List<FacilityDetail>.from(state.datas)..addAll(list));
         refreshController.finishLoad();
       }
     } else {

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

@@ -7,7 +7,7 @@ part of 'facility_active_view_model.dart';
 // **************************************************************************
 
 String _$facilityActiveViewModelHash() =>
-    r'57bc96b84547eef379f700777115155343b5cb78';
+    r'c15699785d72e6c5965eb0f97eed8b03386fc75b';
 
 /// See also [FacilityActiveViewModel].
 @ProviderFor(FacilityActiveViewModel)

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

@@ -9,7 +9,7 @@ import 'package:widgets/my_text_view.dart';
 ///  设施的Active的Item
 class FacilityActiveItem extends StatelessWidget {
   final int index;
-  final FacilityPageList item;
+  final FacilityDetail item;
 
   const FacilityActiveItem({
     required this.index,

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

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

+ 2 - 1
packages/cpt_facility/lib/modules/facility/book/facility_book_view_model.dart

@@ -1,3 +1,4 @@
+import 'package:domain/entity/facility_index_entity.dart';
 import 'package:domain/entity/id_name_entity.dart';
 import 'package:domain/repository/facility_repository.dart';
 import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
@@ -68,7 +69,7 @@ class FacilityBookViewModel extends _$FacilityBookViewModel with DioCancelableMi
   }
 
   // 处理数据与展示的逻辑
-  void handleList(List<IdNameEntity>? list) {
+  void handleList(List<FacilityIndexEntity>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据
       state = state.copyWith(datas: list, loadingState: LoadState.State_Success);

+ 9 - 6
packages/cpt_facility/lib/modules/facility/book/item_facility_book.dart

@@ -1,16 +1,16 @@
 import 'package:cs_resources/theme/app_colors_theme.dart';
-import 'package:domain/entity/id_name_entity.dart';
+import 'package:domain/entity/facility_index_entity.dart';
 import 'package:flutter/material.dart';
+import 'package:shared/utils/log_utils.dart';
+import 'package:shared/utils/util.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/my_text_view.dart';
 
-import '../facility_types.dart';
-
 ///  设施的Book的Item
 class FacilityBookItem extends StatelessWidget {
   final int index;
-  final IdNameEntity item;
+  final FacilityIndexEntity item;
 
   const FacilityBookItem({
     required this.index,
@@ -19,6 +19,7 @@ class FacilityBookItem extends StatelessWidget {
 
   @override
   Widget build(BuildContext context) {
+    Log.d("width:${Utils.extractWidthHeight(item.icon)?[0]} height:${Utils.extractWidthHeight(item.icon)?[1]}");
     return Container(
       width: double.infinity,
       height: 80,
@@ -33,8 +34,10 @@ class FacilityBookItem extends StatelessWidget {
         crossAxisAlignment: CrossAxisAlignment.center,
         children: [
           MyLoadImage(
-            "https://img0.baidu.com/it/u=2679587808,2501833998&fm=253&fmt=auto&app=120&f=JPEG?w=372&h=400",
-            width: 38.5,
+            item.icon,
+            //因为传的是xxhdpi的图片,故要除以3才是显示的宽高
+            width: Utils.extractWidthHeight(item.icon) == null ? 40 : Utils.extractWidthHeight(item.icon)![0] / 3,
+            height: Utils.extractWidthHeight(item.icon) == null ? 40 : Utils.extractWidthHeight(item.icon)![1] / 3,
           ),
           MyTextView(
             item.name ?? "-",

+ 11 - 2
packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_screen.dart

@@ -49,7 +49,7 @@ class FacilityDepositScreen extends HookConsumerWidget {
                 delegate: SliverChildBuilderDelegate(
               (context, index) {
                 return FacilityDepositItem(index: index, item: state.datas[index]).onTap(() {
-                  FacilityDetailPage.startInstance(context: context);
+                  FacilityDetailPage.startInstance(context: context,bookingId: state.datas[index].booking?.id);
                 });
               },
               childCount: state.datas.length,
@@ -116,12 +116,19 @@ class FacilityDepositScreen extends HookConsumerWidget {
     );
   }
 
-  //底部的说明文本脚布局
+  /// 构建页面底部组件
+  ///
+  /// [BuildContext context] 用于访问当前构建上下文,以便获取主题颜色等信息
+  /// [WidgetRef ref] 用于访问和操作应用状态
+  ///
+  /// 返回一个SliverToBoxAdapter,它包含一个列布局,其中包含两个文本视图
+  /// 第一个文本视图显示存款描述的标题,第二个文本视图显示具体的存款描述文本
   _buildFootWidget(BuildContext context, WidgetRef ref) {
     return SliverToBoxAdapter(
       child: Column(
         crossAxisAlignment: CrossAxisAlignment.start,
         children: [
+          // 显示存款描述标题的文本视图
           MyTextView(
             S.current.deposit_desc,
             fontSize: 20,
@@ -131,6 +138,7 @@ class FacilityDepositScreen extends HookConsumerWidget {
             isFontMedium: true,
             textColor: context.appColors.textBlack,
           ),
+          // 显示具体存款描述文本的文本视图
           MyTextView(
             S.current.deposit_desc_txt,
             marginTop: 14,
@@ -145,4 +153,5 @@ class FacilityDepositScreen extends HookConsumerWidget {
       ),
     );
   }
+
 }

+ 2 - 2
packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_state.dart

@@ -9,7 +9,7 @@ class FacilityDepositState {
 
   String? totalDeposit;  //总金额
 
-  List<FacilityPageList> datas; //页面列表数据
+  List<FacilityDetail> datas; //页面列表数据
 
   // ===================================  Begin  ↓  ===================================
 
@@ -24,7 +24,7 @@ class FacilityDepositState {
     LoadState? loadingState,
     String? errorMessage,
     bool? needShowPlaceholder,
-    List<FacilityPageList>? datas,
+    List<FacilityDetail>? datas,
     String? totalDeposit,
   }) {
     return FacilityDepositState(

+ 2 - 2
packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_view_model.dart

@@ -72,7 +72,7 @@ class FacilityDepositViewModel extends _$FacilityDepositViewModel with DioCancel
   }
 
   // 处理数据与展示的逻辑
-  void handleList(List<FacilityPageList>? list) {
+  void handleList(List<FacilityDetail>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_curPage == 1) {
@@ -84,7 +84,7 @@ class FacilityDepositViewModel extends _$FacilityDepositViewModel with DioCancel
         changeLoadingState(LoadState.State_Success, null);
       } else {
         //加载更多
-        state.datas.addAll(List<FacilityPageList>.from(state.datas)..addAll(list));
+        state.datas.addAll(List<FacilityDetail>.from(state.datas)..addAll(list));
         refreshController.finishLoad();
       }
     } else {

+ 1 - 1
packages/cpt_facility/lib/modules/facility/deposit/facility_deposit_view_model.g.dart

@@ -7,7 +7,7 @@ part of 'facility_deposit_view_model.dart';
 // **************************************************************************
 
 String _$facilityDepositViewModelHash() =>
-    r'2b35e0ffd671d3ab67217b51dc076475f7e2a00a';
+    r'8e4a73e233a2fad49624f2be471b578a5ff28bbd';
 
 /// See also [FacilityDepositViewModel].
 @ProviderFor(FacilityDepositViewModel)

+ 1 - 1
packages/cpt_facility/lib/modules/facility/deposit/item_facility_deposit.dart

@@ -9,7 +9,7 @@ import 'package:widgets/my_text_view.dart';
 ///  设施的Deposit的Item
 class FacilityDepositItem extends StatelessWidget {
   final int index;
-  final FacilityPageList item;
+  final FacilityDetail item;
 
   const FacilityDepositItem({
     required this.index,

+ 0 - 52
packages/cpt_facility/lib/modules/facility/facility_types.dart

@@ -1,52 +0,0 @@
-import 'package:cs_resources/generated/assets.dart';
-import 'package:cs_resources/generated/l10n.dart';
-
-
-class FacilityTypes {
-  //对应的type类型 对应的icon的图片与宽高
-  static Map<String, Map<String, dynamic>> iconMap = {
-    //Function Room
-    '1': {
-      'name': S.current.function_room,
-      'icon_path': Assets.facilityFunctionRoomIcon,
-      'width': 39.0,
-      'height': 39.5,
-    },
-    //Gourmet Pavilion
-    '2': {
-      'name': S.current.gourmet_pavilion,
-      'icon_path': Assets.facilityGourmetPavilionIcon,
-      'width': 38.0,
-      'height': 33.5,
-    },
-    //Kids Party Room
-    '3': {
-      'name': S.current.kids_party_room,
-      'icon_path': Assets.facilityKidsPartyRoomIcon,
-      'width': 39.0,
-      'height': 39.0,
-    },
-    //Media Room
-    '4': {
-      'name': S.current.media_room,
-      'icon_path': Assets.facilityMediaRoomIcon,
-      'width': 38.5,
-      'height': 38.0,
-    },
-    //Pet Pavilion
-    '5': {
-      'name': S.current.pet_pavilion,
-      'icon_path': Assets.facilityPetPavilionIcon,
-      'width': 38.5,
-      'height': 36.5,
-    },
-    //Tennis Court
-    '6': {
-      'name': S.current.tennis_court,
-      'icon_path': Assets.facilityTennisCourt,
-      'width': 38.5,
-      'height': 38.5,
-    },
-  };
-
-}

+ 1 - 1
packages/cpt_facility/lib/modules/facility/history/facility_history_screen.dart

@@ -42,7 +42,7 @@ class FacilityHistoryScreen extends HookConsumerWidget {
             SliverList(
                 delegate: SliverChildBuilderDelegate((context, index) {
                     return FacilityHistoryItem(index: index, item: state.datas[index]).onTap((){
-                      FacilityDetailPage.startInstance(context: context);
+                      FacilityDetailPage.startInstance(context: context,bookingId: state.datas[index].booking?.id);
                     });
                   },
                   childCount: state.datas.length,

+ 2 - 2
packages/cpt_facility/lib/modules/facility/history/facility_history_state.dart

@@ -7,7 +7,7 @@ class FacilityHistoryState {
   LoadState loadingState;
   String? errorMessage;
 
-  List<FacilityPageList> datas; //页面列表数据
+  List<FacilityDetail> datas; //页面列表数据
 
   // ===================================  Begin  ↓  ===================================
 
@@ -21,7 +21,7 @@ class FacilityHistoryState {
     LoadState? loadingState,
     String? errorMessage,
     bool? needShowPlaceholder,
-    List<FacilityPageList>? datas,
+    List<FacilityDetail>? datas,
   }) {
     return FacilityHistoryState(
       errorMessage: errorMessage ?? this.errorMessage,

+ 2 - 2
packages/cpt_facility/lib/modules/facility/history/facility_history_view_model.dart

@@ -78,7 +78,7 @@ class FacilityHistoryViewModel extends _$FacilityHistoryViewModel with DioCancel
   }
 
   // 处理数据与展示的逻辑
-  void handleList(List<FacilityPageList>? list) {
+  void handleList(List<FacilityDetail>? list) {
     if (list != null && list.isNotEmpty) {
       //有数据,判断是刷新还是加载更多的数据
       if (_curPage == 1) {
@@ -90,7 +90,7 @@ class FacilityHistoryViewModel extends _$FacilityHistoryViewModel with DioCancel
         changeLoadingState(LoadState.State_Success, null);
       } else {
         //加载更多
-        state.datas.addAll(List<FacilityPageList>.from(state.datas)..addAll(list));
+        state.datas.addAll(List<FacilityDetail>.from(state.datas)..addAll(list));
         refreshController.finishLoad();
       }
     } else {

+ 1 - 1
packages/cpt_facility/lib/modules/facility/history/facility_history_view_model.g.dart

@@ -7,7 +7,7 @@ part of 'facility_history_view_model.dart';
 // **************************************************************************
 
 String _$facilityHistoryViewModelHash() =>
-    r'2565bb75a59c1a94a8c39d5d5985a9e9422b50f0';
+    r'303f1d156d9b2cf7e1fa90ee4922868897e7ddcc';
 
 /// See also [FacilityHistoryViewModel].
 @ProviderFor(FacilityHistoryViewModel)

+ 1 - 1
packages/cpt_facility/lib/modules/facility/history/item_facility_history.dart

@@ -9,7 +9,7 @@ import 'package:widgets/my_text_view.dart';
 ///  设施的History的Item
 class FacilityHistoryItem extends StatelessWidget {
   final int index;
-  final FacilityPageList item;
+  final FacilityDetail item;
 
   const FacilityHistoryItem({
     required this.index,

+ 34 - 5
packages/cpt_facility/lib/router/page/facility_page_router.gr.dart

@@ -51,9 +51,13 @@ abstract class _$FacilityPageRouter extends RootStackRouter {
       );
     },
     FacilityDetailPageRoute.name: (routeData) {
+      final args = routeData.argsAs<FacilityDetailPageRouteArgs>();
       return AutoRoutePage<dynamic>(
         routeData: routeData,
-        child: const FacilityDetailPage(),
+        child: FacilityDetailPage(
+          key: args.key,
+          bookingId: args.bookingId,
+        ),
       );
     },
     FacilityHistoryPageRoute.name: (routeData) {
@@ -183,16 +187,41 @@ class FacilityDepositPageRoute extends PageRouteInfo<void> {
 
 /// generated route for
 /// [FacilityDetailPage]
-class FacilityDetailPageRoute extends PageRouteInfo<void> {
-  const FacilityDetailPageRoute({List<PageRouteInfo>? children})
-      : super(
+class FacilityDetailPageRoute
+    extends PageRouteInfo<FacilityDetailPageRouteArgs> {
+  FacilityDetailPageRoute({
+    Key? key,
+    required String? bookingId,
+    List<PageRouteInfo>? children,
+  }) : super(
           FacilityDetailPageRoute.name,
+          args: FacilityDetailPageRouteArgs(
+            key: key,
+            bookingId: bookingId,
+          ),
           initialChildren: children,
         );
 
   static const String name = 'FacilityDetailPageRoute';
 
-  static const PageInfo<void> page = PageInfo<void>(name);
+  static const PageInfo<FacilityDetailPageRouteArgs> page =
+      PageInfo<FacilityDetailPageRouteArgs>(name);
+}
+
+class FacilityDetailPageRouteArgs {
+  const FacilityDetailPageRouteArgs({
+    this.key,
+    required this.bookingId,
+  });
+
+  final Key? key;
+
+  final String? bookingId;
+
+  @override
+  String toString() {
+    return 'FacilityDetailPageRouteArgs{key: $key, bookingId: $bookingId}';
+  }
 }
 
 /// generated route for

+ 1 - 1
packages/cpt_main/lib/modules/feedback/create/feedback_create_view_model.dart

@@ -93,7 +93,7 @@ class FeedbackCreateViewModel extends _$FeedbackCreateViewModel with DioCancelab
       ToastEngine.show("Enter Your FeedBack Description");
       return;
     }
-    //执行密码登录
+    //执行请求
     final result = await _mainRepository.postFeedback(
       categoryId: state.selectedOption?.id,
       title: title,

+ 1 - 3
packages/cpt_main/lib/modules/visitor/active/visitor_active.dart

@@ -20,10 +20,8 @@ class VisitorActiveScreen extends HookConsumerWidget {
 
     useEffect(() {
       // 组件挂载时执行 - 执行接口请求
-      Future.microtask(() => viewModel.fetchAppliedStaffList());
+      Future.microtask(() => viewModel.fetchList());
       return () {
-        // 组件卸载时执行
-        Log.d("VisitorActiveScreen 组件卸载时执行");
       };
     }, []);
 

+ 3 - 2
packages/cpt_main/lib/modules/visitor/active/visitor_active_state.dart

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

+ 51 - 74
packages/cpt_main/lib/modules/visitor/active/visitor_active_view_model.dart

@@ -1,3 +1,6 @@
+import 'package:domain/entity/visitor_page_entity.dart';
+import 'package:domain/repository/main_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,21 +11,23 @@ import 'visitor_active_state.dart';
 part 'visitor_active_view_model.g.dart';
 
 @riverpod
-class VisitorActiveViewModel extends _$VisitorActiveViewModel {
+class VisitorActiveViewModel extends _$VisitorActiveViewModel with DioCancelableMixin {
+  late final MainRepository _mainRepository;
   var _curPage = 1; //请求参数当前的页面
   var _needShowPlaceholder = true; //是否展示LoadingView
 
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
-    controlFinishRefresh: true,  //允许刷新
-    controlFinishLoad: true,   //允许加载
+    controlFinishRefresh: true, //允许刷新
+    controlFinishLoad: true, //允许加载
   );
 
   @override
   VisitorActiveState build() {
+    _mainRepository = ref.read(mainRepositoryProvider);
     final state = VisitorActiveState(datas: []);
     //初始化默认调用接口
-    Log.d("VisitorActiveViewModel 执行build");
+    registerCancellation();
     return state;
   }
 
@@ -34,100 +39,72 @@ class VisitorActiveViewModel extends _$VisitorActiveViewModel {
   // Refresh 刷新事件
   Future onRefresh() async {
     _curPage = 1;
-    fetchAppliedStaffList();
+    fetchList();
   }
 
   // Refresh 加载事件
   Future loadMore() async {
     _curPage++;
-    fetchAppliedStaffList();
+    fetchList();
   }
 
   // 重试请求
   Future retryRequest() async {
     _curPage = 1;
     _needShowPlaceholder = true;
-    fetchAppliedStaffList();
+    fetchList();
   }
 
   /// 获取服务器数据
-  Future fetchAppliedStaffList() async {
+  Future fetchList() async {
     if (_needShowPlaceholder) {
       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 _mainRepository.fetchVisitorList(
+      type: "active",
+      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<VisitorPageList>? 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<VisitorPageList>.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);
+      }
+    }
+  }
 }

+ 0 - 3
packages/cpt_main/lib/modules/visitor/history/visitor_history.dart

@@ -2,7 +2,6 @@ import 'package:auto_route/auto_route.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter_hooks/flutter_hooks.dart';
 import 'package:hooks_riverpod/hooks_riverpod.dart';
-import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
@@ -21,8 +20,6 @@ class VisitorHistoryScreen extends HookConsumerWidget {
       // 组件挂载时执行 - 执行接口请求
       Future.microtask(() => viewModel.fetchList());
       return () {
-        // 组件卸载时执行
-        Log.d("VisitorHistoryScreen 组件卸载时执行");
       };
     }, []);
 

+ 3 - 2
packages/cpt_main/lib/modules/visitor/history/visitor_history_state.dart

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

+ 47 - 70
packages/cpt_main/lib/modules/visitor/history/visitor_history_view_model.dart

@@ -1,3 +1,6 @@
+import 'package:domain/entity/visitor_page_entity.dart';
+import 'package:domain/repository/main_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,21 +11,23 @@ import 'visitor_history_state.dart';
 part 'visitor_history_view_model.g.dart';
 
 @riverpod
-class VisitorHistoryViewModel extends _$VisitorHistoryViewModel {
+class VisitorHistoryViewModel extends _$VisitorHistoryViewModel with DioCancelableMixin {
+  late final MainRepository _mainRepository;
   var _curPage = 1; //请求参数当前的页面
   var _needShowPlaceholder = true; //是否展示LoadingView
 
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
-    controlFinishRefresh: true,  //允许刷新
-    controlFinishLoad: true,   //允许加载
+    controlFinishRefresh: true, //允许刷新
+    controlFinishLoad: true, //允许加载
   );
 
   @override
   VisitorHistoryState build() {
+    _mainRepository = ref.read(mainRepositoryProvider);
     final state = VisitorHistoryState(datas: []);
     //初始化默认调用接口
-    Log.d("VisitorActiveViewModel 执行build");
+    registerCancellation();
     return state;
   }
 
@@ -56,78 +61,50 @@ class VisitorHistoryViewModel extends _$VisitorHistoryViewModel {
       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 _mainRepository.fetchVisitorList(
+      type: "history",
+      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<VisitorPageList>? 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<VisitorPageList>.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);
+      }
+    }
+  }
 }

+ 9 - 7
packages/cpt_main/lib/modules/visitor/item_visitor.dart

@@ -1,11 +1,13 @@
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/visitor_page_entity.dart';
 import 'package:flutter/material.dart';
+import 'package:shared/utils/util.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_text_view.dart';
 
 class VisitorItem extends StatelessWidget {
   final int index;
-  final String item;
+  final VisitorPageList item;
 
   const VisitorItem({
     required this.index,
@@ -34,7 +36,7 @@ class VisitorItem extends StatelessWidget {
         children: [
           //姓名
           MyTextView(
-            "Wu Bing Bing",
+            item.name ?? "",
             fontSize: 16,
             marginTop: 19,
             marginBottom: 5,
@@ -46,14 +48,14 @@ class VisitorItem extends StatelessWidget {
           Row(
             children: [
               MyTextView(
-                "+86 12345678901",
+                item.phone ?? "",
                 fontSize: 14,
                 textColor: context.appColors.textBlack,
                 isFontRegular: true,
               ),
               const Spacer(),
               MyTextView(
-                "M12****7B",
+                Utils.maskString(item.nric ?? ""),
                 fontSize: 14,
                 textColor: context.appColors.textBlack,
                 isFontRegular: true,
@@ -65,14 +67,14 @@ class VisitorItem extends StatelessWidget {
           Row(
             children: [
               MyTextView(
-                "EFG8878",
+                item.vehicleNumber ?? "",
                 fontSize: 14,
                 textColor: context.appColors.textBlack,
                 isFontRegular: true,
               ),
               const Spacer(),
               MyTextView(
-                "Monday 13 Oct 2024",
+                item.createdAt ?? "",
                 fontSize: 14,
                 textColor: context.appColors.textBlack,
                 isFontRegular: true,
@@ -82,7 +84,7 @@ class VisitorItem extends StatelessWidget {
 
           //备注
           MyTextView(
-            "Visiting a friend's house as a guest",
+            item.note ?? "",
             fontSize: 14,
             marginTop: 6,
             textColor: context.appColors.textDarkGray,

+ 3 - 5
packages/cpt_main/lib/modules/visitor/register/visitor_register_page.dart

@@ -140,13 +140,11 @@ class VisitorRegisterPage extends HookConsumerWidget {
               ),
 
               // 通行时间
-              MyTextView(
-                S.current.access_date,
+              FormRequireText(
+                text: S.current.access_date,
                 textColor: context.appColors.textBlack,
                 fontSize: 17,
-                marginTop: 14.5,
-                isFontMedium: true,
-              ),
+              ).marginOnly(top: 14.5),
               // 选择器
               PickerContainer(
                 content: state.accessDate == null ? "" : DateTimeUtils.formatDate(state.accessDate, format: 'dd MMM yyyy'),

+ 34 - 12
packages/cpt_main/lib/modules/visitor/register/visitor_register_view_model.dart

@@ -1,8 +1,10 @@
-
 import 'package:cpt_main/modules/main/main_page.dart';
 import 'package:cs_resources/generated/l10n.dart';
+import 'package:domain/repository/main_repository.dart';
 import 'package:flutter/cupertino.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:plugin_platform/engine/notify/notify_engine.dart';
+import 'package:plugin_platform/http/dio/dio_cancelable_mixin.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:shared/utils/date_time_utils.dart';
 import 'package:shared/utils/log_utils.dart';
@@ -10,23 +12,26 @@ import 'package:shared/utils/util.dart';
 import 'package:widgets/picker/date_picker_util.dart';
 
 import 'visitor_register_state.dart';
+
 part 'visitor_register_view_model.g.dart';
 
 @riverpod
-class VisitorRegisterViewModel extends _$VisitorRegisterViewModel {
+class VisitorRegisterViewModel extends _$VisitorRegisterViewModel with DioCancelableMixin {
+  late final MainRepository _mainRepository;
 
   @override
-  VisitorRegisterState build(){
+  VisitorRegisterState build() {
+    _mainRepository = ref.read(mainRepositoryProvider);
     final state = VisitorRegisterState();
     initListener(state);
-    ref.onDispose(() {
+    registerCancellation(callback: () {
       onDispose(state);
     });
     return state;
   }
 
   //提交表单
-  void submitVisitorRegister() {
+  void submitVisitorRegister() async {
     state = state.copyWith(
       fullNameErrorText: null,
       phoneErrorText: null,
@@ -56,7 +61,7 @@ class VisitorRegisterViewModel extends _$VisitorRegisterViewModel {
     final nric = nricController.text;
     final plateNumber = plateNumberController.text;
     final note = noteController.text;
-    final accessDate = state.accessDate == null ?  null : DateTimeUtils.formatDate(state.accessDate!,format: 'yyyy-MM-dd');
+    final accessDate = state.accessDate == null ? null : DateTimeUtils.formatDate(state.accessDate!, format: 'yyyy-MM-dd');
 
     Log.d('当前待提交的 fullName:$fullName phone:$phone nric:$nric plateNumber:$plateNumber note:$note accessDate:$accessDate');
 
@@ -75,11 +80,29 @@ class VisitorRegisterViewModel extends _$VisitorRegisterViewModel {
       return;
     }
 
-    //执行密码登录
-    ToastEngine.show('准备执行请求 fullName:$fullName phone:$phone nric:$nric plateNumber:$plateNumber note:$note accessDate:$accessDate');
+    if (Utils.isEmpty(accessDate)) {
+      ToastEngine.show("Select Access Date");
+      return;
+    }
+
+    //执行请求
+    final result = await _mainRepository.createVisitor(
+      name: fullName,
+      phone: phone,
+      nric: nric,
+      vehicleNumber: plateNumber,
+      accessDate: accessDate,
+      note: note,
+      cancelToken: cancelToken,
+    );
 
-    //去首页
-    MainPage.startInstance();
+    if (result.isSuccess) {
+      NotifyEngine.showSuccess(S.current.successful);
+      //去首页
+      MainPage.startInstance();
+    } else {
+      ToastEngine.show(result.errorMsg ?? "UnKnow Error");
+    }
   }
 
   //选择通行时间
@@ -88,7 +111,7 @@ class VisitorRegisterViewModel extends _$VisitorRegisterViewModel {
       selectedDateTime: state.accessDate ?? DateTime.now(),
       mode: CupertinoDatePickerMode.date,
       onDateTimeChanged: (date) {
-       state = state.copyWith(accessDate: date);
+        state = state.copyWith(accessDate: date);
       },
       title: S.current.access_date,
     );
@@ -133,5 +156,4 @@ class VisitorRegisterViewModel extends _$VisitorRegisterViewModel {
 
     Log.d("VisitorRegisterViewModel 销毁 onDispose");
   }
-
 }

+ 0 - 18
packages/cpt_main/lib/modules/visitor/visitor_view_model.dart

@@ -1,9 +1,5 @@
-import 'package:domain/repository/demo_repository.dart';
-import 'package:flutter/material.dart';
-import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 
-import 'package:shared/utils/log_utils.dart';
 
 import 'visitor_state.dart';
 
@@ -11,24 +7,10 @@ part 'visitor_view_model.g.dart';
 
 @riverpod
 class VisitorViewModel extends _$VisitorViewModel {
-  late DemoRepository demoRepository;
 
   @override
   VisitorState build() {
-    demoRepository = ref.read(demoRepositoryProvider);
     return VisitorState();
   }
 
-  /// 获取服务器时间测试
-  void fetchServerTime() async {
-    //请求网络
-    final result = await demoRepository.fetchServerTime("");
-    //校验成功失败
-    if (result.isSuccess) {
-      state = state.copyWith(serverTime: result.data);
-      ToastEngine.show("当前服务器时间戳:${result.data?.timestamps}");
-    } else {
-      ToastEngine.show(result.errorMsg ?? "Network Load Error");
-    }
-  }
 }

+ 1 - 1
packages/cpt_payment/lib/modules/add_card/add_card_view_model.g.dart

@@ -6,7 +6,7 @@ part of 'add_card_view_model.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$addCardViewModelHash() => r'5e7c5e5596a80e95d8dbcc1eb05daa4023684eb9';
+String _$addCardViewModelHash() => r'3d41700a8cb8f07e0f92fc72ffc7718916f00d03';
 
 /// See also [AddCardViewModel].
 @ProviderFor(AddCardViewModel)

+ 1 - 1
packages/cpt_payment/lib/modules/choose_card/choose_card_view_model.g.dart

@@ -7,7 +7,7 @@ part of 'choose_card_view_model.dart';
 // **************************************************************************
 
 String _$chooseCardViewModelHash() =>
-    r'2a690cc283527d4b52eff532a80fb1c9c6a397d8';
+    r'695dfc67ae41a495d3df9ee35782c4dc4e881154';
 
 /// See also [ChooseCardViewModel].
 @ProviderFor(ChooseCardViewModel)

+ 0 - 57
packages/cpt_payment/lib/modules/payment/condo/active/condo_active_screen.dart

@@ -1,57 +0,0 @@
-import 'package:auto_route/auto_route.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_hooks/flutter_hooks.dart';
-import 'package:hooks_riverpod/hooks_riverpod.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:widgets/ext/ex_widget.dart';
-import 'package:widgets/load_state_layout.dart';
-import 'package:widgets/widget_export.dart';
-
-import 'condo_active_view_model.dart';
-import 'item_condo_active.dart';
-
-@RoutePage()
-class CondoActiveScreen extends HookConsumerWidget {
-  @override
-  Widget build(BuildContext context, WidgetRef ref) {
-    final viewModel = ref.read(condoActiveViewModelProvider.notifier);
-    final state = ref.watch(condoActiveViewModelProvider);
-
-    useEffect(() {
-      // 组件挂载时执行 - 执行接口请求
-      Future.microtask(() => viewModel.fetchList());
-      return () {
-        // 组件卸载时执行
-      };
-    }, []);
-
-    return Container(
-      padding: const EdgeInsets.only(top: 60),
-      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,
-          errorRetry: () {
-            viewModel.retryRequest();
-          },
-          successSliverWidget: [
-            SliverList(
-                delegate: SliverChildBuilderDelegate(
-                      (context, index) {
-                    return CondoActiveItem(index: index, item: state.datas[index]).onTap(() {
-
-                    });
-                  },
-                  childCount: state.datas.length,
-                ))
-          ],
-        ),
-      ).marginOnly(top: 5, bottom: 5),
-    );
-  }
-}

+ 0 - 135
packages/cpt_payment/lib/modules/payment/condo/active/item_condo_active.dart

@@ -1,135 +0,0 @@
-
-import 'package:cs_resources/generated/l10n.dart';
-import 'package:cs_resources/theme/app_colors_theme.dart';
-import 'package:flutter/material.dart';
-import 'package:widgets/ext/ex_widget.dart';
-import 'package:widgets/my_text_view.dart';
-
-///  Condo的Active的Item
-class CondoActiveItem extends StatelessWidget {
-  final int index;
-  final String item;
-
-  const CondoActiveItem({
-    required this.index,
-    required this.item,
-  });
-
-  @override
-  Widget build(BuildContext context) {
-    return Container(
-      width: double.infinity,
-      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
-      padding: const EdgeInsets.only(left: 20, right: 15, top: 18, bottom: 23),
-      decoration: BoxDecoration(
-        color: context.appColors.whiteBG,
-        borderRadius: BorderRadius.circular(6.0), // 圆角
-        boxShadow: [
-          BoxShadow(
-            color: const Color(0xFFB8BFD9).withOpacity(0.3), // 阴影颜色
-            offset: const Offset(0, 3), // 阴影的偏移量
-            blurRadius: 8.0, // 模糊半径
-            spreadRadius: 3.0, // 扩散半径
-          ),
-        ],
-      ),
-      child: Row(
-        mainAxisSize: MainAxisSize.max,
-        crossAxisAlignment: CrossAxisAlignment.start,
-        children: [
-          Column(
-            crossAxisAlignment: CrossAxisAlignment.start,
-            children: [
-              //设施
-              MyTextView(
-                "Lift Padding",
-                fontSize: 16,
-                maxLines: 3,
-                textColor: context.appColors.textBlack,
-                isFontMedium: true,
-              ),
-
-              //预订人
-              MyTextView(
-                S.current.booked_by_someone("Wu Bing Bing"),
-                fontSize: 14,
-                marginTop: 3,
-                textColor: context.appColors.textBlack,
-                isFontRegular: true,
-              ),
-
-              //日期
-              MyTextView(
-                "Tue,24 Oct 2023",
-                fontSize: 14,
-                marginTop: 16,
-                textColor: context.appColors.textBlack,
-                isFontRegular: true,
-              ),
-
-              //时间
-              MyTextView(
-                "05:00 PM-10:00 PM",
-                fontSize: 14,
-                marginBottom: 7,
-                marginTop: 3,
-                textColor: context.appColors.textBlack,
-                isFontRegular: true,
-              ),
-
-              //标签
-              Row(
-                children: [
-                  MyTextView(
-                    "Fee Paid",
-                    textColor: context.appColors.textPrimary,
-                    fontSize: 13,
-                    isFontRegular: true,
-                    backgroundColor: context.appColors.lightPurpleBg,
-                    cornerRadius: 3,
-                    paddingLeft: 7,
-                    marginRight: 6,
-                    paddingRight: 7,
-                    paddingTop: 3,
-                    paddingBottom: 3,
-                  ),
-                  MyTextView(
-                    "Deposit",
-                    textColor: context.appColors.textPrimary,
-                    fontSize: 13,
-                    isFontRegular: true,
-                    backgroundColor: context.appColors.lightPurpleBg,
-                    cornerRadius: 3,
-                    paddingLeft: 7,
-                    marginRight: 6,
-                    paddingRight: 7,
-                    paddingTop: 3,
-                    paddingBottom: 3,
-                  )
-                ],
-              )
-            ],
-          ).expanded(),
-          Column(
-            mainAxisSize: MainAxisSize.min,
-            mainAxisAlignment:MainAxisAlignment.start,
-            crossAxisAlignment: CrossAxisAlignment.start,
-            children: [
-              //查看按钮
-              MyTextView(
-                S.current.view,
-                textColor: Colors.white,
-                backgroundColor: context.appColors.btnBgDefault,
-                cornerRadius: 7,
-                paddingTop: 9,
-                paddingBottom: 9,
-                textAlign: TextAlign.center,
-                boxWidth: 60,
-              )
-            ],
-          )
-        ],
-      ),
-    );
-  }
-}

+ 0 - 31
packages/cpt_payment/lib/modules/payment/condo/history/condo_history_state.dart

@@ -1,31 +0,0 @@
-import 'package:widgets/load_state_layout.dart';
-
-class CondoHistoryState {
-
-  //页面 LoadView 状态的展示
-  LoadState loadingState;
-  String? errorMessage;
-
-  List<String> datas; //页面列表数据
-
-  // ===================================  Begin  ↓  ===================================
-
-  CondoHistoryState({
-    this.loadingState = LoadState.State_Loading,
-    this.errorMessage,
-    required this.datas,
-  });
-
-  CondoHistoryState copyWith({
-    LoadState? loadingState,
-    String? errorMessage,
-    bool? needShowPlaceholder,
-    List<String>? datas,
-  }) {
-    return CondoHistoryState(
-      errorMessage: errorMessage ?? this.errorMessage,
-      loadingState: loadingState ?? this.loadingState,
-      datas: datas ?? this.datas,
-    );
-  }
-}

+ 0 - 130
packages/cpt_payment/lib/modules/payment/condo/history/condo_history_view_model.dart

@@ -1,130 +0,0 @@
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:widgets/load_state_layout.dart';
-import 'package:widgets/widget_export.dart';
-
-import 'condo_history_state.dart';
-
-part 'condo_history_view_model.g.dart';
-
-@riverpod
-class CondoHistoryViewModel extends _$CondoHistoryViewModel {
-  var _curPage = 1; //请求参数当前的页面
-  var _needShowPlaceholder = true; //是否展示LoadingView
-
-  // Refresh 控制器
-  final EasyRefreshController refreshController = EasyRefreshController(
-    controlFinishRefresh: true,  //允许刷新
-    controlFinishLoad: true,   //允许加载
-  );
-
-  @override
-  CondoHistoryState build() {
-    return CondoHistoryState(datas: []);
-  }
-
-  //刷新页面状态
-  void changeLoadingState(LoadState loadState, String? errorMsg) {
-    state = state.copyWith(loadingState: loadState, errorMessage: errorMsg);
-  }
-
-  // Refresh 刷新事件
-  Future onRefresh() async {
-    _curPage = 1;
-    fetchList();
-  }
-
-  // Refresh 加载事件
-  Future loadMore() async {
-    _curPage++;
-    fetchList();
-  }
-
-  // 重试请求
-  Future retryRequest() async {
-    _curPage = 1;
-    _needShowPlaceholder = true;
-    fetchList();
-  }
-
-  /// 获取服务器数据
-  Future fetchList() async {
-    if (_needShowPlaceholder) {
-      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);
-    // }
-
-
-    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);
-    } else {
-      //加载更多
-      final allList = state.datas;
-      allList.addAll(list);
-      state.datas.addAll(list);
-
-      refreshController.finishLoad();
-
-      state = state.copyWith(datas: allList);
-    }
-
-    // 最后赋值
-    _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);
-//     }
-//   }
-// }
-}

+ 0 - 27
packages/cpt_payment/lib/modules/payment/condo/history/condo_history_view_model.g.dart

@@ -1,27 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of 'condo_history_view_model.dart';
-
-// **************************************************************************
-// RiverpodGenerator
-// **************************************************************************
-
-String _$condoHistoryViewModelHash() =>
-    r'7ab487088e11c7906117e903b6fcda88f4b5558c';
-
-/// See also [CondoHistoryViewModel].
-@ProviderFor(CondoHistoryViewModel)
-final condoHistoryViewModelProvider = AutoDisposeNotifierProvider<
-    CondoHistoryViewModel, CondoHistoryState>.internal(
-  CondoHistoryViewModel.new,
-  name: r'condoHistoryViewModelProvider',
-  debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
-      ? null
-      : _$condoHistoryViewModelHash,
-  dependencies: null,
-  allTransitiveDependencies: null,
-);
-
-typedef _$CondoHistoryViewModel = AutoDisposeNotifier<CondoHistoryState>;
-// 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 - 136
packages/cpt_payment/lib/modules/payment/condo/history/item_condo_active.dart

@@ -1,136 +0,0 @@
-
-import 'package:cs_resources/generated/l10n.dart';
-import 'package:cs_resources/theme/app_colors_theme.dart';
-import 'package:flutter/material.dart';
-import 'package:widgets/ext/ex_widget.dart';
-import 'package:widgets/my_text_view.dart';
-
-///  Condo的Active的Item
-class CondoActiveItem extends StatelessWidget {
-  final int index;
-  final String item;
-
-  const CondoActiveItem({
-    required this.index,
-    required this.item,
-  });
-
-  @override
-  Widget build(BuildContext context) {
-    return Container(
-      width: double.infinity,
-      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
-      padding: const EdgeInsets.only(left: 20, right: 15, top: 18, bottom: 25),
-      decoration: BoxDecoration(
-        color: context.appColors.whiteBG,
-        borderRadius: BorderRadius.circular(6.0), // 圆角
-      ),
-      child: Row(
-        mainAxisSize: MainAxisSize.max,
-        crossAxisAlignment: CrossAxisAlignment.start,
-        children: [
-          Column(
-            crossAxisAlignment: CrossAxisAlignment.start,
-            children: [
-              //设施
-              MyTextView(
-                "Lift Padding",
-                fontSize: 16,
-                maxLines: 3,
-                textColor: context.appColors.textBlack,
-                isFontMedium: true,
-              ),
-
-              //分类
-              MyTextView(
-                "Booked by YONGLIANG WU",
-                fontSize: 14,
-                marginTop: 3,
-                textColor: context.appColors.textBlack,
-                isFontRegular: true,
-              ),
-
-              //预订人
-              MyTextView(
-                S.current.booked_by_someone("Wu Bing Bing"),
-                fontSize: 14,
-                marginTop: 3,
-                textColor: context.appColors.textBlack,
-                isFontRegular: true,
-              ),
-
-              //日期
-              MyTextView(
-                "Tue,24 Oct 2023",
-                fontSize: 14,
-                marginTop: 16,
-                textColor: context.appColors.textBlack,
-                isFontRegular: true,
-              ),
-
-              //时间
-              MyTextView(
-                "05:00 PM-10:00 PM",
-                fontSize: 14,
-                marginBottom: 7,
-                marginTop: 3,
-                textColor: context.appColors.textBlack,
-                isFontRegular: true,
-              ),
-
-              //标签
-              Row(
-                children: [
-                  MyTextView(
-                    "Fee Paid",
-                    textColor: context.appColors.textPrimary,
-                    fontSize: 13,
-                    isFontRegular: true,
-                    backgroundColor: context.appColors.lightPurpleBg,
-                    cornerRadius: 3,
-                    paddingLeft: 7,
-                    marginRight: 6,
-                    paddingRight: 7,
-                    paddingTop: 3,
-                    paddingBottom: 3,
-                  ),
-                  MyTextView(
-                    "Deposit",
-                    textColor: context.appColors.textPrimary,
-                    fontSize: 13,
-                    isFontRegular: true,
-                    backgroundColor: context.appColors.lightPurpleBg,
-                    cornerRadius: 3,
-                    paddingLeft: 7,
-                    marginRight: 6,
-                    paddingRight: 7,
-                    paddingTop: 3,
-                    paddingBottom: 3,
-                  )
-                ],
-              )
-            ],
-          ).expanded(),
-          Column(
-            mainAxisSize: MainAxisSize.min,
-            mainAxisAlignment:MainAxisAlignment.start,
-            crossAxisAlignment: CrossAxisAlignment.start,
-            children: [
-              //查看按钮
-              MyTextView(
-                S.current.view,
-                textColor: Colors.white,
-                backgroundColor: context.appColors.btnBgDefault,
-                cornerRadius: 7,
-                paddingTop: 9,
-                paddingBottom: 9,
-                textAlign: TextAlign.center,
-                boxWidth: 60,
-              )
-            ],
-          )
-        ],
-      ),
-    );
-  }
-}

+ 0 - 130
packages/cpt_payment/lib/modules/payment/condo/payment/condo_payment_view_model.dart

@@ -1,130 +0,0 @@
-import 'package:riverpod_annotation/riverpod_annotation.dart';
-import 'package:shared/utils/log_utils.dart';
-import 'package:widgets/load_state_layout.dart';
-import 'package:widgets/widget_export.dart';
-
-import 'condo_payment_state.dart';
-
-part 'condo_payment_view_model.g.dart';
-
-@riverpod
-class CondoPaymentViewModel extends _$CondoPaymentViewModel{
-  var _curPage = 1; //请求参数当前的页面
-  var _needShowPlaceholder = true; //是否展示LoadingView
-
-  // Refresh 控制器
-  final EasyRefreshController refreshController = EasyRefreshController(
-    controlFinishRefresh: true,  //允许刷新
-    controlFinishLoad: true,   //允许加载
-  );
-
-  @override
-  CondoPaymentState build() {
-    return CondoPaymentState(datas: []);
-  }
-
-  //刷新页面状态
-  void changeLoadingState(LoadState loadState, String? errorMsg) {
-    state = state.copyWith(loadingState: loadState, errorMessage: errorMsg);
-  }
-
-  // Refresh 刷新事件
-  Future onRefresh() async {
-    _curPage = 1;
-    fetchList();
-  }
-
-  // Refresh 加载事件
-  Future loadMore() async {
-    _curPage++;
-    fetchList();
-  }
-
-  // 重试请求
-  Future retryRequest() async {
-    _curPage = 1;
-    _needShowPlaceholder = true;
-    fetchList();
-  }
-
-  /// 获取服务器数据
-  Future fetchList() async {
-    if (_needShowPlaceholder) {
-      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);
-    // }
-
-
-    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);
-    } else {
-      //加载更多
-      final allList = state.datas;
-      allList.addAll(list);
-      state.datas.addAll(list);
-
-      refreshController.finishLoad();
-
-      state = state.copyWith(datas: allList);
-    }
-
-    // 最后赋值
-    _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);
-//     }
-//   }
-// }
-}

+ 7 - 8
packages/cpt_payment/lib/modules/payment/condo/history/condo_history_screen.dart

@@ -6,15 +6,15 @@ import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
-import 'condo_history_view_model.dart';
-import 'item_condo_history.dart';
+import 'history_list_view_model.dart';
+import 'item_history_list.dart';
 
 @RoutePage()
-class CondoHistoryScreen extends HookConsumerWidget {
+class HistoryListScreen extends HookConsumerWidget {
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final viewModel = ref.read(condoHistoryViewModelProvider.notifier);
-    final state = ref.watch(condoHistoryViewModelProvider);
+    final viewModel = ref.read(historyListViewModelProvider.notifier);
+    final state = ref.watch(historyListViewModelProvider);
 
     useEffect(() {
       // 组件挂载时执行 - 执行接口请求
@@ -24,8 +24,7 @@ class CondoHistoryScreen extends HookConsumerWidget {
       };
     }, []);
 
-    return Container(
-      padding: const EdgeInsets.only(top: 60),
+    return SizedBox(
       width: double.infinity,
       height: double.infinity,
       child: EasyRefresh(
@@ -42,7 +41,7 @@ class CondoHistoryScreen extends HookConsumerWidget {
             SliverList(
                 delegate: SliverChildBuilderDelegate(
               (context, index) {
-                return CondoHistoryItem(index: index, item: state.datas[index]).onTap(() {});
+                return HistoryListItem(index: index, item: state.datas[index]).onTap(() {});
               },
               childCount: state.datas.length,
             ))

+ 4 - 4
packages/cpt_payment/lib/modules/payment/condo/active/condo_active_state.dart

@@ -1,6 +1,6 @@
 import 'package:widgets/load_state_layout.dart';
 
-class CondoActiveState {
+class HistoryListState {
 
   //页面 LoadView 状态的展示
   LoadState loadingState;
@@ -10,19 +10,19 @@ class CondoActiveState {
 
   // ===================================  Begin  ↓  ===================================
 
-  CondoActiveState({
+  HistoryListState({
     this.loadingState = LoadState.State_Loading,
     this.errorMessage,
     required this.datas,
   });
 
-  CondoActiveState copyWith({
+  HistoryListState copyWith({
     LoadState? loadingState,
     String? errorMessage,
     bool? needShowPlaceholder,
     List<String>? datas,
   }) {
-    return CondoActiveState(
+    return HistoryListState(
       errorMessage: errorMessage ?? this.errorMessage,
       loadingState: loadingState ?? this.loadingState,
       datas: datas ?? this.datas,

+ 5 - 6
packages/cpt_payment/lib/modules/payment/condo/active/condo_active_view_model.dart

@@ -3,12 +3,11 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
 
-import 'condo_active_state.dart';
-
-part 'condo_active_view_model.g.dart';
+import 'history_list_state.dart';
+part 'history_list_view_model.g.dart';
 
 @riverpod
-class CondoActiveViewModel extends _$CondoActiveViewModel {
+class HistoryListViewModel extends _$HistoryListViewModel {
   var _curPage = 1; //请求参数当前的页面
   var _needShowPlaceholder = true; //是否展示LoadingView
 
@@ -19,8 +18,8 @@ class CondoActiveViewModel extends _$CondoActiveViewModel {
   );
 
   @override
-  CondoActiveState build() {
-    return CondoActiveState(datas: []);
+  HistoryListState build() {
+    return HistoryListState(datas: []);
   }
 
   //刷新页面状态

+ 11 - 11
packages/cpt_payment/lib/modules/payment/condo/active/condo_active_view_model.g.dart

@@ -1,27 +1,27 @@
 // GENERATED CODE - DO NOT MODIFY BY HAND
 
-part of 'condo_active_view_model.dart';
+part of 'history_list_view_model.dart';
 
 // **************************************************************************
 // RiverpodGenerator
 // **************************************************************************
 
-String _$condoActiveViewModelHash() =>
-    r'd77976d1c081c1aabfafe5895b04bc202ec0beb2';
+String _$historyListViewModelHash() =>
+    r'87eda063f8265a39a0f0ec47b4b1c688ed09b8d1';
 
-/// See also [CondoActiveViewModel].
-@ProviderFor(CondoActiveViewModel)
-final condoActiveViewModelProvider = AutoDisposeNotifierProvider<
-    CondoActiveViewModel, CondoActiveState>.internal(
-  CondoActiveViewModel.new,
-  name: r'condoActiveViewModelProvider',
+/// See also [HistoryListViewModel].
+@ProviderFor(HistoryListViewModel)
+final historyListViewModelProvider = AutoDisposeNotifierProvider<
+    HistoryListViewModel, HistoryListState>.internal(
+  HistoryListViewModel.new,
+  name: r'historyListViewModelProvider',
   debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
       ? null
-      : _$condoActiveViewModelHash,
+      : _$historyListViewModelHash,
   dependencies: null,
   allTransitiveDependencies: null,
 );
 
-typedef _$CondoActiveViewModel = AutoDisposeNotifier<CondoActiveState>;
+typedef _$HistoryListViewModel = AutoDisposeNotifier<HistoryListState>;
 // 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

+ 2 - 2
packages/cpt_payment/lib/modules/payment/condo/history/item_condo_history.dart

@@ -5,11 +5,11 @@ import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_text_view.dart';
 
 ///  Condo的History的Item
-class CondoHistoryItem extends StatelessWidget {
+class HistoryListItem extends StatelessWidget {
   final int index;
   final String item;
 
-  const CondoHistoryItem({
+  const HistoryListItem({
     required this.index,
     required this.item,
   });

+ 1 - 1
packages/cpt_payment/lib/modules/payment/manage/manage_view_model.g.dart

@@ -6,7 +6,7 @@ part of 'manage_view_model.dart';
 // RiverpodGenerator
 // **************************************************************************
 
-String _$manageViewModelHash() => r'293b21a526990c4b60cd1875304d814dbd719f8e';
+String _$manageViewModelHash() => r'f4c5c44517f9bd9640d429bf8f95209aae685b8a';
 
 /// See also [ManageViewModel].
 @ProviderFor(ManageViewModel)

+ 11 - 7
packages/cpt_payment/lib/modules/payment/condo/payment/item_condo_payment.dart

@@ -1,15 +1,18 @@
 import 'package:cs_resources/theme/app_colors_theme.dart';
+import 'package:domain/entity/payment_page_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/my_text_view.dart';
 
+import 'payment_list_types.dart';
+
 /// Condo Active 的 Item 布局
-class CondoPaymentItem extends StatelessWidget {
+class PaymentListItem extends StatelessWidget {
   final int index;
-  final String item;
+  final PaymentPageList item;
 
-  const CondoPaymentItem({
+  const PaymentListItem({
     required this.index,
     required this.item,
   });
@@ -37,13 +40,14 @@ class CondoPaymentItem extends StatelessWidget {
         mainAxisSize: MainAxisSize.max,
         crossAxisAlignment: CrossAxisAlignment.center,
         children: [
-          MyLoadImage(
-            "https://img0.baidu.com/it/u=2679587808,2501833998&fm=253&fmt=auto&app=120&f=JPEG?w=372&h=400",
-            height: 33,
+          MyAssetImage(
+            PaymentListTypes.iconMap[item.type]?['icon_path'],
+            width: PaymentListTypes.iconMap[item.type]?['width'],
+            height: PaymentListTypes.iconMap[item.type]?['height'],
           ),
 
           MyTextView(
-            "Function Room",
+            PaymentListTypes.iconMap[item.type]?['name'],
             marginLeft: 17,
             fontSize: 16,
             textColor: context.appColors.textBlack,

+ 7 - 8
packages/cpt_payment/lib/modules/payment/condo/payment/condo_payment_screen.dart

@@ -7,15 +7,15 @@ import 'package:shared/utils/log_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
 import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/widget_export.dart';
-import 'condo_payment_view_model.dart';
-import 'item_condo_payment.dart';
+import 'payment_list_view_model.dart';
+import 'item_payment_list.dart';
 
 @RoutePage()
-class CondoPaymentScreen extends HookConsumerWidget {
+class PaymentListScreen extends HookConsumerWidget {
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final viewModel = ref.read(condoPaymentViewModelProvider.notifier);
-    final state = ref.watch(condoPaymentViewModelProvider);
+    final viewModel = ref.read(paymentListViewModelProvider.notifier);
+    final state = ref.watch(paymentListViewModelProvider);
 
     useEffect(() {
       // 组件挂载时执行 - 执行接口请求
@@ -25,8 +25,7 @@ class CondoPaymentScreen extends HookConsumerWidget {
       };
     }, []);
 
-    return Container(
-      padding: const EdgeInsets.only(top: 60),
+    return SizedBox(
       width: double.infinity,
       height: double.infinity,
       child: EasyRefresh(
@@ -43,7 +42,7 @@ class CondoPaymentScreen extends HookConsumerWidget {
             SliverList(
                 delegate: SliverChildBuilderDelegate(
                       (context, index) {
-                    return CondoPaymentItem(index: index, item: state.datas[index]).onTap(() {
+                    return PaymentListItem(index: index, item: state.datas[index]).onTap(() {
                       //去信息页面
                       PaymentInfoPage.startInstance(context: context);
                     });

+ 7 - 6
packages/cpt_payment/lib/modules/payment/condo/payment/condo_payment_state.dart

@@ -1,28 +1,29 @@
+import 'package:domain/entity/payment_page_entity.dart';
 import 'package:widgets/load_state_layout.dart';
 
-class CondoPaymentState {
+class PaymentListState {
 
   //页面 LoadView 状态的展示
   LoadState loadingState;
   String? errorMessage;
 
-  List<String> datas; //页面列表数据
+  List<PaymentPageList> datas; //页面列表数据
 
   // ===================================  Begin  ↓  ===================================
 
-  CondoPaymentState({
+  PaymentListState({
     this.loadingState = LoadState.State_Loading,
     this.errorMessage,
     required this.datas,
   });
 
-  CondoPaymentState copyWith({
+  PaymentListState copyWith({
     LoadState? loadingState,
     String? errorMessage,
     bool? needShowPlaceholder,
-    List<String>? datas,
+    List<PaymentPageList>? datas,
   }) {
-    return CondoPaymentState(
+    return PaymentListState(
       errorMessage: errorMessage ?? this.errorMessage,
       loadingState: loadingState ?? this.loadingState,
       datas: datas ?? this.datas,

+ 25 - 0
packages/cpt_payment/lib/modules/payment/payment/payment_list_types.dart

@@ -0,0 +1,25 @@
+
+import 'package:cs_resources/generated/assets.dart';
+import 'package:cs_resources/generated/l10n.dart';
+
+
+class PaymentListTypes {
+  //对应的type类型 对应的icon的图片与宽高
+  static Map<String, Map<String, dynamic>> iconMap = {
+    //物业费
+    'property': {
+      'name': S.current.property_payment,
+      'icon_path': Assets.formCarVehicle,
+      'width': 39.5,
+      'height': 33.5,
+    },
+    //停车费
+    'vehicle': {
+      'name': S.current.parking_fee_payment,
+      'icon_path': Assets.paymentPropertyPaymentIcon,
+      'width': 39.5,
+      'height': 36.0,
+    },
+  };
+
+}

+ 0 - 0
packages/cpt_payment/lib/modules/payment/payment/payment_list_view_model.dart


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