GenerateOrdersViewController.m 20.3 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
//
//  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 ()<UITableViewDelegate,UITableViewDataSource,delecteDelegate>


/**
 *  数据源
 */
@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 = @"地址占位";
        //地址占位
曹云霄's avatar
曹云霄 committed
53
        [[_datasArray objectAtIndex_opple:1] addObject:model];
曹云霄's avatar
曹云霄 committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
        //加入商品信息
        [_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);
108
    [HTTP networkWithDictionaryRequestWithURL:[NSString stringWithFormat:@"%@%@",SERVERREQUESTURL(SHIPPINGADDRESS),[Customermanager manager].model.consumer.fid]  withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
曹云霄's avatar
曹云霄 committed
109 110 111 112 113
        
        [XBLoadingView hideHUDViewWithDefault];
        if (RESULT(returnValue)) {
            RsShippingAddrEntity *address = [[RsShippingAddrEntity alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
            for (NSInteger i=address.list.count-1; i>=0; i--) {
曹云霄's avatar
曹云霄 committed
114
                TOShippingAddrEntity *model = [address.list objectAtIndex_opple:i];
曹云霄's avatar
曹云霄 committed
115 116
                //自定义model
                AddressModel *newmodel = [[AddressModel alloc]initWithDictionary:[model toDictionary] error:nil];
曹云霄's avatar
曹云霄 committed
117
                [[weakSelf.datasArray objectAtIndex_opple:1]insertObject:newmodel atIndex:0];
曹云霄's avatar
曹云霄 committed
118 119
            }
            //地址数组
曹云霄's avatar
曹云霄 committed
120
            NSArray *addressArray = [weakSelf.datasArray objectAtIndex_opple:1];
曹云霄's avatar
曹云霄 committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
            //增加cell
            NSMutableArray *addCellArray = [NSMutableArray array];
            for (int i=0; i<addressArray.count-1; i++) {
                NSIndexPath *indexpath = [NSIndexPath indexPathForRow:i inSection:1];
                [addCellArray addObject:indexpath];
            }
            [weakSelf.generateOrderTableview insertRowsAtIndexPaths:addCellArray withRowAnimation:UITableViewRowAnimationBottom];
        }
        else
        {
            [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
        }
    }withFailureBlock:^(NSError *error) {
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
    }];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0 && indexPath.row == 0) {
        PersonInformationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"secondcell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    else if (indexPath.section == 1)
    {
曹云霄's avatar
曹云霄 committed
148
        NSArray *Addressarr = [self.datasArray objectAtIndex_opple:indexPath.section];
曹云霄's avatar
曹云霄 committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
        if (indexPath.row == Addressarr.count-1) {
            
            GenerateOrdersModifyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Modifycell" forIndexPath:indexPath];
            //增加地址或者修改
            [cell.addAddressButton addTarget:self action:@selector(AddAddressButtonClick) forControlEvents:UIControlEventTouchUpInside];
            [cell.changeButton addTarget:self action:@selector(ChangeButtonClick) forControlEvents:UIControlEventTouchUpInside];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.backgroundColor = RGB(242, 242, 242,1);
            return cell;
        }
        GenerateOrdersTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"consigneecell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = RGB(242, 242, 242,1);
        cell.indexNumber = indexPath.row;
        //回调
        __weak typeof(self) weakSelf = self;
        [cell setBlockSeletced:^(NSInteger index) {
            
            [weakSelf SetCustomerButtonClick:index];
        }];
曹云霄's avatar
曹云霄 committed
169
        cell.NewModel = [self.datasArray objectAtIndex_opple:indexPath.section][indexPath.row];
曹云霄's avatar
曹云霄 committed
170 171
        return cell;
    }
曹云霄's avatar
曹云霄 committed
172
    NSArray *Addressarr = [self.datasArray objectAtIndex_opple:indexPath.section];
曹云霄's avatar
曹云霄 committed
173 174 175 176
    if (indexPath.row == Addressarr.count-1) {
        
        AllpriceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"sixthcell" forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
曹云霄's avatar
曹云霄 committed
177
        cell.goodsAllprice = [self.datasArray objectAtIndex_opple:indexPath.section];
曹云霄's avatar
曹云霄 committed
178 179 180 181
        return cell;
    }
    CommodityListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"fourthcell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
曹云霄's avatar
曹云霄 committed
182
    cell.model = [self.datasArray objectAtIndex_opple:indexPath.section][indexPath.row];
曹云霄's avatar
曹云霄 committed
183 184 185 186 187 188
    return cell;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
曹云霄's avatar
曹云霄 committed
189
    NSArray *arr = [self.datasArray objectAtIndex_opple:section];
曹云霄's avatar
曹云霄 committed
190 191 192 193 194 195 196 197 198 199 200 201 202 203
    return arr.count;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.section) {
        case 0:
        {
            return 110;
        }
            break;
        case 1:
        {
曹云霄's avatar
曹云霄 committed
204
            NSArray *arr = [self.datasArray objectAtIndex_opple:indexPath.section];
曹云霄's avatar
曹云霄 committed
205 206 207 208 209 210 211 212 213
            if (indexPath.row == arr.count-1) {
                
                return 70;
            }
            return 56;
        }
            break;
        case 2:
        {
曹云霄's avatar
曹云霄 committed
214
            NSArray *arr = [self.datasArray objectAtIndex_opple:indexPath.section];
曹云霄's avatar
曹云霄 committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
            if (indexPath.row == arr.count-1) {
                
                return 50;
            }
            return 80;
        }
            break;
            
        default:
            break;
    }
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    switch (section) {
        case 0:
        {
            return 0;
        }
            break;
        case 1:
        {
            return 5;
        }
            break;
        case 2:
        {
            return 44;
        }
            break;
            
        default:
            break;
    }
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    switch (section) {
        case 1:
        {
            UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 5)];
            imageView.image = TCImage(@"lineNew");
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
            [view addSubview:imageView];
            return view;
        }
            break;
        case 2:
        {
            UILabel *titleLabe = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, 100, 44)];
            titleLabe.text = @"购物袋清单";
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
            [view addSubview:titleLabe];
            
            //横线
            UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 43, ScreenWidth, 1)];
            lineView.backgroundColor = RGB(242, 242, 242,1);
            [view addSubview:lineView];
            return view;
        }
            break;
            
        default:
            break;
    }
    return nil;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.datasArray.count;
}

