From f99cf1d5cc50407394501853be06cb39f38a092c Mon Sep 17 00:00:00 2001
From: 单军华 <WindShan@danjunhuas-MacBook-Pro.local>
Date: Wed, 28 Mar 2018 14:09:19 +0800
Subject: [PATCH] 界面更换与适配调整

---
 pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m |  341 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 338 insertions(+), 3 deletions(-)

diff --git a/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m b/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m
index fc95a60..50621ba 100644
--- a/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m
+++ b/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m
@@ -7,9 +7,23 @@
 //
 
 #import "HistoryRecordPage.h"
+#import "GloriaLabel.h"
+#import "NetworkSingleton.h"
 
 @interface HistoryRecordPage ()
-
+{
+    JHLineChart *historyRecordLineChart;
+    NSMutableArray * modelArray;
+    UIButton * _DayBtn;
+    UIButton * _WeekBtn;
+    UIButton * _MonthBtn;
+    int        currentUnit; // 1 ��� 2 ���
+    GloriaLabel* _UnitTipsLabel;
+    NSDate *CurrentDate;
+    NSDate *initialDate;
+    GloriaLabel* _BeginTimesLabel;
+    GloriaLabel* _EndTimesLabel;
+}
 @end
 
 @implementation HistoryRecordPage
@@ -23,14 +37,334 @@
     
     UIImageView * ic_bottom_bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-112-64, SCREEN_WIDTH, 112)];
     ic_bottom_bg.image = [UIImage imageNamed:@"ic_bottom_bg"];
+    ic_bottom_bg.userInteractionEnabled = YES;
     [self.view addSubview:ic_bottom_bg];
     
-    UIImageView * ic_time_bk = [[UIImageView alloc] initWithFrame:CGRectMake(0, 10 , SCREEN_WIDTH, 112)];
+    UIImageView * ic_time_bk = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-225)/2, 15, 225, 25)];
     ic_time_bk.image = [UIImage imageNamed:@"ic_time_bk"];
