diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.m b/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.m index 003c004..72e0e00 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.m +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.m @@ -15,6 +15,9 @@ @property (nonatomic,strong) UITextField *nameField; @property (nonatomic,strong) UITextField *numberField; @property (nonatomic,strong) UIButton *actionBtn; +@property (nonatomic,strong) UIView *gestureView; + + @end @implementation BindWatchPopView @@ -22,11 +25,10 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { - + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; - + [self createUI]; - [self addGesture]; [self addKeyboardNotification]; } @@ -36,20 +38,35 @@ #pragma mark - UI - (void)createUI { - + + self.bottomView = [[UIView alloc] init]; self.bottomView.backgroundColor = UIColor.whiteColor; self.bottomView.layer.cornerRadius = 16; self.bottomView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner; self.bottomView.layer.masksToBounds = YES; [self addSubview:self.bottomView]; - + [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.offset(0); - make.height.offset(342); + make.height.offset(254 + SafetyAreaHeight); }]; - + // 添加透明的手势响应区域(覆盖黑色背景) + UIView *gestureView = [[UIView alloc] init]; + gestureView.backgroundColor = [UIColor clearColor]; + gestureView.userInteractionEnabled = YES; + self.gestureView =gestureView; + [self addSubview:gestureView]; + + [gestureView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.offset(0); + make.bottom.equalTo(self.bottomView.mas_top); + }]; + + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(close)]; + [gestureView addGestureRecognizer:tap]; + /// 拖动条 UIView *indicator = [[UIView alloc] init]; indicator.backgroundColor = UIColorHex(#D8D8D8); @@ -65,7 +82,7 @@ UILabel *titleLab = [[UILabel alloc] init]; - titleLab.text = @"健康监测"; + titleLab.text = @"健康监测工具绑定"; titleLab.font = [UIFont boldSystemFontOfSize:16]; titleLab.textAlignment = NSTextAlignmentCenter; [self.bottomView addSubview:titleLab]; @@ -77,71 +94,120 @@ HQUserInfo * user = [HQCommonUtils keyedUnarchiverWithKey:LoginUserInfo]; - self.workNoField = [self createTextField]; - [self.bottomView addSubview:self.workNoField]; - - [self.workNoField mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.offset(82); - make.right.offset(-15); - make.height.offset(52); - make.top.equalTo(titleLab.mas_bottom).offset(20); - }]; - - - UILabel *workLab = [self createLabel:@"工 号:"]; - if (!ValidStr(user.workNo)) { - self.workNoField.text = [NSString stringWithFormat:@"%@",user.workNo]; - } - [self.bottomView addSubview:workLab]; - - [workLab mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.offset(0); - make.right.equalTo(self.workNoField.mas_left); - make.centerY.equalTo(self.workNoField); - }]; - - - self.nameField = [self createTextField]; - [self.bottomView addSubview:self.nameField]; - - [self.nameField mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.height.equalTo(self.workNoField); - make.top.equalTo(self.workNoField.mas_bottom).offset(16); - }]; + UILabel * nameLabel = [[UILabel alloc] init]; + nameLabel.textColor = UIColorHex(#808080); + nameLabel.font= [UIFont systemFontOfSize:15 weight:UIFontWeightRegular]; + nameLabel.textAlignment = NSTextAlignmentLeft; if (!ValidStr(user.realname)) { - self.nameField.text = [NSString stringWithFormat:@"%@",user.realname]; + nameLabel.text = [NSString stringWithFormat:@"%@",user.realname]; } + [self.bottomView addSubview:nameLabel]; - UILabel *nameLab = [self createLabel:@"姓 名:"]; - [self.bottomView addSubview:nameLab]; - - [nameLab mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.offset(0); - make.right.equalTo(self.nameField.mas_left); - make.centerY.equalTo(self.nameField); + // workLabel 先布局,固定右侧,宽度自适应内容,不压缩 + UILabel * workLabel = [[UILabel alloc] init]; + workLabel.textColor = UIColorHex(#808080); + workLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular]; + workLabel.textAlignment = NSTextAlignmentRight; + // 工号不压缩、不拉伸 + [workLabel setContentCompressionResistancePriority:UILayoutPriorityRequired + forAxis:UILayoutConstraintAxisHorizontal]; + [workLabel setContentHuggingPriority:UILayoutPriorityRequired + forAxis:UILayoutConstraintAxisHorizontal]; + if (!ValidStr(user.workNo)) { + workLabel.text = [NSString stringWithFormat:@"%@", user.workNo]; + } + [self.bottomView addSubview:workLabel]; + + [workLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_offset(-21); + make.top.mas_equalTo(titleLab.mas_bottom).offset(20); }]; + + // nameLabel 左侧固定,右侧距 workLabel 一个字符宽度,姓名优先占满剩余空间 + [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_offset(16); + make.top.mas_equalTo(titleLab.mas_bottom).offset(20); + // 右侧距 workLabel 一个字符间距(约 15pt) + make.right.equalTo(workLabel.mas_left).offset(-15); + }]; + // 姓名可压缩,优先级低于工号 + [nameLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow + forAxis:UILayoutConstraintAxisHorizontal]; + [nameLabel setContentHuggingPriority:UILayoutPriorityDefaultLow + forAxis:UILayoutConstraintAxisHorizontal]; +// self.workNoField = [self createTextField]; +// self.workNoField.userInteractionEnabled = false; +// [self.bottomView addSubview:self.workNoField]; +// +// [self.workNoField mas_makeConstraints:^(MASConstraintMaker *make) { +// make.left.offset(82); +// make.right.offset(-15); +// make.height.offset(52); +// make.top.equalTo(titleLab.mas_bottom).offset(20); +// }]; +// +// + UILabel * watchSNLab = [[UILabel alloc] init]; + watchSNLab.text = @"心脑血管监测工具SN编码:"; + watchSNLab.font = MEDIUMFONT(15); + watchSNLab.textAlignment = NSTextAlignmentLeft; + [self.bottomView addSubview:watchSNLab]; - + [watchSNLab mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(nameLabel.mas_left); + make.right.mas_offset(-21); + make.top.mas_equalTo(nameLabel.mas_bottom).offset(15); + }]; +// +// +// self.nameField = [self createTextField]; +// self.nameField.enabled = false; +// [self.bottomView addSubview:self.nameField]; +// +// [self.nameField mas_makeConstraints:^(MASConstraintMaker *make) { +// make.left.right.height.equalTo(self.workNoField); +// make.top.equalTo(self.workNoField.mas_bottom).offset(16); +// }]; +// if (!ValidStr(user.realname)) { +// self.nameField.text = [NSString stringWithFormat:@"%@",user.realname]; +// } +// +// UILabel *nameLab = [self createLabel:@"姓 名:"]; +// [self.bottomView addSubview:nameLab]; +// +// [nameLab mas_makeConstraints:^(MASConstraintMaker *make) { +// make.left.offset(0); +// make.right.equalTo(self.nameField.mas_left); +// make.centerY.equalTo(self.nameField); +// }]; +// +// self.numberField = [self createTextField]; - self.numberField.backgroundColor = KWhiteColor; + NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@"请输入SN编码" attributes: + @{NSForegroundColorAttributeName:UIColorHex(#B6B6B6), + NSFontAttributeName:[UIFont systemFontOfSize:16 weight:UIFontWeightMedium]} + ]; + self.numberField.attributedPlaceholder = attrString; [self.bottomView addSubview:self.numberField]; [self.numberField mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.height.equalTo(self.workNoField); - make.top.equalTo(self.nameField.mas_bottom).offset(16); + make.left.mas_offset(15); + make.right.mas_offset(-15); + make.height.mas_offset(52); + make.top.equalTo(watchSNLab.mas_bottom).offset(12); }]; + UIView * lineV = [[UIView alloc] init]; + lineV.backgroundColor = UIColorHex(#EAECF1); + [self.bottomView addSubview:lineV]; - UILabel *xulieLab = [self createLabel:@"序列号:"]; - [self.bottomView addSubview:xulieLab]; - - [xulieLab mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.offset(0); - make.right.equalTo(self.numberField.mas_left); - make.centerY.equalTo(self.numberField); + [lineV mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_offset(0); + make.height.mas_offset(1); + make.top.mas_equalTo(self.numberField.mas_bottom).offset(12); }]; - + UIButton *bindBtn = [[UIButton alloc] init]; [bindBtn setTitle:@"解绑" forState:UIControlStateNormal]; bindBtn.backgroundColor = UIColorHex(#21BEBD); @@ -155,7 +221,7 @@ make.centerX.offset(0); make.width.offset(215); make.height.offset(44); - make.top.equalTo(self.numberField.mas_bottom).offset(30); + make.top.equalTo(self.numberField.mas_bottom).offset(23); }]; } @@ -166,13 +232,17 @@ [self.actionBtn setTitle:@"解绑" forState:UIControlStateNormal]; self.numberField.text = self.serialNumber; + self.numberField.backgroundColor = UIColorHex(#F5F7FB); self.numberField.enabled = NO; + } else { [self.actionBtn setTitle:@"绑定" forState:UIControlStateNormal]; self.numberField.text = @""; self.numberField.enabled = YES; + self.numberField.backgroundColor = KWhiteColor; + } } @@ -214,14 +284,6 @@ return field; } -#pragma mark - 点击背景关闭 - -- (void)addGesture { - - UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(close)]; - tap.cancelsTouchesInView = YES; - [self addGestureRecognizer:tap]; -} - (void)close { @@ -245,20 +307,29 @@ } - (void)keyboardShow:(NSNotification *)noti { - + CGRect rect = [noti.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; - CGFloat keyboardH = rect.size.height; - + [UIView animateWithDuration:0.25 animations:^{ self.bottomView.transform = CGAffineTransformMakeTranslation(0, -keyboardH); + // 同步缩小 gestureView,避免手势区域覆盖 bottomView 上的按钮 + [self.gestureView mas_updateConstraints:^(MASConstraintMaker *make) { + make.bottom.equalTo(self.bottomView.mas_top).offset(-keyboardH); + }]; + [self layoutIfNeeded]; }]; } - (void)keyboardHide:(NSNotification *)noti { - + [UIView animateWithDuration:0.25 animations:^{ self.bottomView.transform = CGAffineTransformIdentity; + // 恢复 gestureView 约束 + [self.gestureView mas_updateConstraints:^(MASConstraintMaker *make) { + make.bottom.equalTo(self.bottomView.mas_top).offset(0); + }]; + [self layoutIfNeeded]; }]; } diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h index 3574faf..fd78e30 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h @@ -38,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy, nullable) void (^bindDeviceBlock)(NSString * watchNo); +@property (nonatomic, strong) NSString * totalponits; + @end NS_ASSUME_NONNULL_END diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m index 49df2ab..5b1ceea 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m @@ -19,6 +19,8 @@ @property (nonatomic, strong) SDCycleScrollView *adTitleView; @property (nonatomic, strong) UILabel *nameLabel; @property (nonatomic, strong) XJHomeWatchDataView *watchDataView; +@property (nonatomic, strong) UILabel * toolTitleLab; + @end @@ -158,6 +160,7 @@ toolTitleLab.text = @"今日健康积分 0 | 累计积分 0"; toolTitleLab.textColor = UIColorHex(#116F6B); toolTitleLab.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular]; + self.toolTitleLab = toolTitleLab; [toolsView addSubview:toolTitleLab]; [toolTitleLab mas_makeConstraints:^(MASConstraintMaker *make) { @@ -303,7 +306,7 @@ //手表数据 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 @@ -336,9 +339,19 @@ [self.watchDataView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_offset(12); make.right.mas_offset(-12); - make.height.mas_offset(250); + make.height.mas_offset(104); make.top.mas_equalTo(lastImageView.mas_bottom).offset(12); }]; + + // 高度变化回调:无数据/未登录 104,有数据 205 + self.watchDataView.heightChangeBlock = ^(CGFloat height) { + [weakSelf.watchDataView mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(height); + }]; + [UIView animateWithDuration:0.25 animations:^{ + [weakSelf layoutIfNeeded]; + }]; + }; SDCycleScrollView * questionSDCycles = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]]; @@ -364,6 +377,14 @@ } +-(void)setTotalponits:(NSString *)totalponits { + + _totalponits = totalponits; + + self.toolTitleLab.text = _totalponits; + + +} - (void)setModel:(XJHomeWatchModel *)model { diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h index 25fb59e..6e686e0 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h @@ -46,6 +46,9 @@ typedef void(^watchDataDetailBlick)(); @property (nonatomic, copy) void (^changeTimeClickBlock)(NSString *startDate); +/// 高度变化回调:无数据/未登录时返回 104,有数据时返回 205 +@property (nonatomic, copy, nullable) void (^heightChangeBlock)(CGFloat height); + @end NS_ASSUME_NONNULL_END diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m index e9ebd34..22ecbeb 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m @@ -23,7 +23,7 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距 @property (nonatomic, strong) YYLabel *watchNumberLabel; // -@property (nonatomic, strong) UIScrollView *tabScrollView; +//@property (nonatomic, strong) UIScrollView *tabScrollView; @property (nonatomic, strong) UIView *tabContentView; @property (nonatomic, strong) NSMutableArray *tabButtons; @property (nonatomic, strong) UICollectionView *collectionView; @@ -214,25 +214,25 @@ weekLabel; // [self updateWeekLabelWithType]; // // ── Tab ScrollView ─────────────────────────────────── - _tabScrollView = [[UIScrollView alloc] init]; - _tabScrollView.showsHorizontalScrollIndicator = NO; - _tabScrollView.showsVerticalScrollIndicator = NO; - [self addSubview:_tabScrollView]; - - [_tabScrollView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(heaedImg.mas_bottom); - make.left.right.equalTo(self); - make.height.mas_equalTo(kTabScrollH); - }]; +// _tabScrollView = [[UIScrollView alloc] init]; +// _tabScrollView.showsHorizontalScrollIndicator = NO; +// _tabScrollView.showsVerticalScrollIndicator = NO; +// [self addSubview:_tabScrollView]; +// +// [_tabScrollView mas_makeConstraints:^(MASConstraintMaker *make) { +// make.top.equalTo(heaedImg.mas_bottom); +// make.left.right.equalTo(self); +// make.height.mas_equalTo(kTabScrollH); +// }]; // scrollView 内的容器 view(Masonry 驱动 contentSize) - _tabContentView = [[UIView alloc] init]; - [_tabScrollView addSubview:_tabContentView]; - - [_tabContentView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.equalTo(_tabScrollView); // 四边贴 scrollView - make.height.equalTo(_tabScrollView); // 固定高度 = scrollView,只横向滚动 - }]; +// _tabContentView = [[UIView alloc] init]; +// [_tabScrollView addSubview:_tabContentView]; +// +// [_tabContentView mas_makeConstraints:^(MASConstraintMaker *make) { +// make.edges.equalTo(_tabScrollView); // 四边贴 scrollView +// make.height.equalTo(_tabScrollView); // 固定高度 = scrollView,只横向滚动 +// }]; // ── 底部 CollectionView ────────────────────────────── UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; @@ -252,32 +252,11 @@ weekLabel; [self addSubview:_collectionView]; [_collectionView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(_tabScrollView.mas_bottom); + make.top.equalTo(@40); make.left.right.bottom.equalTo(self); }]; - // ── 紧急开发中占位(tab 非第一个时显示)──────────────── - _devView = [[UIView alloc] init]; - _devView.backgroundColor = KWhiteColor; - _devView.hidden = YES; - [self addSubview:_devView]; - - [_devView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(_tabScrollView.mas_bottom); - make.left.right.bottom.equalTo(self); - }]; - - UILabel *devLabel = [[UILabel alloc] init]; - devLabel.text = @"紧急开发中"; - devLabel.textColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]; - devLabel.font = [UIFont systemFontOfSize:15.0]; - devLabel.textAlignment = NSTextAlignmentCenter; - [_devView addSubview:devLabel]; - - [devLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.center.equalTo(_devView); - }]; - + // ── 未登录占位 Label ───────────────────────────────────────── _emptyLabel = [[UILabel alloc] init]; _emptyLabel.text = @" 暂未登录 "; @@ -298,34 +277,34 @@ weekLabel; [self addSubview:_emptyView]; [_emptyView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(_tabScrollView.mas_bottom); + make.top.equalTo(@40); make.left.right.bottom.equalTo(self); }]; - // 空状态图标,宽高 59,居中,距 Tab 切换 View 底部 16 - UIImageView *emptyImageView = [[UIImageView alloc] init]; - emptyImageView.image = [UIImage imageNamed:@"ic_watch_empty"]; - emptyImageView.contentMode = UIViewContentModeScaleAspectFit; - [_emptyView addSubview:emptyImageView]; - - [emptyImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_offset(16); - make.centerX.equalTo(_emptyView); - make.width.height.mas_offset(59); - }]; - - // 提示文字:~ 暂无数据 ~,字号 11 regular,颜色 #B6B6B6 - UILabel *emptyHintLabel = [[UILabel alloc] init]; - emptyHintLabel.text = @"~ 暂无数据 ~"; - emptyHintLabel.textAlignment = NSTextAlignmentCenter; - emptyHintLabel.textColor = UIColorHex(#B6B6B6); - emptyHintLabel.font = [UIFont systemFontOfSize:11]; - [_emptyView addSubview:emptyHintLabel]; - - [emptyHintLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(emptyImageView.mas_bottom).offset(8); - make.centerX.equalTo(_emptyView); - }]; +// // 空状态图标,宽高 59,居中,距 Tab 切换 View 底部 16 +// UIImageView *emptyImageView = [[UIImageView alloc] init]; +// emptyImageView.image = [UIImage imageNamed:@"ic_watch_empty"]; +// emptyImageView.contentMode = UIViewContentModeScaleAspectFit; +// [_emptyView addSubview:emptyImageView]; +// +// [emptyImageView mas_makeConstraints:^(MASConstraintMaker *make) { +// make.top.mas_offset(16); +// make.centerX.equalTo(_emptyView); +// make.width.height.mas_offset(59); +// }]; +// +// // 提示文字:~ 暂无数据 ~,字号 11 regular,颜色 #B6B6B6 +// UILabel *emptyHintLabel = [[UILabel alloc] init]; +// emptyHintLabel.text = @"~ 暂无数据 ~"; +// emptyHintLabel.textAlignment = NSTextAlignmentCenter; +// emptyHintLabel.textColor = UIColorHex(#B6B6B6); +// emptyHintLabel.font = [UIFont systemFontOfSize:11]; +// [_emptyView addSubview:emptyHintLabel]; +// +// [emptyHintLabel mas_makeConstraints:^(MASConstraintMaker *make) { +// make.top.equalTo(emptyImageView.mas_bottom).offset(8); +// make.centerX.equalTo(_emptyView); +// }]; // 去绑定按钮:宽 80 高 24,medium 13,颜色 #21BEBD,圆角 12,白底边框 1 UIButton *bindBtn = [UIButton buttonWithType:UIButtonTypeCustom]; @@ -341,9 +320,9 @@ weekLabel; [_emptyView addSubview:bindBtn]; [bindBtn mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.equalTo(emptyHintLabel.mas_bottom).offset(8); + make.top.mas_offset(20); make.centerX.equalTo(_emptyView); - make.width.mas_offset(80); + make.width.mas_offset(82); make.height.mas_offset(24); }]; @@ -352,7 +331,6 @@ weekLabel; } else { // 未登录:显示"暂未登录"文字,emptyView 保持隐藏 _emptyLabel.hidden = NO; - _tabScrollView.hidden = NO; _collectionView.hidden = NO; } } @@ -391,10 +369,13 @@ weekLabel; if (_watchModel.hasWatch == true) { //有手表 self.watchNumberLabel.text = [NSString stringWithFormat:@"监测工具编码:%@",_watchModel.watchNo]; + self.watchNumberLabel.textColor = UIColorHex(#14BEBE); + }else { - self.watchNumberLabel.text = @""; + self.watchNumberLabel.text = @"监测工具编码:暂无信息"; + self.watchNumberLabel.textColor = UIColorHex(#808080); self.dataList = @[]; } @@ -473,67 +454,67 @@ weekLabel; #pragma mark - Public: Select Tab -- (void)selectTabAtIndex:(NSInteger)index { - if (index < 0 || index >= (NSInteger)_tabButtons.count) return; - if (![HQCommonUtils isLogin]) { - KPostNotification(KNotificationLoginStateChange, @NO); - return; - } +//- (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 并恢复轮播;其他:显示"紧急开发中"并暂停轮播 +// BOOL isFirst = (index == 0); +// _collectionView.hidden = !isFirst; +// _devView.hidden = isFirst; +// +// if (isFirst) { +// // 切换回第一个 Tab,重新根据数据状态显示 emptyView +// BOOL isEmpty = (_dataList.count == 0); +// _emptyView.hidden = !isEmpty; +// [self p_restartAutoScroll]; +// } else { +// // 切换到其他 Tab,隐藏 emptyView +// _emptyView.hidden = YES; +// [self p_stopAutoScroll]; +// } +// +// // 通知外部高度变化 +// if (self.tabSelectBlock) { +// self.tabSelectBlock(index, _tabTitles[index]); +// } +//} - // 恢复旧 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 并恢复轮播;其他:显示"紧急开发中"并暂停轮播 - BOOL isFirst = (index == 0); - _collectionView.hidden = !isFirst; - _devView.hidden = isFirst; - - if (isFirst) { - // 切换回第一个 Tab,重新根据数据状态显示 emptyView - BOOL isEmpty = (_dataList.count == 0); - _emptyView.hidden = !isEmpty; - [self p_restartAutoScroll]; - } else { - // 切换到其他 Tab,隐藏 emptyView - _emptyView.hidden = YES; - [self p_stopAutoScroll]; - } - - // 通知外部高度变化 - if (self.tabSelectBlock) { - self.tabSelectBlock(index, _tabTitles[index]); - } -} - -/// 若按钮中心超过可视区一半,则滚动将其居中 -- (void)p_scrollToButton:(UIButton *)btn { - // layoutIfNeeded 保证 frame 已计算 - [_tabScrollView layoutIfNeeded]; - - CGFloat scrollW = _tabScrollView.bounds.size.width; - CGFloat contentW = _tabScrollView.contentSize.width; - CGFloat btnCenterX = CGRectGetMidX(btn.frame); - - CGFloat offsetX = 0; - if (btnCenterX > scrollW / 2.0) { - offsetX = btnCenterX - scrollW / 2.0; - offsetX = MIN(offsetX, MAX(contentW - scrollW, 0)); - } - - [_tabScrollView setContentOffset:CGPointMake(offsetX, 0) animated:YES]; -} +///// 若按钮中心超过可视区一半,则滚动将其居中 +//- (void)p_scrollToButton:(UIButton *)btn { +// // layoutIfNeeded 保证 frame 已计算 +// [_tabScrollView layoutIfNeeded]; +// +// CGFloat scrollW = _tabScrollView.bounds.size.width; +// CGFloat contentW = _tabScrollView.contentSize.width; +// CGFloat btnCenterX = CGRectGetMidX(btn.frame); +// +// CGFloat offsetX = 0; +// if (btnCenterX > scrollW / 2.0) { +// offsetX = btnCenterX - scrollW / 2.0; +// offsetX = MIN(offsetX, MAX(contentW - scrollW, 0)); +// } +// +// [_tabScrollView setContentOffset:CGPointMake(offsetX, 0) animated:YES]; +//} #pragma mark - DataList Setter @@ -546,14 +527,12 @@ weekLabel; _emptyLabel.hidden = NO; _emptyView.hidden = YES; _collectionView.hidden = YES; - _tabScrollView.hidden = YES; return; } // 已登录:隐藏 emptyLabel,显示内容区 _emptyLabel.hidden = YES; _collectionView.hidden = NO; - _tabScrollView.hidden = NO; // 无设备数据:显示 emptyView(图标 + 提示 + 去绑定按钮) BOOL isEmpty = (_dataList.count == 0); @@ -567,6 +546,13 @@ weekLabel; } else { [self p_stopAutoScroll]; } + + // 通知外部更新高度:无数据/未登录 104,有数据 205 + BOOL needSmall = (isEmpty || ![HQCommonUtils isLogin]); + CGFloat newHeight = needSmall ? 104.0 : 200.0; + if (self.heightChangeBlock) { + self.heightChangeBlock(newHeight); + } } #pragma mark - UICollectionViewDataSource