#pragma mark -新增或者修改收货地址
- (void)CreateModifyShippingView:(AddressModel *)model Withindex:(NSInteger)cellindex
{
    AddressViewController *address = [[AddressViewController alloc]init];
    address.delegate = self;
    if (model != nil) {
        address.model = model;
        address.isChange = YES;
    }
    address.cellindex = cellindex;
    address.preferredContentSize = CGSizeMake(350, 350);
    address.modalPresentationStyle = UIModalPresentationFormSheet;
    UIPopoverPresentationController *pop = address.popoverPresentationController;
    pop.permittedArrowDirections = UIPopoverArrowDirectionAny;
    pop.sourceView = address.view;
    [self presentViewController:address animated:YES completion:nil];
}

#pragma mark -生成订单
- (IBAction)CreateOrderButtonClick:(UIButton *)sender {
    
    OrderBill *order = [[OrderBill alloc]init];
    //分页
    DataPage *page = [[DataPage alloc]init];
    page.page = ONE;
    order.datapage = page;
    //收货地址
    TOOrderEntity *orderReceiver = [[TOOrderEntity alloc]init];
曹云霄's avatar
曹云霄 committed
320
    NSArray *Adressarr = [self.datasArray objectAtIndex_opple:1];
曹云霄's avatar
曹云霄 committed
321 322 323 324 325
    //总价格
    CGFloat allPrice = ZERO;
    //总数量
    NSInteger allNumber = ZERO;
    for (int i=0; i<Adressarr.count; i++) {
曹云霄's avatar
曹云霄 committed
326 327
        if ([[Adressarr objectAtIndex_opple:i] isKindOfClass:[AddressModel class]]) {
            AddressModel *model = [Adressarr objectAtIndex_opple:i];
曹云霄's avatar
曹云霄 committed
328 329 330
            if (model.isSelected) {
                //收货人信息
                orderReceiver.receiverName = model.name;
331
                orderReceiver.orderTime = [[NSDate date] httpParameterString];
曹云霄's avatar
曹云霄 committed
332 333 334 335
                orderReceiver.receiverMobile = model.miblephone;
                orderReceiver.receiverAddress = model.address;
                order.order = orderReceiver;
                orderReceiver.guideId = [[Shoppersmanager manager] shoppers].employee.fid;
336
                orderReceiver.consumerId = [Customermanager manager].model.consumer.fid;
曹云霄's avatar
曹云霄 committed
337 338 339 340 341
                orderReceiver.orderState = @"001";
                //商品ID
                NSArray *goodArray = [self.datasArray lastObject];
                NSMutableArray *goodidArr = [NSMutableArray array];
                for (int i=0; i<goodArray.count-1; i++) {
曹云霄's avatar
曹云霄 committed
342
                    ShopcarModel *model = [goodArray objectAtIndex_opple:i];
曹云霄's avatar
曹云霄 committed
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
                    TOOrderdetailEntity *orderGoods = [[TOOrderdetailEntity alloc]init];
                    orderGoods.goodsId = model.goodsId;
                    orderGoods.goodsCover = model.goods.pictures;
                    orderGoods.goodsCode = model.goods.code;
                    orderGoods.goodsSpec = model.goods.spec;
                    orderGoods.goodsName = model.goods.name;
                    orderGoods.goodsBrand = model.goods.brandId;
                    orderGoods.goodsNum = [NSString stringWithFormat:@"%ld",(long)model.goodsNum];
                    orderGoods.goodsPrice = model.costPrice;
                    orderGoods.remark = model.goods.spec;
                    orderGoods.goodsUnit = model.goods.unit;
                    //总价
                    allPrice += model.goodsNum *[model.costPrice floatValue];
                    //总数量
                    allNumber += model.goodsNum;
                    orderGoods.goodsTotalPrice = [NSNumber numberWithFloat:model.goodsNum *[model.costPrice floatValue]];
                    [goodidArr addObject:orderGoods];
                }
                //总价
                orderReceiver.orderPrice = [NSNumber numberWithFloat:allPrice];
                orderReceiver.oldPrice = [NSNumber numberWithFloat:allPrice];
                //总数量
                orderReceiver.goodsNum = [NSString stringWithFormat:@"%ld",allNumber];
                order.orderdetailList = (NSArray<TOOrderdetailEntity> *)goodidArr;
                order.order.isSuccessSend = NO;
368 369 370
                order.order.province = [Customermanager manager].model.consumer.province;
                order.order.city = [Customermanager manager].model.consumer.city;
                order.order.country = [Customermanager manager].model.consumer.country;
曹云霄's avatar
曹云霄 committed
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
                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);
                        }
386
                        OrderdetailsViewController *orderDetails = [OrderdetailsViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_MAIN];
曹云霄's avatar
曹云霄 committed
387 388 389 390
                        orderDetails.orderCode = RESPONSE(returnValue);
                        orderDetails.isShowPayButton = YES;
                        orderDetails.isUserInteractionEnabled = YES;
                        orderDetails.isShowHeaderView = YES;
391
                        orderDetails.isShowShareButton = YES;
曹云霄's avatar
曹云霄 committed
392
                        orderDetails.isSliding = YES;//取消滑动返回
393
                        [weakSelf pushViewController:orderDetails animated:YES];
曹云霄's avatar
曹云霄 committed
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
                        
                    }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;
        }
    }
