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

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

static NSString *passgerPriceHeaderIdentify = @"PassgerPriceHeaderIdentify";


陈俊俊's avatar
陈俊俊 committed
20
@interface PassgerPriceViewController ()<UITableViewDataSource,UITableViewDelegate>
陈俊俊's avatar
陈俊俊 committed
21
@property (nonatomic,strong)SMPageControl *pageControl;
陈俊俊's avatar
陈俊俊 committed
22 23 24 25 26

@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)RPassgerView *rpassgerView;


陈俊俊's avatar
陈俊俊 committed
27 28 29 30 31 32 33 34 35 36 37 38 39
@end

@implementation PassgerPriceViewController

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


#pragma mark - 布局
- (void)bulidLayout{
    self.view .backgroundColor = [UIColor whiteColor];
陈俊俊's avatar
陈俊俊 committed
40 41
    CGRect rect = CGRectMake(0, 0, ScreenSize.width, 145);
    self.bgView = [[UIView alloc]initWithFrame:rect];
陈俊俊's avatar
陈俊俊 committed
42
    
陈俊俊's avatar
陈俊俊 committed
43 44 45
    rect = CGRectMake(0, 0, ScreenSize.width, 130);
    self.rpassgerView = [[RPassgerView alloc]initWithFrame:rect];
    [self.bgView addSubview:self.rpassgerView];
陈俊俊's avatar
陈俊俊 committed
46 47
    
    
陈俊俊's avatar
陈俊俊 committed
48 49 50 51
    self.pageControl = [[SMPageControl alloc]initWithFrame:CGRectMake(0, self.rpassgerView.bottom, self.view.width, 10)];
    self.pageControl.numberOfPages = 4;

    self.pageControl.currentPage = 2;
陈俊俊's avatar
陈俊俊 committed
52
    self.pageControl.pageIndicatorTintColor = XXFBgColor;
陈俊俊's avatar
陈俊俊 committed
53
    self.pageControl.currentPageIndicatorTintColor = ReportColor;
陈俊俊's avatar
陈俊俊 committed
54 55
    self.pageControl.indicatorMargin = 15.0f;
    
陈俊俊's avatar
陈俊俊 committed
56 57
    self.pageControl.indicatorDiameter = 10.0f;
    [self.bgView addSubview:self.pageControl];
陈俊俊's avatar
陈俊俊 committed
58
    
陈俊俊's avatar
陈俊俊 committed
59
    rect = CGRectMake(0,0, self.view.width, self.view.height- 158);
陈俊俊's avatar
陈俊俊 committed
60 61 62
    self.tableView = [[UITableView alloc]initWithFrame:rect style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
陈俊俊's avatar
陈俊俊 committed
63 64
    [self.tableView registerClass:[PassengerHeaderCell class] forHeaderFooterViewReuseIdentifier:passgerPriceHeaderIdentify];
    self.tableView.tableHeaderView = self.bgView;
陈俊俊's avatar
陈俊俊 committed
65 66 67 68
    
    [self.view addSubview:self.tableView];
    
}
陈俊俊's avatar
陈俊俊 committed
69 70 71
- (void)setValueInPassgerPrice:(id)compass{
    [self.rpassgerView setPersalesWithCompass:compass];
}
陈俊俊's avatar
陈俊俊 committed
72 73 74 75 76 77

#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
陈俊俊's avatar
陈俊俊 committed
78
    return self.dataArr.count;
陈俊俊's avatar
陈俊俊 committed
79 80
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
陈俊俊's avatar
陈俊俊 committed
81 82 83
    static NSString *passgerPriceCellIdentify = @"PassgerPriceCellIdentify";

    PasengerCell *cell = [tableView dequeueReusableCellWithIdentifier:passgerPriceCellIdentify];
陈俊俊's avatar
陈俊俊 committed
84 85
    
    if(cell == nil) {
陈俊俊's avatar
陈俊俊 committed
86
        cell = [[PasengerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:passgerPriceCellIdentify];
陈俊俊's avatar
陈俊俊 committed
87 88 89 90 91 92
    }
    //没有选中风格
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //取消分割线
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
陈俊俊's avatar
陈俊俊 committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

    OrgCompass *test = _dataArr[indexPath.row];
    if (test.level == 0) {
        cell.dqLabel.textColor = ReportTitleColor;
        cell.dqLabel.font = GXF_FIFTEENTEN_SIZE;
        cell.lineLabel.hidden = NO;
    }else if(test.level == 1)
    {
        cell.dqLabel.textColor = [UIColor blackColor];
        cell.dqLabel.font = GXF_FOURTEENTH_SIZE;
        cell.lineLabel.hidden = NO;
    }else {
        cell.lineLabel.hidden = YES;
        cell.dqLabel.textColor = [UIColor lightGrayColor];
        cell.dqLabel.font = GXF_THREETEENTH_SIZE;
        
    }
    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
115 116
    return cell;
}
陈俊俊's avatar
陈俊俊 committed
117 118 119 120 121
- (void)detailClick:(UIButton *)btn{
    ReportDetailViewController *rvc = [ReportDetailViewController new];
    rvc.title = @"陆金所";
    [self PushViewController:rvc animated:YES];
}
陈俊俊's avatar
陈俊俊 committed
122 123
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
陈俊俊's avatar
陈俊俊 committed
124 125 126 127
    return [PasengerCell cellHeight];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [[NSNotificationCenter defaultCenter]postNotificationName:KNOTIFICATION_GetNextDetailData object:nil userInfo:@{@"indexPath":indexPath}];
陈俊俊's avatar
陈俊俊 committed
128 129 130 131
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
陈俊俊's avatar
陈俊俊 committed
132
    PassengerHeaderCell *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:passgerPriceHeaderIdentify];
陈俊俊's avatar
陈俊俊 committed
133 134
    
    if (headerView == nil) {
陈俊俊's avatar
陈俊俊 committed
135
        headerView = [[PassengerHeaderCell alloc] initWithReuseIdentifier:passgerPriceHeaderIdentify];
陈俊俊's avatar
陈俊俊 committed
136 137
    }
    
陈俊俊's avatar
陈俊俊 committed
138 139
    [headerView buildLayout:@"客单价"];
    [headerView setTotalValue:[NSString stringWithFormat:@"共%ld家",(long)self.count]];
陈俊俊's avatar
陈俊俊 committed
140 141 142 143 144 145
    return headerView;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
陈俊俊's avatar
陈俊俊 committed
146
    return [PassengerHeaderCell viewHeight];
陈俊俊's avatar
陈俊俊 committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
}


- (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