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