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

#import "RPassgerView.h"
10
#import "SMPageControl.h"
陈俊俊's avatar
陈俊俊 committed
11 12
#define LeftWidth   50
#define ImageSize 20
13
#define ContentHeight 25
陈俊俊's avatar
陈俊俊 committed
14
#define TopWidth 200
15
#define CenImageSize 40
陈俊俊's avatar
陈俊俊 committed
16

17 18 19
@interface RPassgerView ()
@property (nonatomic,strong)SMPageControl *pageControl;
@property (nonatomic,assign)NSInteger currentPage;
陈俊俊's avatar
陈俊俊 committed
20 21 22 23 24 25 26 27 28
@end
@implementation RPassgerView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self bulidLayout];
    }
    return self;
}
29 30 31 32 33 34 35 36
- (instancetype)initWithFrame:(CGRect)frame withPage:(NSInteger)currentPage{
    self = [super initWithFrame:frame];
    if (self) {
        self.currentPage = currentPage;
        [self bulidLayout];
    }
    return self;
}
陈俊俊's avatar
陈俊俊 committed
37 38
- (void)bulidLayout{
    
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
    CGRect rect = CGRectMake(0, 0, self.width, self.height);
    
    self.bgImage = [[UIImageView alloc]initWithFrame:rect];
    [self addSubview:self.bgImage];
    
    rect = CGRectMake(self.width/4, 20, CenImageSize, CenImageSize);
    
    self.cenImage = [[UIImageView alloc]initWithFrame:rect];
    self.cenImage.contentMode = UIViewContentModeScaleAspectFit;
    [self addSubview:self.cenImage];
    
    
    rect = CGRectMake(self.cenImage.right+5, 20, ScreenSize.width - self.cenImage.right, ContentHeight);
    self.centerLabel = [[UILabel alloc]initWithFrame:rect];
    self.centerLabel.textColor = ReportContentColor;
    self.centerLabel.font = FontSize(28);
陈俊俊's avatar
陈俊俊 committed
55 56 57
    [self addSubview:self.centerLabel];
    
    
58
    rect = CGRectMake(self.centerLabel.left, self.centerLabel.bottom,self.width-self.centerLabel.left, ContentHeight);
陈俊俊's avatar
陈俊俊 committed
59
    self.dateLabel = [[UILabel alloc]initWithFrame:rect];
60 61 62
    self.dateLabel.textColor = [UIColor lightGrayColor];
    self.dateLabel.font =  GXF_THREETEENTH_SIZE;
    self.dateLabel.textAlignment = NSTextAlignmentLeft;
陈俊俊's avatar
陈俊俊 committed
63
    [self addSubview:self.dateLabel];
64 65


陈俊俊's avatar
陈俊俊 committed
66 67 68 69
    
    CGFloat bottomWidth = (ScreenSize.width - 20*2)/2;
    
    rect = CGRectMake(20, self.dateLabel.bottom,bottomWidth, ContentHeight);
陈俊俊's avatar
陈俊俊 committed
70
    self.lastWeekLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:[UIColor lightGrayColor]];
陈俊俊's avatar
陈俊俊 committed
71 72 73 74 75 76 77 78 79 80 81
    self.lastWeekLabel.enabled = NO;
    [self addSubview:self.lastWeekLabel];
    
    
    rect = CGRectMake(self.lastWeekLabel.left, self.lastWeekLabel.bottom,bottomWidth,20);
    UILabel *weekLabel = [[UILabel alloc]initWithFrame:rect];
    weekLabel.textColor = [UIColor lightGrayColor];
    weekLabel.text = @"比上周同期";
    weekLabel.textAlignment = NSTextAlignmentCenter;
    weekLabel.font = GXF_THREETEENTH_SIZE;
    [self addSubview:weekLabel];
陈俊俊's avatar
陈俊俊 committed
82
    self.weekLabel = weekLabel;
陈俊俊's avatar
陈俊俊 committed
83 84 85
    
    
    rect = CGRectMake(self.lastWeekLabel.right,self.dateLabel.bottom,bottomWidth, ContentHeight);
陈俊俊's avatar
陈俊俊 committed
86
    self.lastYearLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:[UIColor lightGrayColor]];
