glglove месяцев назад: 2
Родитель
Сommit
beb8266a99
21 измененных файлов с 243 добавлено и 216 удалено
  1. 2 2
      packages/cpt_community/lib/components/garage_card.dart
  2. 0 1
      packages/cpt_community/lib/modules/community/community_page.dart
  3. 36 29
      packages/cpt_community/lib/modules/community/community_vm.dart
  4. 0 1
      packages/cpt_community/lib/modules/community/following/following_page.dart
  5. 0 16
      packages/cpt_community/lib/modules/community/following/following_vm.dart
  6. 8 18
      packages/cpt_community/lib/modules/community/foryou/foryou_vm.dart
  7. 0 15
      packages/cpt_community/lib/modules/community/news/news_vm.dart
  8. 1 5
      packages/cpt_community/lib/modules/community/newsfeed_detail/newsfeed_detail_page.dart
  9. 13 25
      packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.dart
  10. 1 1
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_page.dart
  11. 9 27
      packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart
  12. 64 26
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_page.dart
  13. 82 5
      packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_vm.dart
  14. 1 1
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_state.dart
  15. 13 38
      packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.dart
  16. 2 2
      packages/cpt_community/lib/respository/common_garage.dart
  17. 0 3
      packages/cpt_community/pubspec.yaml
  18. 1 0
      packages/cs_plugin_basic/lib/basic_export.dart
  19. 1 0
      packages/cs_widgets/lib/load_state_layout.dart
  20. 3 1
      packages/cs_widgets/lib/widget_export.dart
  21. 6 0
      packages/cs_widgets/pubspec.yaml

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

@@ -242,9 +242,9 @@ class CollectionWidget extends HookConsumerWidget {
           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");
           }
         }
       })

+ 0 - 1
packages/cpt_community/lib/modules/community/community_page.dart

@@ -1,6 +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';

+ 36 - 29
packages/cpt_community/lib/modules/community/community_vm.dart

