PrizeExchangeDetailsViewController.m 5.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14

//
//  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"
15
#import "PrizeExchangeCourierTableViewCell.h"
16
#import "prizeOrderDetailsModel.h"
17 18 19

@interface PrizeExchangeDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>

曹云霄's avatar
曹云霄 committed
20 21 22 23

/**
 兑奖单详情
 */
24
@property (nonatomic,strong) prizeOrderDetailsModel *prizeBillResult;
曹云霄's avatar
曹云霄 committed
25

曹云霄's avatar
曹云霄 committed
26 27 28
/**
 section title Array
 */
29
@property (nonatomic,strong) NSMutableArray *sectionTitleArray;
曹云霄's avatar
曹云霄 committed
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
@end

@implementation PrizeExchangeDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUpTableView];
    [self getPrizeDetailsDataAction];
}

#pragma mark - UITableView
- (void)setUpTableView
{
    self.prizeExchangeDetailsTableView.tableFooterView = [UIView new];
46
    self.prizeExchangeDetailsTableView.sectionHeaderHeight = 60;
47 48 49 50 51 52
}

#pragma mark - 兑奖记录详情
- (void)getPrizeDetailsDataAction
{
    WS(weakSelf);
53
    [XBLoadingView showHUDViewWithDefault];;
54
    NSString *url = [NSString stringWithFormat:SERVERREQUESTURL(PRIZEBILLDETAILS),self.prizeBillNumber];
55
    [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:url WithRequestType:ONE WithParameter:nil WithReturnValueBlock:^(id returnValue) {
56
        
57
        [XBLoadingView hideHUDViewWithDefault];
曹云霄's avatar
曹云霄 committed
58
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
59
            weakSelf.prizeBillResult = [[prizeOrderDetailsModel alloc]initWithDictionary:returnValue[@"data"] error:nil];
曹云霄's avatar
曹云霄 committed
60
        }else {
61
            [XBLoadingView showHUDViewWithText:returnValue[@"message"]];
曹云霄's avatar
曹云霄 committed
62 63
        }
        [weakSelf.prizeExchangeDetailsTableView reloadData];
64
    } WithFailureBlock:^(NSError *error) {
65
        [XBLoadingView hideHUDViewWithDefault];
66
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
67 68 69 70 71 72
    }];
}

#pragma mark - <UITableViewDelegate,UITableViewDataSource>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
曹云霄's avatar
曹云霄 committed
73
    switch (indexPath.section) {
74 75 76
        case ExchangeBillInformation:
        {
            PrizeExchangeBillTableViewCell *billCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeBillTableViewCell" forIndexPath:indexPath];
曹云霄's avatar
曹云霄 committed
77
            billCell.billEntity = self.prizeBillResult.bill;
78 79 80 81 82 83
            return billCell;
        }
            break;
        case ReceivingInformation:
        {
            PrizeExchangeConsigneeTableViewCell *consigneeCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeConsigneeTableViewCell" forIndexPath:indexPath];
曹云霄's avatar
曹云霄 committed
84
            consigneeCell.consigneeEntity = self.prizeBillResult.bill;
85 86 87 88 89 90
            return consigneeCell;
        }
            break;
        case RewardInformation:
        {
            PrizeExchangeInformationTableViewCell *rewardCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeInformationTableViewCell" forIndexPath:indexPath];
91
            rewardCell.giftDetailsArray = self.prizeBillResult.details;
92 93 94
            return rewardCell;
        }
            break;
95 96 97
        case LogisticsInformation:
        {
            PrizeExchangeCourierTableViewCell *logisticsCell = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeCourierTableViewCell" forIndexPath:indexPath];
98
            logisticsCell.billEntity = self.prizeBillResult.bill;
99 100 101
            return logisticsCell;
        }
            break;
102 103 104 105 106 107 108 109
        default:
            break;
    }
    return nil;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
110
    return ONE;
111 112 113 114
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
115
    return self.sectionTitleArray.count;
曹云霄's avatar
曹云霄 committed
116
}
117

曹云霄's avatar
曹云霄 committed
118 119 120 121 122 123
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    PrizeExchangeSectionTableViewCell *headerView = [tableView dequeueReusableCellWithIdentifier:@"PrizeExchangeSectionTableViewCell"];
    headerView.sectionTitleLabel.text = self.sectionTitleArray[section];
    return headerView;
}
124

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
- (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;
}

148

曹云霄's avatar
曹云霄 committed
149
#pragma mark - lazy
150
- (NSMutableArray *)sectionTitleArray
曹云霄's avatar
曹云霄 committed
151 152
{
    if (!_sectionTitleArray) {
153 154 155 156
        _sectionTitleArray = [NSMutableArray arrayWithObjects:@"兑换单信息",@"收货信息",@"奖励信息", nil];
        if (self.isDelivery) {
            [_sectionTitleArray addObject:@"物流信息"];
        }
曹云霄's avatar
曹云霄 committed
157 158 159
    }
    return _sectionTitleArray;
}
160 161 162 163



@end