瀏覽代碼

feat:购物车、结算赠品UI、逻辑对接

“wangdongchao” 1 年之前
父節點
當前提交
e5336c11f0

+ 6 - 0
Asteria.xcodeproj/project.pbxproj

@@ -195,6 +195,7 @@
 		8810F5232BEDF31500346FD4 /* Cart.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8810F5222BEDF31500346FD4 /* Cart.xcassets */; };
 		8810F5232BEDF31500346FD4 /* Cart.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8810F5222BEDF31500346FD4 /* Cart.xcassets */; };
 		8810F5262BEDF9F900346FD4 /* ASCheckoutBottomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8810F5252BEDF9F900346FD4 /* ASCheckoutBottomView.m */; };
 		8810F5262BEDF9F900346FD4 /* ASCheckoutBottomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8810F5252BEDF9F900346FD4 /* ASCheckoutBottomView.m */; };
 		8810F5292BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8810F5282BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m */; };
 		8810F5292BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8810F5282BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m */; };
+		8810F52C2BF1A1CD00346FD4 /* ASAddGiftGoodsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8810F52B2BF1A1CD00346FD4 /* ASAddGiftGoodsView.m */; };
 		8C24ECE114420CDEE7B9B22B /* Pods_Asteria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54DCE8001991D89B696E7D44 /* Pods_Asteria.framework */; };
 		8C24ECE114420CDEE7B9B22B /* Pods_Asteria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54DCE8001991D89B696E7D44 /* Pods_Asteria.framework */; };
 		9A1247942A1B082300126226 /* Fuction_Tool.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1247932A1B082300126226 /* Fuction_Tool.m */; };
 		9A1247942A1B082300126226 /* Fuction_Tool.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1247932A1B082300126226 /* Fuction_Tool.m */; };
 		9A1247972A1B0A2800126226 /* AS_ForgotC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1247962A1B0A2800126226 /* AS_ForgotC.m */; };
 		9A1247972A1B0A2800126226 /* AS_ForgotC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1247962A1B0A2800126226 /* AS_ForgotC.m */; };
@@ -706,6 +707,8 @@
 		8810F5252BEDF9F900346FD4 /* ASCheckoutBottomView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASCheckoutBottomView.m; sourceTree = "<group>"; };
 		8810F5252BEDF9F900346FD4 /* ASCheckoutBottomView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASCheckoutBottomView.m; sourceTree = "<group>"; };
 		8810F5272BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASCheckoutGoodsItemCell.h; sourceTree = "<group>"; };
 		8810F5272BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASCheckoutGoodsItemCell.h; sourceTree = "<group>"; };
 		8810F5282BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASCheckoutGoodsItemCell.m; sourceTree = "<group>"; };
 		8810F5282BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASCheckoutGoodsItemCell.m; sourceTree = "<group>"; };
+		8810F52A2BF1A1CD00346FD4 /* ASAddGiftGoodsView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASAddGiftGoodsView.h; sourceTree = "<group>"; };
+		8810F52B2BF1A1CD00346FD4 /* ASAddGiftGoodsView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASAddGiftGoodsView.m; sourceTree = "<group>"; };
 		9A1247922A1B082300126226 /* Fuction_Tool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Fuction_Tool.h; sourceTree = "<group>"; };
 		9A1247922A1B082300126226 /* Fuction_Tool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Fuction_Tool.h; sourceTree = "<group>"; };
 		9A1247932A1B082300126226 /* Fuction_Tool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Fuction_Tool.m; sourceTree = "<group>"; };
 		9A1247932A1B082300126226 /* Fuction_Tool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Fuction_Tool.m; sourceTree = "<group>"; };
 		9A1247952A1B0A2800126226 /* AS_ForgotC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AS_ForgotC.h; sourceTree = "<group>"; };
 		9A1247952A1B0A2800126226 /* AS_ForgotC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AS_ForgotC.h; sourceTree = "<group>"; };
@@ -2429,6 +2432,8 @@
 				8810F5082BEB159600346FD4 /* ASCheckoutTopView.m */,
 				8810F5082BEB159600346FD4 /* ASCheckoutTopView.m */,
 				8810F5242BEDF9F900346FD4 /* ASCheckoutBottomView.h */,
 				8810F5242BEDF9F900346FD4 /* ASCheckoutBottomView.h */,
 				8810F5252BEDF9F900346FD4 /* ASCheckoutBottomView.m */,
 				8810F5252BEDF9F900346FD4 /* ASCheckoutBottomView.m */,