@@ -41,11 +41,11 @@ class CommunityVm extends _$CommunityVm {
   bool _isSingleSelect = true;
   List<Map<String, dynamic>> _currentSelectedGarageCategory = [];
 
-  Map<int, dynamic> _queryParams = {};
+  Map<int, Map<String, dynamic>> _queryParams = {};
 
   // 获取当前的查询参数
   getCurrentQueryParams(String key) {
-    return _queryParams[key];
+    return _queryParams[state.currentPageViewIdx]?[key];
   }
 
   // 根据索引获取 Provider
@@ -209,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',
@@ -246,34 +240,45 @@ class CommunityVm extends _$CommunityVm {
       //   'name': 'Others',
       // },
     ];
-
     // 获取分类列表
     try {
       // 加入有缓存 就取缓存
-      List<Map<String, dynamic>>? StorageCategoryList = SPUtil.getObjectList(AppConstant.storageGarageCategoryList)?.cast<Map<String, dynamic>>();
+      List<Map<String, dynamic>>? StorageCategoryList = SPUtil.getObjectList(
+          AppConstant.storageGarageCategoryList)?.cast<Map<String, dynamic>>();
 
-      if(StorageCategoryList != null && StorageCategoryList.isNotEmpty){
+      if (StorageCategoryList != null && StorageCategoryList.isNotEmpty) {
         Log.d("取StorageCategoryList 缓存: $StorageCategoryList ");
         garageCategoryList = StorageCategoryList;
-      }else {
-        final result = await getGarageSaleCategoryOptions();
-        if(result.isSuccess){
+      } else {
+        Map<String, dynamic> params = {};
+        final result = await commonGarageRespositoryInstance
+            .fetchGarageCateGoryList(params);
+        if (result.isSuccess) {
           final listJson = result.getListJson();
           // 将 listJson 转换为 List<Map<String, dynamic>>
-          List<Map<String, dynamic>> garageCategoryList = (listJson as List?)?.map((item) => item as Map<String, dynamic>).toList() ?? [];
+          garageCategoryList = (listJson as List?)
+              ?.map((item) => item as Map<String, dynamic>)
+              .toList() ?? [];
           // 将 garageCategoryList 存入缓存
           Log.d("设置StorageCategoryList 缓存");
-          SPUtil.putObjectList(AppConstant.storageGarageCategoryList, garageCategoryList);
+          SPUtil.putObjectList(
+              AppConstant.storageGarageCategoryList, garageCategoryList);
         }
       }
+    } 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
       );
-      // 显示弹框
-      handlerShowChooseGarageCategoryDialog(context, garageCategoryList);
-    }catch(error){
-      Log.d("------获取分类列表error---------- $error");
-    }
   }
 
   Future<void> handlerShowChooseGarageCategoryDialog(BuildContext context, List<Map<String, dynamic>> garageCategoryList) async{
@@ -331,7 +336,7 @@ class CommunityVm extends _$CommunityVm {
 
             providerMap[state.currentPageViewIdx]
               ..setCurrentQueryParams({
-                "category_id": categoryId!,
+                "category_id": _queryParams?[state.currentPageViewIdx]?['categoryId'],
               })
               ..directRefresh();
           },
@@ -341,26 +346,28 @@ class CommunityVm extends _$CommunityVm {
 
   // 搜索
   handlerSearch(String value){
+    Log.d("community_vm 中 搜索 value: $value");
+    _queryParams?[state.currentPageViewIdx]?['keyword'] = value;
     providerMap[state.currentPageViewIdx]
       ..setCurrentQueryParams({
-        "keyword": value,
+        "keyword": _queryParams?[state.currentPageViewIdx]?['keyword'],
       })
-      ..triggerRefresh();
+      ..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?['is_liked']??false);
+    _queryParams[state.currentPageViewIdx]?['is_liked'] = !(_queryParams?[state.currentPageViewIdx]?['is_liked']??false);
 
 
     // 控制外层滚动和内层滚动
@@ -368,7 +375,7 @@ class CommunityVm extends _$CommunityVm {
 
     providerMap[state.currentPageViewIdx]
       ..setCurrentQueryParams({
-        "is_liked": _queryParams?['is_liked'],
+        "is_liked": _queryParams?[state.currentPageViewIdx]?['is_liked'],
       })
       ..directRefresh();
 

+ 0 - 1
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';

+ 0 - 16
packages/cpt_community/lib/modules/community/following/following_vm.dart

@@ -68,30 +68,19 @@ class FollowingVm extends _$FollowingVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.following);
-    if(isShowing){
       Log.d("----following_vm-----loadMore");
       _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();
-    }
   }
 
   // 手动进行刷新
@@ -114,16 +103,11 @@ class FollowingVm extends _$FollowingVm {
 
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.following);
-    if(isShowing){
       Log.d("重新加载数据---9999-----");
       _page = 1;
       refreshController.resetFooter();
       _needShowPlaceholder = false;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
 

+ 8 - 18
packages/cpt_community/lib/modules/community/foryou/foryou_vm.dart

@@ -70,14 +70,9 @@ class ForyouVm extends _$ForyouVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forYou);
-    if(isShowing){
-      Log.d("----foryou_vm-----loadMore");
-      _page++;
-      getListData();
-    }else {
-      refreshController.finishLoad();
-    }
+    Log.d("----foryou_vm-----loadMore");
+    _page++;
+    getListData();
   }
 
   // 手动进行刷新
@@ -89,16 +84,11 @@ class ForyouVm extends _$ForyouVm {
 
   // 下拉刷新
   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();
   }
 
   // 手动进行刷新

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

@@ -77,29 +77,19 @@ class NewsVm extends _$NewsVm {
 
   // 上拉加载 更多
   Future loadMore() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.news);
