RPassgerView.m 10.2 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 82 83 84
    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];
    
    
    rect = CGRectMake(self.lastWeekLabel.right,self.dateLabel.bottom,bottomWidth, ContentHeight);
陈俊俊's avatar
陈俊俊 committed
85
    self.lastYearLabel = [IBTCommon buttonWithTitle:@"" Image:nil frame:rect fontSize:15 fontColor:[UIColor lightGrayColor]];
陈俊俊's avatar
陈俊俊 committed
86 87 88 89 90 91 92 93 94 95 96
    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];
97 98 99 100 101 102 103 104 105 106
    
    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
107 108 109 110 111
}


//客流
- (void)setPassengerWithCompass:(Compass *)compass{
112

陈俊俊's avatar
陈俊俊 committed
113
    //客流数
陈俊俊's avatar
陈俊俊 committed
114 115
    self.centerLabel.text = compass.passenger?[compass.passenger stringValue]:@"---" ;

陈俊俊's avatar
陈俊俊 committed
116
    //客流统计时间
117 118 119 120
    NSString *weekday = @"";
    if ([IBTCommon convertToDateFrom:compass.passengerdate]) {
        weekday = [IBTCommon weekdayStringFromDate:[IBTCommon convertToDateFrom:compass.passengerdate]];
    }
陈俊俊's avatar
陈俊俊 committed
121
    self.dateLabel.text = compass.passengerdate?[NSString stringWithFormat:@"%@%@累计客流量",compass.passengerdate,weekday]:@"无";
陈俊俊's avatar
陈俊俊 committed
122 123 124
    //客流数环比变化率
    if ([compass.passengerChainSign isEqualToString:ReportChainSignPlus]) {
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
125
         [self.lastWeekLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
126
    }else if ([compass.passengerChainSign isEqualToString:ReportChainSignMinus]){
陈俊俊's avatar
陈俊俊 committed
127
        [self.lastWeekLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
128
         [self.lastWeekLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
129
    }
陈俊俊's avatar
陈俊俊 committed
130
    NSString *salesYoStr = compass.passengerChainRate?[NSString stringWithFormat:@"%@%%",compass.passengerChainRate]:@"---";
陈俊俊's avatar
陈俊俊 committed
131 132 133 134
    [self.lastWeekLabel setTitle:salesYoStr forState:UIControlStateNormal];

    //客流数同比变化率
    if ([compass.passengerYoYSign isEqualToString:ReportChainSignPlus]) {
135 136
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainPlusImage] forState:UIControlStateDisabled];
         [self.lastYearLabel setTitleColor:ReportContentColor forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
137
    }else if ([compass.passengerYoYSign isEqualToString:ReportChainSignMinus]){
138 139
        [self.lastYearLabel setImage:[UIImage imageNamed:ReportChainMinusImage] forState:UIControlStateDisabled];
         [self.lastYearLabel setTitleColor:GXF_SAVE_COLOR forState:UIControlStateDisabled];
陈俊俊's avatar
陈俊俊 committed
140
    }
陈俊俊's avatar
陈俊俊 committed
141
    NSString *passengerYoYRateStr = compass.passengerYoYRate?[NSString stringWithFormat:@"%@%%",compass.passengerYoYRate]:@"---";
陈俊俊's avatar
陈俊俊 committed
142 143 144 145 146
    [self.lastYearLabel setTitle:passengerYoYRateStr forState:UIControlStateNormal];
}
//客单价
- (void)setPersalesWithCompass:(Compass *)compass{
    //客单价
陈俊俊's avatar
陈俊俊 committed
147 148
    self.centerLabel.text = compass.persales?[compass.persales stringValue]:@"---";

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

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


@end