+				8810F52A2BF1A1CD00346FD4 /* ASAddGiftGoodsView.h */,
+				8810F52B2BF1A1CD00346FD4 /* ASAddGiftGoodsView.m */,
 				8810F5272BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.h */,
 				8810F5272BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.h */,
 				8810F5282BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m */,
 				8810F5282BEE0DEA00346FD4 /* ASCheckoutGoodsItemCell.m */,
 				8810F50A2BEB590C00346FD4 /* ASCheckoutPointApplyCell.h */,
 				8810F50A2BEB590C00346FD4 /* ASCheckoutPointApplyCell.h */,
@@ -2779,6 +2784,7 @@
 				9AD346002A08D60F005CA070 /* ZFPresentTransition.m in Sources */,
 				9AD346002A08D60F005CA070 /* ZFPresentTransition.m in Sources */,
 				81717D112A3C4AE000648139 /* KWSearchViewModel.m in Sources */,
 				81717D112A3C4AE000648139 /* KWSearchViewModel.m in Sources */,
 				9A337E3B2A04EE1A00D058A5 /* BViewController.m in Sources */,
 				9A337E3B2A04EE1A00D058A5 /* BViewController.m in Sources */,
+				8810F52C2BF1A1CD00346FD4 /* ASAddGiftGoodsView.m in Sources */,
 				9A31EDFD2B468A55009F11EE /* RadioButton.m in Sources */,
 				9A31EDFD2B468A55009F11EE /* RadioButton.m in Sources */,
 				9AD345A72A08D571005CA070 /* TYPageControl.m in Sources */,
 				9AD345A72A08D571005CA070 /* TYPageControl.m in Sources */,
 				81354C0A2A289C350082C93A /* KWScrollOffsetView.m in Sources */,
 				81354C0A2A289C350082C93A /* KWScrollOffsetView.m in Sources */,

+ 4 - 3
Asteria/Common/V/AlertMyCartDeleteV.m

@@ -261,9 +261,10 @@
         _noBtn.backgroundColor = Col_000;
         _noBtn.backgroundColor = Col_000;
         [_noBtn setTitleColor:Col_FFF forState:UIControlStateNormal];
         [_noBtn setTitleColor:Col_FFF forState:UIControlStateNormal];
         [_noBtn addTarget:self action:@selector(handle_noClickEvent:) forControlEvents:UIControlEventTouchUpInside];
         [_noBtn addTarget:self action:@selector(handle_noClickEvent:) forControlEvents:UIControlEventTouchUpInside];
-        NSMutableAttributedString *noString = [[NSMutableAttributedString alloc] initWithString:@"NO"];
-        [noString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [noString length])];
-        [_noBtn setAttributedTitle:noString forState:UIControlStateNormal];
+//        NSMutableAttributedString *noString = [[NSMutableAttributedString alloc] initWithString:@"NO"];
+//        [noString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [noString length])];
+//        [_noBtn setAttributedTitle:noString forState:UIControlStateNormal];
+        [_noBtn setTitle:@"NO" forState:UIControlStateNormal];
         _noBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
         _noBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
         
         
     }
     }

+ 114 - 8
Asteria/Fuction/Cart/Cart_CheckoutC.m

@@ -15,6 +15,10 @@
 #import "CartVM.h"
 #import "CartVM.h"
 #import "ASUserModel.h"
 #import "ASUserModel.h"
 
 
+#import "ASGoodsDetailsVM.h"
+
+#import "ASAddGiftGoodsView.h"
+
 @interface Cart_CheckoutC ()<RY_baseVMprotocol>
 @interface Cart_CheckoutC ()<RY_baseVMprotocol>
 
 
 @property (nonatomic, strong) CartVM *VM;
 @property (nonatomic, strong) CartVM *VM;