-    if(isShowing){
       Log.d("----news_vm-----loadMore");
       _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("----news_vm-----onRefresh ");
       // await Future.delayed(const Duration(seconds: 2));
       _page = 1;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
   // 手动进行刷新
@@ -110,16 +100,11 @@ class NewsVm extends _$NewsVm {
 
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.news);
-    if(isShowing){
       _page = 1;
       _needShowPlaceholder = true;
       getListData();
       Log.d("99999999");
       // refreshController.callRefresh();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
   // 手动进行刷新

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

@@ -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,),

+ 13 - 25
packages/cpt_community/lib/modules/garage/for_rent/for_rent_vm.dart

@@ -103,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){
@@ -117,24 +115,16 @@ 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();
-    }
   }
 
   // 手动进行刷新
@@ -157,14 +147,9 @@ class ForrentVm extends _$ForrentVm {
 
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forRent);
-    if(isShowing){
       _page = 1;
       _needShowPlaceholder = true;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
 
@@ -187,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);
@@ -199,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);
@@ -267,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 {
@@ -279,6 +266,7 @@ class ForrentVm extends _$ForrentVm {
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
     } catch (e) {
+      Log.e("Error: $e");
       ToastEngine.show("Error: $e");
     }
   }

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

@@ -137,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);
                   }

+ 9 - 27
packages/cpt_community/lib/modules/garage/for_sale/for_sale_vm.dart

@@ -72,38 +72,19 @@ 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();
-    }
   }
 
 
