|
@@ -29,6 +29,7 @@
|
|
|
|
|
|
@property (nonatomic, strong) ASCheckoutPointData *pointCellM;
|
|
@property (nonatomic, strong) ASCheckoutPointData *pointCellM;
|
|
@property (nonatomic, strong) ASCheckoutAddressData *addressCellM;
|
|
@property (nonatomic, strong) ASCheckoutAddressData *addressCellM;
|
|
|
|
+@property (nonatomic, strong) ASCheckoutShipMethodData *shipmethodCellM;
|
|
@property (nonatomic, strong) ASCheckoutCommentData *commentCellM;
|
|
@property (nonatomic, strong) ASCheckoutCommentData *commentCellM;
|
|
|
|
|
|
//存放支付方式
|
|
//存放支付方式
|
|
@@ -96,6 +97,20 @@
|
|
if(num ==0){ //使用积分
|
|
if(num ==0){ //使用积分
|
|
self.commentCellM.commentStr = commentData.commentStr;
|
|
self.commentCellM.commentStr = commentData.commentStr;
|
|
}
|
|
}
|
|
|
|
+ } else if ([data isKindOfClass:[ASCheckoutShipMethodData class]]) {
|
|
|
|
+ //选择运输方式、、、、并设置
|
|
|
|
+ ASCheckoutShipMethodData *shipMethodData = (ASCheckoutShipMethodData *)data;
|
|
|
|
+ self.shipmethodCellM = shipMethodData;
|
|
|
|
+ for (int i = 0; i < self.shipmethodCellM.shipMethodArray.count; i++) {
|
|
|
|
+ ASCheckoutShipMethodModel *shipModel = [self.shipmethodCellM.shipMethodArray objectAtIndex:i];
|
|
|
|
+ if (i == num) {
|
|
|
|
+ shipModel.isSelect = YES;
|
|
|
|
+ self.shipmethodCellM.shipMethodModel = shipModel;
|
|
|
|
+ } else {
|
|
|
|
+ shipModel.isSelect = NO;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ [self requestSetShipMethodByAddress];
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -136,14 +151,16 @@
|
|
NSDictionary *shippingDic = [shipping_assignments objectForKey:@"shipping"];
|
|
NSDictionary *shippingDic = [shipping_assignments objectForKey:@"shipping"];
|
|
NSDictionary *addressDic = [shippingDic objectForKey:@"address"];
|
|
NSDictionary *addressDic = [shippingDic objectForKey:@"address"];
|
|
// ASAddressModel *addressModel = [ASAddressModel defualtData];
|
|
// ASAddressModel *addressModel = [ASAddressModel defualtData];
|
|
|
|
+ ASAddressReginModel *reginModel = [ASAddressReginModel mj_objectWithKeyValues:addressDic];
|
|
ASAddressModel *addressModel = [ASAddressModel mj_objectWithKeyValues:addressDic];
|
|
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"];
|
|
|
|
|
|
+ addressModel.region = reginModel;
|
|
|
|
+ if (!NIL(addressModel.postcode)) {
|
|
|
|
+ self.addressCellM.addressModel = addressModel;
|
|
|
|
+
|
|
|
|
+ if (self.shipmethodCellM.shipMethodModel) {
|
|
|
|
+ //默认设置第一个运输方式
|
|
|
|
+ [self requestSetShipMethodByAddress];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//首次进入展示购物车数据UI
|
|
//首次进入展示购物车数据UI
|
|
@@ -155,10 +172,18 @@
|
|
if(sucessOrFail){
|
|
if(sucessOrFail){
|
|
NSArray *shipMethodArr = (NSArray *)data;
|
|
NSArray *shipMethodArr = (NSArray *)data;
|
|
if (shipMethodArr.count > 0) {
|
|
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.shipmethodCellM.shipMethodArray = [ASCheckoutShipMethodModel mj_objectArrayWithKeyValuesArray:shipMethodArr];
|
|
|
|
+ ASCheckoutShipMethodModel *firstModel = self.shipmethodCellM.shipMethodArray[0];
|
|
|
|
+ firstModel.isSelect = YES;
|
|
|
|
+
|
|
|
|
+ self.shipmethodCellM.shipMethodModel = firstModel;
|
|
|
|
+ self.shipmethodCellM.shipmethodSymbol = self.totalsM.currency_symbol;
|
|
|
|
+
|
|
|
|
+ //默认设置第一个运输方式
|
|
|
|
+ [self requestSetShipMethodByAddress];
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
[self reqNet_Cart_cartsMineTotals];
|
|
[self reqNet_Cart_cartsMineTotals];
|
|
}
|
|
}
|
|
@@ -167,11 +192,20 @@
|
|
|
|
|
|
if(sucessOrFail){
|
|
if(sucessOrFail){
|
|
NSArray *shipMethodArr = (NSArray *)data;
|
|
NSArray *shipMethodArr = (NSArray *)data;
|
|
|
|
+
|
|
|
|
+
|
|
if (shipMethodArr.count > 0) {
|
|
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.shipmethodCellM.shipMethodArray = [ASCheckoutShipMethodModel mj_objectArrayWithKeyValuesArray:shipMethodArr];
|
|
|
|
+ ASCheckoutShipMethodModel *firstModel = self.shipmethodCellM.shipMethodArray[0];
|
|
|
|
+ firstModel.isSelect = YES;
|
|
|
|
+ self.shipmethodCellM.shipMethodModel = firstModel;
|
|
|
|
+
|
|
|
|
+ self.shipmethodCellM.shipmethodSymbol = self.totalsM.currency_symbol;
|
|
|
|
+
|
|
|
|
+ if (self.addressCellM.addressModel) {
|
|
|
|
+ //默认设置第一个运输方式
|
|
|
|
+ [self requestSetShipMethodByAddress];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
[self updateData];
|
|
[self updateData];
|
|
@@ -180,7 +214,8 @@
|
|
|| [mark isEqualToString:DEL_cartsMineItems]
|
|
|| [mark isEqualToString:DEL_cartsMineItems]
|
|
|| [mark isEqualToString:PUT_cartsMineCoupons]
|
|
|| [mark isEqualToString:PUT_cartsMineCoupons]
|
|
|| [mark isEqualToString:Chectout_PUT_usePoints]
|
|
|| [mark isEqualToString:Chectout_PUT_usePoints]
|
|
- || [mark isEqualToString:Chectout_DEL_cancelusePoints]){
|
|
|
|
|
|
+ || [mark isEqualToString:Chectout_DEL_cancelusePoints]
|
|
|
|
+ || [mark isEqualToString:Chectout_setShipMethod]){
|
|
if(sucessOrFail){
|
|
if(sucessOrFail){
|
|
[self reqNet_Cart_cartsMineTotals];
|
|
[self reqNet_Cart_cartsMineTotals];
|
|
}else{
|
|
}else{
|
|
@@ -197,7 +232,12 @@
|
|
self.TableV.infodata = [NSMutableArray arrayWithArray:self.totalsM.items];
|
|
self.TableV.infodata = [NSMutableArray arrayWithArray:self.totalsM.items];
|
|
|
|
|
|
//邮寄地址--邮寄方式
|
|
//邮寄地址--邮寄方式
|
|
- [self.TableV.infodata addObject:self.addressCellM];
|
|
|
|
|
|
+ if (self.addressCellM.addressModel) {
|
|
|
|
+ [self.TableV.infodata addObject:self.addressCellM];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //运输方式
|
|
|
|
+ [self.TableV.infodata addObject:self.shipmethodCellM];
|
|
|
|
|
|
//优惠券
|
|
//优惠券
|
|
self.couponCellM.couponAry =[NSMutableArray arrayWithArray: [ASNetTools shared].xxx_couponAry];
|
|
self.couponCellM.couponAry =[NSMutableArray arrayWithArray: [ASNetTools shared].xxx_couponAry];
|
|
@@ -267,14 +307,15 @@
|
|
|
|
|
|
[self.TableV reloadData];
|
|
[self.TableV reloadData];
|
|
} else if ([model isKindOfClass:[ASCheckoutAddressData class]]) {
|
|
} else if ([model isKindOfClass:[ASCheckoutAddressData class]]) {
|
|
|
|
+
|
|
ASAddressListViewController *vc = [ASAddressListViewController new];
|
|
ASAddressListViewController *vc = [ASAddressListViewController new];
|
|
vc.isSelMode = true;
|
|
vc.isSelMode = true;
|
|
- vc.sel_Id = self.addressCellM.addressId;
|
|
|
|
|
|
+ vc.sel_Id = self.addressCellM.addressModel.Id;
|
|
@weakify(self)
|
|
@weakify(self)
|
|
vc.selectAddressBlock = ^(ASAddressModel * _Nonnull addressM) {
|
|
vc.selectAddressBlock = ^(ASAddressModel * _Nonnull addressM) {
|
|
@strongify(self)
|
|
@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.addressCellM.addressModel = addressM;
|
|
|
|
|
|
[self requestAddShipAddress];
|
|
[self requestAddShipAddress];
|
|
};
|
|
};
|
|
@@ -290,12 +331,30 @@
|
|
//添加邮寄地址
|
|
//添加邮寄地址
|
|
- (void)requestAddShipAddress {
|
|
- (void)requestAddShipAddress {
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
- [self.VM ry_requestPostApi:Chectout_addShipAddress_id param:@{@"addressId":self.addressCellM.addressId}];
|
|
|
|
|
|
+ [self.VM ry_requestPostApi:Chectout_addShipAddress_id param:@{@"addressId":self.addressCellM.addressModel.Id}];
|
|
}
|
|
}
|
|
//根据邮寄地址获取邮寄方式
|
|
//根据邮寄地址获取邮寄方式
|
|
- (void)requestGetShipMethodByAddress {
|
|
- (void)requestGetShipMethodByAddress {
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[self.VM ry_requestGetApi:Chectout_getShipMethod param:@{}];
|
|
[self.VM ry_requestGetApi:Chectout_getShipMethod param:@{}];
|
|
}
|
|
}
|
|
|
|
+//设置邮寄方式
|
|
|
|
+- (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"];//移除格式不正确的无用参数
|
|
|
|
+
|
|
|
|
+ NSDictionary *params = @{@"shipping_address":param,
|
|
|
|
+ @"shipping_method_code":self.shipmethodCellM.shipMethodModel.method_code,
|
|
|
|
+ @"shipping_carrier_code":self.shipmethodCellM.shipMethodModel.carrier_code};
|
|
|
|
+
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
|
+ [self.VM ry_requestPostApi:Chectout_setShipMethod param:@{@"addressInformation":params}];
|
|
|
|
+}
|
|
//获取购物车信息(地址信息)
|
|
//获取购物车信息(地址信息)
|
|
- (void)requestCartInfo {
|
|
- (void)requestCartInfo {
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
@@ -343,6 +402,21 @@
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
[self.VM ry_requestDeleteApi:Chectout_DEL_cancelusePoints paramStr:@""];
|
|
[self.VM ry_requestDeleteApi:Chectout_DEL_cancelusePoints paramStr:@""];
|
|
}
|
|
}
|
|
|
|
+//下单
|
|
|
|
+-(void)requestSureOrder{
|
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
|
|
|
+ NSDictionary *param = @{@"method":self.paymentModel.code};
|
|
|
|
+
|
|
|
|
+ [ASNetTools.shared putWithPath:Chectout_PUT_sureOrder param:@{@"paymentMethod":param} success:^(id _Nonnull json) {
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
|
+ NSLog(@"=======%@", json);
|
|
|
|
+
|
|
|
|
+ } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
|
|
+ [MBProgressHUD hideHUDForView:self.view animated:YES];
|
|
|
|
+ NSLog(@"=======%@=====%@", code, msg);
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
|
|
#pragma mark --- 懒加载 ---
|
|
#pragma mark --- 懒加载 ---
|
|
- (void)ucm_bindvmmodel{
|
|
- (void)ucm_bindvmmodel{
|
|
@@ -372,10 +446,16 @@
|
|
- (ASCheckoutAddressData *)addressCellM {
|
|
- (ASCheckoutAddressData *)addressCellM {
|
|
if (!_addressCellM) {
|
|
if (!_addressCellM) {
|
|
_addressCellM = [[ASCheckoutAddressData alloc] init];
|
|
_addressCellM = [[ASCheckoutAddressData alloc] init];
|
|
- _addressCellM.addressInfoStr = @"";
|
|
|
|
}
|
|
}
|
|
return _addressCellM;
|
|
return _addressCellM;
|
|
}
|
|
}
|
|
|
|
+- (ASCheckoutShipMethodData *)shipmethodCellM {
|
|
|
|
+ if (!_shipmethodCellM) {
|
|
|
|
+ _shipmethodCellM = [[ASCheckoutShipMethodData alloc] init];
|
|
|
|
+ }
|
|
|
|
+ return _shipmethodCellM;
|
|
|
|
+}
|
|
|
|
+
|
|
- (ASCheckoutCommentData *)commentCellM {
|
|
- (ASCheckoutCommentData *)commentCellM {
|
|
if (!_commentCellM) {
|
|
if (!_commentCellM) {
|
|
_commentCellM = [[ASCheckoutCommentData alloc] init];
|
|
_commentCellM = [[ASCheckoutCommentData alloc] init];
|
|
@@ -404,7 +484,8 @@
|
|
@weakify(self)
|
|
@weakify(self)
|
|
_bottomView.bottomBlock = ^{
|
|
_bottomView.bottomBlock = ^{
|
|
@strongify(self)
|
|
@strongify(self)
|
|
- [self.view makeToast:@"调起支付"];
|
|
|
|
|
|
+// [self.view makeToast:@"调起支付"];
|
|
|
|
+ [self requestSureOrder];
|
|
};
|
|
};
|
|
}
|
|
}
|
|
return _bottomView;
|
|
return _bottomView;
|