@@ -38,6 +42,15 @@
 @property (nonatomic, strong) ASCheckoutPaymentModel *paymentModel;
 @property (nonatomic, strong) ASCheckoutPaymentModel *paymentModel;
 
 
 
 
+//手动添加赠品至购物车
+@property (nonatomic, strong) ASGoodsDetailsVM *goodsDetailsVM;
+
+@property (nonatomic, strong) ASAddGiftGoodsView *addGiftView;
+@property (nonatomic, strong) NSMutableArray *addGiftParamArr;
+@property (nonatomic, assign) int index;
+@property (nonatomic, assign) int giftShowCount;
+
+
 @end
 @end
 
 
 @implementation Cart_CheckoutC
 @implementation Cart_CheckoutC
@@ -57,6 +70,10 @@
 - (void)initSubviews {
 - (void)initSubviews {
     [super initSubviews];
     [super initSubviews];
     
     
+    self.addGiftParamArr = [[NSMutableArray alloc] initWithCapacity:1];
+    self.index = 0;
+    self.giftShowCount = 0;
+    
     IPhoneXHeigh
     IPhoneXHeigh
     [self setupTableV:[CartCheckTableV class] Frame:CGRectMake(0, securitytop_Y , KScreenWidth, KScreenHeight - securitytop_Y)];
     [self setupTableV:[CartCheckTableV class] Frame:CGRectMake(0, securitytop_Y , KScreenWidth, KScreenHeight - securitytop_Y)];
     self.TableV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
     self.TableV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
@@ -211,16 +228,43 @@
         [self updateData];
         [self updateData];
         
         
     } else if ([mark isEqualToString:Cart_cartsMineItems_Post]
     } else if ([mark isEqualToString:Cart_cartsMineItems_Post]
-              || [mark isEqualToString:DEL_cartsMineItems]
-              || [mark isEqualToString:PUT_cartsMineCoupons]
-              || [mark isEqualToString:Chectout_PUT_usePoints]
-              || [mark isEqualToString:Chectout_DEL_cancelusePoints]
-              || [mark isEqualToString:Chectout_setShipMethod]){
+               || [mark isEqualToString:DEL_cartsMineItems]
+               || [mark isEqualToString:PUT_cartsMineCoupons]
+               || [mark isEqualToString:Chectout_PUT_usePoints]
+               || [mark isEqualToString:Chectout_DEL_cancelusePoints]
+               || [mark isEqualToString:Chectout_setShipMethod]
+               || [mark isEqualToString:Chectout_giftAddCart]){
         if(sucessOrFail){
         if(sucessOrFail){
-            [self reqNet_Cart_cartsMineTotals];
+            if ([mark isEqualToString:Chectout_giftAddCart]) {
+                self.index --;
+                if (self.index == 0) {
+                    [self reqNet_Cart_cartsMineTotals];
+                }
+            } else {
+                [self reqNet_Cart_cartsMineTotals];
+            }
         }else{
         }else{
             [self.view makeToast:(NSString *)data duration:2 position:CSToastPositionCenter];
             [self.view makeToast:(NSString *)data duration:2 position:CSToastPositionCenter];
         }
         }
+    } else if ([mark isEqualToString:Goods_productGetProductsById]) {
+        //请求赠品详情
+        GoodsInformationM *model = (GoodsInformationM *)[arry firstObject];
+                
+        NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:@{@"product_id":model.Id, @"isPromoItems":@"yes"}];
+        if (model.options.count > 0) {
+            NSMutableDictionary *optionDic = [NSMutableDictionary dictionary];
+            for (OptionsModel *optionM in model.options) {
+                OptionsValuesM *valuesM = optionM.values[0];
+                NSString *tempStr =[NSString stringWithFormat:@"options[%@]",optionM.option_id];
+                optionDic[tempStr] =valuesM.option_type_id;
+            }
+            [param addEntriesFromDictionary:optionDic];
+        }
+        [self.addGiftParamArr addObject:param];
+        if (self.giftShowCount < 2 && self.addGiftParamArr.count == 1 && self.addGiftView.hidden) {
+            self.addGiftView.hidden = NO;
+            [self.addGiftView setGiftData:model.add_gooodsImgUrl];
+        }
     }
     }
 }
 }
 
 
