Ver código fonte

update notice board

“shanwenxin” 2 meses atrás
pai
commit
7cd88c5ec0
27 arquivos alterados com 928 adições e 419 exclusões
  1. 53 35
      packages/cpt_notice_board/lib/modules/announ/page/announ_page.dart
  2. 43 31
      packages/cpt_notice_board/lib/modules/announ/page/announ_state.dart
  3. 12 15
      packages/cpt_notice_board/lib/modules/announ/repository/announ_repository.dart
  4. 94 55
      packages/cpt_notice_board/lib/modules/announ/vm/announ_vm.dart
  5. 45 22
      packages/cpt_notice_board/lib/modules/documents/page/documents_page.dart
  6. 43 31
      packages/cpt_notice_board/lib/modules/documents/page/documents_state.dart
  7. 13 16
      packages/cpt_notice_board/lib/modules/documents/repository/documents_repository.dart
  8. 97 49
      packages/cpt_notice_board/lib/modules/documents/vm/documents_vm.dart
  9. 33 12
      packages/cpt_notice_board/lib/modules/event/page/event_page.dart
  10. 43 31
      packages/cpt_notice_board/lib/modules/event/page/event_state.dart
  11. 12 16
      packages/cpt_notice_board/lib/modules/event/repository/event_repository.dart
  12. 93 46
      packages/cpt_notice_board/lib/modules/event/vm/event_vm.dart
  13. 45 45
      packages/cpt_notice_board/lib/modules/notice_board/page/notice_board_page.dart
  14. 4 1
      packages/cpt_rewards/lib/modules/rewards/rewards_page.dart
  15. 4 1
      packages/cpt_rewards/lib/modules/rewards_home/rewards_home_page.dart
  16. 25 0
      packages/cs_domain/lib/entity/notice_board_announ_entity.dart
  17. 25 0
      packages/cs_domain/lib/entity/notice_board_documents_entity.dart
  18. 25 0
      packages/cs_domain/lib/entity/notice_board_event_entity.dart
  19. 27 4
      packages/cs_domain/lib/generated/json/base/json_convert_content.dart
  20. 14 6
      packages/cs_domain/lib/generated/json/feedback_detail_entity.g.dart
  21. 7 3
      packages/cs_domain/lib/generated/json/feedback_list_entity.g.dart
  22. 57 0
      packages/cs_domain/lib/generated/json/notice_board_announ_entity.g.dart
  23. 57 0
      packages/cs_domain/lib/generated/json/notice_board_documents_entity.g.dart
  24. 57 0
      packages/cs_domain/lib/generated/json/notice_board_event_entity.g.dart
  25. BIN
      packages/cs_resources/assets/notice_board/announcement_icon.png
  26. BIN
      packages/cs_resources/assets/notice_board/documents_icon.png
  27. BIN
      packages/cs_resources/assets/notice_board/event_icon.png

+ 53 - 35
packages/cpt_notice_board/lib/modules/announ/page/announ_page.dart

@@ -1,11 +1,13 @@
 import 'package:cpt_notice_board/modules/notice_board/page/notice_board_page.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:shared/utils/log_utils.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
+import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/widget_export.dart';
 import 'package:cs_resources/generated/assets.dart';
@@ -28,7 +30,7 @@ class AnnounPage extends HookConsumerWidget {
     }
   }
 