曹云霄's avatar
曹云霄 committed
429
    for (id objc in [self.datasArray objectAtIndex_opple:1]) {
曹云霄's avatar
曹云霄 committed
430 431 432 433 434 435 436
        
        if ([objc isKindOfClass:[AddressModel class]]) {
            
            AddressModel *model = (AddressModel *)objc;
            model.isSelected = NO;
        }
    }
曹云霄's avatar
曹云霄 committed
437
    AddressModel *model = [[self.datasArray objectAtIndex_opple:1] objectAtIndex_opple:index];
曹云霄's avatar
曹云霄 committed
438 439 440 441 442 443 444 445
    model.isSelected = YES;
}



#pragma mark -修改地址
- (void)ChangeButtonClick
{
曹云霄's avatar
曹云霄 committed
446
    NSArray *arr = [self.datasArray objectAtIndex_opple:1];
曹云霄's avatar
曹云霄 committed
447 448
    for (int i=0; i<arr.count; i++) {
        
曹云霄's avatar
曹云霄 committed
449
        AddressModel *model = [arr objectAtIndex_opple:i];
曹云霄's avatar
曹云霄 committed
450 451 452 453 454
        if ([model isKindOfClass:[AddressModel class]]) {
            
            //判断是否为选中
            if (model.isSelected) {
                
曹云霄's avatar
曹云霄 committed
455
                [self CreateModifyShippingView:[arr objectAtIndex_opple:i] Withindex:i];
曹云霄's avatar
曹云霄 committed
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
                break;
            }else
            {
                if (i == arr.count-1) {
                    [XBLoadingView showHUDViewWithText:@"请先勾选一个地址"];
                }
            }
        }
    }
}


