|
@@ -170,7 +170,11 @@
|
|
//首次进入展示购物车数据UI
|
|
//首次进入展示购物车数据UI
|
|
[self updateData];
|
|
[self updateData];
|
|
}
|
|
}
|
|
- } else if ([mark isEqualToString:Cart_cartInfo]) {
|
|
|
|
|
|
+ } else if ([mark isEqualToString:Chectout_addBillingAddress]) {
|
|
|
|
+ if(sucessOrFail){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }else if ([mark isEqualToString:Cart_cartInfo]) {
|
|
if(sucessOrFail){
|
|
if(sucessOrFail){
|
|
// 获取上次下单地址
|
|
// 获取上次下单地址
|
|
NSDictionary *dic = (NSDictionary *)data;
|
|
NSDictionary *dic = (NSDictionary *)data;
|
|
@@ -264,6 +268,9 @@
|
|
} else if ([mark isEqualToString:Goods_productGetProductsById]) {
|
|
} else if ([mark isEqualToString:Goods_productGetProductsById]) {
|
|
//请求赠品详情
|
|
//请求赠品详情
|
|
if(sucessOrFail) {
|
|
if(sucessOrFail) {
|
|
|
|
+ if (!AS_Array_valid(arry)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
GoodsInformationM *model = (GoodsInformationM *)[arry firstObject];
|
|
GoodsInformationM *model = (GoodsInformationM *)[arry firstObject];
|
|
|
|
|
|
NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:@{@"product_id":model.Id, @"isPromoItems":@"yes"}];
|
|
NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:@{@"product_id":model.Id, @"isPromoItems":@"yes"}];
|
|
@@ -277,7 +284,7 @@
|
|
[param addEntriesFromDictionary:optionDic];
|
|
[param addEntriesFromDictionary:optionDic];
|
|
}
|
|
}
|
|
[self.addGiftParamArr addObject:param];
|
|
[self.addGiftParamArr addObject:param];
|
|
- if (self.giftShowCount < 1 && self.addGiftParamArr.count == 1 && self.addGiftView.hidden) {
|
|
|
|
|
|
+ if (self.giftShowCount <= 1 && self.addGiftParamArr.count == 1 && self.addGiftView.hidden) {
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
self.addGiftView.hidden = NO;
|
|
self.addGiftView.hidden = NO;
|
|
@@ -346,6 +353,8 @@
|
|
NSString *entity_id = productDic[@"entity_id"];
|
|
NSString *entity_id = productDic[@"entity_id"];
|
|
[self reqNet_GoodsDetails_productGetProduct:entity_id];
|
|
[self reqNet_GoodsDetails_productGetProduct:entity_id];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ self.giftShowCount++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -411,19 +420,36 @@
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[self.VM ry_requestPostApi:Chectout_addShipAddress_id param:@{@"addressId":self.addressCellM.addressModel.Id}];
|
|
[self.VM ry_requestPostApi:Chectout_addShipAddress_id param:@{@"addressId":self.addressCellM.addressModel.Id}];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+- (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,
|
|
|
|
+ @"street":street,
|
|
|
|
+ @"email":ASUserInfoManager.shared.userInfo.email};
|
|
|
|
+
|
|
|
|
+ return shipping_address;
|
|
|
|
+// @{@"addressInformation":shipping_address}
|
|
|
|
+}
|
|
|
|
+
|
|
//添加账单地址
|
|
//添加账单地址
|
|
- (void)requestAddBillingAddress {
|
|
- (void)requestAddBillingAddress {
|
|
// [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
// [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
|
|
|
- NSDictionary *addressDic1 = (NSDictionary *)[self.addressCellM.addressModel.region mj_JSONObject];
|
|
|
|
- NSDictionary *addressDic = (NSDictionary *)[self.addressCellM.addressModel mj_JSONObject];
|
|
|
|
- NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:addressDic];
|
|
|
|
- [param addEntriesFromDictionary:addressDic1];
|
|
|
|
-
|
|
|
|
- [param removeObjectForKey:@"extension_attributes"];//移除格式不正确的无用参数
|
|
|
|
|
|
+ NSDictionary *addressInformation = [self getAddressParam:self.addressCellM.addressModel];
|
|
|
|
|
|
|
|
+ NSDictionary *params = @{@"address":addressInformation, @"useForShipping":@"true"};
|
|
|
|
|
|
- [self.VM ry_requestPostApi:Chectout_addBillingAddress param:@{@"address":param, @"useForShipping":@"true"}];
|
|
|
|
|
|
+ [self.VM ry_requestPostApi:Chectout_addBillingAddress param:params];
|
|
}
|
|
}
|
|
//根据邮寄地址获取邮寄方式
|
|
//根据邮寄地址获取邮寄方式
|
|
- (void)requestGetShipMethodByAddress {
|
|
- (void)requestGetShipMethodByAddress {
|
|
@@ -433,24 +459,20 @@
|
|
//设置邮寄方式
|
|
//设置邮寄方式
|
|
- (void)requestSetShipMethodByAddress {
|
|
- (void)requestSetShipMethodByAddress {
|
|
|
|
|
|
- NSDictionary *addressDic1 = (NSDictionary *)[self.addressCellM.addressModel.region mj_JSONObject];
|
|
|
|
- NSDictionary *addressDic = (NSDictionary *)[self.addressCellM.addressModel mj_JSONObject];
|
|
|
|
- NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:addressDic];
|
|
|
|
- [param addEntriesFromDictionary:addressDic1];
|
|
|
|
-
|
|
|
|
- [param removeObjectForKey:@"extension_attributes"];//移除格式不正确的无用参数
|
|
|
|
-
|
|
|
|
if (NIL(self.shipmethodCellM.shipMethodModel.method_code) || NIL(self.shipmethodCellM.shipMethodModel.carrier_code)) {
|
|
if (NIL(self.shipmethodCellM.shipMethodModel.method_code) || NIL(self.shipmethodCellM.shipMethodModel.carrier_code)) {
|
|
[self.view makeToast:self.shipmethodCellM.shipMethodModel.error_message];
|
|
[self.view makeToast:self.shipmethodCellM.shipMethodModel.error_message];
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- NSDictionary *params = @{@"shipping_address":param,
|
|
|
|
|
|
+ NSDictionary *shipping_address = [self getAddressParam:self.addressCellM.addressModel];
|
|
|
|
+
|
|
|
|
+ NSDictionary *params = @{@"shipping_address":shipping_address,
|
|
@"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};
|
|
-
|
|
|
|
|
|
+ NSDictionary *finalDic = @{@"addressInformation":params};
|
|
|
|
+ NSLog(@"finalDic=====%@", [finalDic mj_JSONString]);
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
- [self.VM ry_requestPostApi:Chectout_setShipMethod param:@{@"addressInformation":params}];
|
|
|
|
|
|
+ [self.VM ry_requestPostApi:Chectout_setShipMethod param:finalDic];
|
|
}
|
|
}
|
|
//获取购物车信息(地址信息)
|
|
//获取购物车信息(地址信息)
|
|
- (void)requestCartInfo {
|
|
- (void)requestCartInfo {
|
|
@@ -544,7 +566,7 @@
|
|
NSString *msg = [NSString stringWithFormat:@"%@", [payDic objectForKey:@"msg"]];
|
|
NSString *msg = [NSString stringWithFormat:@"%@", [payDic objectForKey:@"msg"]];
|
|
|
|
|
|
if ([msg isEqualToString:@"Payment anomaly"] && [payMethod isEqualToString:@"klarna_kco"]) {
|
|
if ([msg isEqualToString:@"Payment anomaly"] && [payMethod isEqualToString:@"klarna_kco"]) {
|
|
- [self.view makeToast:@"Payment Failed" duration:0.5 position:CSToastPositionCenter];
|
|
|
|
|
|
+ [self.view makeToast:msg duration:0.5 position:CSToastPositionCenter];
|
|
|
|
|
|
K_WEAK_SELF;
|
|
K_WEAK_SELF;
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
@@ -592,7 +614,7 @@
|
|
for (int i = 0; i < self.addGiftParamArr.count; i++) {
|
|
for (int i = 0; i < self.addGiftParamArr.count; i++) {
|
|
NSDictionary *param = self.addGiftParamArr[i];
|
|
NSDictionary *param = self.addGiftParamArr[i];
|
|
self.index ++;
|
|
self.index ++;
|
|
- self.giftShowCount = 2;
|
|
|
|
|
|
+ self.giftShowCount = 1;
|
|
[self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
|
|
[self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
|
|
}
|
|
}
|
|
}
|
|
}
|