Parcourir la source

feat:bug修改

“wangdongchao” il y a 1 an
Parent
commit
d5b2674e8f

+ 33 - 22
Asteria/Fuction/Cart/Cart_CheckoutC.m

@@ -68,9 +68,10 @@
     //获取支付方式
     [self requestPaymentMode];
     //获取运输方式
-    [self requestGetShipMethodByAddress];
+//    [self requestGetShipMethodByAddress];
     //获取购物车信息(地址信息)
-    [self requestCartInfo];
+//    [self requestCartInfo];
+    [self getDefaultAddress];
     if (!self.totalsM) {
         [self reqNet_Cart_cartsMineTotals];
     }
@@ -187,14 +188,13 @@
 //                ASAddressModel *addressModel = [ASAddressModel defualtData];
                 ASAddressReginModel *reginModel = [ASAddressReginModel mj_objectWithKeyValues:addressDic];
                 ASAddressModel *addressModel = [ASAddressModel mj_objectWithKeyValues:addressDic];
+                
+                
                 addressModel.region = reginModel;
-                if (!NIL(addressModel.postcode)) {
+                if (AS_String_valid(addressModel.postcode) && AS_String_valid(addressModel.telephone)  && AS_String_valid(addressModel.firstname)  && AS_String_valid(addressModel.lastname)) {
                     self.addressCellM.addressModel = addressModel;
                     
-                    if (self.shipmethodCellM.shipMethodModel) {
-                        //默认设置第一个运输方式
-                        [self requestSetShipMethodByAddress];
-                    }
+                    [self requestAddShipAddress];
                     [self requestAddBillingAddress];
                 }
             }
@@ -220,7 +220,6 @@
                 
                 
             }
-//            [self reqNet_Cart_cartsMineTotals];
         }
         /// || [mark isEqualToString:Chectout_addBillingAddress]
     } else if ([mark isEqualToString:Chectout_getShipMethod]) {
@@ -411,6 +410,23 @@
 }
 
 #pragma mark - **************** reqNet ****************
