PassgerPriceViewController.m 4.58 KB
Newer Older
陈俊俊's avatar
陈俊俊 committed
1 2 3 4 5 6 7 8 9
//
//  PassgerPriceViewController.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/11/8.
//  Copyright © 2015年 Xummer. All rights reserved.
//

#import "PassgerPriceViewController.h"
陈俊俊's avatar
陈俊俊 committed
10 11 12 13
#import "PasengerCell.h"
#import "PassengerHeaderCell.h"
#import "RPassgerView.h"
#import "ReportDetailViewController.h"
陈俊俊's avatar
陈俊俊 committed
14 15 16 17 18
#define LeftWidth   50

static NSString *passgerPriceHeaderIdentify = @"PassgerPriceHeaderIdentify";


陈俊俊's avatar
陈俊俊 committed
19 20 21 22 23
@interface PassgerPriceViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong)RPassgerView *rpassgerView;


陈俊俊's avatar
陈俊俊 committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37
@end

@implementation PassgerPriceViewController

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


#pragma mark - 布局
- (void)bulidLayout{
    self.view .backgroundColor = [UIColor whiteColor];
    
38 39 40 41 42 43 44
    CGRect rect = CGRectMake(0, 0, ScreenSize.width, 145);
    self.rpassgerView = [[RPassgerView alloc]initWithFrame:rect withPage:2];
    self.rpassgerView.bgImage.image = [UIImage imageNamed:@"salebg_3"];
    self.rpassgerView.cenImage.image = [UIImage imageNamed:@"sale_3"];

    [self.view addSubview:self.rpassgerView];

陈俊俊's avatar
陈俊俊 committed
45
    
陈俊俊's avatar
陈俊俊 committed
46
    rect = CGRectMake(0,0, self.view.width, self.view.height- 158);
陈俊俊's avatar
陈俊俊 committed
47 48 49
    self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
陈俊俊's avatar
陈俊俊 committed
50
    [self.tableView registerClass:[PassengerHeaderCell class] forHeaderFooterViewReuseIdentifier:passgerPriceHeaderIdentify];
51
    self.tableView.tableHeaderView = self.rpassgerView;
陈俊俊's avatar
陈俊俊 committed
52 53 54 55
    
    [self.view addSubview:self.tableView];
    
}
陈俊俊's avatar
陈俊俊 committed
56 57 58
- (void)setValueInPassgerPrice:(id)compass{
    [self.rpassgerView setPersalesWithCompass:compass];
}
陈俊俊's avatar
陈俊俊 committed
59 60 61 62 63 64

#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
陈俊俊's avatar
陈俊俊 committed
65
    return self.dataArr.count;
陈俊俊's avatar
陈俊俊 committed
66 67
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
陈俊俊's avatar
陈俊俊 committed
68 69 70
    static NSString *passgerPriceCellIdentify = @"PassgerPriceCellIdentify";

    PasengerCell *cell = [tableView dequeueReusableCellWithIdentifier:passgerPriceCellIdentify];
陈俊俊's avatar
陈俊俊 committed
71 72
    
    if(cell == nil) {
陈俊俊's avatar
陈俊俊 committed
73
        cell = [[PasengerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:passgerPriceCellIdentify];
陈俊俊's avatar
陈俊俊 committed
74 75 76 77 78 79
    }
    //没有选中风格
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //取消分割线
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
陈俊俊's avatar
陈俊俊 committed
80

81 82
    Compass *test = _dataArr[indexPath.row];
    [cell setColorAndFont:test.level];
陈俊俊's avatar
陈俊俊 committed
83 84 85 86 87
    if(test != nil) {
        [cell updateCellWithPrice:test index:indexPath];
    }
    cell.detailBtn.tag = indexPath.row;
    [cell.detailBtn addTarget:self action:@selector(detailClick:) forControlEvents:UIControlEventTouchUpInside];
陈俊俊's avatar
陈俊俊 committed
88 89
    return cell;
}
陈俊俊's avatar
陈俊俊 committed
90
- (void)detailClick:(UIButton *)btn{
91 92 93 94 95 96
    Compass *com = self.dataArr[btn.tag];
    NSObject *comObj = [NSNull null];
    if (com) {
        comObj = com;
    }
    [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_GoReportDetail object:nil userInfo:@{@"compass":comObj}];
陈俊俊's avatar
陈俊俊 committed
97
}
陈俊俊's avatar
陈俊俊 committed
98 99
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
陈俊俊's avatar
陈俊俊 committed
100 101 102 103
    return [PasengerCell cellHeight];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [[NSNotificationCenter defaultCenter]postNotificationName:KNOTIFICATION_GetNextDetailData object:nil userInfo:@{@"indexPath":indexPath}];
陈俊俊's avatar
陈俊俊 committed
104 105 106 107
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
陈俊俊's avatar
陈俊俊 committed
108
    PassengerHeaderCell *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:passgerPriceHeaderIdentify];
陈俊俊's avatar
陈俊俊 committed
109 110
    
    if (headerView == nil) {
陈俊俊's avatar
陈俊俊 committed
111
        headerView = [[PassengerHeaderCell alloc] initWithReuseIdentifier:passgerPriceHeaderIdentify];
陈俊俊's avatar
陈俊俊 committed
112 113
    }
    
陈俊俊's avatar
陈俊俊 committed
114 115
    [headerView buildLayout:@"客单价"];
    [headerView setTotalValue:[NSString stringWithFormat:@"共%ld家",(long)self.count]];
陈俊俊's avatar
陈俊俊 committed
116 117 118 119 120 121
    return headerView;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
陈俊俊's avatar
陈俊俊 committed
122
    return [PassengerHeaderCell viewHeight];
陈俊俊's avatar
陈俊俊 committed
123 124 125
}


126

陈俊俊's avatar
陈俊俊 committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
- (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