-  Widget _buildItemLeftSection(BuildContext context, WidgetRef ref, item, _vm) {
+  Widget _buildItemLeftSection(BuildContext context, WidgetRef ref, item, vm) { 
     return Container(
       // color: Colors.blue,
       child: Text(
@@ -42,11 +44,12 @@ class AnnounPage extends HookConsumerWidget {
       ),
     );
   }
-  Widget _buildItemRightSection(BuildContext context, WidgetRef ref, item, _vm) {
+
+  Widget _buildItemRightSection(BuildContext context, WidgetRef ref, item, vm) {
     return Container(
       // color: Colors.green,
       child: Text(
-        item['price'],
+        item['created_at'],
         style: const TextStyle(
             fontSize: 14.0,
             color: Colors.black,
@@ -56,13 +59,14 @@ class AnnounPage extends HookConsumerWidget {
   }
 
   // listitem
-  Widget _buildSaleItem(BuildContext context, WidgetRef ref, item, _vm) {
+  Widget _buildSaleItem(BuildContext context, WidgetRef ref, item, vm) {
     return Container(
-      
       decoration: const BoxDecoration(
         color: Colors.white,
         borderRadius: BorderRadius.all(Radius.circular(6.0)),
-        boxShadow: [BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)],
+        boxShadow: [
+          BoxShadow(color: Color.fromRGBO(184, 191, 217, 0.3), blurRadius: 6)
+        ],
       ),
       child: Column(
         children: [
@@ -74,60 +78,74 @@ class AnnounPage extends HookConsumerWidget {
               crossAxisAlignment: CrossAxisAlignment.start,
               mainAxisAlignment: MainAxisAlignment.center,
               children: [
-                 _buildItemLeftSection(context, ref, item, _vm).marginOnly(bottom: 5),
-                _buildItemRightSection(context, ref, item, _vm),
+                _buildItemLeftSection(context, ref, item, vm)
+                    .marginOnly(bottom: 5),
+                _buildItemRightSection(context, ref, item, vm),
               ],
-            ).paddingOnly(left: 20,right: 20),
+            ).paddingOnly(left: 20, right: 20),
           ).constrained(
             minHeight: 117.5,
           ),
         ],
       ).onTap(() {
         // 去详情
-        // Navigator.push(
-        //   context,
-        //   MaterialPageRoute(builder: (context) => AnnouncementDetailPage()),
-        // );
         AnnouncementDetailPage.startInstance(context: context);
-        // _vm.goNewsDetail(item['title']);
       }),
     ).marginOnly(left: 15, bottom: 15, right: 15);
   }
 
   // list
-  Widget _buildSaleList(BuildContext context, WidgetRef ref, _vm) {
-    List itemsList = _vm.state.list.toList();
+  Widget _buildSaleList(BuildContext context, WidgetRef ref, vm) {
+    List itemsList = vm.state.list.toList();
     return ListView.builder(
       itemCount: itemsList.length,
       itemBuilder: (context, index) {
-        return _buildSaleItem(context, ref, itemsList[index], _vm);
+        return _buildSaleItem(context, ref, itemsList[index], vm);
       },
     );
   }
 
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final _vm = ref.read(announVmProvider.notifier);
-
+    final vm = ref.read(announVmProvider.notifier);
+    final state = ref.watch(announVmProvider);
+    useEffect(() {
+      // 组件挂载时执行 - 执行接口请求
+      Future.microtask(() => vm.initPageData());
+      return () {
+        // 组件卸载时执行
+        Log.d("property_news_page 组件卸载时执行");
+      };
+    }, []);
     return Scaffold(
       // appBar: AppBar(title: Text("资产")),
-      body: Container(
+      body: SizedBox(
+          width: double.infinity,
+          height: double.infinity,
           child: EasyRefresh(
-        // 上拉加载
-        onLoad: () async {
-          Log.d("----onLoad");
-          _vm.onLoadData();
-        },
-        // 下拉刷新
-        onRefresh: () async {
-          Log.d("----onRefresh");
-          _vm.refreshListData();
-        },
-        child: Container(
-            color: ColorUtils.string2Color('#F2F3F6'),
-            padding: const EdgeInsets.only(top: 15),
-            child: _buildSaleList(context, ref, _vm)),
-      )),
+              controller: vm.refreshController,
+              // 上拉加载
+              onLoad: () async {
+                Log.d("----onLoad");
+                vm.loadMore();
+              },
+              // 下拉刷新
+              onRefresh: () async {
+                Log.d("----onRefresh");
+                vm.onRefresh();
+              },
+              child: Container(
+                color: ColorUtils.string2Color('#F2F3F6'),
+                padding: const EdgeInsets.only(top: 15),
+                child: LoadStateLayout(
+                  state: state.loadingState,
+                  errorMessage: state.errorMessage,
+                  errorRetry: () {
+                    vm.retryRequest();
+                  },
+                  successSliverWidget: [_buildSaleList(context, ref, vm)],
+                ),
+              ))),
     );
   }
 }

+ 43 - 31
packages/cpt_notice_board/lib/modules/announ/page/announ_state.dart

@@ -2,48 +2,60 @@
 
 import 'dart:convert';
 
-AnnounState announStateFromJson(String str) => AnnounState.fromJson(json.decode(str));
-
-String announStateToJson(AnnounState data) => json.encode(data.toJson());
+import 'package:widgets/load_state_layout.dart';
 
 class AnnounState {
+  //页面 LoadView 状态的展示
+  LoadState loadingState;
+  String? errorMessage;
+
+  int? page;
+  int? limit = 10;
+  int? count = 1;
+  List<Map<String, dynamic>>? list;
+
   AnnounState({
-    required this.curPage,
-    required this.pageSize,
+    this.loadingState = LoadState.State_Loading,
+    String? errorMessage,
+    this.page = 1,
+    this.limit = 10,
+    this.count = 1,
     required this.list,
-    required this.filterCount,
   });
 
-  int curPage;
-  int pageSize;
-  List<Map<String, dynamic>> list;
-  int filterCount;
-
-  factory AnnounState.fromJson(Map<dynamic, dynamic> json) => AnnounState(
-    curPage: json["curPage"],
-    pageSize: json["pageSize"],
-    list: List<Map<String, dynamic>>.from(json["list"].map((x) => x)),
-    filterCount: json["filterCount"],
-  );
-
-  Map<dynamic, dynamic> toJson() => {
-    "curPage": curPage,
-    "pageSize": pageSize,
-    "list": List<dynamic>.from(list.map((x) => x)),
-    "filterCount": filterCount,
-  };
-
   AnnounState copyWith({
-    int? curPage,
-    int? pageSize,
+    LoadState? loadingState,
+    String? errorMessage,
+    int? page,
+    int? limit,
+    int? count,
     List<Map<String, dynamic>>? list,
-    int? filterCount,
   }) {
     return AnnounState(
-      curPage: curPage ?? this.curPage,
-      pageSize: pageSize ?? this.pageSize,
+      loadingState: loadingState ?? this.loadingState,
+      errorMessage: errorMessage ?? this.errorMessage,
+      page: page ?? this.page,
+      limit: limit ?? this.limit,
+      count: count ?? this.count,
       list: list ?? this.list,
-      filterCount: filterCount ?? this.filterCount,
+    );
+  }
+
+  Map<String, dynamic> toMap() {
+    return {
+      'page': this.page,
+      'limit': this.limit,
+      'count': this.count,
+      'list': this.list,
+    };
+  }
+
+  factory AnnounState.fromMap(Map<String, dynamic> map) {
+    return AnnounState(
+      page: map['page'] as int,
+      limit: map['limit'] as int,
+      count: map['count'] as int,
+      list: map['list'] as List<Map<String, dynamic>>,
     );
   }
 }

+ 12 - 15
packages/cpt_notice_board/lib/modules/announ/repository/announ_repository.dart

@@ -1,9 +1,11 @@
 import 'package:domain/constants/api_constants.dart';
+import 'package:domain/entity/notice_board_announ_entity.dart';
 import 'package:domain/entity/server_time.dart';
 import 'package:plugin_platform/platform_export.dart';
 import 'package:plugin_platform/http/dio_engine.dart';
 import 'package:plugin_platform/http/http_result.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:shared/utils/log_utils.dart';
 import 'package:shared/utils/util.dart';
 
 import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -26,19 +28,14 @@ class AnnounRepository {
 
   AnnounRepository({required this.dioEngine});
 
-  Future<HttpResult<Object>> fetchPropertyNewsList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
+  Future<HttpResult<Object>> fetchList(
+    Map<String, dynamic>? data, {
+    CancelToken? cancelToken,
+  }) async {
     Map<String, dynamic> params = {};
 
-    // if (!Utils.isEmpty(type)) {
-    //   params["type"] = type!;
-    // }
-
     params = data!;
 
-
     Map<String, String> headers = {};
 
     headers["Content-Type"] = "application/x-www-form-urlencoded";
@@ -46,25 +43,25 @@ class AnnounRepository {
 
     final result = await dioEngine.requestNetResult(
       // ApiConstants.apiServerTime, // api 地址
-      '/index.php/api/employee/extra/time', // api 地址
+      '/api/v1/user/notice/announcement/index', // api 地址
       params: params,
       headers: headers,
       method: HttpMethod.GET,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
+      isShowLoadingDialog: false, //是否展示默认的Loading弹窗
+      networkDebounce: true, //是否防抖防止重复请求
       cancelToken: cancelToken,
     );
 
+    Log.d("------请求返回的result--$result--------");
     //根据返回的结果,封装原始数据为Bean/Entity对象
     if (result.isSuccess) {
       //重新赋值data或list
       final json = result.getDataJson();
-      var data = AnnounState.fromJson(json!);
+      var data = NoticeBoardAnnounEntity.fromJson(json!);
       //重新赋值data或list
-      return result.convert<AnnounState>(data: data);
+      return result.convert<NoticeBoardAnnounEntity>(data: data);
     }
     return result.convert();
   }
 
-
 }

+ 94 - 55
packages/cpt_notice_board/lib/modules/announ/vm/announ_vm.dart

@@ -1,7 +1,10 @@
+import 'package:domain/entity/notice_board_announ_entity.dart';
 import 'package:plugin_platform/http/http_result.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:widgets/load_state_layout.dart';
+import 'package:widgets/widget_export.dart';
 import '../page/announ_state.dart';
 import '../repository/announ_repository.dart';
 part 'announ_vm.g.dart';
@@ -9,33 +12,20 @@ part 'announ_vm.g.dart';
 @riverpod
 class AnnounVm extends _$AnnounVm {
   late AnnounRepository announRepository;
+  var page = 1;
+  var limit = 10;
+
+  bool _needShowPlaceholder = false; //是否展示LoadingView
+
+  // Refresh 控制器
+  final EasyRefreshController refreshController = EasyRefreshController(
+    controlFinishRefresh: true, //允许刷新
+    controlFinishLoad: true, //允许加载
+  );
+
   AnnounState initState() {
     return AnnounState(
-      curPage: 1,
-      pageSize: 10,
-      list: [
-        {
-          "id": 1,
-          "title": "Standard Operating procedure For Replacement V...",
-          "price": "Monday 14 Oct 2024, 10:19 AM",
-        },
-        {
-          "id": 2,
-          "title": "Removal Of Items In Dry Risers",
-          "price": "Monday 14 Oct 2024, 10:19 AM",
-        },
-        {
-          "id": 3,
-          "title": "Fire Safety Awareness And Guidelines",
-          "price": "Monday 14 Oct 2024, 10:19 AM",
-        },
-        {
-          "id": 4,
-          "title": "Bicycle Tagging Exercise",
-          "price": "Monday 14 Oct 2024, 10:19 AM",
-        },
-      ],
-      filterCount: 2,
+      list: [],
     );
   }
 
@@ -49,48 +39,73 @@ class AnnounVm extends _$AnnounVm {
     return state;
   }
 
-  // 初始化页面数据
+//刷新页面状态
+  void changeLoadingState(LoadState loadState, String? errorMsg) {
+    state = state.copyWith(loadingState: loadState, errorMessage: errorMsg);
+  }
+
+  // 初始化页面数据&0
   initPageData() {
     Log.d("----property_news_vm-----initPageData");
-    refreshListData();
+    onRefresh();
   }
 
-  // 上拉加载
-  Future onLoadData() async {
-    Log.d("----property_news_vm-----initListData");
+  // 上拉加载 更多
+  Future loadMore() async {
+    Log.d("----property_news_vm-----loadMore");
     // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.filterCount){
+    // if(state.list.length >= state.count){
     //   return;
     // }else {
-    //   int curPage = state.curPage + 1;
-    //   state = state.copyWith(curPage: curPage,);
+    //   int page = page + 1;
+    //   state = state.copyWith(page: page,);
     //   getListData();
     // }
+    // 检查 page 是否为 null,并初始化为 1
+    page++;
+
     getListData();
   }
-// 去新闻详情页
-  void goNewsDetail(String item) {
-    Log.d(item);
-    // PropertyPage.startInstance(context: context, item: item);
+
+  // 下拉刷新
+  Future onRefresh() async {
+    Log.d("----property_news_vm-----onRefresh ");
+
+    // await Future.delayed(const Duration(seconds: 2));
+    page = 1;
+    getListData();
+  }
+
+  // 重试请求
+  Future retryRequest() async {
+    page = 1;
+    _needShowPlaceholder = true;
+    getListData();
   }
+
   // 获取list 列表数据
-  void getListData<T>() async {
-    Log.d("加载listData数据---------------start-----");
+  Future getListData<T>() async {
+    // if (_needShowPlaceholder) {
+    //   changeLoadingState(LoadState.State_Loading, null);
+    // }
+
+    Log.d("加载listData数据---------------start--${page}---");
     try {
       //请求网络
       Map<String, dynamic> params = {
-        "curPage": state.curPage,
-        "pageSize": state.pageSize,
+        "page": page,
+        "limit": limit,
       };
       Log.d("请求参数------$params");
-      final result = await announRepository.fetchPropertyNewsList(params);
-      Log.d("请求完成结果------${result.data}");
+      final result = await announRepository.fetchList(params);
       //校验成功失败
       if (result.isSuccess) {
-        // state = state.copyWith(serverTime: result.data);
-        state = state;
-        ToastEngine.show("获取数据成功");
+        handlerResultList((result.data as NoticeBoardAnnounEntity)
+            .list
+            .cast<NoticeBoardAnnounEntity>());
       } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
     } catch (e) {
@@ -98,15 +113,39 @@ class AnnounVm extends _$AnnounVm {
     }
   }
 
-  // 下拉刷新
-  Future refreshListData() async {
-    Log.d("----property_news_vm-----refreshListData ");
-
-    // await Future.delayed(const Duration(seconds: 2));
+  void handlerResultList(List<NoticeBoardAnnounEntity>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
 
-    state = state.copyWith(curPage: 1, pageSize: 10);
-    // ref.invalidateSelf();
-    // ref.invalidate(propertyNewsVmProvider);
-    getListData();
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+        // update();
+      }
+    } else {
+      if (page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if (state.list!.length == 0) {
+          changeLoadingState(LoadState.State_Empty, null);
+        } else {
+          changeLoadingState(LoadState.State_Success, null);
+        }
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
+    }
   }
 }

+ 45 - 22
packages/cpt_notice_board/lib/modules/documents/page/documents_page.dart

@@ -1,11 +1,13 @@
 import 'package:cpt_notice_board/modules/notice_board/page/notice_board_page.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:shared/utils/log_utils.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
+import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/widget_export.dart';
 import 'package:cs_resources/generated/assets.dart';
@@ -31,7 +33,7 @@ class DocumentsPage extends HookConsumerWidget {
     return Container(
       // color: Colors.blue,
       child: Text(
-        item['title'],
+        item['name'],
         maxLines: 1, // 设置最大行数为2
         overflow: TextOverflow.ellipsis, // 超出部分用省略号表示
         style: const TextStyle(
@@ -62,8 +64,11 @@ class DocumentsPage extends HookConsumerWidget {
             ), // 边框
           ),
         ),
-        child: const Text('Open Folder',
-          style: const TextStyle(color: Colors.white,),
+        child: const Text(
+          'Open Folder',
+          style: const TextStyle(
+            color: Colors.white,
+          ),
         ),
       ),
     );
@@ -98,7 +103,7 @@ class DocumentsPage extends HookConsumerWidget {
                   // child: TextButton(onPressed: (){}, child: Text("fdsfds")),
                 ),
               ],
-            ).paddingOnly(left: 20,right: 20),
+            ).paddingOnly(left: 20, right: 20),
           ).constrained(
             minHeight: 70,
           ),
@@ -124,27 +129,45 @@ class DocumentsPage extends HookConsumerWidget {
 
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final _vm = ref.read(documentsVmProvider.notifier);
-
+    final vm = ref.read(documentsVmProvider.notifier);
+    final state = ref.watch(documentsVmProvider);
+    useEffect(() {
+      // 组件挂载时执行 - 执行接口请求
+      Future.microtask(() => vm.initPageData());
+      return () {
+        // 组件卸载时执行
+        Log.d("property_news_page 组件卸载时执行");
+      };
+    }, []);
     return Scaffold(
       // appBar: AppBar(title: Text("资产")),
-      body: Container(
+      body: SizedBox(
+          width: double.infinity,
+          height: double.infinity,
           child: EasyRefresh(
-        // 上拉加载
-        onLoad: () async {
-          Log.d("----onLoad");
-          _vm.onLoadData();
-        },
-        // 下拉刷新
-        onRefresh: () async {
-          Log.d("----onRefresh");
-          _vm.refreshListData();
-        },
-        child: Container(
-            color: ColorUtils.string2Color('#F2F3F6'),
-            padding: const EdgeInsets.only(top: 15),
-            child: _buildSaleList(context, ref, _vm)),
-      )),
+              controller: vm.refreshController,
+              // 上拉加载
+              onLoad: () async {
+                Log.d("----onLoad");
+                vm.loadMore();
+              },
+              // 下拉刷新
+              onRefresh: () async {
+                Log.d("----onRefresh");
+                vm.onRefresh();
+              },
+              child: Container(
+                color: ColorUtils.string2Color('#F2F3F6'),
+                padding: const EdgeInsets.only(top: 15),
+                child: LoadStateLayout(
+                  state: state.loadingState,
+                  errorMessage: state.errorMessage,
+                  errorRetry: () {
+                    vm.retryRequest();
+                  },
+                  successSliverWidget: [_buildSaleList(context, ref, vm)],
+                ),
+              ))),
     );
   }
 }

+ 43 - 31
packages/cpt_notice_board/lib/modules/documents/page/documents_state.dart

@@ -2,48 +2,60 @@
 
 import 'dart:convert';
 
-DocumentsState documentsStateFromJson(String str) => DocumentsState.fromJson(json.decode(str));
-
-String documentsStateToJson(DocumentsState data) => json.encode(data.toJson());
+import 'package:widgets/load_state_layout.dart';
 
 class DocumentsState {
+  //页面 LoadView 状态的展示
+  LoadState loadingState;
+  String? errorMessage;
+
+  int? page;
+  int? limit = 10;
+  int? count = 1;
+  List<Map<String, dynamic>>? list;
+
   DocumentsState({
-    required this.curPage,
-    required this.pageSize,
+    this.loadingState = LoadState.State_Loading,
+    String? errorMessage,
+    this.page = 1,
+    this.limit = 10,
+    this.count = 1,
     required this.list,
-    required this.filterCount,
   });
 
-  int curPage;
-  int pageSize;
-  List<Map<String, dynamic>> list;
-  int filterCount;
-
-  factory DocumentsState.fromJson(Map<dynamic, dynamic> json) => DocumentsState(
-    curPage: json["curPage"],
-    pageSize: json["pageSize"],
-    list: List<Map<String, dynamic>>.from(json["list"].map((x) => x)),
-    filterCount: json["filterCount"],
-  );
-
-  Map<dynamic, dynamic> toJson() => {
-    "curPage": curPage,
-    "pageSize": pageSize,
-    "list": List<dynamic>.from(list.map((x) => x)),
-    "filterCount": filterCount,
-  };
-
   DocumentsState copyWith({
-    int? curPage,
-    int? pageSize,
+    LoadState? loadingState,
+    String? errorMessage,
+    int? page,
+    int? limit,
+    int? count,
     List<Map<String, dynamic>>? list,
-    int? filterCount,
   }) {
     return DocumentsState(
-      curPage: curPage ?? this.curPage,
-      pageSize: pageSize ?? this.pageSize,
+      loadingState: loadingState ?? this.loadingState,
+      errorMessage: errorMessage ?? this.errorMessage,
+      page: page ?? this.page,
+      limit: limit ?? this.limit,
+      count: count ?? this.count,
       list: list ?? this.list,
-      filterCount: filterCount ?? this.filterCount,
+    );
+  }
+
+  Map<String, dynamic> toMap() {
+    return {
+      'page': this.page,
+      'limit': this.limit,
+      'count': this.count,
+      'list': this.list,
+    };
+  }
+
+  factory DocumentsState.fromMap(Map<String, dynamic> map) {
+    return DocumentsState(
+      page: map['page'] as int,
+      limit: map['limit'] as int,
+      count: map['count'] as int,
+      list: map['list'] as List<Map<String, dynamic>>,
     );
   }
 }

+ 13 - 16
packages/cpt_notice_board/lib/modules/documents/repository/documents_repository.dart

@@ -1,9 +1,11 @@
 import 'package:domain/constants/api_constants.dart';
+import 'package:domain/entity/notice_board_documents_entity.dart';
 import 'package:domain/entity/server_time.dart';
 import 'package:plugin_platform/platform_export.dart';
 import 'package:plugin_platform/http/dio_engine.dart';
 import 'package:plugin_platform/http/http_result.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:shared/utils/log_utils.dart';
 import 'package:shared/utils/util.dart';
 
 import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -14,7 +16,7 @@ part 'documents_repository.g.dart';
 
 @Riverpod(keepAlive: true)
 DocumentsRepository documentsRepository(Ref ref) {
-  final dioEngine = ref.watch(dioEngineProvider);
+  final dioEngine = ref.watch(dioEngineProvider); 
   return DocumentsRepository(dioEngine: dioEngine);
 }
 
@@ -25,20 +27,14 @@ class DocumentsRepository {
   DioEngine dioEngine;
 
   DocumentsRepository({required this.dioEngine});
-
-  Future<HttpResult<Object>> fetchPropertyNewsList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
+Future<HttpResult<Object>> fetchList(
+    Map<String, dynamic>? data, {
+    CancelToken? cancelToken,
+  }) async {
     Map<String, dynamic> params = {};
 
-    // if (!Utils.isEmpty(type)) {
-    //   params["type"] = type!;
-    // }
-
     params = data!;
 
-
     Map<String, String> headers = {};
 
     headers["Content-Type"] = "application/x-www-form-urlencoded";
@@ -46,22 +42,23 @@ class DocumentsRepository {
 
     final result = await dioEngine.requestNetResult(
       // ApiConstants.apiServerTime, // api 地址
-      '/index.php/api/employee/extra/time', // api 地址
+      '/api/v1/user/notice/document/index', // api 地址
       params: params,
       headers: headers,
       method: HttpMethod.GET,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
+      isShowLoadingDialog: false, //是否展示默认的Loading弹窗
+      networkDebounce: true, //是否防抖防止重复请求
       cancelToken: cancelToken,
     );
 
+    Log.d("------请求返回的result--$result--------");
     //根据返回的结果,封装原始数据为Bean/Entity对象
     if (result.isSuccess) {
       //重新赋值data或list
       final json = result.getDataJson();
-      var data = DocumentsState.fromJson(json!);
+      var data = NoticeBoardDocumentsEntity.fromJson(json!);
       //重新赋值data或list
-      return result.convert<DocumentsState>(data: data);
+      return result.convert<NoticeBoardDocumentsEntity>(data: data);
     }
     return result.convert();
   }

+ 97 - 49
packages/cpt_notice_board/lib/modules/documents/vm/documents_vm.dart

@@ -1,7 +1,10 @@
+import 'package:domain/entity/notice_board_documents_entity.dart';
 import 'package:plugin_platform/http/http_result.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:widgets/load_state_layout.dart';
+import 'package:widgets/widget_export.dart';
 import '../page/documents_state.dart';
 import '../repository/documents_repository.dart';
 part 'documents_vm.g.dart';
@@ -9,23 +12,21 @@ part 'documents_vm.g.dart';
 @riverpod
 class DocumentsVm extends _$DocumentsVm {
   late DocumentsRepository documentsRepository;
+  var page = 1;
+  var limit = 10;
+
+  bool _needShowPlaceholder = false; //是否展示LoadingView
+
+  // Refresh 控制器
+  final EasyRefreshController refreshController = EasyRefreshController(
+    controlFinishRefresh: true, //允许刷新
+    controlFinishLoad: true, //允许加载
+  );
+
   DocumentsState initState() {
+    // 初始化页面数据&0
     return DocumentsState(
-      curPage: 1,
-      pageSize: 10,
-      list: [
-        {
-          "id": 1,
-          "title": "18 Sep 2024 BIK 39#09-XX 1337 psd 1001 sqft",
-          "price": "\$1.338 M",
-        },
-        {
-          "id": 2,
-          "title": "18 Sep 2024 BIK 39#09-XX 1337 psd 1001 sqft",
-          "price": "\$1.338 M",
-        },
-      ],
-      filterCount: 2,
+      list: [],
     );
   }
 
@@ -39,48 +40,74 @@ class DocumentsVm extends _$DocumentsVm {
     return state;
   }
 
-  // 初始化页面数据
+//刷新页面状态
+  void changeLoadingState(LoadState loadState, String? errorMsg) {
+    state = state.copyWith(loadingState: loadState, errorMessage: errorMsg);
+  }
+
+  // 初始化页面数据&0
   initPageData() {
     Log.d("----property_news_vm-----initPageData");
-    refreshListData();
+    onRefresh();
   }
 
-  // 上拉加载
-  Future onLoadData() async {
-    Log.d("----property_news_vm-----initListData");
+  // 上拉加载 更多
+  Future loadMore() async {
+    Log.d("----property_news_vm-----loadMore");
     // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.filterCount){
+    // if(state.list.length >= state.count){
     //   return;
     // }else {
-    //   int curPage = state.curPage + 1;
-    //   state = state.copyWith(curPage: curPage,);
+    //   int page = page + 1;
+    //   state = state.copyWith(page: page,);
     //   getListData();
     // }
+    // 检查 page 是否为 null,并初始化为 1
+    page++;
+
     getListData();
   }
-// 去新闻详情页
-  void goNewsDetail(String item) {
-    Log.d(item);
-    // PropertyPage.startInstance(context: context, item: item);
+
+  // 下拉刷新
+  Future onRefresh() async {
+    Log.d("----property_news_vm-----onRefresh ");
+
+    // await Future.delayed(const Duration(seconds: 2));
+    page = 1;
+    getListData();
   }
+
+  // 重试请求
+  Future retryRequest() async {
+    page = 1;
+    _needShowPlaceholder = true;
+    getListData();
+  }
+
   // 获取list 列表数据
-  void getListData<T>() async {
-    Log.d("加载listData数据---------------start-----");
+  Future getListData<T>() async {
+    // if (_needShowPlaceholder) {
+    //   changeLoadingState(LoadState.State_Loading, null);
+    // }
+
+    Log.d("加载listData数据---------------start--${page}---");
     try {
       //请求网络
-      Map<String, dynamic>  params = {
-        "curPage": state.curPage,
-        "pageSize": state.pageSize,
+      Map<String, dynamic> params = {
+        "page": page,
+        "limit": limit,
+        "parent_id":0
       };
       Log.d("请求参数------$params");
-      final result = await documentsRepository.fetchPropertyNewsList(params);
-      Log.d("请求完成结果------${result.data}");
+      final result = await documentsRepository.fetchList(params);
       //校验成功失败
       if (result.isSuccess) {
-        // state = state.copyWith(serverTime: result.data);
-        state = state;
-        ToastEngine.show("获取数据成功");
+        handlerResultList((result.data as NoticeBoardDocumentsEntity)
+            .list
+            .cast<NoticeBoardDocumentsEntity>());
       } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
     } catch (e) {
@@ -88,18 +115,39 @@ class DocumentsVm extends _$DocumentsVm {
     }
   }
 
+  void handlerResultList(List<NoticeBoardDocumentsEntity>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
 
-  // 下拉刷新
-  Future refreshListData() async {
-    Log.d("----property_news_vm-----refreshListData ");
-
-    // await Future.delayed(const Duration(seconds: 2));
-
-    state = state.copyWith(curPage: 1, pageSize: 10);
-    // ref.invalidateSelf();
-    // ref.invalidate(propertyNewsVmProvider);
-    getListData();
-
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+        // update();
+      }
+    } else {
+      if (page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if (state.list!.length == 0) {
+          changeLoadingState(LoadState.State_Empty, null);
+        } else {
+          changeLoadingState(LoadState.State_Success, null);
+        }
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
+    }
   }
-
 }

+ 33 - 12
packages/cpt_notice_board/lib/modules/event/page/event_page.dart

@@ -2,11 +2,13 @@ import 'package:cpt_notice_board/modules/event_detail/page/event_detail_page.dar
 import 'package:cpt_notice_board/modules/notice_board/page/notice_board_page.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:shared/utils/log_utils.dart';
 import 'package:shared/utils/color_utils.dart';
 import 'package:widgets/ext/ex_widget.dart';
+import 'package:widgets/load_state_layout.dart';
 import 'package:widgets/my_load_image.dart';
 import 'package:widgets/widget_export.dart';
 import 'package:cs_resources/generated/assets.dart';
@@ -44,7 +46,7 @@ class EventPage extends HookConsumerWidget {
     return Container(
       // color: Colors.green,
       child: Text(
-        item['price'],
+        item['created_at'],
         style: const TextStyle(
             fontSize: 14.0,
             color: Colors.black,
@@ -106,26 +108,45 @@ class EventPage extends HookConsumerWidget {
 
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final _vm = ref.read(eventVmProvider.notifier);
-
+    final vm = ref.read(eventVmProvider.notifier);
+    final state = ref.watch(eventVmProvider);
+    useEffect(() {
+      // 组件挂载时执行 - 执行接口请求
+      Future.microtask(() => vm.initPageData());
+      return () {
+        // 组件卸载时执行
+        Log.d("property_news_page 组件卸载时执行");
+      };
+    }, []);
     return Scaffold(
       // appBar: AppBar(title: Text("资产")),
-      body: EasyRefresh(
+      body: SizedBox(
+          width: double.infinity,
+          height: double.infinity,
+          child: EasyRefresh(
+              controller: vm.refreshController,
               // 上拉加载
               onLoad: () async {
-      Log.d("----onLoad");
-      _vm.onLoadData();
+                Log.d("----onLoad");
+                vm.loadMore();
               },
               // 下拉刷新
               onRefresh: () async {
-      Log.d("----onRefresh");
-      _vm.refreshListData();
+                Log.d("----onRefresh");
+                vm.onRefresh();
               },
               child: Container(
-        color: ColorUtils.string2Color('#F2F3F6'),
-        padding: const EdgeInsets.only(top: 15),
-        child: _buildSaleList(context, ref, _vm)),
-            ),
+                color: ColorUtils.string2Color('#F2F3F6'),
+                padding: const EdgeInsets.only(top: 15),
+                child: LoadStateLayout(
+                  state: state.loadingState,
+                  errorMessage: state.errorMessage,
+                  errorRetry: () {
+                    vm.retryRequest();
+                  },
+                  successSliverWidget: [_buildSaleList(context, ref, vm)],
+                ),
+              ))),
     );
   }
 }

+ 43 - 31
packages/cpt_notice_board/lib/modules/event/page/event_state.dart

@@ -2,48 +2,60 @@
 
 import 'dart:convert';
 
-EventState eventStateFromJson(String str) => EventState.fromJson(json.decode(str));
-
-String eventStateToJson(EventState data) => json.encode(data.toJson());
+import 'package:widgets/load_state_layout.dart';
 
 class EventState {
+  //页面 LoadView 状态的展示
+  LoadState loadingState;
+  String? errorMessage;
+
+  int? page;
+  int? limit = 10;
+  int? count = 1;
+  List<Map<String, dynamic>>? list;
+
   EventState({
-    required this.curPage,
-    required this.pageSize,
+    this.loadingState = LoadState.State_Loading,
+    String? errorMessage,
+    this.page = 1,
+    this.limit = 10,
+    this.count = 1,
     required this.list,
-    required this.filterCount,
   });
 
-  int curPage;
-  int pageSize;
-  List<Map<String, dynamic>> list;
-  int filterCount;
-
-  factory EventState.fromJson(Map<dynamic, dynamic> json) => EventState(
-    curPage: json["curPage"],
-    pageSize: json["pageSize"],
-    list: List<Map<String, dynamic>>.from(json["list"].map((x) => x)),
-    filterCount: json["filterCount"],
-  );
-
-  Map<dynamic, dynamic> toJson() => {
-    "curPage": curPage,
-    "pageSize": pageSize,
-    "list": List<dynamic>.from(list.map((x) => x)),
-    "filterCount": filterCount,
-  };
-
   EventState copyWith({
-    int? curPage,
-    int? pageSize,
+    LoadState? loadingState,
+    String? errorMessage,
+    int? page,
+    int? limit,
+    int? count,
     List<Map<String, dynamic>>? list,
-    int? filterCount,
   }) {
     return EventState(
-      curPage: curPage ?? this.curPage,
-      pageSize: pageSize ?? this.pageSize,
+      loadingState: loadingState ?? this.loadingState,
+      errorMessage: errorMessage ?? this.errorMessage,
+      page: page ?? this.page,
+      limit: limit ?? this.limit,
+      count: count ?? this.count,
       list: list ?? this.list,
-      filterCount: filterCount ?? this.filterCount,
+    );
+  }
+
+  Map<String, dynamic> toMap() {
+    return {
+      'page': this.page,
+      'limit': this.limit,
+      'count': this.count,
+      'list': this.list,
+    };
+  }
+
+  factory EventState.fromMap(Map<String, dynamic> map) {
+    return EventState(
+      page: map['page'] as int,
+      limit: map['limit'] as int,
+      count: map['count'] as int,
+      list: map['list'] as List<Map<String, dynamic>>,
     );
   }
 }

+ 12 - 16
packages/cpt_notice_board/lib/modules/event/repository/event_repository.dart

@@ -1,9 +1,11 @@
 import 'package:domain/constants/api_constants.dart';
+import 'package:domain/entity/notice_board_event_entity.dart';
 import 'package:domain/entity/server_time.dart';
 import 'package:plugin_platform/platform_export.dart';
 import 'package:plugin_platform/http/dio_engine.dart';
 import 'package:plugin_platform/http/http_result.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
+import 'package:shared/utils/log_utils.dart';
 import 'package:shared/utils/util.dart';
 
 import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -26,19 +28,14 @@ class EventRepository {
 
   EventRepository({required this.dioEngine});
 
-  Future<HttpResult<Object>> fetchPropertyNewsList(
-      Map<String, dynamic>? data, {
-        CancelToken? cancelToken,
-      }) async {
+  Future<HttpResult<Object>> fetchList(
+    Map<String, dynamic>? data, {
+    CancelToken? cancelToken,
+  }) async {
     Map<String, dynamic> params = {};
 
-    // if (!Utils.isEmpty(type)) {
-    //   params["type"] = type!;
-    // }
-
     params = data!;
 
-
     Map<String, String> headers = {};
 
     headers["Content-Type"] = "application/x-www-form-urlencoded";
@@ -46,25 +43,24 @@ class EventRepository {
 
     final result = await dioEngine.requestNetResult(
       // ApiConstants.apiServerTime, // api 地址
-      '/index.php/api/employee/extra/time', // api 地址
+      '/api/v1/user/notice/event/index', // api 地址
       params: params,
       headers: headers,
       method: HttpMethod.GET,
-      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
-      networkDebounce: true,   //是否防抖防止重复请求
+      isShowLoadingDialog: false, //是否展示默认的Loading弹窗
+      networkDebounce: true, //是否防抖防止重复请求
       cancelToken: cancelToken,
     );
 
+    Log.d("------请求返回的result--$result--------");
     //根据返回的结果,封装原始数据为Bean/Entity对象
     if (result.isSuccess) {
       //重新赋值data或list
       final json = result.getDataJson();
-      var data = EventState.fromJson(json!);
+      var data = NoticeBoardEventEntity.fromJson(json!);
       //重新赋值data或list
-      return result.convert<EventState>(data: data);
+      return result.convert<NoticeBoardEventEntity>(data: data);
     }
     return result.convert();
   }
-
-
 }

+ 93 - 46
packages/cpt_notice_board/lib/modules/event/vm/event_vm.dart

@@ -1,7 +1,10 @@
 import 'package:plugin_platform/http/http_result.dart';
+import 'package:domain/entity/notice_board_event_entity.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:shared/utils/log_utils.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
+import 'package:widgets/load_state_layout.dart';
+import 'package:widgets/widget_export.dart';
 import '../page/event_state.dart';
 import '../repository/event_repository.dart';
 part 'event_vm.g.dart';
@@ -9,24 +12,21 @@ part 'event_vm.g.dart';
 @riverpod
 class EventVm extends _$EventVm {
   late EventRepository eventRepository;
+  var page = 1;
+  var limit = 10;
+
+  bool _needShowPlaceholder = false; //是否展示LoadingView
+
+  // Refresh 控制器
+  final EasyRefreshController refreshController = EasyRefreshController(
+    controlFinishRefresh: true, //允许刷新
+    controlFinishLoad: true, //允许加载
+  );
+
   EventState initState() {
+  // 初始化页面数据&0
     return EventState(
-      curPage: 1,
-      pageSize: 10,
-      list: [
-        {
-          "id": 1,
-          "title":
-              "The community will hold the activity of making Zongzi on the Loong Boat ……",
-          "price": "Monday 14 0ct 2024, 15:00 PM~18:00PM",
-        },
-        {
-          "id": 2,
-          "title": "Community basketball competition activities",
-          "price": "Monday 14 Oct 2024, 10:19 AM",
-        },
-      ],
-      filterCount: 2,
+      list: [],
     );
   }
 
@@ -40,50 +40,73 @@ class EventVm extends _$EventVm {
     return state;
   }
 
-  // 初始化页面数据
+//刷新页面状态
+  void changeLoadingState(LoadState loadState, String? errorMsg) {
+    state = state.copyWith(loadingState: loadState, errorMessage: errorMsg);
+  }
+
+  // 初始化页面数据&0
   initPageData() {
     Log.d("----property_news_vm-----initPageData");
-    refreshListData();
+    onRefresh();
   }
 
-  // 上拉加载
-  Future onLoadData() async {
-    Log.d("----property_news_vm-----initListData");
+  // 上拉加载 更多
+  Future loadMore() async {
+    Log.d("----property_news_vm-----loadMore");
     // await Future.delayed(const Duration(seconds: 2));
-    // if(state.list.length >= state.filterCount){
+    // if(state.list.length >= state.count){
     //   return;
     // }else {
-    //   int curPage = state.curPage + 1;
-    //   state = state.copyWith(curPage: curPage,);
+    //   int page = page + 1;
+    //   state = state.copyWith(page: page,);
     //   getListData();
     // }
+    // 检查 page 是否为 null,并初始化为 1
+    page++;
+
+    getListData();
+  }
+
+  // 下拉刷新
+  Future onRefresh() async {
+    Log.d("----property_news_vm-----onRefresh ");
+
+    // await Future.delayed(const Duration(seconds: 2));
+    page = 1;
     getListData();
   }
 
-// 去新闻详情页
-  void goNewsDetail(String item) {
-    Log.d(item);
-    // PropertyPage.startInstance(context: context, item: item);
+  // 重试请求
+  Future retryRequest() async {
+    page = 1;
+    _needShowPlaceholder = true;
+    getListData();
   }
 
   // 获取list 列表数据
-  void getListData<T>() async {
-    Log.d("加载listData数据---------------start-----");
+  Future getListData<T>() async {
+    // if (_needShowPlaceholder) {
+    //   changeLoadingState(LoadState.State_Loading, null);
+    // }
+
+    Log.d("加载listData数据---------------start--${page}---");
     try {
       //请求网络
       Map<String, dynamic> params = {
-        "curPage": state.curPage,
-        "pageSize": state.pageSize,
+        "page": page,
+        "limit": limit,
       };
       Log.d("请求参数------$params");
-      final result = await eventRepository.fetchPropertyNewsList(params);
-      Log.d("请求完成结果------${result.data}");
+      final result = await eventRepository.fetchList(params);
       //校验成功失败
       if (result.isSuccess) {
-        // state = state.copyWith(serverTime: result.data);
-        state = state;
-        ToastEngine.show("获取数据成功");
+        handlerResultList((result.data as NoticeBoardEventEntity)
+            .list
+            .cast<NoticeBoardEventEntity>());
       } else {
+        String errorMessage = result.errorMsg!;
+        changeLoadingState(LoadState.State_Error, errorMessage);
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
     } catch (e) {
@@ -91,15 +114,39 @@ class EventVm extends _$EventVm {
     }
   }
 
-  // 下拉刷新
-  Future refreshListData() async {
-    Log.d("----property_news_vm-----refreshListData ");
-
-    // await Future.delayed(const Duration(seconds: 2));
+  void handlerResultList(List<NoticeBoardEventEntity>? list) {
+    if (list != null && list.isNotEmpty) {
+      //有数据,判断是刷新还是加载更多的数据
+      if (page == 1) {
+        //刷新的方式
+        state.list!.clear();
+        state.list!.addAll(list.map((item) => item.toJson()).toList());
+        refreshController.finishRefresh();
 
-    state = state.copyWith(curPage: 1, pageSize: 10);
-    // ref.invalidateSelf();
-    // ref.invalidate(propertyNewsVmProvider);
-    getListData();
+        //更新展示的状态
+        changeLoadingState(LoadState.State_Success, null);
+      } else {
+        //加载更多
+        final allList = state.list;
+        state = state.copyWith(list: allList);
+        refreshController.finishLoad();
+        // update();
+      }
+    } else {
+      if (page == 1) {
+        //展示无数据的布局
+        state.list!.clear();
+        changeLoadingState(LoadState.State_Empty, null);
+        refreshController.finishRefresh();
+      } else {
+        //展示加载完成,没有更多数据了
+        if (state.list!.length == 0) {
+          changeLoadingState(LoadState.State_Empty, null);
+        } else {
+          changeLoadingState(LoadState.State_Success, null);
+        }
+        refreshController.finishLoad(IndicatorResult.noMore);
+      }
+    }
   }
 }

+ 45 - 45
packages/cpt_notice_board/lib/modules/notice_board/page/notice_board_page.dart

@@ -44,53 +44,53 @@ class NoticeBoardPage extends HookConsumerWidget {
           children: List.generate(topSectionsData.length, (index) {
             final item = topSectionsData[index];
             return Column(
-                children: [
-                  Container(
-                    width: MediaQuery.of(context).size.width /
-                            topSectionsData.length -
-                        36,
-                    height: 70,
-                    decoration: BoxDecoration(
-                      // color: currentTabIdx == index ? ColorUtils.string2Color('#E6F2FF') : Colors.white,
-                      shape: BoxShape.circle, // 设置为圆形
-                      boxShadow: tabsRouter.activeIndex == index
-                          ? [
-                              BoxShadow(
-                                color: context
-                                    .appColors.tabLightBlueShadow, // 设置阴影颜色
-                                blurRadius: 5, // 设置模糊半径
-                                spreadRadius: 0.05, // 控制阴影扩散
-                                offset: const Offset(0, 4), // 设置阴影偏移量
-                              ),
-                            ]
-                          : [], // 未选中时无阴影,
-                    ),
-                    child: MyAssetImage(
-                      item['icon'],
-                      width: MediaQuery.of(context).size.width /
-                              topSectionsData.length -
-                          36,
-                      height: 70,
-                    ).onTap(
-                      () {
-                        tabsRouter.setActiveIndex(index);
-                      },
-                      type: ClickType.throttle,
-                    ),
+              children: [
+                Container(
+                  width: MediaQuery.of(context).size.width /
+                          topSectionsData.length -
+                      36,
+                  height: 70,
+                  padding: const EdgeInsets.only(
+                      top: 18, left: 15, right: 15, bottom: 15),
+                  decoration: BoxDecoration(
+                    color:  ColorUtils.string2Color('#E6F2FF'),
+                    shape: BoxShape.circle, // 设置为圆形
+                    boxShadow: tabsRouter.activeIndex == index
+                        ? [
+                            BoxShadow(
+                              color: context
+                                  .appColors.tabLightBlueShadow, // 设置阴影颜色
+                              blurRadius: 5, // 设置模糊半径
+                              spreadRadius: 0.05, // 控制阴影扩散
+                              offset: const Offset(0, 4), // 设置阴影偏移量
+                            ),
+                          ]
+                        : [], // 未选中时无阴影,
                   ),
-                  SizedBox.fromSize(size: const Size(0, 9)),
-                  MyTextView(
-                    item['title'],
-                    maxLines: 1, // 设置最大行数为2
-                    isTextEllipsis: true, // 超出部分用省略号表示
-                    fontSize: 13,
-                    textColor: currentTabIdx == index
-                        ? ColorUtils.string2Color('#4161D0')
-                        : Colors.black,
-                    isFontMedium: true,
+                  child: MyAssetImage(
+                    item['icon'],
+                    width: 39,
+                    height: 36,
+                  ).onTap(
+                    () {
+                      tabsRouter.setActiveIndex(index);
+                    },
+                    type: ClickType.throttle,
                   ),
-                ],
-              ).marginOnly(left: 18, right: 18, top: 10, bottom: 10);
+                ),
+                SizedBox.fromSize(size: const Size(0, 9)),
+                MyTextView(
+                  item['title'],
+                  maxLines: 1, // 设置最大行数为2
+                  isTextEllipsis: true, // 超出部分用省略号表示
+                  fontSize: 13,
+                  textColor: currentTabIdx == index
+                      ? ColorUtils.string2Color('#4161D0')
+                      : Colors.black,
+                  isFontMedium: true,
+                ),
+              ],
+            ).marginOnly(left: 18, right: 18, top: 10, bottom: 10);
           }),
         ),
       ),

+ 4 - 1
packages/cpt_rewards/lib/modules/rewards/rewards_page.dart

@@ -53,7 +53,10 @@ class RewardsPage extends HookConsumerWidget {
               Assets.rewardsRewardsBack,
               width: 44,
               height: 44,
-            ),
+            ).onTap(() {
+              // backCallback
+              Navigator.pop(context);
+            }),
             // const Text(
             //   '1526 Available Points',
             //   style: TextStyle(

+ 4 - 1
packages/cpt_rewards/lib/modules/rewards_home/rewards_home_page.dart

@@ -53,7 +53,10 @@ class RewardsHomePage extends HookConsumerWidget {
               Assets.rewardsRewardsBack,
               width: 44,
               height: 44,
-            ),
+            ).onTap(() {
+              // backCallback
+              Navigator.pop(context);
+            }),
             const Text(
               '1526 Available Points',
               style: TextStyle(

+ 25 - 0
packages/cs_domain/lib/entity/notice_board_announ_entity.dart

@@ -0,0 +1,25 @@
+import 'package:domain/generated/json/base/json_field.dart';
+import 'package:domain/generated/json/notice_board_announ_entity.g.dart';
+import 'dart:convert';
+export 'package:domain/generated/json/notice_board_announ_entity.g.dart';
+
+@JsonSerializable()
+class NoticeBoardAnnounEntity {
+	late int count = 0;
+	late int page = 0;
+	late int limit = 0;
+	@JSONField(name: "count_page")
+	late int countPage = 0;
+	late List<dynamic> list = [];
+
+	NoticeBoardAnnounEntity();
+
+	factory NoticeBoardAnnounEntity.fromJson(Map<String, dynamic> json) => $NoticeBoardAnnounEntityFromJson(json);
+
+	Map<String, dynamic> toJson() => $NoticeBoardAnnounEntityToJson(this);
+
+	@override
+	String toString() {
+		return jsonEncode(this);
+	}
+}

+ 25 - 0
packages/cs_domain/lib/entity/notice_board_documents_entity.dart

@@ -0,0 +1,25 @@
+import 'package:domain/generated/json/base/json_field.dart';
+import 'package:domain/generated/json/notice_board_documents_entity.g.dart';
+import 'dart:convert';
+export 'package:domain/generated/json/notice_board_documents_entity.g.dart';
+
+@JsonSerializable()
+class NoticeBoardDocumentsEntity {
+	late int count = 0;
+	late int page = 0;
+	late int limit = 0;
+	@JSONField(name: "count_page")
+	late int countPage = 0;
+	late List<dynamic> list = [];
+
+	NoticeBoardDocumentsEntity();
+
+	factory NoticeBoardDocumentsEntity.fromJson(Map<String, dynamic> json) => $NoticeBoardDocumentsEntityFromJson(json);
+
+	Map<String, dynamic> toJson() => $NoticeBoardDocumentsEntityToJson(this);
+
+	@override
+	String toString() {
+		return jsonEncode(this);
+	}
+}

+ 25 - 0
packages/cs_domain/lib/entity/notice_board_event_entity.dart

@@ -0,0 +1,25 @@
+import 'package:domain/generated/json/base/json_field.dart';
+import 'package:domain/generated/json/notice_board_event_entity.g.dart';
+import 'dart:convert';
+export 'package:domain/generated/json/notice_board_event_entity.g.dart';
+
+@JsonSerializable()
+class NoticeBoardEventEntity {
+	late int count = 0;
+	late int page = 0;
+	late int limit = 0;
+	@JSONField(name: "count_page")
+	late int countPage = 0;
+	late List<dynamic> list = [];
+
+	NoticeBoardEventEntity();
+
+	factory NoticeBoardEventEntity.fromJson(Map<String, dynamic> json) => $NoticeBoardEventEntityFromJson(json);
+
+	Map<String, dynamic> toJson() => $NoticeBoardEventEntityToJson(this);
+
+	@override
+	String toString() {
+		return jsonEncode(this);
+	}
+}

+ 27 - 4
packages/cs_domain/lib/generated/json/base/json_convert_content.dart

@@ -13,6 +13,9 @@ import 'package:domain/entity/newsfeed_comment_publish_entity.dart';
 import 'package:domain/entity/newsfeed_following_entity.dart';
 import 'package:domain/entity/newsfeed_foryou_entity.dart';
 import 'package:domain/entity/newsfeed_news_entity.dart';
+import 'package:domain/entity/notice_board_announ_entity.dart';
+import 'package:domain/entity/notice_board_documents_entity.dart';
+import 'package:domain/entity/notice_board_event_entity.dart';
 import 'package:domain/entity/property_news_entity.dart';
 import 'package:domain/entity/property_sale_rent_entity.dart';
 import 'package:domain/entity/server_time.dart';
@@ -163,16 +166,20 @@ class JsonConvert {
           CaptchaImgEntity.fromJson(e)).toList() as M;
     }
     if (<FeedbackDetailEntity>[] is M) {
-      return data.map<FeedbackDetailEntity>((Map<String, dynamic> e) => FeedbackDetailEntity.fromJson(e)).toList() as M;
+      return data.map<FeedbackDetailEntity>((Map<String, dynamic> e) =>
+          FeedbackDetailEntity.fromJson(e)).toList() as M;
     }
     if (<FeedbackDetailReplies>[] is M) {
-      return data.map<FeedbackDetailReplies>((Map<String, dynamic> e) => FeedbackDetailReplies.fromJson(e)).toList() as M;
+      return data.map<FeedbackDetailReplies>((Map<String, dynamic> e) =>
+          FeedbackDetailReplies.fromJson(e)).toList() as M;
     }
     if (<FeedbackListEntity>[] is M) {
-      return data.map<FeedbackListEntity>((Map<String, dynamic> e) => FeedbackListEntity.fromJson(e)).toList() as M;
+      return data.map<FeedbackListEntity>((Map<String, dynamic> e) =>
+          FeedbackListEntity.fromJson(e)).toList() as M;
     }
     if (<FeedbackItemEntity>[] is M) {
-      return data.map<FeedbackItemEntity>((Map<String, dynamic> e) => FeedbackItemEntity.fromJson(e)).toList() as M;
+      return data.map<FeedbackItemEntity>((Map<String, dynamic> e) =>
+          FeedbackItemEntity.fromJson(e)).toList() as M;
     }
     if (<IdNameEntity>[] is M) {
       return data.map<IdNameEntity>((Map<String, dynamic> e) =>
@@ -218,6 +225,18 @@ class JsonConvert {
       return data.map<NewsfeedNewsListAccount>((Map<String, dynamic> e) =>
           NewsfeedNewsListAccount.fromJson(e)).toList() as M;
     }
+    if (<NoticeBoardAnnounEntity>[] is M) {
+      return data.map<NoticeBoardAnnounEntity>((Map<String, dynamic> e) =>
+          NoticeBoardAnnounEntity.fromJson(e)).toList() as M;
+    }
+    if (<NoticeBoardDocumentsEntity>[] is M) {
+      return data.map<NoticeBoardDocumentsEntity>((Map<String, dynamic> e) =>
+          NoticeBoardDocumentsEntity.fromJson(e)).toList() as M;
+    }
+    if (<NoticeBoardEventEntity>[] is M) {
+      return data.map<NoticeBoardEventEntity>((Map<String, dynamic> e) =>
+          NoticeBoardEventEntity.fromJson(e)).toList() as M;
+    }
     if (<PropertyNewsEntity>[] is M) {
       return data.map<PropertyNewsEntity>((Map<String, dynamic> e) =>
           PropertyNewsEntity.fromJson(e)).toList() as M;
@@ -306,6 +325,10 @@ class JsonConvertClassCollection {
     (NewsfeedNewsEntity).toString(): NewsfeedNewsEntity.fromJson,
     (NewsfeedNewsList).toString(): NewsfeedNewsList.fromJson,
     (NewsfeedNewsListAccount).toString(): NewsfeedNewsListAccount.fromJson,
+    (NoticeBoardAnnounEntity).toString(): NoticeBoardAnnounEntity.fromJson,
+    (NoticeBoardDocumentsEntity).toString(): NoticeBoardDocumentsEntity
+        .fromJson,
+    (NoticeBoardEventEntity).toString(): NoticeBoardEventEntity.fromJson,
     (PropertyNewsEntity).toString(): PropertyNewsEntity.fromJson,
     (PropertyNewsList).toString(): PropertyNewsList.fromJson,
     (PropertySaleRentEntity).toString(): PropertySaleRentEntity.fromJson,

+ 14 - 6
packages/cs_domain/lib/generated/json/feedback_detail_entity.g.dart

@@ -30,12 +30,17 @@ FeedbackDetailEntity $FeedbackDetailEntityFromJson(Map<String, dynamic> json) {
   if (createdAt != null) {
     feedbackDetailEntity.createdAt = createdAt;
   }
-  final IdNameEntity? category = jsonConvert.convert<IdNameEntity>(json['category']);
+  final IdNameEntity? category = jsonConvert.convert<IdNameEntity>(
+      json['category']);
   if (category != null) {
     feedbackDetailEntity.category = category;
   }
-  final List<FeedbackDetailReplies>? replies = (json['replies'] as List<dynamic>?)?.map(
-          (e) => jsonConvert.convert<FeedbackDetailReplies>(e) as FeedbackDetailReplies).toList();
+  final List<FeedbackDetailReplies>? replies = (json['replies'] as List<
+      dynamic>?)
+      ?.map(
+          (e) =>
+      jsonConvert.convert<FeedbackDetailReplies>(e) as FeedbackDetailReplies)
+      .toList();
   if (replies != null) {
     feedbackDetailEntity.replies = replies;
   }
@@ -78,7 +83,8 @@ extension FeedbackDetailEntityExtension on FeedbackDetailEntity {
   }
 }
 
-FeedbackDetailReplies $FeedbackDetailRepliesFromJson(Map<String, dynamic> json) {
+FeedbackDetailReplies $FeedbackDetailRepliesFromJson(
+    Map<String, dynamic> json) {
   final FeedbackDetailReplies feedbackDetailReplies = FeedbackDetailReplies();
   final String? id = jsonConvert.convert<String>(json['id']);
   if (id != null) {
@@ -97,14 +103,16 @@ FeedbackDetailReplies $FeedbackDetailRepliesFromJson(Map<String, dynamic> json)
   if (createdAt != null) {
     feedbackDetailReplies.createdAt = createdAt;
   }
-  final IdNameEntity? accountable = jsonConvert.convert<IdNameEntity>(json['accountable']);
+  final IdNameEntity? accountable = jsonConvert.convert<IdNameEntity>(
+      json['accountable']);
   if (accountable != null) {
     feedbackDetailReplies.accountable = accountable;
   }
   return feedbackDetailReplies;
 }
 
-Map<String, dynamic> $FeedbackDetailRepliesToJson(FeedbackDetailReplies entity) {
+Map<String, dynamic> $FeedbackDetailRepliesToJson(
+    FeedbackDetailReplies entity) {
   final Map<String, dynamic> data = <String, dynamic>{};
   data['id'] = entity.id;
   data['content'] = entity.content;

+ 7 - 3
packages/cs_domain/lib/generated/json/feedback_list_entity.g.dart

@@ -21,8 +21,11 @@ FeedbackListEntity $FeedbackListEntityFromJson(Map<String, dynamic> json) {
   if (limit != null) {
     feedbackListEntity.limit = limit;
   }
-  final List<FeedbackItemEntity>? list = (json['list'] as List<dynamic>?)?.map(
-          (e) => jsonConvert.convert<FeedbackItemEntity>(e) as FeedbackItemEntity).toList();
+  final List<FeedbackItemEntity>? list = (json['list'] as List<dynamic>?)
+      ?.map(
+          (e) =>
+      jsonConvert.convert<FeedbackItemEntity>(e) as FeedbackItemEntity)
+      .toList();
   if (list != null) {
     feedbackListEntity.list = list;
   }
@@ -78,7 +81,8 @@ FeedbackItemEntity $FeedbackItemEntityFromJson(Map<String, dynamic> json) {
   if (createdAt != null) {
     feedbackItemEntity.createdAt = createdAt;
   }
-  final IdNameEntity? category = jsonConvert.convert<IdNameEntity>(json['category']);
+  final IdNameEntity? category = jsonConvert.convert<IdNameEntity>(
+      json['category']);
   if (category != null) {
     feedbackItemEntity.category = category;
   }

+ 57 - 0
packages/cs_domain/lib/generated/json/notice_board_announ_entity.g.dart

@@ -0,0 +1,57 @@
+import 'package:domain/generated/json/base/json_convert_content.dart';
+import 'package:domain/entity/notice_board_announ_entity.dart';
+
+NoticeBoardAnnounEntity $NoticeBoardAnnounEntityFromJson(
+    Map<String, dynamic> json) {
+  final NoticeBoardAnnounEntity noticeBoardAnnounEntity = NoticeBoardAnnounEntity();
+  final int? count = jsonConvert.convert<int>(json['count']);
+  if (count != null) {
+    noticeBoardAnnounEntity.count = count;
+  }
+  final int? page = jsonConvert.convert<int>(json['page']);
+  if (page != null) {
+    noticeBoardAnnounEntity.page = page;
+  }
+  final int? limit = jsonConvert.convert<int>(json['limit']);
+  if (limit != null) {
+    noticeBoardAnnounEntity.limit = limit;
+  }
+  final int? countPage = jsonConvert.convert<int>(json['count_page']);
+  if (countPage != null) {
+    noticeBoardAnnounEntity.countPage = countPage;
+  }
+  final List<dynamic>? list = (json['list'] as List<dynamic>?)?.map(
+          (e) => e).toList();
+  if (list != null) {
+    noticeBoardAnnounEntity.list = list;
+  }
+  return noticeBoardAnnounEntity;
+}
+
+Map<String, dynamic> $NoticeBoardAnnounEntityToJson(
+    NoticeBoardAnnounEntity entity) {
+  final Map<String, dynamic> data = <String, dynamic>{};
+  data['count'] = entity.count;
+  data['page'] = entity.page;
+  data['limit'] = entity.limit;
+  data['count_page'] = entity.countPage;
+  data['list'] = entity.list;
+  return data;
+}
+
+extension NoticeBoardAnnounEntityExtension on NoticeBoardAnnounEntity {
+  NoticeBoardAnnounEntity copyWith({
+    int? count,
+    int? page,
+    int? limit,
+    int? countPage,
+    List<dynamic>? list,
+  }) {
+    return NoticeBoardAnnounEntity()
+      ..count = count ?? this.count
+      ..page = page ?? this.page
+      ..limit = limit ?? this.limit
+      ..countPage = countPage ?? this.countPage
+      ..list = list ?? this.list;
+  }
+}

+ 57 - 0
packages/cs_domain/lib/generated/json/notice_board_documents_entity.g.dart

@@ -0,0 +1,57 @@
+import 'package:domain/generated/json/base/json_convert_content.dart';
+import 'package:domain/entity/notice_board_documents_entity.dart';
+
+NoticeBoardDocumentsEntity $NoticeBoardDocumentsEntityFromJson(
+    Map<String, dynamic> json) {
+  final NoticeBoardDocumentsEntity noticeBoardDocumentsEntity = NoticeBoardDocumentsEntity();
+  final int? count = jsonConvert.convert<int>(json['count']);
+  if (count != null) {
+    noticeBoardDocumentsEntity.count = count;
+  }
+  final int? page = jsonConvert.convert<int>(json['page']);
+  if (page != null) {
+    noticeBoardDocumentsEntity.page = page;
+  }
+  final int? limit = jsonConvert.convert<int>(json['limit']);
+  if (limit != null) {
+    noticeBoardDocumentsEntity.limit = limit;
+  }
+  final int? countPage = jsonConvert.convert<int>(json['count_page']);
+  if (countPage != null) {
+    noticeBoardDocumentsEntity.countPage = countPage;
+  }
+  final List<dynamic>? list = (json['list'] as List<dynamic>?)?.map(
+          (e) => e).toList();
+  if (list != null) {
+    noticeBoardDocumentsEntity.list = list;
+  }
+  return noticeBoardDocumentsEntity;
+}
+
+Map<String, dynamic> $NoticeBoardDocumentsEntityToJson(
+    NoticeBoardDocumentsEntity entity) {
+  final Map<String, dynamic> data = <String, dynamic>{};
+  data['count'] = entity.count;
+  data['page'] = entity.page;
+  data['limit'] = entity.limit;
+  data['count_page'] = entity.countPage;
+  data['list'] = entity.list;
+  return data;
+}
+
+extension NoticeBoardDocumentsEntityExtension on NoticeBoardDocumentsEntity {
+  NoticeBoardDocumentsEntity copyWith({
+    int? count,
+    int? page,
+    int? limit,
+    int? countPage,
+    List<dynamic>? list,
+  }) {
+    return NoticeBoardDocumentsEntity()
+      ..count = count ?? this.count
+      ..page = page ?? this.page
+      ..limit = limit ?? this.limit
+      ..countPage = countPage ?? this.countPage
+      ..list = list ?? this.list;
+  }
+}

+ 57 - 0
packages/cs_domain/lib/generated/json/notice_board_event_entity.g.dart

@@ -0,0 +1,57 @@
+import 'package:domain/generated/json/base/json_convert_content.dart';
+import 'package:domain/entity/notice_board_event_entity.dart';
+
+NoticeBoardEventEntity $NoticeBoardEventEntityFromJson(
+    Map<String, dynamic> json) {
+  final NoticeBoardEventEntity noticeBoardEventEntity = NoticeBoardEventEntity();
+  final int? count = jsonConvert.convert<int>(json['count']);
+  if (count != null) {
+    noticeBoardEventEntity.count = count;
+  }
+  final int? page = jsonConvert.convert<int>(json['page']);
+  if (page != null) {
+    noticeBoardEventEntity.page = page;
+  }
+  final int? limit = jsonConvert.convert<int>(json['limit']);
+  if (limit != null) {
+    noticeBoardEventEntity.limit = limit;
+  }
+  final int? countPage = jsonConvert.convert<int>(json['count_page']);
+  if (countPage != null) {
+    noticeBoardEventEntity.countPage = countPage;
+  }
+  final List<dynamic>? list = (json['list'] as List<dynamic>?)?.map(
+          (e) => e).toList();
+  if (list != null) {
+    noticeBoardEventEntity.list = list;
+  }
+  return noticeBoardEventEntity;
+}
+
+Map<String, dynamic> $NoticeBoardEventEntityToJson(
+    NoticeBoardEventEntity entity) {
+  final Map<String, dynamic> data = <String, dynamic>{};
+  data['count'] = entity.count;
+  data['page'] = entity.page;
+  data['limit'] = entity.limit;
+  data['count_page'] = entity.countPage;
+  data['list'] = entity.list;
+  return data;
+}
+
+extension NoticeBoardEventEntityExtension on NoticeBoardEventEntity {
+  NoticeBoardEventEntity copyWith({
+    int? count,
+    int? page,
+    int? limit,
+    int? countPage,
+    List<dynamic>? list,
+  }) {
+    return NoticeBoardEventEntity()
+      ..count = count ?? this.count
+      ..page = page ?? this.page
+      ..limit = limit ?? this.limit
+      ..countPage = countPage ?? this.countPage
+      ..list = list ?? this.list;
+  }
+}

BIN
packages/cs_resources/assets/notice_board/announcement_icon.png


BIN
packages/cs_resources/assets/notice_board/documents_icon.png


BIN
packages/cs_resources/assets/notice_board/event_icon.png