陈俊俊's avatar
陈俊俊 committed
87 88 89 90 91 92 93 94 95 96 97
    self.lastYearLabel.enabled = NO;
    [self addSubview:self.lastYearLabel];
    
    
    rect = CGRectMake(self.lastWeekLabel.right, self.lastYearLabel.bottom,bottomWidth,20);
    UILabel *yearLabel = [[UILabel alloc]initWithFrame:rect];
    yearLabel.textColor = [UIColor lightGrayColor];
    yearLabel.textAlignment = NSTextAlignmentCenter;
    yearLabel.text = @"比去年同期";
    yearLabel.font = GXF_THREETEENTH_SIZE;
    [self addSubview:yearLabel];
98 99 100 101 102 103 104 105 106 107
    
    self.pageControl = [[SMPageControl alloc]initWithFrame:CGRectMake(0, yearLabel.bottom+5, ScreenSize.width, 10)];
    self.pageControl.numberOfPages = 4;

    self.pageControl.currentPage = self.currentPage;
    self.pageControl.pageIndicatorImage = [UIImage imageNamed:@"white_point"];
    self.pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"yellow_point"];
    self.pageControl.indicatorMargin = 5.0f;
    self.pageControl.indicatorDiameter = 10.0f;
    [self addSubview:self.pageControl];
陈俊俊's avatar
陈俊俊 committed
108
}
陈俊俊's avatar
陈俊俊 committed
109 110 111 112 113 114 115 116 117 118 119
- (void)setWeekLabelStr:(NSString *)weekLabelStr{
    NSString *typeStr = @"";
    if ([weekLabelStr isEqualToString:SaleEnDay]) {
        typeStr = OrderLastWeak;
    }else if([weekLabelStr isEqualToString:SaleEnWeek]){
        typeStr = OrderLastWeak;
    }else if([weekLabelStr isEqualToString:SaleEnMonth]){
        typeStr = OrderLastMonth;
    }
    self.weekLabel.text = typeStr;
}
陈俊俊's avatar
陈俊俊 committed
120 121
//客流
- (void)setPassengerWithCompass:(Compass *)compass{
122

陈俊俊's avatar
陈俊俊 committed
123
    //客流数
陈俊俊's avatar
陈俊俊 committed
124
    self.centerLabel.text = compass.passenger?[IBTCommon countNumAndChangeformat:[IBTCommon stringDisposeWithFloat:[compass.passenger floatValue]]]:@"---" ;
陈俊俊's avatar
陈俊俊 committed
125

陈俊俊's avatar
陈俊俊 committed
126
    //客流统计时间
127 128 129 130
    NSString *weekday = @"";
    if ([IBTCommon convertToDateFrom:compass.passengerdate]) {
        weekday = [IBTCommon weekdayStringFromDate:[IBTCommon convertToDateFrom:compass.passengerdate]];
    }
陈俊俊's avatar
陈俊俊 committed
131
    self.dateLabel.text = compass.passengerdate?[NSString stringWithFormat:@"%@%@累计客流量",compass.passengerdate,weekday]:@"无";
陈俊俊's avatar
陈俊俊 committed
132 133 134
    //客流数环比变化率
    if ([compass.passengerChainSign isEqualToString:ReportChainSignPlus]) {
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
135
         [self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
136
    }else if ([compass.passengerChainSign isEqualToString:ReportChainSignMinus]){
陈俊俊's avatar
陈俊俊 committed
137
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
138
         [self.lastWeekLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
139
    }
陈俊俊's avatar
陈俊俊 committed
140
    NSString *salesYoStr = compass.passengerChainRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.passengerChainRate floatValue]]]:@"---";
陈俊俊's avatar
陈俊俊 committed
141 142 143 144
    [self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal];

    //客流数同比变化率
    if ([compass.passengerYoYSign isEqualToString:ReportChainSignPlus]) {
145 146
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
         [self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
147
    }else if ([compass.passengerYoYSign isEqualToString:ReportChainSignMinus]){
148 149
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
         [self.lastYearLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
150
    }
陈俊俊's avatar
陈俊俊 committed
151
    NSString *passengerYoYRateStr = compass.passengerYoYRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.passengerYoYRate floatValue]]]:@"---";