@@ -128,14 +109,9 @@ class ForsaleVm extends _$ForsaleVm {
 
   // 重试请求
   Future retryRequest() async {
-    bool isShowing = await ref.read(communityVmProvider.notifier).isCurrentPageViewShowing(CommunityPageViewIdxData.forSale);
-    if(isShowing){
       _page = 1;
       _needShowPlaceholder = true;
       getListData();
-    }else {
-      refreshController.finishRefresh();
-    }
   }
 
 
@@ -235,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 {
@@ -247,6 +228,7 @@ class ForsaleVm extends _$ForsaleVm {
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
     } catch (e) {
+      Log.e("Error: $e");
       ToastEngine.show("Error: $e");
     }
   }

+ 64 - 26
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_page.dart

@@ -11,6 +11,7 @@ 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';
@@ -44,7 +45,9 @@ class GaragesaleDetailPage extends HookConsumerWidget {
     GarageSaleRentDetailEntity detailInfo = state.datas?? GarageSaleRentDetailEntity();
     String title =  detailInfo.title?? '';
     int price =  detailInfo.price?? 0;
-    String contactType = '';
+
+    String contactType =  detailInfo.contact??'';
+
     String description = '';
 
 
@@ -70,15 +73,13 @@ class GaragesaleDetailPage extends HookConsumerWidget {
             child: EasyRefresh(
               controller: vm.refreshController,
               // 上拉加载
-              onLoad: () async{
-                Log.d("----onLoad");
-                // vm.loadMore();
-              },
+              onLoad: null,
               // 下拉刷新
               onRefresh: () async{
                 Log.d("----onRefresh");
                 vm.onRefresh();
               },
+              // header: MaterialHeader(),
               child: Stack(
                 children:[
                   LoadStateLayout(
@@ -106,11 +107,14 @@ class GaragesaleDetailPage extends HookConsumerWidget {
                   ),
                   Visibility(
                     visible: state.loadingState == LoadState.State_Success,
-                    child: _buildWhatsApp(context, ref,
-                      title:title,
-                      price:price,
-                      contactType:contactType,
-                      description:description,
+                    child: Visibility(
+                      visible: vm.isContactWhatsApp(contactType),
+                      child: _buildWhatsApp(context, ref,
+                        title:title,
+                        price:price,
+                        contactType:contactType,
+                        description:description,
+                      ),
                     ),
                   ),
                 ]
@@ -140,8 +144,8 @@ class GaragesaleDetailPage extends HookConsumerWidget {
       bottom: 42,
       child: InkWell(
         onTap: () {
-          // 跳转 WhatsApp
-          vm.gotoWhatsApp();
+          // 点击了whatsapp
+          vm.handlerClickWhatsapp(context, contactType, title, price);
         },
         child: const MyAssetImage(Assets.communityWhatsAPP, width: 57,height: 57,),
       ),
@@ -149,11 +153,13 @@ class GaragesaleDetailPage extends HookConsumerWidget {
   }
 
   Widget _buildContentBox(BuildContext context, WidgetRef ref, GarageSaleRentDetailEntity detailInfo) {
-    String goods_img = detailInfo.resources?[0]??'';
+    List<String> resources = detailInfo.resources??[];
+    String goods_img = resources[0]??'';
     String title =  detailInfo.title??'';
     int price = detailInfo.price??0;
     String contactType =  '';
     String description = detailInfo.description??'';
+    CarouselSliderController buttonCarouselController = CarouselSliderController();
     return Column(
       crossAxisAlignment: CrossAxisAlignment.start,
       children: [
@@ -161,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(
@@ -202,17 +217,20 @@ class GaragesaleDetailPage extends HookConsumerWidget {
         required GarageSaleRentDetailEntity detailInfo,
       }
       ) {
-    final state = ref.watch(garagesaleDetailVmProvider);
-
+    final vm = ref.read(garagesaleDetailVmProvider.notifier);
 
     GarageSaleRentDetailAccount  account = detailInfo.account?? GarageSaleRentDetailAccount();
 
     String publisher =  account.name??'-';
-    String contactType =  '';
     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,
       color: ColorUtils.string2Color('#4161D0'),
@@ -255,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(
-                        "$likes_count",
+                        "${_likes_count.value}",
                         fontSize: 18,
                         textColor: Colors.white,
                         isFontRegular: true,
@@ -282,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,),
                     ],
                   ),
                 ),

+ 82 - 5
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';
@@ -20,7 +24,7 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
   late CommonGarageRespository commonGarageRespositoryInstance;
 
   int _detailId = 0;
-  String _detailType = "";
+  String _detailType = "forSale"; // forSale  forRent
 
   bool _needShowPlaceholder = false; //是否展示LoadingView
   int _page = 1;  // 当前页
@@ -30,7 +34,7 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
   // Refresh 控制器
   final EasyRefreshController refreshController = EasyRefreshController(
     controlFinishRefresh: true,  //允许刷新
-    controlFinishLoad: false,   //允许加载
+    controlFinishLoad: true,   //允许加载
   );
 
   GarageDetailState initState() {
@@ -167,8 +171,81 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
   }
 
 
-  // 去whatsapp
-  gotoWhatsApp(){
-    // 跳转 WhatsApp
+  // 点击了底部的收藏按钮
+  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){
+
+    }
+  }
+
+  // 判断是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,
+    );
+
+    if (await canLaunchUrl(launchUri)) {
+      await launchUrl(launchUri);
+    } else {
+      ToastEngine.show("Could not launch $launchUri");
+      throw 'Could not launch $launchUri';
+    }
   }
 }

+ 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

+ 13 - 38
packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.dart

@@ -138,46 +138,21 @@ class GaragesalePostVm extends _$GaragesalePostVm {
   }
 
   Future<List<String>> getGarageCategoryList() async{
+    final communityVm = ref.read(communityVmProvider.notifier);
+    List<Map<String, dynamic>> garageCategoryList = await communityVm.getGarageSaleCategoryOptions();
+
     // 获取分类列表
     List<String> catNameResult = [];
-    try {
-      // 加入有缓存 就取缓存
-      List<Map<String, dynamic>>? StorageCategoryList = SPUtil.getObjectList(AppConstant.storageGarageCategoryList)?.cast<Map<String, dynamic>>();
-
-      if(StorageCategoryList != null && StorageCategoryList.isNotEmpty){
-        Log.d("取StorageCategoryList 缓存: $StorageCategoryList ");
-        _resCategoryOptionsList = StorageCategoryList;
-        // 将 listJson 转换为 List<String>
-        catNameResult = (StorageCategoryList as List)!.map((e) => (e['name'] as String)).toList()?? [];;
-      }else {
-        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();
-          Log.d("_resCategoryOptionsList   $_resCategoryOptionsList");
-          // 将 listJson 转换为 List<Map<String, dynamic>>
-          List<Map<String, dynamic>> garageCategoryList = (listJson as List?)?.map((item) => item as Map<String, dynamic>).toList() ?? [];
-          _resCategoryOptionsList = garageCategoryList;
-          // 将 garageCategoryList 存入缓存
-          Log.d("设置StorageCategoryList 缓存");
-          SPUtil.putObjectList(AppConstant.storageGarageCategoryList, garageCategoryList);
-
-          // 将 listJson 转换为 List<String>
-          List<String> catNameResult = (listJson as List)!.map((e) => (e['name'] as String)).toList()?? [];
-
-          Log.d("--initialSelectedItem----$_initialSaleSelectedItem-");
-        }
-      }
-      state = state.copyWith(
-        saleSelectedOption:_initialSaleSelectedItem,
-        categoryOptionsList: catNameResult,
-      );
-    }catch(error){
-      Log.d("------获取分类列表error---------- $error");
-    }
+
+    _resCategoryOptionsList = garageCategoryList;
+
+    // 将 listJson 转换为 List<String>
+    catNameResult = (garageCategoryList as List)!.map((e) => (e['name'] as String)).toList()?? [];
+
+    state = state.copyWith(
+      saleSelectedOption:_initialSaleSelectedItem,
+      categoryOptionsList: catNameResult,
+    );
 
     return catNameResult;
   }

+ 2 - 2
packages/cpt_community/lib/respository/common_garage.dart

@@ -238,8 +238,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 地址

+ 0 - 3
packages/cpt_community/pubspec.yaml

@@ -48,9 +48,6 @@ dependencies:
   # Hooks 简化 Riverpod 获取
   hooks_riverpod: ^2.5.1
 
-  # extended_nested_scroll_view
-  extended_nested_scroll_view: ^6.2.1
-
 dev_dependencies:
   flutter_test:
     sdk: flutter

+ 1 - 0
packages/cs_plugin_basic/lib/basic_export.dart

@@ -4,3 +4,4 @@ export 'package:share_plus/share_plus.dart';
 export 'package:visibility_detector/visibility_detector.dart';
 
 
+

+ 1 - 0
packages/cs_widgets/lib/load_state_layout.dart

@@ -152,6 +152,7 @@ class _LoadStateLayoutState extends State<LoadStateLayout> {
                   widget.errorMessage ?? 'Data loading failed! Please refresh and try again',
                   marginTop: 18,
                   fontSize: 14,
+                  textAlign: TextAlign.center,
                   textColor: widget.themeColor ?? context.appColors.textDarkGray,
                 ),
               ],

+ 3 - 1
packages/cs_widgets/lib/widget_export.dart

@@ -6,4 +6,6 @@ export 'package:easy_refresh/easy_refresh.dart';
 export 'package:flutter_html/flutter_html.dart';
 export 'package:webview_flutter/webview_flutter.dart';
 export 'package:hand_signature/signature.dart';
-export 'shatter/weekly_calendar/weekly_calendar.dart';
+export 'shatter/weekly_calendar/weekly_calendar.dart';
+export 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
+export 'package:carousel_slider/carousel_slider.dart';

+ 6 - 0
packages/cs_widgets/pubspec.yaml

@@ -72,6 +72,12 @@ dependencies:
   #手写签名 https://pub.dev/packages/hand_signature
   hand_signature: ^3.0.2
 
+  # extended_nested_scroll_view
+  extended_nested_scroll_view: ^6.2.1
+
+  # 轮播图
+  carousel_slider: ^5.0.0
+
 
 flutter:
   uses-material-design: true