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

#import "PasengerCell.h"
#define Sale_Cell_Height  50
陈俊俊's avatar
陈俊俊 committed
11 12
#define Left_Width 160
#define Left_margin 0
陈俊俊's avatar
陈俊俊 committed
13 14 15 16 17 18 19 20 21 22 23 24 25
@interface PasengerCell ()


@property (nonatomic, strong) UIFont *textFont;
@property (nonatomic, strong) UIFont *titleFont;

@property (nonatomic, strong) NSIndexPath *indexPath;

@end


@implementation PasengerCell

陈俊俊's avatar
陈俊俊 committed
26 27 28 29 30 31 32
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self buildLayout];
    }
    return self;
}
陈俊俊's avatar
陈俊俊 committed
33 34 35 36 37 38 39 40 41 42

+ (CGFloat)cellHeight
{
    return Sale_Cell_Height;
}

#pragma mark - build view

- (void)buildLayout
{
陈俊俊's avatar
陈俊俊 committed
43

陈俊俊's avatar
陈俊俊 committed
44
    if(self.textFont == nil) {
陈俊俊's avatar
陈俊俊 committed
45
        self.textFont = [UIFont systemFontOfSize:15];
陈俊俊's avatar
陈俊俊 committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
    }
    
    if(self.titleFont == nil) {
        self.titleFont = [UIFont systemFontOfSize:17];
    }
    
    //页面布局
    [self createView];
}

//创建视图
- (void)createView
{
    
    CGRect rect = CGRectMake(Left_margin,0, Left_Width, Sale_Cell_Height);
    self.dqLabel = [IBTCommon labelWithTitle:@"0101第一片区" frame:rect textFont:self.textFont];
陈俊俊's avatar
陈俊俊 committed
62
    self.dqLabel.textColor = ReportTitleColor;
陈俊俊's avatar
陈俊俊 committed
63 64
    [self.contentView addSubview:self.dqLabel];
    
陈俊俊's avatar
陈俊俊 committed
65
    CGFloat width = (ScreenSize.width - self.dqLabel.right - 35)/2;
陈俊俊's avatar
陈俊俊 committed
66 67 68 69 70 71 72 73 74 75 76
    
    rect = CGRectMake(self.dqLabel.right , 0, width, Sale_Cell_Height);
    self.saleLabel = [IBTCommon labelWithTitle:@"60.0" frame:rect textFont:self.textFont];
    self.saleLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.saleLabel];
    
    rect = CGRectMake(self.saleLabel.right, 0, width, Sale_Cell_Height);
    self.lastWeekLabel = [IBTCommon labelWithTitle:@"14.20%" frame:rect textFont:self.textFont];
    self.lastWeekLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.lastWeekLabel];
    
陈俊俊's avatar
陈俊俊 committed
77 78 79 80 81 82 83 84 85
    rect = CGRectMake(self.lastWeekLabel.right, 0, 35, Sale_Cell_Height);
    self.detailBtn = [IBTCommon buttonWithTitle:@"详" Image:nil frame:rect fontSize:20 fontColor:ReportColor];
    self.detailBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
    [self.contentView addSubview:self.detailBtn];
    
    
    self.lineLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, Sale_Cell_Height - 1, ScreenSize.width, 1))];
    self.lineLabel.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.lineLabel];
陈俊俊's avatar
陈俊俊 committed
86 87 88 89 90
    
}


#pragma mark - update view
陈俊俊's avatar
陈俊俊 committed
91 92
//客单价
- (void)updateCellWithPrice:(OrgCompass *)sale index:(NSIndexPath *)indexPath
陈俊俊's avatar
陈俊俊 committed
93 94
{
    self.indexPath = indexPath;
陈俊俊's avatar
陈俊俊 committed
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
    //组织name
    self.dqLabel.text = sale.orgname;
    //客单价
    self.saleLabel.text = sale.persales;
    //客单价比变化率
    if ([sale.persalesChainSign isEqualToString:ReportChainSignPlus]) {
        self.lastWeekLabel.textColor = ReportContentColor;
    }else{
        self.lastWeekLabel.textColor = GXF_NAVIGAYION_COLOR;
    }
    NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",sale.persalesChainRate];
    self.lastWeekLabel.text = salesYoStr;
}
//客流量
- (void)updateCellWithFlow:(OrgCompass *)sale index:(NSIndexPath *)indexPath
{
    self.indexPath = indexPath;
    //组织name
    self.dqLabel.text = sale.orgname;
    //客流量
    self.saleLabel.text = sale.passenger;
    //客流量比变化率
    if ([sale.passengerChainSign isEqualToString:ReportChainSignPlus]) {
        self.lastWeekLabel.textColor = ReportContentColor;
    }else{
        self.lastWeekLabel.textColor = GXF_NAVIGAYION_COLOR;
    }
    NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",sale.passengerChainRate];
    self.lastWeekLabel.text = salesYoStr;
   
}
//毛利率
- (void)updateCellWithGross:(OrgCompass *)sale index:(NSIndexPath *)indexPath{
    self.indexPath = indexPath;
    //组织name
    self.dqLabel.text = sale.orgname;
    //毛利率
    self.saleLabel.text = sale.grossprofit;
    //毛利率比变化率
    if ([sale.grossprofitChainSign isEqualToString:ReportChainSignPlus]) {
        self.lastWeekLabel.textColor = ReportContentColor;
    }else{
        self.lastWeekLabel.textColor = GXF_NAVIGAYION_COLOR;
    }
    NSString *salesYoStr = [NSString stringWithFormat:@"%@%%",sale.grossprofitChainRate];
    self.lastWeekLabel.text = salesYoStr;
陈俊俊's avatar
陈俊俊 committed
141 142 143 144 145 146 147 148
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end