+//每次进来获取用户默认地址
+- (void)getDefaultAddress {
+    NSArray *addressArr = ASUserInfoManager.shared.userInfo.addresses;
+    
+    if (AS_Array_valid(addressArr)) {
+        self.addressCellM.addressModel = addressArr.firstObject;
+        for (ASAddressModel *addressModel in addressArr) {
+            if ([addressModel.default_shipping isEqualToString:@"1"]) {
+                self.addressCellM.addressModel = addressModel;
+            }
+        }
+        
+        [self requestAddShipAddress];
+        [self requestAddBillingAddress];
+    }
+}
+
 //获取支付方式
 - (void)requestPaymentMode {
     [self.VM ry_requestGetApi:Chectout_getPaymentMode param:@{}];
@@ -422,33 +438,28 @@
 }
 
 - (NSDictionary *)getAddressParam:(ASAddressModel *)addressModel {
-    NSDictionary *param = @{};
     
     NSArray *street = addressModel.street;
-    NSDictionary *shipping_address = @{@"region_code":addressModel.region_id,
-                                       @"country_id":addressModel.country_id,
-                                       @"postcode":addressModel.postcode,
-                                       @"lastname":addressModel.lastname,
-                                       @"firstname":addressModel.firstname,
-                                       @"city":addressModel.city,
-                                       @"region":addressModel.region.region,
-                                       @"region_id":addressModel.region.region_id,
-                                       @"telephone":addressModel.telephone,
+    NSDictionary *shipping_address = @{@"region_code":AS_String_NotNull(addressModel.region_id),
+                                       @"country_id":AS_String_NotNull(addressModel.country_id),
+                                       @"postcode":AS_String_NotNull(addressModel.postcode),
+                                       @"lastname":AS_String_NotNull(addressModel.lastname),
+                                       @"firstname":AS_String_NotNull(addressModel.firstname),
+                                       @"city":AS_String_NotNull(addressModel.city),
+                                       @"region":AS_String_NotNull(addressModel.region.region),
+                                       @"region_id":AS_String_NotNull(addressModel.region.region_id),
+                                       @"telephone":AS_String_NotNull(addressModel.telephone),
                                        @"street":street,
                                        @"email":ASUserInfoManager.shared.userInfo.email};
     
     return shipping_address;
-//    @{@"addressInformation":shipping_address}
 }
 
 //添加账单地址
 - (void)requestAddBillingAddress {
-//    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     
     NSDictionary *addressInformation = [self getAddressParam:self.addressCellM.addressModel];
-    
     NSDictionary *params = @{@"address":addressInformation, @"useForShipping":@"true"};
-    
     [self.VM ry_requestPostApi:Chectout_addBillingAddress param:params];
 }
 //根据邮寄地址获取邮寄方式

+ 0 - 3
Asteria/Fuction/Goods/VM/ASGoodsDetailsVM.h

@@ -23,9 +23,6 @@
 ///添加评论
 #define Reviews_rewriteProductAddReview BaseRequestrUrl(@"rewrite/product/addReview")
 
-//加购相关内容
-#define Size_rewriteCartAddProducts BaseRequestrUrl(@"rewrite/cart/addProducts")
-
 
 
 NS_ASSUME_NONNULL_BEGIN

+ 2 - 2
Asteria/Fuction/Login/VC/AS_LoginC.m

@@ -256,7 +256,7 @@
 -(EamilTFmatchV *)xxx_emailTFV{
     if (!_xxx_emailTFV) {
         _xxx_emailTFV = [[EamilTFmatchV alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 50)];
-        _xxx_emailTFV.xxx_emailTF.text = @"845600348@qq.com";
+//        _xxx_emailTFV.xxx_emailTF.text = @"845600348@qq.com";
     }
     return _xxx_emailTFV;
 }
@@ -265,7 +265,7 @@
 - (PassWordSecureBtnV *)xxx_passwordV {
     if (!_xxx_passwordV) {
         _xxx_passwordV = [[PassWordSecureBtnV alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(self.xxx_emailTFV.frame)+30, KScreenWidth-40, 50+20)];
-        _xxx_passwordV.xxx_passwordTF.text = @"nuli322103";
+//        _xxx_passwordV.xxx_passwordTF.text = @"nuli322103";
     }
     return _xxx_passwordV;
 }

+ 5 - 2
Asteria/Fuction/UserCenter/Orders/Controller/ASOrderDetailsViewController.m

@@ -164,9 +164,12 @@
 - (ASPayFinishHeadView *)paySuccessView {
     if (!_paySuccessView) {
         _paySuccessView = [[ASPayFinishHeadView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 100) status:1 desc:self.orderId];
-//        K_WEAK_SELF;
+        K_WEAK_SELF;
         _paySuccessView.clickBlock = ^(int type) {
-    //        K_STRONG_SELF;
+            K_STRONG_SELF;
+            if (type == 1) {
+                [Fuction_Tool popToHomeVc];
+            }
         };
         _paySuccessView.frame = CGRectMake(0, 0, KScreenWidth, [_paySuccessView getViewHeight]);
     }

+ 66 - 4
Asteria/Fuction/UserCenter/Orders/Controller/ASOrderListSubController.m

@@ -18,6 +18,8 @@
 @property (nonatomic, assign) NSInteger page;
 @property (nonatomic, strong) ASOrderListViewModel *vm;
 
+@property (nonatomic, assign) NSInteger addCartCount;
+
 @end
 
 @implementation ASOrderListSubController
@@ -135,11 +137,20 @@
             return;
         }
         // 查看订单
-        NSLog(@"查看订单 view order");
         
-        ASOrderDetailsViewController *orderDetailsVC = [[ASOrderDetailsViewController alloc] init];
-        orderDetailsVC.orderId = model.entity_id;
-        [self.navigationController pushViewController:orderDetailsVC animated:YES];
+        if (type == 0) {//订单详情
+            ASOrderDetailsViewController *orderDetailsVC = [[ASOrderDetailsViewController alloc] init];
+            orderDetailsVC.orderId = model.entity_id;
+            [self.navigationController pushViewController:orderDetailsVC animated:YES];
+        } else if (type == 1) {//Track Order
+            ASOrderDetailsViewController *orderDetailsVC = [[ASOrderDetailsViewController alloc] init];
+            orderDetailsVC.orderId = model.entity_id;
+            [self.navigationController pushViewController:orderDetailsVC animated:YES];
+        } else if (type == 2) {
+            [self reorderClickWithData:model];
+        }
+        
+        
         
         //            KWM_OrderViewC *vc = [[KWM_OrderViewC alloc]init];
         //            vc.order_id = m.orderId;
@@ -149,4 +160,55 @@
     
 }
 