@@ -269,8 +313,21 @@
     //支付方式数据
     //支付方式数据
     [self.TableV.infodata addObjectsFromArray:self.paymentArray];
     [self.TableV.infodata addObjectsFromArray:self.paymentArray];
     
     
+    //手动添加赠品功能
+    [self.addGiftParamArr removeAllObjects];
     
     
-    
+    NSDictionary *freeData = (NSDictionary *)[[self.totalsM.extension_attributes objectForKey:@"free_data"] mj_JSONObject];
+    BOOL is_show = [[freeData objectForKey:@"is_show"] boolValue];
+    if (is_show && self.giftShowCount< 2) {//显示存在赠品
+        NSArray *productArr = [freeData objectForKey:@"products"];
+        if (productArr.count > 0) { //存在赠品
+            for (int i = 0; i < productArr.count; i++) {
+                NSDictionary *productDic = productArr[i];
+                NSString *entity_id = productDic[@"entity_id"];
+                [self reqNet_GoodsDetails_productGetProduct:entity_id];
+            }
+        }
+    }
     
     
     [self.TableV reloadData];
     [self.TableV reloadData];
 }
 }
@@ -348,6 +405,11 @@
     
     
     [param removeObjectForKey:@"extension_attributes"];//移除格式不正确的无用参数
     [param removeObjectForKey:@"extension_attributes"];//移除格式不正确的无用参数
     
     
+    if (NIL(self.shipmethodCellM.shipMethodModel.method_code) || NIL(self.shipmethodCellM.shipMethodModel.carrier_code)) {
+        [self.view makeToast:@"运输方式获取失败"];
+        return;
+    }
+    
     NSDictionary *params = @{@"shipping_address":param,
     NSDictionary *params = @{@"shipping_address":param,
                              @"shipping_method_code":self.shipmethodCellM.shipMethodModel.method_code,
                              @"shipping_method_code":self.shipmethodCellM.shipMethodModel.method_code,
                              @"shipping_carrier_code":self.shipmethodCellM.shipMethodModel.carrier_code};
                              @"shipping_carrier_code":self.shipmethodCellM.shipMethodModel.carrier_code};
@@ -385,7 +447,7 @@
 }
 }
 -(void)reqNet_PUT_cartsMineCoupons:(NSString *)coupon{
 -(void)reqNet_PUT_cartsMineCoupons:(NSString *)coupon{
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-
+    self.giftShowCount = 0;
     [self.VM ry_requestPutApi:PUT_cartsMineCoupons param:coupon];
     [self.VM ry_requestPutApi:PUT_cartsMineCoupons param:coupon];
 }
 }
 -(void)reqNet_DEL_cartsMineCoupons{
 -(void)reqNet_DEL_cartsMineCoupons{
@@ -418,9 +480,34 @@
     
     
 }
 }
 
 
