PrizeExchangeDetailsViewController.m 4.96 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 53 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 108 109 110 111 112 113 114 115 116 117 118 119 120 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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162

//
//  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"
#import "prizeOrderDetailsModel.h"

@interface PrizeExchangeDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>


/**
 兑奖单详情
 */
@property (nonatomic,strong) prizeOrderDetailsModel *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);
    [XBLoadingView showHUDViewWithDefault];;
    NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(PRIZEBILLDETAILS),self.prizeBillNumber];
    [HTTP networkWithDictionaryRequestWithURL:url withRequestType:ONE withParameter:nil withReturnValueBlock:^(id returnValue) {
        
        [XBLoadingView hideHUDViewWithDefault];
        if (RESULT(returnValue)) {
            weakSelf.prizeBillResult = [[prizeOrderDetailsModel alloc]initWithDictionary:RESPONSE(returnValue) error:nil];
        }else {
            [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
        }
        [weakSelf.prizeExchangeDetailsTableView reloadData];
    } withFailureBlock:^(NSError *error) {
        [XBLoadingView showHUDViewWithText: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];
            rewardCell.giftDetailsArray = self.prizeBillResult.details;
            return rewardCell;
        }
            break;
        case LogisticsInformation:
        {
            PrizeExchangeCourierTableViewCell *logisticsCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeCourierTableViewCell" forIndexPath:indexPath];
            logisticsCell.billEntity = self.prizeBillResult.bill;
            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;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.section) {
        case ExchangeBillInformation:
        case ReceivingInformation:
            return 100;
            break;
        case RewardInformation:
        {
            return self.prizeBillResult.giftHeight;
        }
            break;
        case LogisticsInformation:
        {
            return 60;
        }
            break;
        default:
            break;
    }
    return 0;
}


#pragma mark - lazy
- (NSMutableArray *)sectionTitleArray
{
    if (!_sectionTitleArray) {
        _sectionTitleArray = [NSMutableArray arrayWithObjects:@"兑换单信息",@"收货信息",@"奖励信息", nil];
        if (self.isDelivery) {
            [_sectionTitleArray addObject:@"物流信息"];
        }
    }
    return _sectionTitleArray;
}



@end