-    [self.view addSubview:ic_time_bk];
+    ic_time_bk.userInteractionEnabled = YES;
+    [ic_bottom_bg addSubview:ic_time_bk];
+    
+    // Y = 0 75 150
+    
+    currentUnit = 1;
+    CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:[NSDate date] dayCount:-1]];
+    initialDate = CurrentDate;
+    _DayBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _DayBtn.frame = CGRectMake(0, 0, 75, 25);
+    [_DayBtn setBackgroundImage:[UIImage imageNamed:@"ic_time_item_bk"] forState:UIControlStateNormal];
+    [_DayBtn setTitle:@"���" forState:UIControlStateNormal];
+    _DayBtn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
+    [_DayBtn setTitleColor:kUIColorFromRGB(0xffffff) forState:UIControlStateNormal];
+    [_DayBtn addTarget:self action:@selector(unitDayLogin) forControlEvents:UIControlEventTouchUpInside];
+    [ic_time_bk addSubview:_DayBtn];
+    
+    _WeekBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _WeekBtn.frame = CGRectMake(75, 0, 75, 25);
+    [_WeekBtn setBackgroundImage:[UIImage imageNamed:@"ic_time_item_bk"] forState:UIControlStateNormal];
+    [_WeekBtn setTitle:@"���" forState:UIControlStateNormal];
+    _WeekBtn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
+    [_WeekBtn setTitleColor:kUIColorFromRGB(0xffffff) forState:UIControlStateNormal];
+    [_WeekBtn addTarget:self action:@selector(unitWeekLogin) forControlEvents:UIControlEventTouchUpInside];
+    [ic_time_bk addSubview:_WeekBtn];
+    [_WeekBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+    
+    _MonthBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _MonthBtn.frame = CGRectMake(150, 0,75, 25);
+    [_MonthBtn setBackgroundImage:[UIImage imageNamed:@"ic_time_item_bk"] forState:UIControlStateNormal];
+    [_MonthBtn setTitle:@"���" forState:UIControlStateNormal];
+    _MonthBtn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
+    [_MonthBtn setTitleColor:kUIColorFromRGB(0xffffff) forState:UIControlStateNormal];
+    [_MonthBtn addTarget:self action:@selector(unitMonthLogin) forControlEvents:UIControlEventTouchUpInside];
+    [ic_time_bk addSubview:_MonthBtn];
+    [_MonthBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+
+    
+    UIImageView * ic_line = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, (112-15-25-52)/2 + 15 + 25 , 1, 52)];
+    ic_line.image = [UIImage imageNamed:@"ic_line"];
+    [ic_bottom_bg addSubview:ic_line];
+    
+    GloriaLabel* _AvgValueLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 15 + 25 + 10,SCREEN_WIDTH/2, 20)];
+    _AvgValueLabel.font = [UIFont systemFontOfSize:14];
+    _AvgValueLabel.textAlignment = UITextAlignmentCenter;
+    _AvgValueLabel.textColor = kUIColorFromRGB(0xffffff);
+    _AvgValueLabel.text = @"���������";
+    [ic_bottom_bg addSubview:_AvgValueLabel];
+    
+    GloriaLabel* _YearLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 15 + 25 + 10 + 20,SCREEN_WIDTH/2, 30)];
+    _YearLabel.font = [UIFont boldSystemFontOfSize:18];
+    _YearLabel.textAlignment = UITextAlignmentCenter;
+    _YearLabel.textColor = kUIColorFromRGB(0xffffff);
+    _YearLabel.text = @"10";
+    [ic_bottom_bg addSubview:_YearLabel];
+    
+    // ���������������������������label���������
+    CGSize size = [_YearLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:18.0f] constrainedToSize:CGSizeMake(self.view.frame.size.width, 300) lineBreakMode:NSLineBreakByWordWrapping];
+    
+    GloriaLabel* _UnitLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/4+size.width/2+2, 15 + 25 + 10 + 20,SCREEN_WIDTH/2, 30)];
+    _UnitLabel.font = [UIFont systemFontOfSize:14];
+    _UnitLabel.textAlignment = UITextAlignmentLeft;
+    _UnitLabel.textColor = kUIColorFromRGB(0xffffff);
+    _UnitLabel.text = @"��W/c���";
+    [ic_bottom_bg addSubview:_UnitLabel];
+    
+    GloriaLabel* _StatusTipsLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, 15 + 25 + 10,SCREEN_WIDTH/2, 20)];
+    _StatusTipsLabel.font = [UIFont systemFontOfSize:14];
+    _StatusTipsLabel.textAlignment = UITextAlignmentCenter;
+    _StatusTipsLabel.textColor = kUIColorFromRGB(0xffffff);
+    _StatusTipsLabel.text = @"������";
+    [ic_bottom_bg addSubview:_StatusTipsLabel];
+    
+    GloriaLabel* _StatusLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, 15 + 25 + 10+ 20,SCREEN_WIDTH/2, 20)];
+    _StatusLabel.font = [UIFont boldSystemFontOfSize:18];
+    _StatusLabel.textAlignment = UITextAlignmentCenter;
+    _StatusLabel.textColor = kUIColorFromRGB(0xffffff);
+    _StatusLabel.text = @"������";
+    [ic_bottom_bg addSubview:_StatusLabel];
+    
+    _BeginTimesLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH, 20)];
+    _BeginTimesLabel.font = [UIFont boldSystemFontOfSize:14];
+    _BeginTimesLabel.textAlignment = UITextAlignmentCenter;
+    _BeginTimesLabel.textColor = RgbColor(0, 146, 252);
+    _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
+    [self.view  addSubview:_BeginTimesLabel];
+    
+    GloriaLabel* _TimesLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 20,SCREEN_WIDTH, 20)];
+    _TimesLabel.font = [UIFont boldSystemFontOfSize:14];
+    _TimesLabel.textAlignment = UITextAlignmentCenter;
+    _TimesLabel.textColor = RgbColor(0, 146, 252);
+    _TimesLabel.text = @"���";
+    [self.view  addSubview:_TimesLabel];
+    
+    _EndTimesLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 40,SCREEN_WIDTH, 20)];
+    _EndTimesLabel.font = [UIFont boldSystemFontOfSize:14];
+    _EndTimesLabel.textAlignment = UITextAlignmentCenter;
+    _EndTimesLabel.textColor = RgbColor(0, 146, 252);
+    _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+    [self.view  addSubview:_EndTimesLabel];
+    
+    UIButton * _arraw_leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _arraw_leftBtn.frame = CGRectMake(88, 20 , 15, 15);
+    [_arraw_leftBtn setBackgroundImage:[UIImage imageNamed:@"icon_arraw_left"] forState:UIControlStateNormal];
+    _arraw_leftBtn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
+    [_arraw_leftBtn setTitleColor:kUIColorFromRGB(0xfebead) forState:UIControlStateNormal];
+    [_arraw_leftBtn addTarget:self action:@selector(leftLogin) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:_arraw_leftBtn];
     
     
+    UIButton * _arraw_rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _arraw_rightBtn.frame = CGRectMake(SCREEN_WIDTH-88-15, 20, 15, 15);
+    [_arraw_rightBtn setBackgroundImage:[UIImage imageNamed:@"icon_arraw_right"] forState:UIControlStateNormal];
+    _arraw_rightBtn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
+    [_arraw_rightBtn setTitleColor:kUIColorFromRGB(0xfebead) forState:UIControlStateNormal];
+    [_arraw_rightBtn addTarget:self action:@selector(rightLogin) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:_arraw_rightBtn];
+
+    
+    modelArray = [[NSMutableArray alloc] init];
+    
+     [self drawHistoryRecordLine];
+    
+    _UnitTipsLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-112-64-30, SCREEN_WIDTH, 20)];
+    _UnitTipsLabel.font = [UIFont boldSystemFontOfSize:14];
+    _UnitTipsLabel.textAlignment = UITextAlignmentCenter;
+    _UnitTipsLabel.textColor = RgbColor(0, 146, 252);
+    _UnitTipsLabel.text = @"���������(������)";
+    [self.view  addSubview:_UnitTipsLabel];
+    
+    [self GetUserDataList];
     // Do any additional setup after loading the view.