+//请求赠品商品详情
+-(void)reqNet_GoodsDetails_productGetProduct:(NSString *)enterId{
+    NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
+//    [params setObject:@"55475" forKey:@"productId"];
+    [params setObject:enterId forKey:@"productId"];
+    [params setObject:ASCurrencyManager.shared.currentCur forKey:@"currencyCode"];
+//    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+    [self.goodsDetailsVM ry_requestGetApi:Goods_productGetProductsById param:params];
+}
+
+//赠品加车
+- (void)requestGiftAddCart {
+    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+    
+    for (int i = 0; i < self.addGiftParamArr.count; i++) {
+        NSDictionary *param = self.addGiftParamArr[i];
+        self.index ++;
+        self.giftShowCount = 2;
+        [self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
+    }
+    
+    
+}
+
 #pragma mark --- 懒加载 ---
 #pragma mark --- 懒加载 ---
 - (void)ucm_bindvmmodel{
 - (void)ucm_bindvmmodel{
     self.VM = [[CartVM alloc] initDelegate:self];
     self.VM = [[CartVM alloc] initDelegate:self];
+    self.goodsDetailsVM = [[ASGoodsDetailsVM alloc] initDelegate:self];
 }
 }
 
 
 - (MyCartCouponCellData *)couponCellM {
 - (MyCartCouponCellData *)couponCellM {
@@ -491,6 +578,25 @@
     return _bottomView;
     return _bottomView;
 }
 }
 
 
+- (ASAddGiftGoodsView *)addGiftView {
+    if (!_addGiftView) {
+        _addGiftView = [[ASAddGiftGoodsView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
+        @weakify(self)
+        _addGiftView.addBlock = ^(int type) {
+            @strongify(self)
+            self.addGiftView.hidden = YES;
+            if (type == 1) {
+                [self requestGiftAddCart];
+            } else {
+                self.giftShowCount ++;
+            }
+        };
+        _addGiftView.hidden = YES;
+        [[UIApplication sharedApplication].keyWindow addSubview:_addGiftView];
+    }
+    return _addGiftView;
+}
+
 #pragma mark - **************** reqNet ****************
 #pragma mark - **************** reqNet ****************
 
 
 
 

+ 116 - 4
Asteria/Fuction/Cart/Cart_MyCartC.m

@@ -9,6 +9,11 @@
 #import "CartVM.h"
 #import "CartVM.h"
 #import "MyCarlTableV.h"
 #import "MyCarlTableV.h"
 #import "Cart_CheckoutC.h"
 #import "Cart_CheckoutC.h"
+
+#import "ASGoodsDetailsVM.h"
+
+#import "ASAddGiftGoodsView.h"
+
 @interface Cart_MyCartC ()<RY_baseVMprotocol>
 @interface Cart_MyCartC ()<RY_baseVMprotocol>
 @property (nonatomic, strong) CartVM *VM;
 @property (nonatomic, strong) CartVM *VM;
 @property (nonatomic, strong) UIView *topBgV;
 @property (nonatomic, strong) UIView *topBgV;
@@ -20,6 +25,16 @@
 @property (nonatomic, strong) MyCartCouponCellData *couponCellM;
 @property (nonatomic, strong) MyCartCouponCellData *couponCellM;
 @property (nonatomic, strong) MyCartGrandTotalCellData *totalCellM;
 @property (nonatomic, strong) MyCartGrandTotalCellData *totalCellM;
 @property (nonatomic, strong) UIButton *postBtn;
 @property (nonatomic, strong) UIButton *postBtn;
+
+
+//手动添加赠品至购物车
+@property (nonatomic, strong) ASGoodsDetailsVM *goodsDetailsVM;
+
+@property (nonatomic, strong) ASAddGiftGoodsView *addGiftView;
+@property (nonatomic, strong) NSMutableArray *addGiftParamArr;
+@property (nonatomic, assign) int index;
+@property (nonatomic, assign) int giftShowCount;
+
 @end
 @end
 
 
 @implementation Cart_MyCartC
 @implementation Cart_MyCartC
@@ -55,7 +70,10 @@
     
     
     [self.view addSubview:self.postBtn];
     [self.view addSubview:self.postBtn];
     self.postBtn.mj_y = CGRectGetMaxY(self.TableV.frame);
     self.postBtn.mj_y = CGRectGetMaxY(self.TableV.frame);
-
+    
+    self.addGiftParamArr = [[NSMutableArray alloc] initWithCapacity:1];
+    self.index = 0;
+    self.giftShowCount = 0;
 }
 }
 
 
 
 
@@ -87,8 +105,11 @@
 }
 }
 - (void)ucm_bindvmmodel{
 - (void)ucm_bindvmmodel{
     self.VM = [[CartVM alloc] initDelegate:self];
     self.VM = [[CartVM alloc] initDelegate:self];
+    self.goodsDetailsVM = [[ASGoodsDetailsVM alloc] initDelegate:self];
 }
 }
 
 
+
+
 #pragma mark - **************** reqNet ****************
 #pragma mark - **************** reqNet ****************
 ///获取购物车
 ///获取购物车
 -(void)reqNet_Cart_cartsMineTotals{
 -(void)reqNet_Cart_cartsMineTotals{
@@ -115,7 +136,7 @@
 }
 }
 -(void)reqNet_PUT_cartsMineCoupons:(NSString *)coupon{
 -(void)reqNet_PUT_cartsMineCoupons:(NSString *)coupon{
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
-
+    self.giftShowCount = 0;
     [self.VM ry_requestPutApi:PUT_cartsMineCoupons param:coupon];
     [self.VM ry_requestPutApi:PUT_cartsMineCoupons param:coupon];
 }
 }
 -(void)reqNet_DEL_cartsMineCoupons{
 -(void)reqNet_DEL_cartsMineCoupons{
@@ -123,6 +144,29 @@
     [self.VM ry_requestDeleteApi:DEL_cartsMineCoupons paramStr:@""];
     [self.VM ry_requestDeleteApi:DEL_cartsMineCoupons paramStr:@""];
 }
 }
 
 
