// // GenerateOrdersViewController.m // Lighting // // Created by 曹云霄 on 16/5/5. // Copyright © 2016年 上海勾芒科技有限公司. All rights reserved. // #import "GenerateOrdersViewController.h" #import "GenerateOrdersTableViewCell.h" #import "GenerateOrdersModifyTableViewCell.h" #import "PersonInformationTableViewCell.h" #import "CommodityListTableViewCell.h" #import "AllpriceTableViewCell.h" #import "AddaddressViewController.h" #import "AppDelegate.h" #import "OrderdetailsViewController.h" #import "AddressViewController.h" #import "AddressModel.h" @interface GenerateOrdersViewController () /** * 数据源 */ @property (nonatomic,strong) NSMutableArray *datasArray; @property (nonatomic,strong) UIView *Tabbarview; @end @implementation GenerateOrdersViewController /** * 初始化数据源 */ - (NSMutableArray *)datasArray { if (_datasArray == nil) { _datasArray = [NSMutableArray array]; for (int i=0; i<3; i++) { NSMutableArray *arr = [NSMutableArray array]; [_datasArray addObject:arr]; } //加入客户信息model Customermanager *customerModel = [Customermanager manager]; [[_datasArray firstObject] addObject:customerModel]; AddressModel *model = [[AddressModel alloc]init]; model.name = @"地址占位"; //地址占位 [[_datasArray objectAtIndex_opple:1] addObject:model]; //加入商品信息 [_datasArray replaceObjectAtIndex:2 withObject:_settlementGoodsdatas]; } return _datasArray; } #pragma mark -渲染完成 - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.navigationController.fd_fullscreenPopGestureRecognizer.enabled = NO; if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } } #pragma mark -视图即将消失 - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.navigationController.fd_fullscreenPopGestureRecognizer.enabled = YES; if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; } } - (void)viewDidLoad { [super viewDidLoad]; [self uiConfigAction]; [self getAddressDatasRequest]; } #pragma mark -UI - (void)uiConfigAction { self.generateOrderTableview.dataSource = self; self.generateOrderTableview.delegate = self; self.generateOrderTableview.tableFooterView = [UIView new]; self.backShoppingbagsButton.layer.masksToBounds = YES; self.backShoppingbagsButton.layer.cornerRadius = kCornerRadius; self.createOrderButton.layer.masksToBounds = YES; self.createOrderButton.layer.cornerRadius = kCornerRadius; } #pragma mark -获得地址信息 - (void)getAddressDatasRequest { [XBLoadingView showHUDViewWithDefault]; WS(weakSelf); [HTTP networkWithDictionaryRequestWithURL:[NSString stringWithFormat:@"%@%@",SERVERREQUESTURL(SHIPPINGADDRESS),[Customermanager manager].model.fid] withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) { [XBLoadingView hideHUDViewWithDefault]; if (RESULT(returnValue)) { RsShippingAddrEntity *address = [[RsShippingAddrEntity alloc]initWithDictionary:RESPONSE(returnValue) error:nil]; for (NSInteger i=address.list.count-1; i>=0; i--) { TOShippingAddrEntity *model = [address.list objectAtIndex_opple:i]; //自定义model AddressModel *newmodel = [[AddressModel alloc]initWithDictionary:[model toDictionary] error:nil]; [[weakSelf.datasArray objectAtIndex_opple:1]insertObject:newmodel atIndex:0]; } //地址数组 NSArray *addressArray = [weakSelf.datasArray objectAtIndex_opple:1]; //增加cell NSMutableArray *addCellArray = [NSMutableArray array]; for (int i=0; i *)goodidArr; order.order.isSuccessSend = NO; order.order.province = [Customermanager manager].model.province; order.order.city = [Customermanager manager].model.city; order.order.country = [Customermanager manager].model.country; order.order.storeNumber = [Shoppersmanager manager].shoppers.storeCode; [XBLoadingView showHUDViewWithDefault]; WS(weakSelf); [HTTP networkRequestWithURL:SERVERREQUESTURL(CREATEORDER) withRequestType:ZERO withParameter:order withReturnValueBlock:^(id returnValue) { [XBLoadingView hideHUDViewWithDefault]; if (RESULT(returnValue)) { //商品购物车id NSMutableArray *codeArrray = [NSMutableArray array]; for (ShopcarModel *model in _settlementGoodsdatas) { [codeArrray addObject:model.fid?model.fid:@" "]; } //调用删除购物车 if (weakSelf.DelecteSelectedGoods) { weakSelf.DelecteSelectedGoods(codeArrray); } OrderdetailsViewController *orderDetails = [[[weakSelf class] getMainStoryboardClass] instantiateViewControllerWithIdentifier:@"orderdetails"]; orderDetails.orderCode = RESPONSE(returnValue); orderDetails.isShowPayButton = YES; orderDetails.isUserInteractionEnabled = YES; orderDetails.isShowHeaderView = YES; orderDetails.isSliding = YES;//取消滑动返回 [weakSelf.navigationController pushViewController:orderDetails animated:YES]; }else { [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)]; } }withFailureBlock:^(NSError *error) { [XBLoadingView hideHUDViewWithDefault]; [XBLoadingView showHUDViewWithText:error.localizedDescription]; }]; return; } else if (i == Adressarr.count -1) { [XBLoadingView showHUDViewWithText:@"未选中地址"]; } } } } #pragma mark -返回购物车 - (IBAction)BackShoppingBagsButtonClick:(UIButton *)sender { [self.navigationController popViewControllerAnimated:YES]; } #pragma mark -设置为当前地址回调 - (void)SetCustomerButtonClick:(NSInteger)index; { for (UITableViewCell *cell in self.generateOrderTableview.visibleCells) { if ([cell isKindOfClass:[GenerateOrdersTableViewCell class]]) { GenerateOrdersTableViewCell *Newcell = (GenerateOrdersTableViewCell *)cell; Newcell.isSelectedButton.selected = NO; } } for (id objc in [self.datasArray objectAtIndex_opple:1]) { if ([objc isKindOfClass:[AddressModel class]]) { AddressModel *model = (AddressModel *)objc; model.isSelected = NO; } } AddressModel *model = [[self.datasArray objectAtIndex_opple:1] objectAtIndex_opple:index]; model.isSelected = YES; } #pragma mark -修改地址 - (void)ChangeButtonClick { NSArray *arr = [self.datasArray objectAtIndex_opple:1]; for (int i=0; i