+}
+
+-(void)leftLogin
+{
+    CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:CurrentDate dayCount:-(currentUnit+1)]];
+    _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
+    _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+    [self GetUserDataList];
+}
+
+-(void)rightLogin
+{
+    if( ![[DateUtil stringFromDateYMD:CurrentDate] isEqualToString: [DateUtil stringFromDateYMD:initialDate]])
+    {
+        CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:CurrentDate dayCount:(currentUnit+1)]];
+        _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
+        _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+        [self GetUserDataList];
+    }
+}
+
+
+-(void)GetUserDataList
+{
+    //[UserDefault stringForKey:@"user_id"]
+    NSString *path = [[NSString alloc] initWithFormat:GET_DATALIST];
+    
+    NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
+    [params setValue:[UserDefault stringForKey:@"user_id"] forKey:@"user_id"];
+    [params setValue:_BeginTimesLabel.text forKey:@"start_time"];
+    [params setValue:_EndTimesLabel.text forKey:@"end_time"];
+    
+    MPWeakSelf(self);
+    [NetworkSingleton networkingGetMethod:params urlName:path success:^(id responseBody)
+     {
+         MPStrongSelf(self);
+         BaseResModel * resModel = [Global toBaseModel:responseBody];
+         
+         if(resModel.code == 0)
+         {
+             //[UserDefault setObject:self.is_open_upload forKey:@"is_open_upload"];
+             [UserDefault synchronize];
+             
+             //[self.tableView reloadData];
+             [Global alertMessageEx:resModel.desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self];
+         }
+         else
+         {
+             [Global alertMessageEx:resModel.desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self];
+         }
+     }
+                                  failure:^(NSString *error)
+     {
+         
+         [Global alertMessageEx:error title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self];
+     }];
+}
+
+
+-(void)unitMonthLogin
+{
+    currentUnit = 28;
+    [_DayBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+    [_WeekBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+    [_MonthBtn setBackgroundImage:[UIImage imageNamed:@"ic_time_item_bk"] forState:UIControlStateNormal];
+    CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:[NSDate date] dayCount:-1]];
+    _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
+    _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+    [self GetUserDataList];
+}
+
+-(void)unitWeekLogin
+{
+    currentUnit = 7;
+    [_WeekBtn setBackgroundImage:[UIImage imageNamed:@"ic_time_item_bk"] forState:UIControlStateNormal];
+    [_MonthBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+    [_DayBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+    CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:[NSDate date] dayCount:-1]];
+    _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
+    _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+    [self GetUserDataList];
+}
+
+-(void)unitDayLogin
+{
+    currentUnit = 1;
+    [_DayBtn setBackgroundImage:[UIImage imageNamed:@"ic_time_item_bk"] forState:UIControlStateNormal];
+    [_WeekBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+    [_MonthBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
+    CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:[NSDate date] dayCount:-1]];
+    _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
+    _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+    [self GetUserDataList];
+}
+
+-(void)drawHistoryRecordLine
+{
+    
+    /*     Create object        */
+    historyRecordLineChart = [[JHLineChart alloc] initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH-20, SCREEN_HEIGHT-112-64-40-40-20) andLineChartType:JHChartLineEveryValueForEveryX];
+    
+    /* The scale value of the X axis can be passed into the NSString or NSNumber type and the data structure changes with the change of the line chart type. The details look at the document or other quadrant X axis data source sample.*/
+    
+    //co2LineChart.xLineDataArr = @[@"10:00",@"11:21",@"12:32",@"13:33",@"14:43",@"15:33",@"16:11",@"17:21"];
+    
+    /* The different types of the broken line chart, according to the quadrant division, different quadrant correspond to different X axis scale data source and different value data source. */
+    
+    historyRecordLineChart.lineChartQuadrantType = JHLineChartQuadrantTypeFirstQuardrant;
+    
+    historyRecordLineChart.lineWidth = 3.0;
+    historyRecordLineChart.valueArr = [NSMutableArray array];
+    NSMutableArray * valueTeampArr = [[NSMutableArray alloc] init];
+    //for (int i = 0; i < modelArray.count; i++)
+    for (int i = 0; i < 10; i++)
+    {
+        //LiveDataModel * model = [modelArray objectAtIndex:i];
+        
+        [valueTeampArr addObject:[NSString stringWithFormat:@"%d",i*(rand()%10)]];
+        [historyRecordLineChart.xLineDataArr addObject:[NSString stringWithFormat:@"%d",i]];
+    }
+    
+    //NSMutableArray * valueTeampArr = [[NSMutableArray alloc] init];
+    //for (int i = 0; i < 8; i++)
+    //{
+    //    [valueTeampArr addObject:@"3000"];
+    //    [co2LineChart.xLineDataArr addObject:[NSString stringWithFormat:@"%d",i]];
+    //}
+    
+    [historyRecordLineChart.valueArr addObject:valueTeampArr];
+    
+    [historyRecordLineChart updateYScale];
+    
+    /*  ������������������������������*/
+    historyRecordLineChart.showYLevelLine = YES;
+    /*         *  whether this chart shows leading lines for value point or not,default is YES  ������������������������������*/
+    historyRecordLineChart.showValueLeadingLine = NO;
+    //historyRecordLineChart.showYLine = NO;
+    historyRecordLineChart.yLineDataArr  = @[@"10",@"20",@"30",@"40",@"50",@"60",@"70",@"80",@"90",@"100"];//[NSMutableArray array];
+    // ������������
+    /* Line Chart colors ������������ */
+    historyRecordLineChart.valueLineColorArr =@[RgbColor(143, 246, 218)];
+    /* Colors for every line chart ������������������*/
+    historyRecordLineChart.pointColorArr = @[RgbColor(36, 209, 215)];
+    
+    
+    /* color for XY axis XY������������������*/
+    historyRecordLineChart.xAndYLineColor = RgbColor(0, 146, 252);
+    /* XY axis scale color XY������������������������*/
+    historyRecordLineChart.xAndYNumberColor = RgbColor(0, 146, 252);
+    /* Dotted line color of the coordinate point */
+    historyRecordLineChart.positionLineColorArr = @[RgbColor(0, 146, 252)];
+    /*  ������������������������*/
+    historyRecordLineChart.pointNumberColorArr = @[[UIColor orangeColor]];
+    /*        Set whether to fill the content, the default is False   ������������������������������      */
+    historyRecordLineChart.contentFill = NO;
+    /*        Set whether the curve path         */
+    historyRecordLineChart.pathCurve = YES;
+    /*        Set fill color array      ���������������������������������    */
+    historyRecordLineChart.contentFillColorArr = @[[UIColor orangeColor]];
+    
+    [self.view addSubview:historyRecordLineChart];
+    /*       Start animation        */
+    [historyRecordLineChart showAnimation];
+    
+    //GloriaLabel * timeTips = [[GloriaLabel alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-200)/2, 215+150, 200, 30)];
+    //[timeTips setText:@"������(���)"];
+    //timeTips.textColor = RgbColor(171, 172, 173);
+    //timeTips.textAlignment = UITextAlignmentCenter;
+    //timeTips.font = [UIFont boldSystemFontOfSize:14];
+    //[self.view addSubview:timeTips];
+    
+}
+
+-(void) reDrawLine
+{
+    if( modelArray.count == 10 )
+    {
+        [historyRecordLineChart.xLineDataArr removeAllObjects];
+        [historyRecordLineChart.valueArr removeAllObjects];
+    }
+    
+    for (int i = 0; i < modelArray.count; i++)
+    {
+        //LiveDataModel * model = [modelArray objectAtIndex:i];
+        
+        //[historyRecordLineChart.valueArr addObject:model.x5];
+        [historyRecordLineChart.xLineDataArr addObject:[NSString stringWithFormat:@"%d",i]];
+    }
+    
+    /*Start animation*/
+    [historyRecordLineChart  showAnimation];
 }
 
 -(void)backAticon
@@ -44,6 +378,7 @@
     // Dispose of any resources that can be recreated.
 }
 
+
 /*
 #pragma mark - Navigation
 

--
Gitblit v1.8.0