// // PrizeExchangeDetailsViewController.m // Lighting // // Created by 曹云霄 on 2016/11/22. // Copyright © 2016年 上海勾芒科技有限公司. All rights reserved. // #import "PrizeExchangeDetailsViewController.h" #import "PrizeExchangeBillTableViewCell.h" #import "PrizeExchangeSectionTableViewCell.h" #import "PrizeExchangeInformationTableViewCell.h" #import "PrizeExchangeConsigneeTableViewCell.h" #import "PrizeExchangeCourierTableViewCell.h" @interface PrizeExchangeDetailsViewController ()<UITableViewDelegate,UITableViewDataSource> /** 兑奖单详情 */ @property (nonatomic,strong) RsPrizeBill *prizeBillResult; /** section title Array */ @property (nonatomic,strong) NSMutableArray *sectionTitleArray; @end @implementation PrizeExchangeDetailsViewController - (void)viewDidLoad { [super viewDidLoad]; [self setUpTableView]; [self getPrizeDetailsDataAction]; } #pragma mark - UITableView - (void)setUpTableView { self.prizeExchangeDetailsTableView.tableFooterView = [UIView new]; self.prizeExchangeDetailsTableView.sectionHeaderHeight = 60; } #pragma mark - 兑奖记录详情 - (void)getPrizeDetailsDataAction { WS(weakSelf); [self CreateMBProgressHUDLoding]; NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(PRIZEBILLDETAILS),@"demo11611221750244"]; [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:url WithCallClass:weakSelf WithRequestType:ONE WithParameter:nil WithReturnValueBlock:^(id returnValue) { [weakSelf RemoveMBProgressHUDLoding]; if ([returnValue[@"code"] isEqualToNumber:@0]) { weakSelf.prizeBillResult = [[RsPrizeBill alloc]initWithDictionary:returnValue[@"data"] error:nil]; }else { [weakSelf ErrorMBProgressView:returnValue[@"message"]]; } [weakSelf.prizeExchangeDetailsTableView reloadData]; } WithErrorCodeBlock:^(id errorCodeValue) { [weakSelf ErrorMBProgressView:NETWORK]; } WithFailureBlock:^(NSError *error) { [weakSelf ErrorMBProgressView:error.localizedDescription]; }]; } #pragma mark - <UITableViewDelegate,UITableViewDataSource> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { switch (indexPath.section) { case ExchangeBillInformation: { PrizeExchangeBillTableViewCell *billCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeBillTableViewCell" forIndexPath:indexPath]; billCell.billEntity = self.prizeBillResult.bill; return billCell; } break; case ReceivingInformation: { PrizeExchangeConsigneeTableViewCell *consigneeCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeConsigneeTableViewCell" forIndexPath:indexPath]; consigneeCell.consigneeEntity = self.prizeBillResult.bill; return consigneeCell; } break; case RewardInformation: { PrizeExchangeInformationTableViewCell *rewardCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeInformationTableViewCell" forIndexPath:indexPath]; return rewardCell; } break; case LogisticsInformation: { PrizeExchangeCourierTableViewCell *logisticsCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeCourierTableViewCell" forIndexPath:indexPath]; return logisticsCell; } break; default: break; } return nil; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return ONE; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return self.sectionTitleArray.count; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { PrizeExchangeSectionTableViewCell *headerView = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeSectionTableViewCell"]; headerView.sectionTitleLabel.text = self.sectionTitleArray[section]; return headerView; } #pragma mark - lazy - (NSMutableArray *)sectionTitleArray { if (!_sectionTitleArray) { _sectionTitleArray = [NSMutableArray arrayWithObjects:@"兑换单信息",@"收货信息",@"奖励信息", nil]; if (self.isDelivery) { [_sectionTitleArray addObject:@"物流信息"]; } } return _sectionTitleArray; } @end