瀏覽代碼

地址列表选择模式适配

Abel 1 年之前
父節點
當前提交
4b48d5897f

+ 2 - 0
Asteria/ASUI/SizeDefine.h

@@ -22,4 +22,6 @@
 
 #define kBottomSafeSpace (kStatusBarH > 20 ? 34 : 0)
 
+#define STR(str) ([NSString stringWithFormat:@"%@", str])
+
 #endif /* SizeDefine_h */

+ 1 - 1
Asteria/Fuction/UserCenter/Address/ASAddressListViewController.h

@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *sel_Id;
 
 /// 选择回调事件
-@property (nonatomic , copy) void(^selectAddressBlock)(ASMineAddressModel *addressM);
+@property (nonatomic , copy) void(^selectAddressBlock)(ASAddressModel *addressM);
 
 @end
 

+ 21 - 13
Asteria/Fuction/UserCenter/Address/ASAddressListViewController.m

@@ -134,6 +134,14 @@
     ASAddressModel *model = [ASAddressModel defualtData];
     vc.m =  model;
     vc.isEdit = false;
+    vc.isCartEdit = self.isSelMode;
+    __weak typeof(self) weakSelf = self;
+    vc.saveSuccess = ^(ASAddressModel * _Nonnull addressM) {
+        if (weakSelf.selectAddressBlock) {
+            weakSelf.selectAddressBlock(addressM);
+            [weakSelf.navigationController popViewControllerAnimated:true];
+        }
+    };
     [self.navigationController pushViewController:vc animated:true];
 }
 
@@ -170,20 +178,20 @@
     }else{
         cell.checkBtn.hidden = YES;
     }
-    @weakify(self)
+    __weak typeof(self) weakSelf = self;
     [cell setEditBack:^{
-//        @strongify(self)
-//        // 去编辑地址
-//        KWEditAddressViewController *vc = [KWEditAddressViewController new];
-//        vc.m = m;
-//        vc.isEdit = true;
-//        if(self.addressType == AddressTypeShippingAddress){
-//            vc.editAddressType = EditAddressTypeShippingAddress;
-//            vc.tempListC = self;
-//        }else{
-//            vc.editAddressType = EditAddressTypeSettingAddress;
-//        }
-//        [self.navigationController pushViewController:vc animated:true];
+        // 去编辑地址
+        ASEditAddressViewController *vc = [ASEditAddressViewController new];
+        vc.m = m;
+        vc.isEdit = true;
+        vc.isCartEdit = weakSelf.isSelMode;
+        vc.saveSuccess = ^(ASAddressModel * _Nonnull addressM) {
+            if (weakSelf.selectAddressBlock) {
+                weakSelf.selectAddressBlock(addressM);
+                [weakSelf.navigationController popViewControllerAnimated:true];
+            }
+        };
+        [weakSelf.navigationController pushViewController:vc animated:true];
     }];
     return  cell;
 }

+ 0 - 2
Asteria/Fuction/UserCenter/Address/ASAddressViewModel.h

@@ -17,9 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, strong) NSMutableArray<KWCountryAddressModel *> *countryArr;
 @property (nonatomic, strong) NSMutableArray<KWProvinceAddressModel *> *provinceArr;
 
-@property (nonatomic, strong) NSMutableArray<ASMineAddressModel *> *addressArr;
 
-- (void)getMineAddressList:(void(^)(void))complate;
 
 - (void)upAddress:(ASAddressModel *)addressModel complate:(void(^)(BOOL,NSString *))complate;
 

+ 1 - 52
Asteria/Fuction/UserCenter/Address/ASAddressViewModel.m

@@ -41,57 +41,6 @@
     return arr;
 }
 
-- (void)getMineAddressList:(void(^)(void))complate {
-    NSDictionary *dic = @{};
-    complate();
-    
-//    @weakify(self);
-    
-//    [PPNetworkHelper POST:MineUserAddress parameters:dic success:^(id responseObject) {
-//        
-//        if (RequestSuccess) {
-//            NSLog(@"success:%@",responseObject);
-//            NSDictionary *temDic = (NSDictionary *)responseObject;
-//            KWMineAddressModel *defaultBillingAddress = [KWMineAddressModel mj_objectWithKeyValues:temDic[@"data"][@"defaultBillingAddress"]];
-//            defaultBillingAddress.title = @"Default Billing Address";
-//            defaultBillingAddress.addressType = 1;
-//                
-//            
-//            KWMineAddressModel *defaultShippingAddress = [KWMineAddressModel mj_objectWithKeyValues:temDic[@"data"][@"defaultShippingAddress"]];
-//            defaultShippingAddress.title = @"Default Shipping Address";
-//            defaultShippingAddress.addressType = 2;
-//             
-//            NSMutableArray *arr = [KWMineAddressModel mj_objectArrayWithKeyValuesArray:temDic[@"data"][@"additionalAddressEntries"]];
-//
-//            if (( defaultShippingAddress && ![defaultShippingAddress.Id isEmpty]) &&
-//                [defaultShippingAddress.Id isEqualToString:defaultBillingAddress.Id] &&
-//                ( defaultBillingAddress && ![defaultBillingAddress.Id isEmpty])) {
-//                defaultBillingAddress.addressType = 3;
-//                defaultBillingAddress.title = @"Default Billing Address\nDefault Shipping Address";
-//                self.defaultBillAderssM = defaultBillingAddress;
-//                [arr insertObject:defaultBillingAddress atIndex:0];
-//            }else{
-//                if ( defaultShippingAddress && ![defaultShippingAddress.Id isEmpty]) {
-//                    [arr insertObject:defaultShippingAddress atIndex:0];
-//                }
-//                if ( defaultBillingAddress && ![defaultBillingAddress.Id isEmpty]) {
-//                    self.defaultBillAderssM = defaultBillingAddress;
-//                    [arr insertObject:defaultBillingAddress atIndex:0];
-//                }
-//            }
-//     
-//            weak_self.addressArr = arr;
-//            
-//        } else {
-//            weak_self.addressArr = [NSMutableArray array];
-//        }
-//        complate();
-//    } failure:^(NSError *error) {
-//        NSLog(@"err:%@",error);
-//        weak_self.addressArr = [NSMutableArray array];
-//        complate();
-//    }];
-    
-}
+
 
 @end

