From 1d39caf7235522ae121db7a188ba41a706217407 Mon Sep 17 00:00:00 2001
From: 单军华 <WindShan@danjunhuas-MacBook-Pro.local>
Date: Sat, 28 Apr 2018 09:39:49 +0800
Subject: [PATCH] 清理多余代码,优化

---
 pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m |   90 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 81 insertions(+), 9 deletions(-)

diff --git a/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m b/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m
index 50621ba..3953ee9 100644
--- a/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m
+++ b/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m
@@ -9,6 +9,8 @@
 #import "HistoryRecordPage.h"
 #import "GloriaLabel.h"
 #import "NetworkSingleton.h"
+#import "AdNoticeView.h"
+#import "NoticeModel.h"
 
 @interface HistoryRecordPage ()
 {
@@ -23,7 +25,12 @@
     NSDate *initialDate;
     GloriaLabel* _BeginTimesLabel;
     GloriaLabel* _EndTimesLabel;
+    NSString * _beginTimeStr;
+    NSString * _EndTimeStr;
 }
+
+@property (nonatomic, strong) AdNoticeView * adNoticeView; // ������������
+
 @end
 
 @implementation HistoryRecordPage
@@ -129,6 +136,9 @@
     _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
     [self.view  addSubview:_BeginTimesLabel];
     
+    _beginTimeStr = _BeginTimesLabel.text;
+    _EndTimeStr = _beginTimeStr;
+    
     GloriaLabel* _TimesLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 20,SCREEN_WIDTH, 20)];
     _TimesLabel.font = [UIFont boldSystemFontOfSize:14];
     _TimesLabel.textAlignment = UITextAlignmentCenter;
@@ -159,8 +169,7 @@
     [_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];
@@ -169,10 +178,12 @@
     _UnitTipsLabel.font = [UIFont boldSystemFontOfSize:14];
     _UnitTipsLabel.textAlignment = UITextAlignmentCenter;
     _UnitTipsLabel.textColor = RgbColor(0, 146, 252);
-    _UnitTipsLabel.text = @"���������(������)";
+    _UnitTipsLabel.text = @"���������(������)";
     [self.view  addSubview:_UnitTipsLabel];
     
     [self GetUserDataList];
+    
+    [self GetNoticeInfo];
     // Do any additional setup after loading the view.
 }
 
@@ -181,6 +192,17 @@
     CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:CurrentDate dayCount:-(currentUnit+1)]];
     _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
     _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+    
+    _beginTimeStr = [NSString stringWithFormat:@"%@",_BeginTimesLabel.text];
+    if(currentUnit == 1)
+    {
+        _EndTimeStr = _BeginTimesLabel.text ;
+    }
+    else
+    {
+        _EndTimeStr = _EndTimesLabel.text;
+    }
+    
     [self GetUserDataList];
 }
 
@@ -196,15 +218,12 @@
 }
 
 
--(void)GetUserDataList
+-(void)GetNoticeInfo
 {
     //[UserDefault stringForKey:@"user_id"]
-    NSString *path = [[NSString alloc] initWithFormat:GET_DATALIST];
+    NSString *path = [[NSString alloc] initWithFormat:GET_NOTICE];
     
     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)
@@ -217,6 +236,54 @@
              //[UserDefault setObject:self.is_open_upload forKey:@"is_open_upload"];
              [UserDefault synchronize];
              
+             
+             NoticeModel * model = [NoticeModel mj_objectWithKeyValues:resModel.content];
+             
+             if (self.adNoticeView == nil)
+             {
+                 self.adNoticeView = [[AdNoticeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) dataModel:model];
+                 //self.adNoticeView.delegate = self;
+                 [self.view addSubview:self.adNoticeView];
+             }
+            else
+            {
+               [self.adNoticeView setUIView:model];
+            }
+         }
+         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)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:_beginTimeStr forKey:@"start_time"];
+    [params setValue:_EndTimeStr 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];
          }
@@ -243,6 +310,7 @@
     _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
     _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
     [self GetUserDataList];
+    _UnitTipsLabel.text = @"���������(������)";
 }
 
 -(void)unitWeekLogin
@@ -255,6 +323,7 @@
     _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
     _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
     [self GetUserDataList];
+    _UnitTipsLabel.text = @"���������(������)";
 }
 
 -(void)unitDayLogin
@@ -266,6 +335,9 @@
     CurrentDate = [DateUtil dateFromStringYMD:[DateUtil stringFromOffDateYMD:[NSDate date] dayCount:-1]];
     _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit];
     _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate];
+    _beginTimeStr = [NSString stringWithFormat:@"%@",_BeginTimesLabel.text];
+    _EndTimeStr = _BeginTimesLabel.text ;
+    _UnitTipsLabel.text = @"���������(������)";
     [self GetUserDataList];
 }
 
@@ -291,7 +363,7 @@
     {
         //LiveDataModel * model = [modelArray objectAtIndex:i];
         
-        [valueTeampArr addObject:[NSString stringWithFormat:@"%d",i*(rand()%10)]];
+        [valueTeampArr addObject:[NSString stringWithFormat:@"%d",0]];
         [historyRecordLineChart.xLineDataArr addObject:[NSString stringWithFormat:@"%d",i]];
     }
     

--
Gitblit v1.8.0