Переглянути джерело

mypost 的rent 和sale 可以删除 和编辑

glglove 4 тижнів тому
батько
коміт
ee27bea798

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

@@ -136,7 +136,7 @@ class GarageCard extends StatelessWidget {
           // 发布人信息
           Expanded(
             child: Padding(
-              padding: EdgeInsets.only(left: (useType == GarageCardUseType.forSale || useType == GarageCardUseType.forRent)?10:0, right: 10, bottom: 17.5),
+              padding: EdgeInsets.only(left: (useType == GarageCardUseType.forSale || useType == GarageCardUseType.forRent)?10:0, right: 10, bottom: 10.5),
               child: Row(
                 mainAxisAlignment: MainAxisAlignment.spaceAround,
                 crossAxisAlignment: CrossAxisAlignment.center,
@@ -154,7 +154,7 @@ class GarageCard extends StatelessWidget {
                     child: Column(
                       mainAxisAlignment: MainAxisAlignment.center,
                       crossAxisAlignment: CrossAxisAlignment.start,
-                      mainAxisSize: MainAxisSize.max,
+                      mainAxisSize: MainAxisSize.min,
                       children: [
                         if (useType == GarageCardUseType.forSale || useType == GarageCardUseType.forRent)
                           MyTextView(
@@ -179,7 +179,7 @@ class GarageCard extends StatelessWidget {
                           fontSize: 10,
                           textColor: context.appColors.textBlack,
                           isFontRegular: true,
-                        ).expanded(),
+                        ),
                       ]
                     )
                   ),

+ 42 - 14
packages/cpt_community/lib/modules/garage/garagesale_detail/garagesale_detail_page.dart

@@ -27,7 +27,7 @@ import 'package:widgets/widget_export.dart';
 @RoutePage()
 class GaragesaleDetailPage extends HookConsumerWidget {
   final int id;
-  final String type;  // forSale  forRent
+  final String type;  // forSale  forRent  mineForSale  mineForRent
 
   const GaragesaleDetailPage({Key? key, required this.id, required this.type}) : super(key: key);
   // 启动当前页面
@@ -44,7 +44,7 @@ class GaragesaleDetailPage extends HookConsumerWidget {
   Widget build(BuildContext context, WidgetRef ref) {
     final state = ref.watch(garagesaleDetailVmProvider);
     final vm = ref.read(garagesaleDetailVmProvider.notifier);
-    final String pageTitle = (type == 'forSale') ? 'For Sale' :'For Rent';
+    final String pageTitle = (type == 'forSale' || type == 'mineForSale') ? 'For Sale' :'For Rent';
     GlobalKey _likeButtonKey = GlobalKey<MyLikeButtonState>();
 
     GarageSaleRentDetailEntity? detailInfo = state.datas?? null;
@@ -69,6 +69,19 @@ class GaragesaleDetailPage extends HookConsumerWidget {
         context,
         pageTitle,
         backgroundColor: context.appColors.backgroundWhite,
+        actions: [
+          type=='mineForSale'||type=='mineForRent'?Center(
+            child: MyTextView(
+              'Delete',
+              textColor: context.appColors.redDefault,
+              fontSize: 16,
+              isFontMedium: true,
+              marginRight: 20,
+            ).onTap((){
+              vm.deleteMyGarageData(context, id!);
+            }),
+          ): SizedBox.shrink()
+        ],
       ),
       backgroundColor: context.appColors.backgroundDefault,
       body: Column(
@@ -237,19 +250,16 @@ class GaragesaleDetailPage extends HookConsumerWidget {
 
     GarageSaleRentDetailAccount  account = detailInfo.account?? GarageSaleRentDetailAccount();
 
-    Log.d("0000000 ${detailInfo.likesCount}");
     String publisher =  account.name??'-';
     String publisherAvatar = account.avatar??'-';
 
     String contactType =  detailInfo.contact??'';
     String publisherTime =  detailInfo.createdAt??'-';
     int? likes_count =  detailInfo.likesCount??0;
-    Log.d("666666 ${likes_count}");
 
 
     final _likes_count = useState<int>(likes_count!);
     final _isLiked = useState<bool>(false);
-    Log.d("4344 ${_likes_count.value}");
 
 
     return Container(
@@ -334,22 +344,40 @@ class GaragesaleDetailPage extends HookConsumerWidget {
                   ),
                 ),
                 // const MyAssetImage(Assets.communityCollection, width: 18,height: 18,),
-                Visibility(
-                  visible: vm.isContactMobile(contactType),
-                  child:  Row(
+                // 如果从我的post 页面进入的 则电话处固定显示 编辑的入口图标
+                if(type == 'mineForSale' ||  type=='mineForRent')
+                  Row(
                     children: [
                       const SizedBox(width: 4,),
                       const MyAssetImage(
-                        Assets.communityPhone,
-                        width: 21.5,
-                        height: 18,
+                        Assets.communityEdit,
+                        width: 20.5,
+                        height: 20,
                       ).onTap((){
-                        vm.handlerClickMobile(context, contactType);
+                        // 进入到 编辑页面
+                        vm.goToEditPage(context, type, detailInfo);
                       }),
                       const SizedBox(width: 15,),
                     ],
-                  ),
-                ),
+                  )
+                else
+                  // 如果不是从我的post 页面进入的则电话处显示 拨打电话的入口图标
+                  Visibility(
+                    visible: vm.isContactMobile(contactType),
+                    child:  Row(
+                      children: [
+                        const SizedBox(width: 4,),
+                        const MyAssetImage(
+                          Assets.communityPhone,
+                          width: 21.5,
+                          height: 18,
+                        ).onTap((){
+                          vm.handlerClickMobile(context, contactType);
+                        }),
+                        const SizedBox(width: 15,),
+                      ],
+                    ),
+                  )
               ],
             ),
           ),

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

@@ -5,17 +5,21 @@ 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_basic/provider/user_config/user_config_service.dart';
+import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
 import 'package:plugin_platform/engine/permission/permission_engine.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:riverpod_annotation/riverpod_annotation.dart';
 import 'package:router/ext/auto_router_extensions.dart';
 import 'package:shared/utils/log_utils.dart';
+import 'package:widgets/dialog/app_default_dialog.dart';
 import 'package:widgets/load_state_layout.dart';
 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_post/garagesale_post_page.dart';
 import 'garagesale_detail_state.dart';
 
 part 'garagesale_detail_vm.g.dart';
@@ -115,7 +119,36 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
     _detailType = type;
   }
 
-  Future getDetailData<T>() async {
+  // 删除 garagesale 数据
+  Future deleteMyGarageData(BuildContext? context, int id) async {
+    DialogEngine.show(
+      widget: AppDefaultDialog(
+        message: "Are you sure you want to delete?",
+        confirmAction: () async {
+          try {
+            Map<String, dynamic> params = {
+              "id": _detailId,
+            };
+            final result = await commonGarageRespositoryInstance.deleteMyGarage(params);
+            if(result.isSuccess){
+              // 更新用户信息
+              UserConfigService.getInstance().refreshUserInfo();
+              // 返回上级
+              appRouter.maybePop();
+            } else {
+              String errorMessage = result.errorMsg!;
+              changeLoadingState(LoadState.State_Error, errorMessage);
+              ToastEngine.show(result.errorMsg ?? "Network Load Error");
+            }
+          } catch (e) {
+            ToastEngine.show("Error: $e");
+          }
+        },
+      ));
+  }
+
+  // 获取 garagesage 详情数据
+  Future<GarageSaleRentDetailEntity?> getDetailData<T>() async {
     if (_needShowPlaceholder) {
       changeLoadingState(LoadState.State_Loading, null);
     }
@@ -163,6 +196,7 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
         changeLoadingState(LoadState.State_Error, errorMessage);
         ToastEngine.show(result.errorMsg ?? "Network Load Error");
       }
+      return result.data as GarageSaleRentDetailEntity;
     } catch (e) {
       ToastEngine.show("Error: $e");
     }
@@ -251,4 +285,12 @@ class GaragesaleDetailVm extends _$GaragesaleDetailVm {
       }
     });
   }
+
+  // 去 garagesale_post 页面 进行编辑
+  Future<void> goToEditPage(BuildContext context,String minetype, GarageSaleRentDetailEntity detailInfo) async {
+    //  type 为  forSale forRent mineForSale mineForRent
+    // 点击发布的按钮 跳转到garagesale 发布的页面
+    int type = minetype == "mineForSale" ? 3 : 4;
+    GaragesalePostPage.startInstance(type: type, );
+  }
 }

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

@@ -22,7 +22,7 @@ import 'garagesale_post_vm.dart';
 
 @RoutePage()
 class GaragesalePostPage extends HookConsumerWidget {
-  int type = 1;  // 类型(1=Sale,2=Rent)
+  int type = 1;  // 类型(1=Sale,2=Rent, 3=mineForSale 4=mineForRent)
   final VoidCallback? sCallback; // 成功回调函数
   final VoidCallback? fCallback; // 失败回调函数
   GaragesalePostPage({Key? key, required this.type, this.sCallback, this.fCallback}) : super(key: key);
@@ -54,7 +54,7 @@ class GaragesalePostPage extends HookConsumerWidget {
     return Scaffold(
       appBar: MyAppBar.appBar(
         context,
-        "Post New Item",
+        (type==1 || type==2)?"Post New Item":"Edit",
         backgroundColor: context.appColors.backgroundWhite,
       ),
       backgroundColor: Colors.white,
@@ -257,7 +257,7 @@ class GaragesalePostPage extends HookConsumerWidget {
       maxImages: 10,
       spacing: 10,
       aspectRatio: 108 / 80,
-      initialImages: state.imgList,
+      initialImages: state.imgList??[],
       onImagesChanged: (list) {
         vm.setImgList(list);
       },

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

@@ -21,6 +21,9 @@ class GaragesalePostPageState {
   // 描述
   final String? description;
 
+  // 价格
+  final String? price;
+
   // contact type 类型选项
   final List<String> contactTypeOptionsList = ["Mobile Phone", "WhatsApp",];
   String? contactTypeSelectedOption;
@@ -37,55 +40,64 @@ class GaragesalePostPageState {
   List<String> categoryOptionsList = [];
   String? categorySelectedOption;
 
+
   // 选择的图片
-  final List<String> imgList;
+  List<String>? imgList = [];
 
   GaragesalePostPageState({
     formData,
-    required this.imgList,
     required this.categoryOptionsList,
+    this.imgList,
     this.titleErrorText,
     this.contactInfoErrorText,
     this.priceErrorText,
     this.descriptionErrorText,
     this.title,
     this.description,
+    this.price,
     this.contactInformation,
     this.contactTypeSelectedOption,
     this.saleSelectedOption,
     this.categorySelectedOption,
   }): formData = formData ?? {
     'sale': {
-      'value': '',
-      'controller': TextEditingController(),
+      'value': saleSelectedOption ?? '',
+      'controller': TextEditingController(text: saleSelectedOption ?? ''),
       'hintText': '',
       'focusNode': FocusNode(),
       'obsecure': false,
     },
     'category': {
-      'value': '',
-      'controller': TextEditingController(),
+      'value': categorySelectedOption??'',
+      'controller': TextEditingController(text: categorySelectedOption??''),
       'hintText': '',
       'focusNode': FocusNode(),
       'obsecure': false,
     },
     'title': {
-      'value': '',
-      'controller': TextEditingController(),
+      'value': title ?? '',
+      'controller': TextEditingController(text: title ?? ''),
       'hintText': '',
       'focusNode': FocusNode(),
       'obsecure': false,
     },
     'price': {
-      'value': '',
-      'controller': TextEditingController(),
+      'value': price ?? '',
+      'controller': TextEditingController(text: price ??''),
+      'hintText': '',
+      'focusNode': FocusNode(),
+      'obsecure': false,
+    },
+    'contactInfo': {
+      'value': contactInformation ?? '',
+      'controller': TextEditingController(text: contactInformation ?? ''),
       'hintText': '',
       'focusNode': FocusNode(),
       'obsecure': false,
     },
     'description': {
-      'value': '',
-      'controller': TextEditingController(),
+      'value': description??'',
+      'controller': TextEditingController(text: description??''),
       'hintText': '',
       'focusNode': FocusNode(),
       'obsecure': false,
@@ -106,11 +118,13 @@ class GaragesalePostPageState {
     String? categorySelectedOption,
     String? title,
     String? description,
+    String? price,
   }) {
     return GaragesalePostPageState(
       formData: formData ?? this.formData,
       title: title ?? this.title,
       description: description ?? this.description,
+      price: price ?? this.price,
       imgList: imgList ?? this.imgList,
       categoryOptionsList: categoryOptionsList ?? this.categoryOptionsList,
       contactInformation: contactInformation ?? this.contactInformation,

+ 176 - 23
packages/cpt_community/lib/modules/garage/garagesale_post/garagesale_post_vm.dart

@@ -2,10 +2,13 @@
 import 'dart:async';
 
 import 'package:cpt_community/modules/community/community_vm.dart';
+import 'package:cpt_community/modules/garage/garagesale_detail/garagesale_detail_vm.dart';
 import 'package:cs_resources/generated/assets.dart';
+import 'package:domain/entity/garage_sale_rent_detail_entity.dart';
 import 'package:flutter/material.dart';
 import 'package:plugin_basic/constants/app_constant.dart';
 import 'package:plugin_basic/provider/user_config/user_config_service.dart';
+import 'package:plugin_platform/engine/loading/loading_engine.dart';
 import 'package:plugin_platform/engine/sp/sp_util.dart';
 import 'package:plugin_platform/engine/toast/toast_engine.dart';
 import 'package:plugin_platform/http/http_result.dart';
@@ -32,7 +35,8 @@ class GaragesalePostVm extends _$GaragesalePostVm {
   List _resCategoryOptionsList = [];
   int _initialSaleSelectIndex = 0;
   String _initialSaleSelectedItem = '';
-  int _type = 1; // 类型(1=Sale,2=Rent)
+  int _type = 1; // 类型(1=Sale,2=Rent, 3=mineForSale 4=mineForRent)
+  late GarageSaleRentDetailEntity _detailData;
 
   GaragesalePostPageState initState() {
     return GaragesalePostPageState(
@@ -92,7 +96,6 @@ class GaragesalePostVm extends _$GaragesalePostVm {
           'obsecure': false,
         },
       },
-      imgList: [],
     );
   }
 
@@ -120,16 +123,20 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     // 初始化回显 sale 分类
     initSaleCategory();
     this.getGarageCategoryList();
+    if(_type == 3 || _type == 4){
+      // mypost 页面进来的 是编辑 需要回显
+      this.initEchoData();
+    }
   }
 
   initSaleCategory() {
     state.saleOptionsList.asMap().forEach((index, item) => {
-      if(_type == 1){
+      if(_type == 1 || _type == 3){
         if(item == 'For Sale'){
           _initialSaleSelectIndex = index,
           _initialSaleSelectedItem = item
         }
-      }else if(_type == 2){
+      }else if(_type == 2 || _type == 4){
         if(item == 'For Rent'){
           _initialSaleSelectIndex = index,
           _initialSaleSelectedItem = item
@@ -138,6 +145,102 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     });
   }
 
+  // mypost页面通过详情然后编辑 进入的 需要初始化回显数据
+  initEchoData() async{
+    LoadingEngine.show();
+    // 调取 详情接口
+    final garagesaleDetailVm = ref.read(garagesaleDetailVmProvider.notifier);
+    final _detailData = await garagesaleDetailVm.getDetailData();
+    if(_detailData != null){
+      // 回显 title
+      String title = _detailData.title??'';
+      String price = _detailData.price?.toString()??'0';
+      String description = _detailData.description??'';
+      String saleSelectedOption = _type==3? 'For Sale':'For Rent';
+      String contact = _detailData.contact??'';
+      String contactInformation = garagesaleDetailVm.getContactNumber(contact)??'';
+      String contactType = ''; // 联系方式 类型 Mobile Phone   WhatsApp
+      // final category_id = result.category_id??'';
+      // final categorySelectedOption = result.category??'';
+      String categorySelectedOption = 'Kids';
+      // 根据 categorySelectedOption
+
+      List<String> imgList = _detailData.resources??[];
+      Log.d("imgList--------$imgList");
+
+      if(contact.isNotEmpty){
+        if(garagesaleDetailVm.isContactMobile(contact)){
+          // 是mobile
+         state.contactTypeSelectedOption = 'Mobile Phone';
+          contactType = 'Mobile Phone';
+        }else if(garagesaleDetailVm.isContactWhatsApp(contact)){
+          // 是whatsapp
+          state.contactTypeSelectedOption = 'WhatsApp';
+          contactType = 'WhatsApp';
+        }
+      }
+
+      // category_id
+
+      final newFormdata = {
+        'sale': {
+          'value': saleSelectedOption,
+          'controller': TextEditingController(text: saleSelectedOption ?? ''),
+          'hintText': '',
+          'focusNode': FocusNode(),
+          'obsecure': false,
+        },
+        'category': {
+          'value': categorySelectedOption??'',
+          'controller': TextEditingController(text: categorySelectedOption??''),
+          'hintText': '',
+          'focusNode': FocusNode(),
+          'obsecure': false,
+        },
+        'title': {
+          'value': title ?? '',
+          'controller': TextEditingController(text: title ?? ''),
+          'hintText': '',
+          'focusNode': FocusNode(),
+          'obsecure': false,
+        },
+        'contactInfo': {
+          'value': contactInformation ?? '',
+          'controller': TextEditingController(text: contactInformation ?? ''),
+          'hintText': '',
+          'focusNode': FocusNode(),
+          'obsecure': false,
+        },
+        'price': {
+          'value': price ?? '',
+          'controller': TextEditingController(text: price != null? price.toString():''),
+          'hintText': '',
+          'focusNode': FocusNode(),
+          'obsecure': false,
+        },
+        'description': {
+          'value': description??'',
+          'controller': TextEditingController(text: description??''),
+          'hintText': '',
+          'focusNode': FocusNode(),
+          'obsecure': false,
+        },
+      };
+
+      state = state.copyWith(
+        title: title,
+        description: description,
+        price: price,
+        categorySelectedOption: categorySelectedOption,
+        contactTypeSelectedOption: contactType,
+        contactInformation: contactInformation,
+          imgList: imgList,
+        formData: {...state.formData, ...newFormdata}
+      );
+    }
+    LoadingEngine.dismiss();
+  }
+
   Future<List<String>> getGarageCategoryList() async{
     final communityVm = ref.read(communityVmProvider.notifier);
     List<Map<String, dynamic>> garageCategoryList = await communityVm.getGarageSaleCategoryOptions();
@@ -252,9 +355,11 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     }
   }
 
+
   ///提交反馈
   Future submitGaragesalePost(BuildContext context, {VoidCallback? sCallback, VoidCallback? fCallback}) async{
     Log.d("GaragesalePostPageState 提交表单");
+
     state = state.copyWith(titleErrorText: null, descriptionErrorText: null);
     _dismissKeyboard(keyStr: "");
 
@@ -336,28 +441,76 @@ class GaragesalePostVm extends _$GaragesalePostVm {
       totalContactStr = 'email:$contactInfoValue';
     }
 
-    // 提交数据
-    final resResult = await handlerSubmitPost(
-      type: saleValue == 'For Sale'? 1:2,
-      titleValue: titleValue,
-      categoryId: categoryId!,
-      priceValue: priceValue,
-      descriptionValue: descriptionValue,
-      contactValue: totalContactStr,
-      imgList: state.imgList,
-    );
-
-    if(resResult.isSuccess){
-      // 更新用户信息
-      UserConfigService.getInstance().refreshUserInfo();
 
-      final communitVm = ref.read(communityVmProvider.notifier);
-      communitVm.getCurrentPageViewVm(null).initPageData();
-      // Navigator.pop(context);
-      appRouter.maybePop();
+    if(_type == 1 || _type == 2){
+      // 新增 提交数据
+      final resResult = await handlerSubmitPost(
+        type: saleValue == 'For Sale'? 1:2,
+        titleValue: titleValue,
+        categoryId: categoryId!,
+        priceValue: priceValue,
+        descriptionValue: descriptionValue,
+        contactValue: totalContactStr,
+        imgList: state.imgList??[],
+      );
+
+      if(resResult.isSuccess){
+        // 更新用户信息
+        UserConfigService.getInstance().refreshUserInfo();
+
+        final communitVm = ref.read(communityVmProvider.notifier);
+        communitVm.getCurrentPageViewVm(null).initPageData();
+        // Navigator.pop(context);
+        appRouter.maybePop();
+      }
+    }else if(_type == 3 || _type ==4){
+      // 调用编辑提交的接口
+      // mypost 入口进入的  编辑 提交数据
+      final resResult = await handlerSubmitEdit(
+        id: _detailData.id!,
+        titleValue: titleValue,
+        categoryId: categoryId!,
+        priceValue: priceValue,
+        descriptionValue: descriptionValue,
+        contactValue: totalContactStr,
+        imgList: state.imgList??[],
+      );
+      if(resResult.isSuccess){
+        // 更新用户信息
+        // UserConfigService.getInstance().refreshUserInfo();
+
+        final garagesaleDetailVm = ref.read(garagesaleDetailVmProvider.notifier);
+        final _detailData = await garagesaleDetailVm.getDetailData();
+        // Navigator.pop(context);
+        appRouter.maybePop();
+      }
     }
   }
 
+  // 编辑
+  Future<HttpResult<Object>> handlerSubmitEdit({
+    required int id,
+    required String titleValue,
+    required int categoryId,
+    required String priceValue,
+    required String contactValue,
+    required String descriptionValue,
+    required List imgList,
+  }) async{
+    final params = <String, dynamic>{
+      "id": id,
+      "category_id": categoryId,
+      "title": titleValue,
+      "price": priceValue,
+      "description": descriptionValue,
+      "contact": contactValue,  // string($例如:whatsapp:+8617671757687 或 mobile:+8617671757687)
+      "resources": imgList,
+    };
+    final result =  await commonGarageRespositoryInstance.updateMyGarage(params);
+    return result;
+  }
+
+  // 新增
   Future<HttpResult<Object>> handlerSubmitPost({
     required int type,
     required String titleValue,
@@ -368,7 +521,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
     required List imgList,
   }) async{
       final params = <String, dynamic>{
-        "type": type, // 1 = Sale  2 = Rent
+        "type": type, // 1 = For Sale  2 = For Rent
         "category_id": categoryId,
         "title": titleValue,
         "price": priceValue,

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

@@ -223,6 +223,6 @@ class MyPostsForRentVm extends _$MyPostsForRentVm {
   // 去详情页面
   void handlerGotoDetail(id){
     Log.d("去详情页面");
-    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forRent'));
+    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'mineForSale'));
   }
 }

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

@@ -265,6 +265,6 @@ class MyPostsForSaleVm extends _$MyPostsForSaleVm {
   // 去详情页面
   void handlerGotoDetail(id){
     Log.d("去详情页面");
-    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'forSale'));
+    appRouter.push(GaragesaleDetailPageRoute(id: id, type: 'mineForSale'));
   }
 }

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

@@ -231,6 +231,101 @@ class CommonGarageRespository {
     return result.convert();
   }
 
+  // 更新 发布的 garage
+  Future<HttpResult<Object>> updateMyGarage(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    List<String> paths = data!["resources"] as List<String>;
+
+    Map<String, String> files = {};
+    if (paths != null && paths.isNotEmpty) {
+      paths.asMap().forEach((index, path) {
+        files["resources[$index]"] = path;
+      });
+    }
+    // 删除 resources 属性
+    params.remove("resources");
+
+    final result = await dioEngine.requestNetResult(
+      // ApiConstants.apiServerTime, // api 地址
+      '/api/v1/user/garage-sale/index/update', // api 地址
+      params: params,
+      paths: files,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: json);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+  // 删除 发布的 garage
+  Future<HttpResult<Object>> deleteMyGarage(
+      Map<String, dynamic>? data, {
+        CancelToken? cancelToken,
+      }) async {
+    Map<String, dynamic> params = {};
+    params = data!;
+    Map<String, String> headers = {};
+    headers["Content-Type"] = "application/x-www-form-urlencoded";
+    headers["Accept"] = "application/x.yyjobs-api.v1+json";
+
+    // List<String> paths = data!["resources"] as List<String>;
+    // Map<String, String> files = {};
+    // if (paths != null && paths.isNotEmpty) {
+    //   paths.asMap().forEach((index, path) {
+    //     files["resources[$index]"] = path;
+    //   });
+    // }
+    // 删除 resources 属性
+    // params.remove("resources");
+
+    final result = await dioEngine.requestNetResult(
+      '/api/v1/user/garage-sale/index/delete', // api 地址
+      params: params,
+      // paths: files,
+      headers: headers,
+      method: HttpMethod.POST,
+      isShowLoadingDialog: true,  //是否展示默认的Loading弹窗
+      networkDebounce: true,   //是否防抖防止重复请求
+      cancelToken: cancelToken,
+    );
+    //根据返回的结果,封装原始数据为Bean/Entity对象
+    if (result.isSuccess) {
+      //重新赋值data或list
+      final json = result.getDataJson();
+      // var data = NewsfeedForyouEntity.fromJson(json!);
+      //重新赋值data或list
+      return result.convert(data: json);
+    }else {
+      if(result.errorMsg != null && result.errorMsg!.isNotEmpty){
+        ToastEngine.show("${result.errorMsg}");
+      }
+    }
+    return result.convert();
+  }
+
+
   // 获取 详情信息
   Future<HttpResult<Object>> fetchGarageDetailInfo(
       Map<String, dynamic>? data, {