+
+- (void)reorderClickWithData:(KWMineHomeOrderModel *)orderModel {
+    
+    NSMutableArray *itemOptionArr = [[NSMutableArray alloc] initWithCapacity:1];
+    
+    for (KWMineOrderProInfoModel *proModel in orderModel.items) {
+        
+        if (![proModel.name hasPrefix:@"FREE"]) {
+            if (AS_Array_valid(proModel.custom_options)) {
+                
+                NSMutableDictionary *optionParam = [NSMutableDictionary dictionary];
+                for (NSDictionary *optionsDic in proModel.custom_options) {
+                    [optionParam setValue:optionsDic[@"option_value"] forKey:[NSString stringWithFormat:@"options[%@]", optionsDic[@"option_id"]]];
+                }
+                [optionParam setValue:proModel.product_id forKey:@"product"];
+                [optionParam setValue:@"1" forKey:@"qty"];
+                
+                [itemOptionArr addObject:optionParam];
+            }
+        }
+    }
+    
+    self.addCartCount = itemOptionArr.count;
+    if (self.addCartCount == 0) {
+        return;
+    }
+    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+    
+    for (NSDictionary *param in itemOptionArr) {
+        [self requestAddCartWithParams:param];
+    }
+}
+
+
+- (void)requestAddCartWithParams:(NSDictionary *)params {
+    K_WEAK_SELF;
+    [self.vm orderGoodsAddCartWithParam:params complete:^(BOOL isSuccess, NSString * _Nonnull msg) {
+        
+        K_STRONG_SELF;
+        self.addCartCount--;
+        
+        if (self.addCartCount == 0) {
+            [self.view makeToast:@"Success" duration:2 position:CSToastPositionCenter title:nil image:nil style:nil completion:^(BOOL didTap) {
+                [Fuction_Tool popToRootViewController:2];
+            }];
+            [MBProgressHUD hideHUDForView:self.view animated:YES];
+        }
+    }];
+}
+
+
 @end

+ 4 - 1
Asteria/Fuction/UserCenter/Orders/Controller/ASPayFailedViewController.m

@@ -32,7 +32,10 @@
     [self.scrollView addSubview:payFailedView];
     K_WEAK_SELF;
     payFailedView.clickBlock = ^(int type) {
-//        K_STRONG_SELF;
+        K_STRONG_SELF;
+        if (type == 1) {
+            [self.navigationController popViewControllerAnimated:true];
+        }
     };
     
     float viewHeight = [payFailedView getViewHeight];

+ 1 - 1
Asteria/Fuction/UserCenter/Orders/View/ASOrderListCell.m

@@ -113,7 +113,7 @@
     btStv.alignment = UIStackViewAlignmentFill;
     
     [self.bgV addSubview:btStv];
-    [btStv addArrangedSubview:self.trackBt];
+//    [btStv addArrangedSubview:self.trackBt];
     [btStv addArrangedSubview:self.reorderBt];
     [btStv addArrangedSubview:self.viewBt];
     [btStv addArrangedSubview:self.paynowBt];

+ 4 - 0
Asteria/Fuction/UserCenter/Orders/ViewModel/ASOrderListViewModel.h

@@ -14,6 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
 
 - (void)getOrderNet:(NSString *)status page:(NSInteger)page com:(void(^)(NSArray<KWMineHomeOrderModel *> *))com;
 
+- (void)orderGoodsAddCartWithParam:(NSDictionary *)param complete:(void(^)(BOOL isSuccess, NSString *msg))completeBlock;
+
+
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 16 - 0
Asteria/Fuction/UserCenter/Orders/ViewModel/ASOrderListViewModel.m

