From 7db6ba57b17fb7c0c364219750b14ee3d5cc351b Mon Sep 17 00:00:00 2001 From: 单军华 <WindShan@danjunhuas-MacBook-Pro.local> Date: Fri, 04 May 2018 08:34:16 +0800 Subject: [PATCH] 报警声音和历史数据提交 --- pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m | 102 +++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 86 insertions(+), 16 deletions(-) diff --git a/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m b/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m index 5e30416..56ea0ac 100644 --- a/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m +++ b/pregnancy_guard/BaseProject/Controller/Mine/HistoryRecordPage.m @@ -11,6 +11,7 @@ #import "NetworkSingleton.h" #import "AdNoticeView.h" #import "NoticeModel.h" +#import "HistoryDataModel.h" @interface HistoryRecordPage () { @@ -27,6 +28,8 @@ GloriaLabel* _EndTimesLabel; NSString * _beginTimeStr; NSString * _EndTimeStr; + GloriaLabel* _StatusLabel; + GloriaLabel* _YearLabel; } @property (nonatomic, strong) AdNoticeView * adNoticeView; // ������������ @@ -91,18 +94,18 @@ 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)]; + GloriaLabel* _AvgValueLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/4, 15 + 25 + 10,SCREEN_WIDTH/4, 20)]; _AvgValueLabel.font = [UIFont systemFontOfSize:14]; - _AvgValueLabel.textAlignment = UITextAlignmentCenter; + _AvgValueLabel.textAlignment = UITextAlignmentLeft; _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 = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 15 + 25 + 10 + 20,SCREEN_WIDTH/4, 30)]; _YearLabel.font = [UIFont boldSystemFontOfSize:18]; - _YearLabel.textAlignment = UITextAlignmentCenter; + _YearLabel.textAlignment = UITextAlignmentRight; _YearLabel.textColor = kUIColorFromRGB(0xffffff); - _YearLabel.text = @"10"; + _YearLabel.text = @"0"; [ic_bottom_bg addSubview:_YearLabel]; // ���������������������������label��������� @@ -122,11 +125,11 @@ _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 = [[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 = @"������"; + _StatusLabel.text = @"������"; [ic_bottom_bg addSubview:_StatusLabel]; _BeginTimesLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH, 20)]; @@ -183,11 +186,7 @@ [self GetUserDataList]; - NoticeModel * model = [[NoticeModel alloc] init]; - self.adNoticeView = [[AdNoticeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) dataModel:model]; - //self.adNoticeView.delegate = self; - [self.view addSubview:self.adNoticeView]; - + [self GetNoticeInfo]; // Do any additional setup after loading the view. } @@ -221,6 +220,52 @@ } } + +-(void)GetNoticeInfo +{ + //[UserDefault stringForKey:@"user_id"] + NSString *path = [[NSString alloc] initWithFormat:GET_NOTICE]; + + NSMutableDictionary * params = [[NSMutableDictionary alloc] init]; + + 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]; + + + 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"] @@ -239,11 +284,36 @@ if(resModel.code == 0) { - //[UserDefault setObject:self.is_open_upload forKey:@"is_open_upload"]; - [UserDefault synchronize]; + _StatusLabel.text = [resModel.content objectForKey:@"status"]; + float avg = [[resModel.content objectForKey:@"avg"] floatValue]; + _YearLabel.text = [NSString stringWithFormat:@"%02.02f",avg]; + NSMutableArray * TempArr = [HistoryDataModel mj_objectArrayWithKeyValuesArray:[resModel.content objectForKey:@"data"]]; + + if( [TempArr count] == 0 ) + { + [Global alertMessageEx:resModel.desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + } + else + { + [modelArray removeAllObjects]; + [modelArray addObjectsFromArray:TempArr]; + [historyRecordLineChart.valueArr removeAllObjects]; + [historyRecordLineChart.valueArr addObjectsFromArray:modelArray]; + [historyRecordLineChart.xLineDataArr removeAllObjects]; + for (NSInteger i = 0; i < modelArray.count; i++) + { + [historyRecordLineChart.xLineDataArr addObject:[NSString stringWithFormat:@"%d",i]]; + } + + // [valuepm25Arr replaceObjectAtIndex:7 withObject: [NSString stringWithFormat:@"%ld",[model.x1 integerValue]/100 + i]]; + // [valueco2Arr replaceObjectAtIndex:7 withObject:[NSString stringWithFormat:@"%ld",[model.x5 integerValue]/1000 +i]]; + + [historyRecordLineChart clearLine]; + } + //[self.tableView reloadData]; - [Global alertMessageEx:resModel.desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; + //[Global alertMessageEx:resModel.desc title:@"������������" okTtitle:nil cancelTitle:@"OK" delegate:self]; } else { @@ -321,7 +391,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