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.
170 lines
5.6 KiB
170 lines
5.6 KiB
// |
|
// StepViewController.m |
|
// LekangGuard |
|
// |
|
// Created by ecell on 2022/12/9. |
|
// |
|
|
|
#import "StepViewController.h" |
|
#import "NewStepChartCell.h" |
|
|
|
@interface StepViewController ()<UITableViewDelegate,UITableViewDataSource> |
|
|
|
@property (nonatomic ,strong) UITableView *stepTable; |
|
|
|
/// 今天的步数 |
|
@property (assign, nonatomic) NSInteger todayData; |
|
|
|
/// 一周步数 |
|
@property (nonatomic ,strong) NSMutableArray *weekStepArr; |
|
|
|
|
|
@property (nonatomic ,strong) UILabel *bottomLabelView; |
|
|
|
@end |
|
|
|
@implementation StepViewController |
|
|
|
- (void)viewDidLoad { |
|
[super viewDidLoad]; |
|
// Do any additional setup after loading the view. |
|
self.zx_navTitle = GJText(@"计步"); |
|
self.todayData = 0; |
|
[self QueryCurrentStep]; |
|
[self QueryWeekStep]; |
|
[self.view addSubview:self.stepTable]; |
|
[self.stepTable mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.view); |
|
make.top.equalTo(self.view).offset(iPhoneX_NavHeight); |
|
make.bottom.equalTo(self.view.mas_bottom); |
|
}]; |
|
} |
|
|
|
- (UITableView *)stepTable |
|
{ |
|
if (!_stepTable) |
|
{ |
|
_stepTable = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; |
|
_stepTable.backgroundColor = KKClearColor; |
|
_stepTable.delegate = self; |
|
_stepTable.dataSource = self; |
|
|
|
_stepTable.bounces = NO; //禁止弹跳 |
|
_stepTable.showsHorizontalScrollIndicator = NO; |
|
_stepTable.showsVerticalScrollIndicator = NO; |
|
//去线 |
|
_stepTable.separatorStyle = UITableViewCellSelectionStyleNone; |
|
// iOS 11 系统 tableView 会自动调整高度 在 Gounp 模式下 头部的高度会有问题 ,需要对 预设的高度设置为0 |
|
_stepTable.estimatedRowHeight = 0; |
|
_stepTable.estimatedSectionHeaderHeight = 0; |
|
_stepTable.estimatedSectionFooterHeight = 0; |
|
[_stepTable registerNib:[UINib nibWithNibName:@"NewStepChartCell" bundle:nil] forCellReuseIdentifier:@"NewStepChartCellID"]; |
|
_stepTable.tableFooterView = self.bottomLabelView; |
|
} |
|
return _stepTable; |
|
} |
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section |
|
{ |
|
return 1; |
|
} |
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section |
|
{ |
|
return 0.01; |
|
} |
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
return 461; |
|
} |
|
|
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath |
|
{ |
|
NewStepChartCell *cell = [tableView dequeueReusableCellWithIdentifier:@"NewStepChartCellID" forIndexPath:indexPath]; |
|
if(self.weekStepArr) |
|
{ |
|
[cell setStepDataList:self.weekStepArr WithTodayData:self.todayData]; |
|
} |
|
return cell; |
|
} |
|
|
|
#pragma mark 头部提示View |
|
/// 头部提示View |
|
- (UILabel *)bottomLabelView |
|
{ |
|
if (!_bottomLabelView) |
|
{ |
|
UIEdgeInsets insets = {10, 10, 10, 10}; |
|
_bottomLabelView = [UICommon ui_label:CGRectMake(15, 10, SCREEN_WIDTH-30, Adapted(50)) lines:0 align:NSTextAlignmentLeft font:FontADA_(13) textColor:[UIColor systemGrayColor] text:GJText(@"温馨提示:每天累计步数,到24点清零") Radius:0]; |
|
// [_bottomLabelView drawTextInRect:UIEdgeInsetsInsetRect(_bottomLabelView.frame, insets)]; |
|
// _bottomLabelView.adjustsFontSizeToFitWidth = YES; |
|
// _bottomLabelView.baselineAdjustment = UIBaselineAdjustmentAlignCenters; |
|
} |
|
return _bottomLabelView; |
|
} |
|
|
|
#pragma mark 查询今日计步数 |
|
/// 查询今日计步数 |
|
- (void)QueryCurrentStep |
|
{ |
|
[UICommon MessageUpload:@"加载中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:APIManager.sharedManager.deviceModel.imei forKey:@"imei"]; |
|
//[parameters setValue:APIManager.sharedManager.loginModel.openid forKey:@"openid"]; |
|
[[[APIManager sharedManager] APGET:QueryCurrentStep_URL parameters:parameters resultClass:StepModel.class] subscribeNext:^(StepModel *model) { |
|
[UICommon HidenLoading]; |
|
if (model) |
|
{ |
|
self.todayData = model.walksNum; |
|
} |
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
#pragma mark 查询一周计步数 |
|
/// 查询一周计步数 |
|
- (void)QueryWeekStep |
|
{ |
|
[UICommon MessageUpload:@"加载中"]; |
|
NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
|
[parameters setValue:APIManager.sharedManager.deviceModel.imei forKey:@"imei"]; |
|
[[[APIManager sharedManager] APGET:QueryWeekStep_URL parameters:parameters resultClass:nil] subscribeNext:^(NSArray *arr) { |
|
[UICommon HidenLoading]; |
|
[self.weekStepArr removeAllObjects]; |
|
if (ARRAYHASVALUE(arr)) |
|
{ |
|
for (NSDictionary *dic in arr) |
|
{ |
|
StepModel *model = [StepModel yy_modelWithJSON:dic]; |
|
[self.weekStepArr addObject:model]; |
|
} |
|
} |
|
[self.stepTable reloadData]; |
|
|
|
} error:^(NSError * _Nullable error) { |
|
NSDictionary *dic = error.userInfo; |
|
[UICommon MessageErrorText:dic[NSLocalizedDescriptionKey]]; |
|
}]; |
|
} |
|
|
|
- (NSMutableArray *)weekStepArr |
|
{ |
|
if (!_weekStepArr) _weekStepArr = [NSMutableArray new]; |
|
return _weekStepArr; |
|
} |
|
|
|
/* |
|
#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
|
|
|