| | |
| | | #import "HistoryRecordPage.h" |
| | | #import "GloriaLabel.h" |
| | | #import "NetworkSingleton.h" |
| | | #import "AdNoticeView.h" |
| | | #import "NoticeModel.h" |
| | | #import "HistoryDataModel.h" |
| | | |
| | | @interface HistoryRecordPage () |
| | | { |
| | |
| | | NSDate *initialDate; |
| | | GloriaLabel* _BeginTimesLabel; |
| | | GloriaLabel* _EndTimesLabel; |
| | | NSString * _beginTimeStr; |
| | | NSString * _EndTimeStr; |
| | | GloriaLabel* _StatusLabel; |
| | | GloriaLabel* _YearLabel; |
| | | } |
| | | |
| | | @property (nonatomic, strong) AdNoticeView * adNoticeView; // 广告控件 |
| | | |
| | | @end |
| | | |
| | | @implementation HistoryRecordPage |
| | |
| | | self.title = @"历史记录"; |
| | | [self setNavigationLeft:@"ic_back_arraw.png" sel:@selector(backAticon)]; |
| | | |
| | | UIImageView * ic_bottom_bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-112-64, SCREEN_WIDTH, 112)]; |
| | | UIImageView * ic_bottom_bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-112-NavBar_Height, SCREEN_WIDTH, 112)]; |
| | | ic_bottom_bg.image = [UIImage imageNamed:@"ic_bottom_bg"]; |
| | | ic_bottom_bg.userInteractionEnabled = YES; |
| | | [self.view addSubview:ic_bottom_bg]; |
| | |
| | | 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的大小 |
| | |
| | | _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)]; |
| | |
| | | _BeginTimesLabel.textColor = RgbColor(0, 146, 252); |
| | | _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]; |
| | |
| | | [_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 = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-112-NavBar_Height-30, SCREEN_WIDTH, 20)]; |
| | | _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. |
| | | } |
| | | |
| | |
| | | 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]; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | -(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) |
| | |
| | | //[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) |
| | | { |
| | | _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 |
| | | { |
| | |
| | | _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit]; |
| | | _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate]; |
| | | [self GetUserDataList]; |
| | | _UnitTipsLabel.text = @"时间段(按月)"; |
| | | } |
| | | |
| | | -(void)unitWeekLogin |
| | |
| | | _BeginTimesLabel.text = [DateUtil stringFromOffDateYMD:CurrentDate dayCount:-currentUnit]; |
| | | _EndTimesLabel.text = [DateUtil stringFromDateYMD:CurrentDate]; |
| | | [self GetUserDataList]; |
| | | _UnitTipsLabel.text = @"时间段(按周)"; |
| | | } |
| | | |
| | | -(void)unitDayLogin |
| | |
| | | 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]; |
| | | } |
| | | |
| | |
| | | { |
| | | |
| | | /* Create object */ |
| | | historyRecordLineChart = [[JHLineChart alloc] initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH-20, SCREEN_HEIGHT-112-64-40-40-20) andLineChartType:JHChartLineEveryValueForEveryX]; |
| | | historyRecordLineChart = [[JHLineChart alloc] initWithFrame:CGRectMake(0, 60, SCREEN_WIDTH-20, SCREEN_HEIGHT-112-NavBar_Height-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.*/ |
| | | |
| | |
| | | { |
| | | //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]]; |
| | | } |
| | | |