- 手动集成微信 OpenSDK-NoPay,创建 XJWeChatManager 统一管理分享能力 - 地图卡片新增长按手势,通过代理模式实现「转发到微信」,分享含高德导航链接 - 聊天页新增群成员侧滑面板,支持查看成员列表及一键拨号 - 新增急救资源详情页(XJFirstAidResourceDetailVC)及选择联系人页 - 首页健康知识/资讯模块,含双视图列表及 H5 跳转 - 修复急救资源详情页编译报错 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
365 lines
12 KiB
Objective-C
365 lines
12 KiB
Objective-C
//
|
||
// BindWatchPopView.m
|
||
// XinjiangProject
|
||
//
|
||
// Created by Apple on 2026/3/12.
|
||
//
|
||
|
||
#import "BindWatchPopView.h"
|
||
|
||
@interface BindWatchPopView ()
|
||
|
||
@property (nonatomic,strong) UIView *bottomView;
|
||
|
||
@property (nonatomic,strong) UITextField *workNoField;
|
||
@property (nonatomic,strong) UITextField *nameField;
|
||
@property (nonatomic,strong) UITextField *numberField;
|
||
@property (nonatomic,strong) UIButton *actionBtn;
|
||
@property (nonatomic,strong) UIView *gestureView;
|
||
|
||
|
||
@end
|
||
|
||
@implementation BindWatchPopView
|
||
|
||
- (instancetype)initWithFrame:(CGRect)frame {
|
||
|
||
if (self = [super initWithFrame:frame]) {
|
||
|
||
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
|
||
|
||
[self createUI];
|
||
[self addKeyboardNotification];
|
||
}
|
||
|
||
return self;
|
||
}
|
||
|
||
#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(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);
|
||
indicator.layer.cornerRadius = 3;
|
||
[self.bottomView addSubview:indicator];
|
||
|
||
[indicator mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerX.offset(0);
|
||
make.top.offset(8);
|
||
make.width.offset(40);
|
||
make.height.offset(6);
|
||
}];
|
||
|
||
|
||
UILabel *titleLab = [[UILabel alloc] init];
|
||
titleLab.text = @"健康监测工具绑定";
|
||
titleLab.font = [UIFont boldSystemFontOfSize:16];
|
||
titleLab.textAlignment = NSTextAlignmentCenter;
|
||
[self.bottomView addSubview:titleLab];
|
||
|
||
[titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.right.offset(0);
|
||
make.top.offset(28);
|
||
}];
|
||
|
||
HQUserInfo * user = [HQCommonUtils keyedUnarchiverWithKey:LoginUserInfo];
|
||
|
||
UILabel * nameLabel = [[UILabel alloc] init];
|
||
nameLabel.textColor = UIColorHex(#808080);
|
||
nameLabel.font= [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
|
||
nameLabel.textAlignment = NSTextAlignmentLeft;
|
||
if (!ValidStr(user.realname)) {
|
||
nameLabel.text = [NSString stringWithFormat:@"%@",user.realname];
|
||
}
|
||
[self.bottomView addSubview:nameLabel];
|
||
|
||
// 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];
|
||
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.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];
|
||
|
||
[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);
|
||
bindBtn.layer.cornerRadius = 22;
|
||
bindBtn.titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||
[bindBtn addTarget:self action:@selector(bindwatchClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
self.actionBtn = bindBtn;
|
||
[self.bottomView addSubview:bindBtn];
|
||
|
||
[bindBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.centerX.offset(0);
|
||
make.width.offset(215);
|
||
make.height.offset(44);
|
||
make.top.equalTo(self.numberField.mas_bottom).offset(23);
|
||
}];
|
||
|
||
}
|
||
|
||
- (void)updateUI {
|
||
|
||
if (self.type == BindWatchTypeUnbind) {
|
||
|
||
// 解绑页面:显示已绑定SN,按钮改为"绑定"并禁用(30%透明度,不可点击)
|
||
[self.actionBtn setTitle:@"绑定" forState:UIControlStateNormal];
|
||
self.actionBtn.alpha = 0.3;
|
||
self.actionBtn.userInteractionEnabled = NO;
|
||
self.numberField.text = self.serialNumber;
|
||
self.numberField.backgroundColor = UIColorHex(#F5F7FB);
|
||
self.numberField.enabled = NO;
|
||
|
||
} else {
|
||
|
||
// 绑定页面:正常可点击
|
||
[self.actionBtn setTitle:@"绑定" forState:UIControlStateNormal];
|
||
self.actionBtn.alpha = 1.0;
|
||
self.actionBtn.userInteractionEnabled = YES;
|
||
self.numberField.text = @"";
|
||
self.numberField.enabled = YES;
|
||
self.numberField.backgroundColor = KWhiteColor;
|
||
|
||
}
|
||
}
|
||
|
||
- (void)bindwatchClick:(UIButton *)btn {
|
||
|
||
NSString *number = self.numberField.text;
|
||
|
||
if (self.actionBlock) {
|
||
self.actionBlock(self.type, number);
|
||
}
|
||
|
||
[self close];
|
||
}
|
||
#pragma mark - 创建控件
|
||
|
||
- (UILabel *)createLabel:(NSString *)text {
|
||
|
||
UILabel *lab = [[UILabel alloc] init];
|
||
lab.text = text;
|
||
lab.font = [UIFont systemFontOfSize:16];
|
||
lab.textAlignment = NSTextAlignmentCenter;
|
||
|
||
return lab;
|
||
}
|
||
|
||
- (UITextField *)createTextField {
|
||
|
||
UITextField *field = [[UITextField alloc] init];
|
||
field.backgroundColor = UIColorHex(#F5F7FB);
|
||
field.layer.cornerRadius = 8;
|
||
field.layer.borderWidth = 1;
|
||
field.layer.borderColor = UIColorHex(#E6E6EA).CGColor;
|
||
|
||
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 12, 52)];
|
||
field.leftView = leftView;
|
||
field.leftViewMode = UITextFieldViewModeAlways;
|
||
|
||
return field;
|
||
}
|
||
|
||
|
||
- (void)close {
|
||
|
||
[self endEditing:YES];
|
||
|
||
[UIView animateWithDuration:0.25 animations:^{
|
||
self.bottomView.transform = CGAffineTransformMakeTranslation(0, 342);
|
||
self.alpha = 0;
|
||
} completion:^(BOOL finished) {
|
||
[self removeFromSuperview];
|
||
}];
|
||
}
|
||
|
||
#pragma mark - 键盘
|
||
|
||
- (void)addKeyboardNotification {
|
||
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardWillShowNotification object:nil];
|
||
|
||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardHide:) name:UIKeyboardWillHideNotification object:nil];
|
||
}
|
||
|
||
- (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];
|
||
}];
|
||
}
|
||
|
||
#pragma mark - show
|
||
|
||
- (void)show {
|
||
|
||
[self updateUI];
|
||
|
||
UIWindow *window = UIApplication.sharedApplication.keyWindow;
|
||
|
||
self.frame = window.bounds;
|
||
|
||
[window addSubview:self];
|
||
|
||
self.bottomView.transform = CGAffineTransformMakeTranslation(0, 342);
|
||
|
||
[UIView animateWithDuration:0.25 animations:^{
|
||
self.bottomView.transform = CGAffineTransformIdentity;
|
||
}];
|
||
}
|
||
|
||
- (void)dealloc {
|
||
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||
}
|
||
|
||
@end
|