#pragma mark -新增地址
- (void)AddAddressButtonClick
{
    [self CreateModifyShippingView:nil Withindex:0];
}


#pragma mark -新增地址回调
- (void)addAddressCell:(AddressModel *)model
{
    [self dismissViewControllerAnimated:YES completion:nil];
曹云霄's avatar
曹云霄 committed
479
    [[self.datasArray objectAtIndex_opple:1]insertObject:model atIndex:0];
曹云霄's avatar
曹云霄 committed
480 481 482 483 484 485 486 487 488 489 490
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:0 inSection:1];
    [self.generateOrderTableview insertRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationLeft];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.generateOrderTableview reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
    });
}

#pragma mark -修改地址回调
- (void)changeAddresscell:(AddressModel *)model withcellindex:(NSInteger)cellindex
{
    [self dismissViewControllerAnimated:YES completion:nil];
曹云霄's avatar
曹云霄 committed
491
    [[self.datasArray yx_objectAtIndex:1]replaceObjectAtIndex:cellindex withObject:model];
曹云霄's avatar
曹云霄 committed
492 493 494 495 496 497 498 499
    NSIndexPath *indexpath = [NSIndexPath indexPathForRow:cellindex inSection:1];
    [self.generateOrderTableview reloadRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationLeft];
}

#pragma mark -删除地址
- (void)delecteCell:(NSString *)addressid
{
    [self dismissViewControllerAnimated:YES completion:nil];
曹云霄's avatar
曹云霄 committed
500
    NSArray *arr = [self.datasArray objectAtIndex_opple:1];
曹云霄's avatar
曹云霄 committed
501 502
    for (int i=0; i<arr.count; i++) {
        
曹云霄's avatar
曹云霄 committed
503
        if ([[arr objectAtIndex_opple:i] isKindOfClass:[AddressModel class]]) {
曹云霄's avatar
曹云霄 committed
504
            
曹云霄's avatar
曹云霄 committed
505
            AddressModel *model = [arr objectAtIndex_opple:i];
曹云霄's avatar
曹云霄 committed
506 507 508
            //判断是否为选中
            if ([model.fid isEqualToString:addressid]) {
                
曹云霄's avatar
曹云霄 committed
509
                [[self.datasArray yx_objectAtIndex:1] removeObjectAtIndex:i];
曹云霄's avatar
曹云霄 committed
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
                NSIndexPath *indexpath = [NSIndexPath indexPathForRow:i inSection:1];
                [self.generateOrderTableview deleteRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationLeft];
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    [self.generateOrderTableview reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
                });
                break;
            }
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end