+ 1 - 1
Asteria/Fuction/UserCenter/Address/ASMineAddressCell.h

@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, strong) UIButton *editBt;
 @property (nonatomic, strong) UILabel *titleLB;
 
-- (void)setData:(ASMineAddressModel *)m;
+- (void)setData:(ASAddressModel *)m;
 
 @property (nonatomic, copy) btnClickBlock editBack;
 @property (nonatomic, copy) btnClickBlock checkBack;

+ 0 - 22
Asteria/Fuction/UserCenter/Address/ASMineAddressModel.h

@@ -9,28 +9,6 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface ASMineAddressModel : NSObject
-
-@property (nonatomic, copy) NSString *title;
-/// 0:啥也不是   默认地址 1:bill Adress   2:shiping Address      3:bill Adress 和shiping Address
-@property (nonatomic, assign) NSInteger addressType;
-
-@property (nonatomic, copy) NSString *Id;// [string]    是            展开
-@property (nonatomic, copy) NSString *firstname;// [string]    是            展开
-@property (nonatomic, copy) NSString *lastname;// [string]    是            展开
-@property (nonatomic, copy) NSString *city;// [string]    是            展开
-@property (nonatomic, copy) NSString *country_id;// [string]    是            展开
-@property (nonatomic, copy) NSString *country;
-@property (nonatomic, copy) NSString *region;// 地区 [string]    是            展开
-@property (nonatomic, copy) NSString *region_id;// [string]    是            展开
-@property (nonatomic, copy) NSString *postcode;// [string]    是            展开
-@property (nonatomic, copy) NSString *telephone;// [string]    是            展开
-@property (nonatomic, copy) NSString *street;//
-
-+ (ASMineAddressModel *)defualtData;
-
-@end
-
 
 @interface KWCountryAddressModel : NSObject
 

+ 0 - 26
Asteria/Fuction/UserCenter/Address/ASMineAddressModel.m

@@ -7,33 +7,7 @@
 
 #import "ASMineAddressModel.h"
 
-@implementation ASMineAddressModel
 
-+ (NSDictionary *)mj_replacedKeyFromPropertyName {
-    return @{
-        @"Id": @"id",
-    };
-}
-
-+ (ASMineAddressModel *)defualtData {
-
-    ASMineAddressModel *m = [ASMineAddressModel new];
-    m.title = @"";
-    m.firstname = @"";
-    m.lastname = @"";
-    m.street = @"";
-    m.postcode = @"";
-    m.city = @"";
-    m.region = @"";
-    m.telephone = @"";
-    m.country = @"Unites States";
-    m.country_id = @"US";
-    
-
-    return m;
-}
-
-@end
 
 @implementation KWCountryAddressModel
 

+ 3 - 0
Asteria/Fuction/UserCenter/Address/edit/ASEditAddressViewController.h

@@ -15,6 +15,9 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, assign) BOOL isEdit;
 @property (nonatomic, assign) BOOL isCartEdit;
 
+/// 选择回调事件
+@property (nonatomic , copy) void(^saveSuccess)(ASAddressModel *addressM);
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 12 - 9
Asteria/Fuction/UserCenter/Address/edit/ASEditAddressViewController.m

@@ -103,14 +103,14 @@
 
 
 - (void)setEditDefualtData {
-    NSArray<NSString *> *arr = @[self.m.firstname,
-                                 self.m.lastname,
-                                 self.m.street,
-                                 self.m.postcode,
-                                 self.m.city,
-                                 self.m.country,
-                                 self.m.region.region,
-                                 self.m.telephone
+    NSArray<NSString *> *arr = @[STR(self.m.firstname),
+                                 STR(self.m.lastname),
+                                 STR(self.m.street.firstObject),
+                                 STR(self.m.postcode),
+                                 STR(self.m.city),
+                                 STR(self.m.country),
+                                 STR(self.m.region.region),
+                                 STR(self.m.telephone)
     ];
     
     for (int i= 0 ; i<arr.count; i++) {
@@ -388,7 +388,7 @@
                     self.m.lastname = text;
                     break;
                 case 2:
-                    self.m.street = text;
+                    self.m.street = [NSArray arrayWithObject: text];
                     break;
                 case 3:
                     self.m.postcode = text;
@@ -434,6 +434,9 @@
         if (success) {
             [weak_self.view makeToast:@"Edit Successed"];
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.5), dispatch_get_main_queue(), ^{
+                if (weak_self.isCartEdit && weak_self.saveSuccess) {
+                    weak_self.saveSuccess(self.m);
+                }
                 [weak_self.navigationController popViewControllerAnimated:true];
             });
         } else {