陈俊俊's avatar
陈俊俊 committed
152 153 154 155 156
    [self.lastYearLabel setTitle:passengerYoYRateStr forState:UIControlStateNormal];
}
//客单价
- (void)setPersalesWithCompass:(Compass *)compass{
    //客单价
陈俊俊's avatar
陈俊俊 committed
157
    self.centerLabel.text = compass.persales?[IBTCommon stringDisposeWithFloat:[compass.persales floatValue]]:@"---";
陈俊俊's avatar
陈俊俊 committed
158

陈俊俊's avatar
陈俊俊 committed
159
    //客单价统计时间
160 161 162 163
    NSString *weekday = @"";
    if ([IBTCommon convertToDateFrom:compass.persalesdate]) {
        weekday = [IBTCommon weekdayStringFromDate:[IBTCommon convertToDateFrom:compass.persalesdate]];
    }
陈俊俊's avatar
陈俊俊 committed
164
    self.dateLabel.text = compass.persalesdate?[NSString stringWithFormat:@"%@%@客单价",compass.persalesdate,weekday]:@"无";
陈俊俊's avatar
陈俊俊 committed
165 166 167
    //客单价环比变化率
    if ([compass.persalesChainSign isEqualToString:ReportChainSignPlus]) {
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
168
        [self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
169
    }else if ([compass.persalesChainSign isEqualToString:ReportChainSignMinus]){
陈俊俊's avatar
陈俊俊 committed
170
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
171
        [self.lastWeekLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
172
    }
陈俊俊's avatar
陈俊俊 committed
173
    NSString *salesYoStr = compass.persalesChainRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.persalesChainRate floatValue]]]:@"---";
陈俊俊's avatar
陈俊俊 committed
174 175 176 177 178
    [self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal];
    
    //客单价同比变化率
    if ([compass.persalesYoYSign isEqualToString:ReportChainSignPlus]) {
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
179
        [self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
180
    }else if ([compass.persalesYoYSign isEqualToString:ReportChainSignMinus]){
陈俊俊's avatar
陈俊俊 committed
181
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
182
        [self.lastYearLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
183
    }
陈俊俊's avatar
陈俊俊 committed
184
    NSString *passengerYoYRateStr = compass.persalesYoYRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.persalesYoYRate floatValue]]]:@"---";
陈俊俊's avatar
陈俊俊 committed
185 186 187 188 189
    [self.lastYearLabel setTitle:passengerYoYRateStr forState:UIControlStateNormal];
}
//毛利率
- (void)setGrossprofitWithCompass:(Compass *)compass{
    //毛利率
陈俊俊's avatar
陈俊俊 committed
190
    self.centerLabel.text = compass.grossprofit?[IBTCommon stringDisposeWithFloat:[compass.grossprofit floatValue]]:@"---";
陈俊俊's avatar
陈俊俊 committed
191

陈俊俊's avatar
陈俊俊 committed
192
    //毛利率统计时间
193 194 195 196
    NSString *weekday = @"";
    if ([IBTCommon convertToDateFrom:compass.grossprofitdate]) {
        weekday = [IBTCommon weekdayStringFromDate:[IBTCommon convertToDateFrom:compass.grossprofitdate]];
    }
陈俊俊's avatar
陈俊俊 committed
197
    self.dateLabel.text = compass.grossprofitdate?[NSString stringWithFormat:@"%@%@毛利率",compass.grossprofitdate,weekday]:@"无";
陈俊俊's avatar
陈俊俊 committed
198 199 200
    //毛利率环比变化率
    if ([compass.grossprofitChainSign isEqualToString:ReportChainSignPlus]) {
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
201
        [self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
202
    }else if([compass.grossprofitChainSign isEqualToString:ReportChainSignMinus]){
陈俊俊's avatar
陈俊俊 committed
203
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
204
        [self.lastWeekLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
205
    }
陈俊俊's avatar
陈俊俊 committed
206
    NSString *salesYoStr = compass.grossprofitChainRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.grossprofitChainRate floatValue]]]:@"---";
陈俊俊's avatar
陈俊俊 committed
207 208 209 210 211
    [self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal];
    
    //毛利率同比变化率
    if ([compass.grossprofitYoYSign isEqualToString:ReportChainSignPlus]) {
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
212
        [self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
213
    }else if ([compass.grossprofitYoYSign isEqualToString:ReportChainSignMinus]){
陈俊俊's avatar
陈俊俊 committed
214
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
215
        [self.lastYearLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
216
    }
陈俊俊's avatar
陈俊俊 committed
217
    NSString *passengerYoYRateStr = compass.grossprofitYoYRate?[NSString stringWithFormat:@"%@%%",[IBTCommon stringDisposeWithFloat:[compass.grossprofitYoYRate floatValue]]]:@"---";
陈俊俊's avatar
陈俊俊 committed
218 219 220 221 222
    [self.lastYearLabel setTitle:passengerYoYRateStr forState:UIControlStateNormal];
}


@end