+//请求赠品商品详情
+-(void)reqNet_GoodsDetails_productGetProduct:(NSString *)enterId{
+    NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
+//    [params setObject:@"55475" forKey:@"productId"];
+    [params setObject:enterId forKey:@"productId"];
+    [params setObject:ASCurrencyManager.shared.currentCur forKey:@"currencyCode"];
+//    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+    [self.goodsDetailsVM ry_requestGetApi:Goods_productGetProductsById param:params];
+}
+
+//赠品加车
+- (void)requestGiftAddCart {
+    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+    
+    for (int i = 0; i < self.addGiftParamArr.count; i++) {
+        NSDictionary *param = self.addGiftParamArr[i];
+        self.index ++;
+        [self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
+    }
+    
+    
+}
+
 - (void)ry_respnsData:(id)data 
 - (void)ry_respnsData:(id)data 
              parseAry:(NSMutableArray *)arry
              parseAry:(NSMutableArray *)arry
                sucess:(BOOL)sucessOrFail 
                sucess:(BOOL)sucessOrFail 
@@ -153,16 +197,65 @@
             data.currency_symbol = model.currency_symbol;
             data.currency_symbol = model.currency_symbol;
             [self.TableV.infodata addObject:data];
             [self.TableV.infodata addObject:data];
             
             
+            //手动添加赠品功能
+            [self.addGiftParamArr removeAllObjects];
+            
+            NSDictionary *freeData = (NSDictionary *)[[self.totalsM.extension_attributes objectForKey:@"free_data"] mj_JSONObject];
+            BOOL is_show = [[freeData objectForKey:@"is_show"] boolValue];
+            if (is_show && self.giftShowCount< 1) {//显示存在赠品
+                NSArray *productArr = [freeData objectForKey:@"products"];
+                if (productArr.count > 0) { //存在赠品
+                    for (int i = 0; i < productArr.count; i++) {
+                        NSDictionary *productDic = productArr[i];
+                        NSString *entity_id = productDic[@"entity_id"];
+                        [self reqNet_GoodsDetails_productGetProduct:entity_id];
+                    }
+                }
+            }
+            
             [self.TableV reloadData];
             [self.TableV reloadData];
         }
         }
     }else if ([mark isEqualToString:Cart_cartsMineItems_Post]
     }else if ([mark isEqualToString:Cart_cartsMineItems_Post]
               || [mark isEqualToString:DEL_cartsMineItems]
               || [mark isEqualToString:DEL_cartsMineItems]
-              || [mark isEqualToString:PUT_cartsMineCoupons]){
+              || [mark isEqualToString:PUT_cartsMineCoupons]
+              || [mark isEqualToString:Chectout_giftAddCart]){
         if(sucessOrFail){
         if(sucessOrFail){
-            [self reqNet_Cart_cartsMineTotals];
+            
+            if ([mark isEqualToString:Chectout_giftAddCart]) {
+                self.index --;
+                if (self.index == 0) {
+                    [self reqNet_Cart_cartsMineTotals];
+                }
+            } else {
+                [self reqNet_Cart_cartsMineTotals];
+            }
+            
+            
         }else{
         }else{
             [self.view makeToast:(NSString *)data duration:2 position:CSToastPositionCenter];
             [self.view makeToast:(NSString *)data duration:2 position:CSToastPositionCenter];
         }
         }
+    } else if ([mark isEqualToString:Goods_productGetProductsById]) {
+        //请求赠品详情
+        GoodsInformationM *model = (GoodsInformationM *)[arry firstObject];
+        
+        NSLog(@"optionsoptions====%@=====%@", model.Id, model.options);
+        
+        NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:@{@"product_id":model.Id, @"isPromoItems":@"yes"}];
+        if (model.options.count > 0) {
+            NSMutableDictionary *optionDic = [NSMutableDictionary dictionary];
+            for (OptionsModel *optionM in model.options) {
+                OptionsValuesM *valuesM = optionM.values[0];
+                NSString *tempStr =[NSString stringWithFormat:@"options[%@]",optionM.option_id];
+                optionDic[tempStr] =valuesM.option_type_id;
+            }
+            [param addEntriesFromDictionary:optionDic];
+        }
+//        param = /*@{@"product_id":model.Id, @"isPromoItems":@"1"}*/;
+        [self.addGiftParamArr addObject:param];
+        if (self.giftShowCount < 1 && self.addGiftParamArr.count == 1 && self.addGiftView.hidden) {
+            self.addGiftView.hidden = NO;
+            [self.addGiftView setGiftData:model.add_gooodsImgUrl];
+        }
     }
     }
 }
 }
 - (void)tapcellTriggereventIndex:(NSIndexPath *)index model:(id)model{
 - (void)tapcellTriggereventIndex:(NSIndexPath *)index model:(id)model{
@@ -243,4 +336,23 @@
     return _postBtn;
     return _postBtn;
 }
 }
 
 