@@ -16,6 +16,8 @@
     NSMutableDictionary *paraDic = [NSMutableDictionary dictionaryWithDictionary:@{
         @"searchCriteria[pageSize]":@10,
         @"searchCriteria[currentPage]":@(page),
+        @"searchCriteria[sortOrders][0][field]":@"created_at",
+        @"searchCriteria[sortOrders][0][direction]":@"desc"
     }];
     if (![status.localizedLowercaseString isEqualToString:@"all"]) {
         [paraDic addEntriesFromDictionary:@{
@@ -41,4 +43,18 @@
 }
 
 
+- (void)orderGoodsAddCartWithParam:(NSDictionary *)param complete:(void(^)(BOOL isSuccess, NSString *msg))completeBlock {
+    [ASNetTools.shared formData_postWithPath:Size_rewriteCartAddProducts param:param success:^(id _Nonnull json) {
+        NSLog(@"mark--addcart--param-%@\n-json--%@", param,json);
+        
+        completeBlock(YES, @"Success");
+        
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        NSLog(@"mark--addcart--param-%@\n-Error--%@",param,msg);
+        
+        completeBlock(NO, @"failed");
+    }];
+}
+
+
 @end

+ 1 - 0
Asteria/Fuction/UserCenter/Points/model/ASPointDetailModel.h

@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *points_balance;
 @property (nonatomic, copy) NSString *comment;
 @property (nonatomic, copy) NSString *created_at;
+@property (nonatomic, copy) NSString *event_data;
 
 
 @end

+ 1 - 1
Asteria/Fuction/UserCenter/Points/view/ASPointDetailCell.m

@@ -21,7 +21,7 @@
 @implementation ASPointDetailCell
 
 - (void)setData:(ASPointDetailModel *)model {
-    self.titleLb.text = model.comment;
+    self.titleLb.text = model.event_data;
     
     self.dateLb.text = model.created_at;
     self.pointsLb.text = [NSString stringWithFormat:@"%@ Points",model.points_delta];

+ 4 - 1
Asteria/Fuction/UserCenter/UserCenterHome/ASUserCenterViewModel.m

@@ -14,7 +14,10 @@
 - (void)getAllOrderNet:(void(^)(NSArray<KWMineHomeOrderModel *> *))com {
     NSDictionary *para = @{
         @"url": @"/V1/orders",
-        @"params": @{@"searchCriteria[pageSize]":@4, @"searchCriteria[currentPage]":@1},
+        @"params": @{@"searchCriteria[pageSize]":@4,
+                     @"searchCriteria[currentPage]":@1,
+                     @"searchCriteria[sortOrders][0][field]":@"created_at",
+                     @"searchCriteria[sortOrders][0][direction]":@"desc"}
     };
     [ASNetTools.shared postWithPath:getAllOrders param:para success:^(id _Nonnull json) {
         NSLog(@"---getAllOrders---result:%@------",json);

+ 1 - 0
Asteria/Fuction/UserCenter/UserCenterHome/models/KWMineHomeOrderModel.h

@@ -38,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *qty_ordered;
 @property (nonatomic, copy) NSString *currency_symbol;
 @property (nonatomic, copy) NSString *is_gift;
+@property (nonatomic, strong) NSArray *custom_options;//当前选中规格
 
 @end
 

+ 2 - 2
Asteria/Fuction/UserCenter/UserCenterHome/models/KWMineHomeOrderModel.m

@@ -31,8 +31,8 @@
 + (NSDictionary *)mj_replacedKeyFromPropertyName {
     return @{
         @"image":@"extension_attributes.image",
-        @"is_gift": @"extension_attributes.is_gift"
-        
+        @"is_gift": @"extension_attributes.is_gift",
+        @"custom_options":@"product_option.extension_attributes.custom_options"
     };
 }
 

+ 4 - 0
Asteria/NetTools/ASNetApis.h

@@ -44,6 +44,10 @@
 #define getProductListUrl @"catalog/category/view"
 #define getProdectDetail BaseRequestrUrl(@"rewrite/product/getProductsById")
 
+// MARK: - 商品详情
+//加购相关内容
+#define Size_rewriteCartAddProducts BaseRequestrUrl(@"rewrite/cart/addProducts")
+
 // MARK: - 货币
 #define getAllCurrencyUrl BaseRequestrUrl(@"directory/currency")
 

+ 2 - 0
Asteria/Product/Tool/Fuction_Tool.h

@@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
 +(void)pop_toLoginVC;
 + (void)popToHomeVc;
 
++ (void)popToRootViewController:(NSInteger)index;
+
 
 +(void)tool_shareImgStr:(NSString *)imgStr sharetitle:(NSString *)title shareUrl:(NSString *)urlStr currentVC:(UIViewController *)vc;
 

+ 8 - 0
Asteria/Product/Tool/Fuction_Tool.m

@@ -17,6 +17,14 @@
     }
 }
 
++ (void)popToRootViewController:(NSInteger)index {
+    [[Current_normalTool currentNav] popToRootViewControllerAnimated:false];
+    UITabBarController *tabvc = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
+    if ([tabvc isKindOfClass:[UITabBarController self]]) {
+        tabvc.selectedIndex = index;
+    }
+}
+
 +(void)push_BaseWebUrl:(NSString *)url webTitle:(NSString *)title{
     XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
     [vc xxx_dsWebLoadUrl:url];