|
@@ -6,11 +6,13 @@
|
|
|
//
|
|
|
|
|
|
#import "Cart_CheckoutC.h"
|
|
|
+#import "ASAddressListViewController.h"
|
|
|
+
|
|
|
+#import "ASCheckoutTopView.h"
|
|
|
#import "CartCheckTableV.h"
|
|
|
|
|
|
#import "CartVM.h"
|
|
|
-
|
|
|
-#import "ASCheckoutTopView.h"
|
|
|
+#import "ASUserModel.h"
|
|
|
|
|
|
@interface Cart_CheckoutC ()<RY_baseVMprotocol>
|
|
|
|
|
@@ -23,6 +25,8 @@
|
|
|
@property (nonatomic, strong) MyCartGrandTotalCellData *totalCellM;
|
|
|
|
|
|
@property (nonatomic, strong) ASCheckoutPointData *pointCellM;
|
|
|
+@property (nonatomic, strong) ASCheckoutAddressData *addressCellM;
|
|
|
+
|
|
|
|
|
|
//存放支付方式
|
|
|
@property (nonatomic, strong) NSArray *paymentArray;
|
|
@@ -39,6 +43,10 @@
|
|
|
|
|
|
//获取支付方式
|
|
|
[self requestPaymentMode];
|
|
|
+ //获取运输方式
|
|
|
+ [self requestGetShipMethodByAddress];
|
|
|
+ //获取购物车信息(地址信息)
|
|
|
+ [self requestCartInfo];
|
|
|
}
|
|
|
|
|
|
- (void)initSubviews {
|
|
@@ -95,14 +103,63 @@
|
|
|
[self updateData];
|
|
|
}
|
|
|
} else if ([mark isEqualToString:Chectout_getPaymentMode]) {
|
|
|
-
|
|
|
if(sucessOrFail){
|
|
|
-
|
|
|
// 更新支付方式
|
|
|
self.paymentArray = arry;
|
|
|
//首次进入展示购物车数据UI
|
|
|
[self updateData];
|
|
|
}
|
|
|
+ } else if ([mark isEqualToString:Cart_cartInfo]) {
|
|
|
+ if(sucessOrFail){
|
|
|
+ // 获取上次下单地址
|
|
|
+ NSDictionary *dic = (NSDictionary *)data;
|
|
|
+ NSArray *array = [[dic objectForKey:@"extension_attributes"] objectForKey:@"shipping_assignments"];
|
|
|
+
|
|
|
+ if (array.count > 0) {
|
|
|
+ NSDictionary *shipping_assignments = array[0];
|
|
|
+ NSDictionary *shippingDic = [shipping_assignments objectForKey:@"shipping"];
|
|
|
+ NSDictionary *addressDic = [shippingDic objectForKey:@"address"];
|
|
|
+// ASAddressModel *addressModel = [ASAddressModel defualtData];
|
|
|
+ ASAddressModel *addressModel = [ASAddressModel mj_objectWithKeyValues:addressDic];
|
|
|
+ if (NIL(addressModel.postcode)) {
|
|
|
+ self.addressCellM.addressInfoStr = @"";
|
|
|
+ self.addressCellM.shipmethodStr = @"";
|
|
|
+ } else {
|
|
|
+ self.addressCellM.addressInfoStr = [NSString stringWithFormat:@"%@ %@ %@ %@,%@ tel:%@", addressModel.firstname, addressModel.lastname, [addressModel.street componentsJoinedByString:@" "], addressModel.city, addressModel.postcode, addressModel.telephone];
|
|
|
+ self.addressCellM.shipmethodStr = [shippingDic objectForKey:@"method"];
|
|
|
+ self.addressCellM.addressId = [addressDic objectForKey:@"customer_address_id"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //首次进入展示购物车数据UI
|
|
|
+ [self updateData];
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if ([mark isEqualToString:Chectout_addShipAddress_id]) {
|
|
|
+
|
|
|
+ if(sucessOrFail){
|
|
|
+ NSArray *shipMethodArr = (NSArray *)data;
|
|
|
+ if (shipMethodArr.count > 0) {
|
|
|
+ NSDictionary *shipMethodDic = shipMethodArr[0];
|
|
|
+ self.addressCellM.shipmethodStr = [NSString stringWithFormat:@"%@ %@", shipMethodDic[@"method_title"], shipMethodDic[@"carrier_title"]];
|
|
|
+ self.addressCellM.shipmethodPrice = shipMethodDic[@"amount"];
|
|
|
+ self.addressCellM.shipmethodSymbol = self.totalsM.currency_symbol;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ [self updateData];
|
|
|
+
|
|
|
+ } else if ([mark isEqualToString:Chectout_getShipMethod]) {
|
|
|
+
|
|
|
+ if(sucessOrFail){
|
|
|
+ NSArray *shipMethodArr = (NSArray *)data;
|
|
|
+ if (shipMethodArr.count > 0) {
|
|
|
+ NSDictionary *shipMethodDic = shipMethodArr[0];
|
|
|
+ self.addressCellM.shipmethodStr = [NSString stringWithFormat:@"%@ %@", shipMethodDic[@"method_title"], shipMethodDic[@"carrier_title"]];
|
|
|
+ self.addressCellM.shipmethodPrice = shipMethodDic[@"amount"];
|
|
|
+ self.addressCellM.shipmethodSymbol = self.totalsM.currency_symbol;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [self updateData];
|
|
|
|
|
|
} else if ([mark isEqualToString:Cart_cartsMineItems_Post]
|
|
|
|| [mark isEqualToString:DEL_cartsMineItems]
|
|
@@ -136,6 +193,11 @@
|
|
|
self.pointCellM.pointBalance = @"10";
|
|
|
[self.TableV.infodata addObject:self.pointCellM];
|
|
|
|
|
|
+ //邮寄地址--邮寄方式
|
|
|
+ [self.TableV.infodata addObject:self.addressCellM];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// MyCartPayTypeCellData *data = [[MyCartPayTypeCellData alloc]init];
|
|
|
// data.final_prices_f = [self.totalsM.subtotal floatValue];
|
|
|
// data.currency_symbol = self.totalsM.currency_symbol;
|
|
@@ -177,6 +239,19 @@
|
|
|
}
|
|
|
|
|
|
[self.TableV reloadData];
|
|
|
+ } else if ([model isKindOfClass:[ASCheckoutAddressData class]]) {
|
|
|
+ ASAddressListViewController *vc = [ASAddressListViewController new];
|
|
|
+ vc.isSelMode = true;
|
|
|
+ vc.sel_Id = self.addressCellM.addressId;
|
|
|
+ @weakify(self)
|
|
|
+ vc.selectAddressBlock = ^(ASAddressModel * _Nonnull addressM) {
|
|
|
+ @strongify(self)
|
|
|
+ self.addressCellM.addressInfoStr = [NSString stringWithFormat:@"%@ %@ %@ %@,%@ tel:%@", addressM.firstname, addressM.lastname, [addressM.street componentsJoinedByString:@" "], addressM.city, addressM.postcode, addressM.telephone];
|
|
|
+ self.addressCellM.addressId = addressM.Id;
|
|
|
+
|
|
|
+ [self requestAddShipAddress];
|
|
|
+ };
|
|
|
+ [self.navigationController pushViewController:vc animated:true];
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -185,7 +260,21 @@
|
|
|
- (void)requestPaymentMode {
|
|
|
[self.VM ry_requestGetApi:Chectout_getPaymentMode param:@{}];
|
|
|
}
|
|
|
-///获取购物车
|
|
|
+//添加邮寄地址
|
|
|
+- (void)requestAddShipAddress {
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
+ [self.VM ry_requestPostApi:Chectout_addShipAddress_id param:@{@"addressId":self.addressCellM.addressId}];
|
|
|
+}
|
|
|
+//根据邮寄地址获取邮寄方式
|
|
|
+- (void)requestGetShipMethodByAddress {
|
|
|
+ [self.VM ry_requestGetApi:Chectout_getShipMethod param:@{}];
|
|
|
+}
|
|
|
+//获取购物车信息(地址信息)
|
|
|
+- (void)requestCartInfo {
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
+ [self.VM ry_requestGetApi:Cart_cartInfo param:@{}];
|
|
|
+}
|
|
|
+///获取购物车信息(报价整合)
|
|
|
-(void)reqNet_Cart_cartsMineTotals{
|
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
[self.VM ry_requestGetApi:Cart_cartsMineTotals param:@{}];
|
|
@@ -243,6 +332,14 @@
|
|
|
}
|
|
|
return _pointCellM;
|
|
|
}
|
|
|
+- (ASCheckoutAddressData *)addressCellM {
|
|
|
+ if (!_addressCellM) {
|
|
|
+ _addressCellM = [[ASCheckoutAddressData alloc] init];
|
|
|
+ _addressCellM.addressInfoStr = @"";
|
|
|
+ }
|
|
|
+ return _addressCellM;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- (ASCheckoutTopView *)topView {
|
|
|
if (!_topView) {
|