+- (ASAddGiftGoodsView *)addGiftView {
+    if (!_addGiftView) {
+        _addGiftView = [[ASAddGiftGoodsView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
+        @weakify(self)
+        _addGiftView.addBlock = ^(int type) {
+            @strongify(self)
+            self.addGiftView.hidden = YES;
+            if (type == 1) {
+                [self requestGiftAddCart];
+            } else {
+                self.giftShowCount ++;
+            }
+        };
+        _addGiftView.hidden = YES;
+        [[UIApplication sharedApplication].keyWindow addSubview:_addGiftView];
+    }
+    return _addGiftView;
+}
+
 @end
 @end

+ 30 - 0
Asteria/Fuction/Cart/Checkout/ASAddGiftGoodsView.h

@@ -0,0 +1,30 @@
+//
+//  ASAddGiftGoodsView.h
+//  Asteria
+//
+//  Created by xingyu on 2024/5/13.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+typedef void(^ASAddGiftAddBlock)(int type);
+
+@interface ASAddGiftData : NSObject
+
+@property (nonatomic, copy) NSString *isShowGift;
+
+@property (nonatomic, strong) NSArray *productsArr;
+
+@end
+
+@interface ASAddGiftGoodsView : UIView
+
+@property (nonatomic, copy) ASAddGiftAddBlock addBlock;
+
+- (void)setGiftData:(NSString *)imageStr;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 106 - 0
Asteria/Fuction/Cart/Checkout/ASAddGiftGoodsView.m

@@ -0,0 +1,106 @@
+//
+//  ASAddGiftGoodsView.m
+//  Asteria
+//
+//  Created by xingyu on 2024/5/13.
+//
+
+#import "ASAddGiftGoodsView.h"
+
+@interface ASAddGiftGoodsView()
+
+@property (nonatomic, strong) UIImageView *goodsImage;
+
+@end
+
+@implementation ASAddGiftGoodsView
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    if (self = [super initWithFrame:frame]) {
+        
+        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
+        
+        UIView *backView = [[UIView alloc] init];
+        backView.backgroundColor = Col_FFF;
+        TT_ViewRadius(backView, 8);
+        [self addSubview:backView];
+        [backView mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.center.equalTo(self);
+            make.width.mas_equalTo(300);
+        }];
+        
+        UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+        [closeBtn setImage:[UIImage imageNamed:@"base_close_black"] forState:UIControlStateNormal];
+        [closeBtn addTarget:self action:@selector(_closeClick) forControlEvents:UIControlEventTouchUpInside];
+        [backView addSubview:closeBtn];
+        [closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.top.mas_equalTo(10);
+            make.right.mas_equalTo(-10);
+            make.width.height.mas_equalTo(36);
+        }];
+        
+        UILabel *topLab = [UILabel labelCreateWithText:@"Congratulations!" font:[UIFont fontWithName:Rob_Bold size:14] textColor:Col_000];
+        [backView addSubview:topLab];
+        [topLab mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.centerX.equalTo(backView);
+            make.top.mas_equalTo(56);
+        }];
+        
+        UILabel *descLab = [UILabel labelCreateWithText:@"You got a free gift" font:[UIFont fontWithName:Rob_Regular size:14] textColor:Col_000];
+        [backView addSubview:descLab];
+        [descLab mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.centerX.equalTo(backView);
+            make.top.mas_equalTo(topLab.mas_bottom).offset(10);
+        }];
+        
+        _goodsImage = [[UIImageView alloc] init];
+        [backView addSubview:_goodsImage];
+        [_goodsImage mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.centerX.equalTo(backView);
+            make.top.mas_equalTo(descLab.mas_bottom).offset(10);
+            make.width.height.mas_equalTo(86);
+        }];
+        
+        UIButton *getBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+        [getBtn setTitle:@"Get" forState:UIControlStateNormal];
+        [getBtn setTitleColor:Col_FFF forState:UIControlStateNormal];
+        getBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
+        getBtn.backgroundColor = Col_000;
+        [getBtn addTarget:self action:@selector(_addCart) forControlEvents:UIControlEventTouchUpInside];
+        TT_ViewRadius(getBtn, 4);
+        [backView addSubview:getBtn];
+        [getBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.left.mas_equalTo(34);
+            make.right.mas_equalTo(-34);
+            make.top.equalTo(_goodsImage.mas_bottom).offset(30);
+            make.height.mas_equalTo(35);
+            make.bottom.mas_equalTo(-30);
+        }];
+        
+    }
+    return self;
+}
+
+- (void)setGiftData:(NSString *)imageStr {
+    
+    NSString *imageAllStr = [NSString stringWithFormat:@"https:%@%@%@",HostPath,ProductImgPath,imageStr];
+    
+    [self.goodsImage sd_setImageWithURL:[NSURL URLWithString:imageAllStr] placeholderImage:UIImageDefaultImg_SD];
+}
+
+- (void)_addCart {
+    
+//    [self removeFromSuperview];
+    
+    if (self.addBlock) {
+        self.addBlock(1);
+    }
+}
+
+- (void)_closeClick {
+    if (self.addBlock) {
+        self.addBlock(0);
+    }
+}
+
+@end

