You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
282 lines
9.9 KiB
282 lines
9.9 KiB
![]()
2 years ago
|
//
|
||
|
// BloodAndOxygenViewController.m
|
||
|
// tongxin
|
||
|
//
|
||
|
// Created by ecell on 2023/4/27.
|
||
|
// Copyright © 2023 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "BloodAndOxygenViewController.h"
|
||
|
#import "VRGCalendarView.h"
|
||
|
#import "BloodAndOxygenTableViewCell.h"
|
||
|
#import "BloodAndOxygenHeaderView.h"
|
||
|
#import "CommonTableView.h"
|
||
|
|
||
|
@interface BloodAndOxygenViewController ()<VRGCalendarViewDelegate>
|
||
|
|
||
|
|
||
|
@property (nonatomic ,strong) CommonTableView *commTable;
|
||
|
|
||
|
@property (nonatomic ,strong) BloodAndOxygenHeaderView *headerView;
|
||
|
|
||
|
/// 当前时间
|
||
|
@property (nonatomic ,weak) UIButton *centerBtn;
|
||
|
|
||
|
|
||
|
@property (nonatomic ,strong) VRGCalendarView *calendar;
|
||
|
|
||
|
|
||
|
@property (nonatomic ,strong) UIControl *overlayView;
|
||
|
|
||
|
|
||
|
@property (nonatomic ,weak) UIButton *rightBtn;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation BloodAndOxygenViewController
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
// Do any additional setup after loading the view.
|
||
|
self.view.backgroundColor = UIColor.whiteColor;
|
||
|
NSString *today = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970];
|
||
|
UIButton *leftBtn = [UIButton new];
|
||
|
leftBtn.backgroundColor = mainColor;
|
||
|
[leftBtn setTitle:@"前一天" forState:0];
|
||
|
[leftBtn setTitleColor:UIColor.whiteColor forState:0];
|
||
|
leftBtn.titleLabel.font = Font_(12);
|
||
|
leftBtn.layer.cornerRadius = 3;
|
||
|
leftBtn.layer.masksToBounds = YES;
|
||
|
leftBtn.tag = 0;
|
||
|
[leftBtn addTarget:self action:@selector(switchTime:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self.view addSubview:leftBtn];
|
||
|
[leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.equalTo(self.view).offset(15);
|
||
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight+15);
|
||
|
make.size.mas_equalTo(CGSizeMake(60, 25));
|
||
|
}];
|
||
|
|
||
|
UIButton *rightBtn = [UIButton new];
|
||
|
rightBtn.backgroundColor = mainColor;
|
||
|
[rightBtn setTitle:@"后一天" forState:0];
|
||
|
[rightBtn setTitleColor:UIColor.whiteColor forState:0];
|
||
|
rightBtn.titleLabel.font = Font_(12);
|
||
|
rightBtn.layer.cornerRadius = 3;
|
||
|
rightBtn.layer.masksToBounds = YES;
|
||
|
rightBtn.tag = 1;
|
||
|
[rightBtn addTarget:self action:@selector(switchTime:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
self.rightBtn = rightBtn;
|
||
|
[self.view addSubview:rightBtn];
|
||
|
[rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.right.equalTo(self.view.mas_right).inset(15);
|
||
|
make.centerY.equalTo(leftBtn);
|
||
|
make.size.mas_equalTo(CGSizeMake(60, 25));
|
||
|
}];
|
||
|
|
||
|
UIButton *centerBtn = [UIButton new];
|
||
|
[centerBtn setTitle:@"今天" forState:0];
|
||
|
[centerBtn setTitleColor:UIColor.blackColor forState:0];
|
||
|
centerBtn.titleLabel.font = Font_(12);
|
||
|
centerBtn.tag = 2;
|
||
|
[centerBtn addTarget:self action:@selector(switchTime:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
self.centerBtn = centerBtn;
|
||
|
[self.view addSubview:centerBtn];
|
||
|
[centerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.centerX.equalTo(self.view);
|
||
|
make.centerY.equalTo(leftBtn);
|
||
|
make.size.mas_equalTo(CGSizeMake(120, 25));
|
||
|
}];
|
||
|
[self getModel:today];
|
||
|
|
||
|
[self.view addSubview:self.commTable];
|
||
|
[self.commTable mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.left.right.equalTo(self.view);
|
||
|
make.top.equalTo(leftBtn.mas_bottom).offset(15);
|
||
|
make.bottom.equalTo(self.view.mas_bottom);
|
||
|
}];
|
||
|
|
||
|
}
|
||
|
|
||
|
- (BloodAndOxygenHeaderView *)headerView
|
||
|
{
|
||
|
if (!_headerView)
|
||
|
{
|
||
|
_headerView = [[BloodAndOxygenHeaderView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-110)];
|
||
|
_headerView.types = self.types;
|
||
|
}
|
||
|
return _headerView;
|
||
|
}
|
||
|
|
||
|
- (CommonTableView *)commTable
|
||
|
{
|
||
|
if (!_commTable)
|
||
|
{
|
||
|
_commTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:0 cellRow:0 isAdaptive:NO isLine:NO commonCell:BloodAndOxygenTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) {
|
||
|
|
||
|
} selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) {
|
||
|
|
||
|
} DidscrollView:^(UIScrollView * _Nonnull scrollView) {
|
||
|
|
||
|
}];
|
||
|
}
|
||
|
_commTable.tableHeaderView = self.headerView;
|
||
|
_commTable.tableHeaderView.height = ScreenHeight-110;
|
||
|
|
||
|
return _commTable;
|
||
|
}
|
||
|
|
||
|
|
||
|
/// 按钮点击方法
|
||
|
- (void)switchTime:(UIButton *)sender
|
||
|
{
|
||
|
if (sender.tag == 0)
|
||
|
{
|
||
|
/// 前一天
|
||
|
NSString *paramsDay;
|
||
|
if([self.centerBtn.titleLabel.text isEqualToString:@"今天"])
|
||
|
{
|
||
|
//昨天
|
||
|
paramsDay = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970 - 60*60*24];
|
||
|
[self.centerBtn setTitle:@"昨天" forState:0];
|
||
|
}
|
||
|
else if([self.centerBtn.titleLabel.text isEqualToString:@"昨天"])
|
||
|
{
|
||
|
paramsDay = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970 - 2 * 60*60*24];
|
||
|
[self.centerBtn setTitle:paramsDay forState:0];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//当前位置的天数转换成的时间戳
|
||
|
NSTimeInterval tempTime = [myHelper getDateWithStr:self.centerBtn.titleLabel.text dateFormat:@"yyyy-MM-dd"].timeIntervalSince1970;
|
||
|
paramsDay = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:tempTime - 60*60*24];
|
||
|
[self.centerBtn setTitle:paramsDay forState:0];
|
||
|
}
|
||
|
[self getModel:paramsDay];
|
||
|
|
||
|
}
|
||
|
else if (sender.tag == 1)
|
||
|
{
|
||
|
/// 后一天
|
||
|
if([self.centerBtn.titleLabel.text isEqualToString:@"昨天"])
|
||
|
{
|
||
|
[self.centerBtn setTitle:@"今天" forState:0];
|
||
|
NSString *today = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970];
|
||
|
[self getModel:today];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if ([self.centerBtn.titleLabel.text isEqualToString:@"今天"])
|
||
|
return;
|
||
|
//当前位置的天数转换成的时间戳
|
||
|
NSTimeInterval tempTime = [myHelper getDateWithStr:self.centerBtn.titleLabel.text dateFormat:@"yyyy-MM-dd"].timeIntervalSince1970;
|
||
|
NSString *paramsDay = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:tempTime + 60*60*24];
|
||
|
//对比昨天和今天
|
||
|
//昨天
|
||
|
NSString *yesterday = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970 - 60*60*24];
|
||
|
//今天
|
||
|
NSString *today = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970];
|
||
|
if([paramsDay isEqualToString:yesterday])
|
||
|
[self.centerBtn setTitle:@"昨天" forState:0];
|
||
|
else if([paramsDay isEqualToString:today])
|
||
|
[self.centerBtn setTitle:@"今天" forState:0];
|
||
|
else
|
||
|
[self.centerBtn setTitle:paramsDay forState:0];
|
||
|
|
||
|
[self getModel:paramsDay];
|
||
|
}
|
||
|
}
|
||
|
else if (sender.tag == 2)
|
||
|
{
|
||
|
[self dismissCalendarView];
|
||
|
_overlayView = [[UIControl alloc]initWithFrame:self.view.bounds];
|
||
|
[_overlayView addTarget:self action:@selector(dismissCalendarView) forControlEvents:UIControlEventTouchUpInside];
|
||
|
_calendar = [[VRGCalendarView alloc] init];
|
||
|
_calendar.limitDay = 60;
|
||
|
CGRect c = _calendar.frame;
|
||
|
c.origin.y = 125;
|
||
|
_calendar.frame = c;
|
||
|
_calendar.delegate=self;
|
||
|
|
||
|
_calendar.alpha = 1;
|
||
|
[self.view addSubview:_overlayView];
|
||
|
[self.view addSubview:_calendar];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)dismissCalendarView{
|
||
|
if(_overlayView){
|
||
|
[_overlayView removeFromSuperview];
|
||
|
_overlayView = nil;
|
||
|
[UIView animateWithDuration:0.35 animations:^{
|
||
|
self.calendar.alpha = 0;
|
||
|
}completion:^(BOOL finished) {
|
||
|
[self.calendar removeFromSuperview];
|
||
|
}];
|
||
|
|
||
|
}
|
||
|
}
|
||
|
#pragma mark - 日期选择Delegate
|
||
|
-(void)calendarView:(VRGCalendarView *)calendarView switchedToMonth:(int)month targetHeight:(float)targetHeight animated:(BOOL)animated {
|
||
|
|
||
|
}
|
||
|
|
||
|
-(void)calendarView:(VRGCalendarView *)calendarView dateSelected:(NSDate *)date {
|
||
|
|
||
|
NSString *selectDay = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" date:date];
|
||
|
//对比昨天和今天
|
||
|
//昨天
|
||
|
NSString *yesterday = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970 - 60*60*24];
|
||
|
//今天
|
||
|
NSString *today = [myHelper getDateFormatWithStr:@"yyyy-MM-dd" timeInterval:[NSDate date].timeIntervalSince1970];
|
||
|
if([selectDay isEqualToString:yesterday])
|
||
|
[self.centerBtn setTitle:@"昨天" forState:0];
|
||
|
else if([selectDay isEqualToString:today])
|
||
|
[self.centerBtn setTitle:@"今天" forState:0];
|
||
|
else
|
||
|
[self.centerBtn setTitle:selectDay forState:0];
|
||
|
|
||
|
|
||
|
[self getModel:yesterday];
|
||
|
[self dismissCalendarView];
|
||
|
}
|
||
|
|
||
|
- (void)getModel:(NSString *)time
|
||
|
{
|
||
|
self.rightBtn.enabled = [self.centerBtn.currentTitle isEqualToString:@"今天"] ? NO : YES;
|
||
|
self.rightBtn.alpha = [self.centerBtn.currentTitle isEqualToString:@"今天"] ? .5 : 1;
|
||
|
WEAKSELF
|
||
|
[cUser GetBloodModel:time Url:self.types == 888 ? HTTP_HHTWHITE__BLOOD : HTTP_HHTWHITE__OXYGEN Success:^(id responseObject) {
|
||
|
|
||
|
NSLog(@"%@",responseObject);
|
||
|
weakSelf.headerView.dayTime = time;
|
||
|
weakSelf.headerView.msgDic = responseObject;
|
||
|
[weakSelf.commTable reloadData];
|
||
|
if(weakSelf.types == 888)
|
||
|
{
|
||
|
/// 血压
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
/// 血氧
|
||
|
}
|
||
|
|
||
|
} failure:^(NSError *error) {
|
||
|
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/*
|
||
|
#pragma mark - Navigation
|
||
|
|
||
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||
|
// Get the new view controller using [segue destinationViewController].
|
||
|
// Pass the selected object to the new view controller.
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
@end
|