首页手表监测
This commit is contained in:
@@ -86,8 +86,8 @@
|
||||
|
||||
//#define Http @"https://xj-api.mcrm.vip:8888"//
|
||||
#define Http @"http://192.168.1.47"//王昊
|
||||
#define H5DevHost @"xj-admin.mcrm.vip:8888"//
|
||||
#define IntervenH5 @"https://console-xj-admin.mcrm.vip:8888"
|
||||
#define H5DevHost @"xj-api.mcrm.vip:8888"//
|
||||
#define IntervenH5 @"https://xj-admin.mcrm.vip:8888"
|
||||
#define SCHEME @"https" //
|
||||
|
||||
//新疆项目后期的调试环境由阿里云迁移至公司内部主机服务器,功能联调和测试可用以下的环境地址
|
||||
|
||||
@@ -15,16 +15,10 @@
|
||||
|
||||
@interface XJHomePageV2HeardView ()<SDCycleScrollViewDelegate>
|
||||
|
||||
@property (nonatomic, strong) UIView * messageview;
|
||||
|
||||
|
||||
@property (nonatomic, strong) SDCycleScrollView * adTitleView;
|
||||
|
||||
@property (nonatomic, strong) UILabel * nameLabel;
|
||||
|
||||
@property (nonatomic, strong) XJHomeWatchDataView * watchDataView;
|
||||
|
||||
|
||||
@property (nonatomic, strong) UIView *messageview;
|
||||
@property (nonatomic, strong) SDCycleScrollView *adTitleView;
|
||||
@property (nonatomic, strong) UILabel *nameLabel;
|
||||
@property (nonatomic, strong) XJHomeWatchDataView *watchDataView;
|
||||
|
||||
@end
|
||||
|
||||
@@ -309,12 +303,23 @@
|
||||
|
||||
//手表数据
|
||||
self.watchDataView = [[XJHomeWatchDataView alloc] initWithFrame:CGRectZero];
|
||||
self.watchDataView.tabTitles = @[@"心脑血管", @"癌症", @"慢呼", @"糖尿病", @"亚健康",@"心脑血管", @"癌症", @"慢呼", @"糖尿病", @"亚健康"];
|
||||
self.watchDataView.tabTitles = @[@"心脑血管", @"癌症", @"慢呼", @"糖尿病", @"亚健康"];
|
||||
self.watchDataView.tabSelectBlock = ^(NSInteger index, NSString *title) {
|
||||
DLog(@"选中 %ld - %@", index, title);
|
||||
// 切换 collectionView 到对应 page
|
||||
|
||||
};
|
||||
MJWeakSelf
|
||||
self.watchDataView.tabSelectBlock = ^(NSInteger index, NSString *title) {
|
||||
// tab 0 完整高度,其他收缩(header 40 + tab 52 + 内容区 68 = 160)
|
||||
CGFloat height = (index == 0) ? 250 : 160;
|
||||
[weakSelf.watchDataView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(height);
|
||||
}];
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
[weakSelf layoutIfNeeded];
|
||||
}];
|
||||
};
|
||||
self.watchDataView.watchMoreBlock = ^{
|
||||
if ([self.homeTopDelegate respondsToSelector:@selector(watchDetailClick)]) {
|
||||
[self.homeTopDelegate watchDetailClick];
|
||||
@@ -326,7 +331,7 @@
|
||||
[self.watchDataView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_offset(12);
|
||||
make.right.mas_offset(-12);
|
||||
make.height.mas_offset(300);
|
||||
make.height.mas_offset(250);
|
||||
make.top.mas_equalTo(lastImageView.mas_bottom).offset(12);
|
||||
}];
|
||||
|
||||
|
||||
+15
-21
@@ -137,32 +137,26 @@
|
||||
make.left.mas_offset(13);
|
||||
make.top.bottom.mas_offset(0);
|
||||
}];
|
||||
|
||||
|
||||
YYLabel * morelabel = [[YYLabel alloc] init];
|
||||
|
||||
morelabel.text = @">";
|
||||
morelabel.textAlignment = NSTextAlignmentRight;
|
||||
morelabel.textColor = UIColorHex(#999999);
|
||||
morelabel.font = SYSTEMFONT(14);
|
||||
MJWeakSelf
|
||||
[morelabel setTextTapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
if (self.lookMoreBlock) {
|
||||
self.lookMoreBlock();
|
||||
}
|
||||
}];
|
||||
[sectionHeardView addSubview:morelabel];
|
||||
|
||||
[morelabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_offset(-13);
|
||||
|
||||
UIButton * moreBtn = [[UIButton alloc] init];
|
||||
[moreBtn setImage:[UIImage imageNamed:@"wacthRightAccow"] forState:UIControlStateNormal];
|
||||
[moreBtn addTarget:self action:@selector(moreClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[sectionHeardView addSubview:moreBtn];
|
||||
[moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_offset(-8);
|
||||
make.centerY.mas_equalTo(sectionHeardView);
|
||||
make.width.height.mas_offset(20);
|
||||
make.width.height.mas_offset(30);
|
||||
}];
|
||||
|
||||
return sectionHeardView;
|
||||
|
||||
}
|
||||
|
||||
- (void)moreClick {
|
||||
|
||||
if (self.lookMoreBlock) {
|
||||
self.lookMoreBlock();
|
||||
}
|
||||
|
||||
}
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
|
||||
|
||||
return [[UIView alloc] init];
|
||||
|
||||
+19
-18
@@ -22,7 +22,7 @@
|
||||
@property (nonatomic, strong) UILabel *leftDataLabel; // 左卡数据
|
||||
@property (nonatomic, strong) UILabel *backRightLabel; // 右卡标题 "平均心率"
|
||||
@property (nonatomic, strong) UILabel *rightDataLabel; // 右卡数据
|
||||
@property (nonatomic, strong) UILabel *timeLabel; // 底部更新时间
|
||||
//@property (nonatomic, strong) UILabel *timeLabel; // 底部更新时间
|
||||
@property (nonatomic, strong) UIView *emptyView;
|
||||
@property (nonatomic, strong) XJHomeWatchModel *model;
|
||||
@property (nonatomic, assign) NSInteger currentTabIndex;
|
||||
@@ -54,10 +54,11 @@
|
||||
|
||||
[self.heartImg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.contentView).offset(15);
|
||||
make.top.equalTo(self.contentView).offset(kRealValue(24));
|
||||
make.top.equalTo(self.contentView).offset(13);
|
||||
make.size.mas_equalTo(CGSizeMake(32, 32));
|
||||
}];
|
||||
|
||||
|
||||
// ── 类型标题 "最新心率" ───────────────────────────────
|
||||
self.updateLabel = [[UILabel alloc] init];
|
||||
self.updateLabel.font = BOLDSYSTEMFONT(14);
|
||||
@@ -150,7 +151,7 @@
|
||||
make.top.equalTo(self.backLeftLabel.mas_bottom).offset(13);
|
||||
make.height.mas_equalTo(17);
|
||||
}];
|
||||
|
||||
|
||||
// ── 右卡片 ───────────────────────────────────────────
|
||||
UIView *backRight = [[UIView alloc] init];
|
||||
backRight.layer.cornerRadius = 8;
|
||||
@@ -204,19 +205,19 @@
|
||||
}];
|
||||
|
||||
// ── 底部更新时间 ─────────────────────────────────────
|
||||
self.timeLabel = [[UILabel alloc] init];
|
||||
self.timeLabel.textColor = UIColorHex(#77849E);
|
||||
self.timeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.timeLabel.text = @"更新时间:--:--";
|
||||
self.timeLabel.font = MEDIUMFONT(12);
|
||||
[self.contentView addSubview:self.timeLabel];
|
||||
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(backLeft.mas_bottom).offset(8);
|
||||
make.left.equalTo(self.contentView).offset(15);
|
||||
make.right.equalTo(self.contentView).offset(-15);
|
||||
make.height.mas_equalTo(32);
|
||||
}];
|
||||
// self.timeLabel = [[UILabel alloc] init];
|
||||
// self.timeLabel.textColor = UIColorHex(#77849E);
|
||||
// self.timeLabel.textAlignment = NSTextAlignmentLeft;
|
||||
// self.timeLabel.text = @"更新时间:--:--";
|
||||
// self.timeLabel.font = MEDIUMFONT(12);
|
||||
// [self.contentView addSubview:self.timeLabel];
|
||||
//
|
||||
// [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.top.equalTo(backLeft.mas_bottom).offset(8);
|
||||
// make.left.equalTo(self.contentView).offset(15);
|
||||
// make.right.equalTo(self.contentView).offset(-15);
|
||||
// make.height.mas_equalTo(32);
|
||||
// }];
|
||||
|
||||
// ── 无数据占位 ───────────────────────────────────────
|
||||
self.emptyView = [[UIView alloc] init];
|
||||
@@ -267,10 +268,10 @@
|
||||
|
||||
if (!ValidStr(_model.latestTime)) {
|
||||
self.updateTimeLabel.text = _model.latestTime;
|
||||
self.timeLabel.text = [NSString stringWithFormat:@"更新时间:%@", _model.latestTime];
|
||||
// self.timeLabel.text = [NSString stringWithFormat:@"更新时间:%@", _model.latestTime];
|
||||
} else {
|
||||
self.updateTimeLabel.text = @"--:--";
|
||||
self.timeLabel.text = @"更新时间:--:--";
|
||||
// self.timeLabel.text = @"更新时间:--:--";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ typedef void(^watchDataDetailBlick)();
|
||||
|
||||
@property (nonatomic, strong) XJHomeWatchModel * watchModel;
|
||||
|
||||
@property (nonatomic, copy) void (^changeTimeClickBlock)(NSString *startDate);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -29,7 +29,24 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
@property (nonatomic, strong) UICollectionView *collectionView;
|
||||
@property (nonatomic, strong) UILabel *emptyLabel; // 无数据占位
|
||||
@property (nonatomic, strong) UIView *devView; // 紧急开发中占位
|
||||
@property (nonatomic, assign) NSInteger selectedIndex;
|
||||
@property (nonatomic, assign) NSInteger selectedIndex; // 当前选中的 Tab 下标
|
||||
@property (nonatomic, assign) NSInteger carouselPage; // collectionView 当前轮播页码(与 Tab 无关)
|
||||
@property (nonatomic, strong) NSTimer *autoScrollTimer; // 轮播定时器
|
||||
|
||||
@property (nonatomic, strong) UIView *
|
||||
timeView;
|
||||
|
||||
@property (nonatomic, strong) UIButton *
|
||||
preBtn;
|
||||
|
||||
|
||||
@property (nonatomic, strong) UIButton *
|
||||
nextBtn;
|
||||
|
||||
@property (nonatomic, strong) UILabel *
|
||||
weekLabel;
|
||||
|
||||
@property (nonatomic, strong) NSDate * currentDayDate; // 当前选中的日
|
||||
|
||||
@end
|
||||
|
||||
@@ -52,8 +69,7 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
- (void)p_setupUI {
|
||||
_selectedIndex = 0;
|
||||
_tabButtons = [NSMutableArray array];
|
||||
|
||||
|
||||
self.currentDayDate = [NSDate date];
|
||||
UIImageView * heaedImg = [[UIImageView alloc] init];
|
||||
heaedImg.image = [UIImage imageNamed:@"heaedTitleBackImg"];
|
||||
heaedImg.userInteractionEnabled = true;
|
||||
@@ -83,26 +99,35 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
}];
|
||||
|
||||
|
||||
|
||||
YYLabel * morelabel = [[YYLabel alloc] init];
|
||||
morelabel.text = @">";
|
||||
morelabel.textAlignment = NSTextAlignmentRight;
|
||||
morelabel.textColor = UIColorHex(#999999);
|
||||
morelabel.font = SYSTEMFONT(14);
|
||||
MJWeakSelf
|
||||
[morelabel setTextTapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
if (self.watchMoreBlock) {
|
||||
self.watchMoreBlock();
|
||||
}
|
||||
}];
|
||||
[heaedImg addSubview:morelabel];
|
||||
|
||||
[morelabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_offset(-13);
|
||||
UIButton * moreBtn = [[UIButton alloc] init];
|
||||
[moreBtn setImage:[UIImage imageNamed:@"wacthRightAccow"] forState:UIControlStateNormal];
|
||||
[moreBtn addTarget:self action:@selector(moreClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[heaedImg addSubview:moreBtn];
|
||||
[moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_offset(-8);
|
||||
make.centerY.mas_equalTo(heaedImg);
|
||||
make.width.height.mas_offset(20);
|
||||
make.width.height.mas_offset(30);
|
||||
}];
|
||||
|
||||
// YYLabel * morelabel = [[YYLabel alloc] init];
|
||||
// morelabel.text = @">";
|
||||
// morelabel.textAlignment = NSTextAlignmentRight;
|
||||
// morelabel.textColor = UIColorHex(#999999);
|
||||
// morelabel.font = SYSTEMFONT(14);
|
||||
// MJWeakSelf
|
||||
// [morelabel setTextTapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||||
// if (self.watchMoreBlock) {
|
||||
// self.watchMoreBlock();
|
||||
// }
|
||||
// }];
|
||||
// [heaedImg addSubview:morelabel];
|
||||
//
|
||||
// [morelabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.right.mas_offset(-13);
|
||||
// make.centerY.mas_equalTo(heaedImg);
|
||||
// make.width.height.mas_offset(20);
|
||||
// }];
|
||||
//
|
||||
self.watchNumberLabel = [[UILabel alloc] init];
|
||||
|
||||
self.watchNumberLabel.text = @"监测工具编码:--";
|
||||
@@ -116,12 +141,69 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
[heaedImg addSubview:self.watchNumberLabel];
|
||||
|
||||
[self.watchNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(morelabel.mas_left).offset(6);
|
||||
make.right.mas_equalTo(moreBtn.mas_left);
|
||||
make.top.mas_offset(0);
|
||||
make.height.mas_offset(40);
|
||||
}];
|
||||
|
||||
|
||||
//日期切换
|
||||
// self.timeView = [[UIView alloc] init];
|
||||
// self.timeView.backgroundColor = KWhiteColor;
|
||||
// [self addSubview:self.timeView];
|
||||
//
|
||||
// [self.timeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.right.mas_offset(0);
|
||||
// make.top.mas_equalTo(heaedImg.mas_bottom);
|
||||
// make.height.mas_offset(52);
|
||||
// }];
|
||||
//
|
||||
// UIButton *preBtn = [[UIButton alloc] init];
|
||||
// [preBtn setTitle:@"上一天" forState:UIControlStateNormal];
|
||||
// [preBtn setImage:[UIImage imageNamed:@"blackLeftAccow"] forState:UIControlStateNormal];
|
||||
// [preBtn setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal];
|
||||
// preBtn.titleLabel.font = MEDIUMFONT(12);
|
||||
// preBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -8, 0, 8); // 左边多 4px 间距
|
||||
// self.preBtn = preBtn;
|
||||
// [preBtn addTarget:self action:@selector(previousWeekAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
// [self.timeView addSubview:preBtn];
|
||||
//
|
||||
// [preBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.mas_equalTo(@46);
|
||||
// make.width.mas_offset(60); // 注意宽度要能容纳文字+图片
|
||||
// make.centerY.mas_equalTo(self.timeView);
|
||||
// }];
|
||||
// preBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
|
||||
//
|
||||
//
|
||||
// UIButton *rightBtn = [[UIButton alloc] init];
|
||||
// [rightBtn setImage:[UIImage imageNamed:@"blackRightAccow"] forState:UIControlStateNormal];
|
||||
// [rightBtn setTitle:@"下一天" forState:UIControlStateNormal];
|
||||
// [rightBtn setTitleColor:UIColorHex(#333333) forState:UIControlStateNormal];
|
||||
// rightBtn.titleLabel.font = MEDIUMFONT(12);
|
||||
// rightBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0); // 左边多 4px 间距
|
||||
// self.nextBtn = rightBtn;
|
||||
// [rightBtn addTarget:self action:@selector(nextWeekAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
// [self.timeView addSubview:rightBtn];
|
||||
// [rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.right.mas_equalTo(@-46);
|
||||
// make.width.mas_offset(60); // 记得宽度要能容下文字+图片
|
||||
// make.centerY.mas_equalTo(self.timeView);
|
||||
// }];
|
||||
//
|
||||
// self.weekLabel = [[UILabel alloc] init];
|
||||
// self.weekLabel.textAlignment = NSTextAlignmentCenter;
|
||||
// self.weekLabel.textColor = UIColorHex(#333333);
|
||||
// self.weekLabel.font = MEDIUMFONT(12);
|
||||
// [self.timeView addSubview: self.weekLabel];
|
||||
//
|
||||
// [self.weekLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.right.mas_equalTo(rightBtn.mas_left);
|
||||
// make.left.mas_equalTo(preBtn.mas_right);
|
||||
// make.centerY.mas_equalTo(self.timeView);
|
||||
// make.top.mas_offset(0);
|
||||
// }];
|
||||
//
|
||||
// [self updateWeekLabelWithType];
|
||||
//
|
||||
// ── Tab ScrollView ───────────────────────────────────
|
||||
_tabScrollView = [[UIScrollView alloc] init];
|
||||
_tabScrollView.showsHorizontalScrollIndicator = NO;
|
||||
@@ -129,7 +211,7 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
[self addSubview:_tabScrollView];
|
||||
|
||||
[_tabScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(heaedImg.mas_bottom).offset(10);
|
||||
make.top.equalTo(heaedImg.mas_bottom);
|
||||
make.left.right.equalTo(self);
|
||||
make.height.mas_equalTo(kTabScrollH);
|
||||
}];
|
||||
@@ -187,30 +269,42 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
make.center.equalTo(_devView);
|
||||
}];
|
||||
|
||||
// ── 无数据占位 ────────────────────────────────────────
|
||||
// ── 占位 Label(直接加在 self,不受 collectionView 隐藏影响)────
|
||||
_emptyLabel = [[UILabel alloc] init];
|
||||
_emptyLabel.text = @"暂无穿戴设备";
|
||||
_emptyLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_emptyLabel.textColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0];
|
||||
_emptyLabel.font = [UIFont systemFontOfSize:15.0];
|
||||
_emptyLabel.hidden = YES;
|
||||
[_collectionView addSubview:_emptyLabel];
|
||||
[self.collectionView addSubview:_emptyLabel];
|
||||
|
||||
[_emptyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.equalTo(_collectionView);
|
||||
make.centerY.equalTo(_collectionView);
|
||||
make.center.equalTo(self.collectionView);
|
||||
}];
|
||||
|
||||
if ([HQCommonUtils isLogin]) {
|
||||
// 已登录,等待数据回调
|
||||
} else {
|
||||
_emptyLabel.text = @"~ 暂未登录 ~";
|
||||
_emptyLabel.hidden = NO;
|
||||
_tabScrollView.hidden = false;
|
||||
_collectionView.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)moreClick {
|
||||
|
||||
if (self.watchMoreBlock) {
|
||||
self.watchMoreBlock();
|
||||
}
|
||||
|
||||
}
|
||||
- (void)setWatchModel:(XJHomeWatchModel *)watchModel {
|
||||
|
||||
_watchModel = watchModel;
|
||||
|
||||
if (_watchModel.hasWatch == true) {
|
||||
//有手表
|
||||
self.watchNumberLabel.text = [NSString stringWithFormat:@"%@:%@",_watchModel.watchModel,_watchModel.watchNo];
|
||||
|
||||
self.watchNumberLabel.text = [NSString stringWithFormat:@"监测工具编码:%@",_watchModel.watchNo];
|
||||
|
||||
}else
|
||||
{
|
||||
@@ -229,7 +323,7 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
for (UIButton *btn in _tabButtons) [btn removeFromSuperview];
|
||||
[_tabButtons removeAllObjects];
|
||||
|
||||
UIFont *font = [UIFont systemFontOfSize:14.0];
|
||||
UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold];
|
||||
UIButton *prevBtn = nil;
|
||||
|
||||
for (NSInteger i = 0; i < (NSInteger)tabTitles.count; i++) {
|
||||
@@ -241,7 +335,7 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
options:NSStringDrawingUsesLineFragmentOrigin
|
||||
attributes:@{NSFontAttributeName: font}
|
||||
context:nil].size.width);
|
||||
CGFloat btnW = textW + kButtonPadX * 2;
|
||||
CGFloat btnW = textW + kRealValue(kButtonPadX) * 2;
|
||||
|
||||
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
btn.tag = i;
|
||||
@@ -286,36 +380,49 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
- (void)p_tabButtonTapped:(UIButton *)sender {
|
||||
NSInteger index = sender.tag;
|
||||
[self selectTabAtIndex:index];
|
||||
if (self.tabSelectBlock) {
|
||||
self.tabSelectBlock(index, _tabTitles[index]);
|
||||
}
|
||||
// 用户主动点击,重置轮播计时器
|
||||
[self p_restartAutoScroll];
|
||||
}
|
||||
|
||||
#pragma mark - Public: Select Tab
|
||||
|
||||
- (void)selectTabAtIndex:(NSInteger)index {
|
||||
if (index < 0 || index >= (NSInteger)_tabButtons.count) return;
|
||||
if (![HQCommonUtils isLogin]) {
|
||||
KPostNotification(KNotificationLoginStateChange, @NO);
|
||||
return;
|
||||
}
|
||||
|
||||
// 恢复旧选中样式
|
||||
// 恢复旧 Tab 样式
|
||||
UIButton *oldBtn = _tabButtons[_selectedIndex];
|
||||
oldBtn.backgroundColor = UIColorHex(#F6F7FB);
|
||||
oldBtn.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
|
||||
[oldBtn setTitleColor:UIColorHex(#808080) forState:UIControlStateNormal];
|
||||
|
||||
// 设置新选中样式
|
||||
// 设置新 Tab 样式
|
||||
_selectedIndex = index;
|
||||
UIButton *newBtn = _tabButtons[index];
|
||||
newBtn.backgroundColor = UIColorHex(#14BEBE);
|
||||
newBtn.titleLabel.font = BOLDSYSTEMFONT(14);
|
||||
[newBtn setTitleColor:KWhiteColor forState:UIControlStateNormal];
|
||||
|
||||
// 滚动让选中按钮可见/居中
|
||||
[self p_scrollToButton:newBtn];
|
||||
|
||||
// tab 0:显示 CollectionView;其他:显示"紧急开发中"
|
||||
// tab 0:显示 CollectionView 并恢复轮播;其他:显示"紧急开发中"并暂停轮播
|
||||
BOOL isFirst = (index == 0);
|
||||
_collectionView.hidden = !isFirst;
|
||||
_devView.hidden = isFirst;
|
||||
|
||||
if (isFirst) {
|
||||
[self p_restartAutoScroll];
|
||||
} else {
|
||||
[self p_stopAutoScroll];
|
||||
}
|
||||
|
||||
// 通知外部高度变化
|
||||
if (self.tabSelectBlock) {
|
||||
self.tabSelectBlock(index, _tabTitles[index]);
|
||||
}
|
||||
}
|
||||
|
||||
/// 若按钮中心超过可视区一半,则滚动将其居中
|
||||
@@ -341,10 +448,29 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
- (void)setDataList:(NSArray *)dataList {
|
||||
_dataList = [dataList copy];
|
||||
|
||||
if (![HQCommonUtils isLogin]) {
|
||||
_emptyLabel.text = @"~ 暂未登录 ~";
|
||||
_emptyLabel.hidden = NO;
|
||||
_collectionView.hidden = YES;
|
||||
_tabScrollView.hidden = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
_collectionView.hidden = NO;
|
||||
_tabScrollView.hidden = NO;
|
||||
|
||||
BOOL isEmpty = (_dataList.count == 0);
|
||||
_emptyLabel.text = @"您目前未配备智能穿戴设备";
|
||||
_emptyLabel.hidden = !isEmpty;
|
||||
|
||||
[_collectionView reloadData];
|
||||
|
||||
// 有多条数据才启动轮播
|
||||
if (_dataList.count > 1) {
|
||||
[self p_startAutoScroll];
|
||||
} else {
|
||||
[self p_stopAutoScroll];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDataSource
|
||||
@@ -382,4 +508,133 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距
|
||||
// 预留:外部如需监听 cell 点击可在此通过 block 回调
|
||||
}
|
||||
|
||||
#pragma mark - UIScrollViewDelegate(手动滑动同步 Tab)
|
||||
|
||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
||||
if (scrollView != _collectionView) return;
|
||||
// 更新轮播页码(与 Tab selectedIndex 无关)
|
||||
_carouselPage = (NSInteger)(scrollView.contentOffset.x / MAX(scrollView.bounds.size.width, 1));
|
||||
[self p_restartAutoScroll];
|
||||
}
|
||||
|
||||
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
|
||||
if (scrollView != _collectionView) return;
|
||||
// 手指触碰时暂停自动轮播,避免与手势冲突
|
||||
[self p_stopAutoScroll];
|
||||
}
|
||||
|
||||
#pragma mark - 轮播
|
||||
|
||||
/// 启动自动轮播(3 秒一次)
|
||||
- (void)p_startAutoScroll {
|
||||
[self p_stopAutoScroll];
|
||||
if (_dataList.count <= 1) return;
|
||||
_autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:3.0
|
||||
target:self
|
||||
selector:@selector(p_autoScrollToNext)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
// 加入 NSRunLoopCommonModes,防止父 ScrollView 滚动时定时器暂停
|
||||
[[NSRunLoop mainRunLoop] addTimer:_autoScrollTimer forMode:NSRunLoopCommonModes];
|
||||
}
|
||||
|
||||
/// 停止自动轮播
|
||||
- (void)p_stopAutoScroll {
|
||||
[_autoScrollTimer invalidate];
|
||||
_autoScrollTimer = nil;
|
||||
}
|
||||
|
||||
/// 重置定时器(用户交互后调用)
|
||||
- (void)p_restartAutoScroll {
|
||||
if (_dataList.count > 1) [self p_startAutoScroll];
|
||||
}
|
||||
|
||||
/// 滚到下一页,最后一页→第一页不用动画,避免明显跳动
|
||||
- (void)p_autoScrollToNext {
|
||||
if (_dataList.count == 0) return;
|
||||
NSInteger next = (_carouselPage + 1) % _dataList.count;
|
||||
BOOL animated = (next != 0);
|
||||
[self p_scrollCollectionToIndex:next animated:animated];
|
||||
}
|
||||
|
||||
/// 滚动 collectionView 到指定页,只更新 carouselPage,不影响 Tab
|
||||
- (void)p_scrollCollectionToIndex:(NSInteger)index animated:(BOOL)animated {
|
||||
if (index < 0 || index >= (NSInteger)_dataList.count) return;
|
||||
_carouselPage = index;
|
||||
NSIndexPath *ip = [NSIndexPath indexPathForItem:index inSection:0];
|
||||
[_collectionView scrollToItemAtIndexPath:ip
|
||||
atScrollPosition:UICollectionViewScrollPositionLeft
|
||||
animated:animated];
|
||||
}
|
||||
|
||||
/// 离开父视图时停止轮播,防止 timer 持有 self 造成内存泄漏
|
||||
- (void)willMoveToSuperview:(UIView *)newSuperview {
|
||||
[super willMoveToSuperview:newSuperview];
|
||||
if (!newSuperview) [self p_stopAutoScroll];
|
||||
}
|
||||
|
||||
#pragma mark - 上一日/上一周、下一日/下一周
|
||||
|
||||
// 上一日/上一周
|
||||
- (void)previousWeekAction {
|
||||
|
||||
self.currentDayDate = [self dateByAddingDays:-1 toDate:self.currentDayDate];
|
||||
[self updateWeekLabelWithType];
|
||||
[self checkNextButtonState];
|
||||
}
|
||||
|
||||
// 下一日/下一周
|
||||
- (void)nextWeekAction {
|
||||
self.currentDayDate = [self dateByAddingDays:1 toDate:self.currentDayDate];
|
||||
[self updateWeekLabelWithType];
|
||||
[self checkNextButtonState];
|
||||
}
|
||||
|
||||
- (void)updateWeekLabelWithType {
|
||||
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.dateFormat = @"yyyy-MM-dd";
|
||||
self.weekLabel.text = [formatter stringFromDate:self.currentDayDate];
|
||||
|
||||
if (self.changeTimeClickBlock) {
|
||||
NSString *dayYMD = [self formatDateToYMDString:self.currentDayDate];
|
||||
self.changeTimeClickBlock(dayYMD); //
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 日期加减
|
||||
- (NSDate *)dateByAddingDays:(NSInteger)days toDate:(NSDate *)date {
|
||||
return [date dateByAddingTimeInterval:days*24*60*60];
|
||||
}
|
||||
|
||||
- (NSString *)formatDateToYMDString:(NSDate *)date {
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
[formatter setDateFormat:@"yyyy-MM-dd"];
|
||||
return [formatter stringFromDate:date];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 检查下一天/下一周按钮状态
|
||||
|
||||
- (void)checkNextButtonState {
|
||||
NSCalendar *calendar = [NSCalendar currentCalendar];
|
||||
[calendar setFirstWeekday:2]; // 周一为第一天
|
||||
|
||||
NSDate *today = [NSDate date];
|
||||
|
||||
NSDate *currentOnly = [self dateByRemovingTime:self.currentDayDate];
|
||||
NSDate *todayOnly = [self dateByRemovingTime:today];
|
||||
self.nextBtn.enabled = ([currentOnly compare:todayOnly] == NSOrderedAscending);
|
||||
|
||||
}
|
||||
|
||||
// 去掉时分秒
|
||||
- (NSDate *)dateByRemovingTime:(NSDate *)date {
|
||||
NSCalendar *calendar = [NSCalendar currentCalendar];
|
||||
NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay
|
||||
fromDate:date];
|
||||
return [calendar dateFromComponents:components];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -363,6 +363,13 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半
|
||||
|
||||
});
|
||||
}
|
||||
if ([tag isEqualToString:@"WEARWATCH"]) {
|
||||
self.topView.watchArray = @[];
|
||||
}
|
||||
if ([tag isEqualToString:@"WEARWATCH"]) {
|
||||
self.topView.watchArray = @[];
|
||||
}
|
||||
|
||||
[self showMBProgressHUDOnlyWithString:message];
|
||||
[self hiddenAllMBProgressHUD];
|
||||
|
||||
@@ -603,19 +610,36 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半
|
||||
|
||||
}
|
||||
if ([tag isEqualToString:@"WATCHDETAIL"]) {
|
||||
///** 数据类型:0=心率 1=血氧 2=压力 3=体温 4=睡眠 */
|
||||
NSArray * array = response;
|
||||
|
||||
NSMutableArray * dataArray = [[NSMutableArray alloc] init];
|
||||
|
||||
for (NSDictionary * dic in array) {
|
||||
if (ValidDict(dic)) {
|
||||
XJHomeWatchModel * model = [XJHomeWatchModel modelWithDictionary:dic];
|
||||
|
||||
[dataArray addObject:model];
|
||||
}
|
||||
// 数据类型:0=心率 1=血氧 2=压力 3=体温 4=睡眠
|
||||
NSArray *array = response;
|
||||
|
||||
// 容错:接口返回非数组时不处理
|
||||
if (!ValidArray(array)) {
|
||||
self.topView.watchArray = @[];
|
||||
return;
|
||||
}
|
||||
self.topView.watchArray = dataArray;
|
||||
|
||||
NSMutableArray *dataArray = [[NSMutableArray alloc] init];
|
||||
|
||||
for (NSDictionary *dic in array) {
|
||||
// 容错:过滤非字典数据
|
||||
if (!ValidDict(dic)) continue;
|
||||
|
||||
XJHomeWatchModel *model = [XJHomeWatchModel modelWithDictionary:dic];
|
||||
|
||||
// 容错:type 不在有效范围 0-4 内的数据丢弃
|
||||
NSInteger type = [model.type intValue];
|
||||
if (type < 0 || type > 4) continue;
|
||||
|
||||
[dataArray addObject:model];
|
||||
}
|
||||
|
||||
// 按 type 升序排列,保证 collectionView 顺序固定为 0→1→2→3→4
|
||||
NSArray *sortedArray = [dataArray sortedArrayUsingComparator:^NSComparisonResult(XJHomeWatchModel *a, XJHomeWatchModel *b) {
|
||||
return [@([a.type intValue]) compare:@([b.type intValue])];
|
||||
}];
|
||||
|
||||
self.topView.watchArray = sortedArray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -939,7 +963,10 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半
|
||||
|
||||
self.AIBannerImage = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
|
||||
self.AIBannerImage.backgroundColor = KClearColor;
|
||||
self.AIBannerImage.placeholderImage = nil;
|
||||
self.AIBannerImage.delegate = self;
|
||||
self.AIBannerImage.layer.cornerRadius = 12;
|
||||
self.AIBannerImage.layer.masksToBounds = true;
|
||||
self.AIBannerImage.currentPageDotImage = [UIImage imageNamed:@"pageControlDot"];
|
||||
self.AIBannerImage.pageDotImage = [UIImage imageNamed:@"pageControlNomalDot"];
|
||||
self.AIBannerImage.pageDotColor = KWhiteColor;
|
||||
@@ -1128,7 +1155,13 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半
|
||||
}
|
||||
|
||||
- (void)watchDetailClick {
|
||||
KPostNotification(KNotificSelectWatchTabbar,nil);
|
||||
|
||||
if([HQCommonUtils isLogin]) {
|
||||
KPostNotification(KNotificSelectWatchTabbar,nil);
|
||||
}else
|
||||
{
|
||||
KPostNotification(KNotificationLoginStateChange, @NO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -541,7 +541,7 @@
|
||||
detailVC.webUrl = [NSString stringWithFormat:@"%@/static/monitor/index.html?p=%@&r=%@&t=%@&id=%@&d=%@&h=%@#/%@",
|
||||
IntervenH5, @"heartRate", H5DevHost, User_Token, User_ID, time, SCHEME, @"heartRate"];
|
||||
detailVC.navTitle = @"心率";
|
||||
|
||||
|
||||
|
||||
}
|
||||
if ([type isEqualToString:@"spo2"]) {
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "wacthRightAccow.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "wacthRightAccow@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "wacthRightAccow@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 283 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 484 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 878 B |
Reference in New Issue
Block a user