+ 2 - 2
Asteria/Fuction/Cart/Checkout/ASCheckoutGoodsItemCell.m

@@ -154,8 +154,8 @@
     if(itemM.isGift){
     if(itemM.isGift){
         self.bgDesLab.hidden = YES;
         self.bgDesLab.hidden = YES;
     }else{
     }else{
-        self.bgDesLab.hidden = NO;
-        self.bgDesLab.text = [NSString stringWithFormat:@"SAVE %@%.2f",itemM.currency_symbol,[itemM.initial_price floatValue]-[itemM.price floatValue]];
+        self.bgDesLab.hidden = YES;
+//        self.bgDesLab.text = [NSString stringWithFormat:@"SAVE %@%.2f",itemM.currency_symbol,[itemM.initial_price floatValue]-[itemM.price floatValue]];
         self.countV.numLab.text = MM_str(itemM.qty);
         self.countV.numLab.text = MM_str(itemM.qty);
         [self.countV xxx_changeBtnIsEnable:YES num:[self.countV.numLab.text integerValue]];
         [self.countV xxx_changeBtnIsEnable:YES num:[self.countV.numLab.text integerValue]];
     }
     }

+ 3 - 0
Asteria/Fuction/Cart/VM/CartVM.h

@@ -39,6 +39,9 @@
 //下单
 //下单
 #define Chectout_PUT_sureOrder       BaseRequestrUrl(@"carts/mine/order")
 #define Chectout_PUT_sureOrder       BaseRequestrUrl(@"carts/mine/order")
 
 
+//赠品手动加车
+#define Chectout_giftAddCart         BaseRequestrUrl(@"addGiftProduct")
+
 NS_ASSUME_NONNULL_BEGIN
 NS_ASSUME_NONNULL_BEGIN
 
 
 @interface CartVM : RYBaseVM
 @interface CartVM : RYBaseVM