diff --git a/XinjiangProject/XinjiangProject.xcodeproj/project.pbxproj b/XinjiangProject/XinjiangProject.xcodeproj/project.pbxproj index 8e4fecf..26fa44c 100644 --- a/XinjiangProject/XinjiangProject.xcodeproj/project.pbxproj +++ b/XinjiangProject/XinjiangProject.xcodeproj/project.pbxproj @@ -375,7 +375,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_TEAM = A7CC5LW224; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_PREFIX_HEADER = "$(SRCROOT)/XinjiangProject/Supporting Files/PrefixHeader.pch"; @@ -419,7 +419,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_TEAM = A7CC5LW224; ENABLE_USER_SCRIPT_SANDBOXING = NO; GCC_PREFIX_HEADER = "$(SRCROOT)/XinjiangProject/Supporting Files/PrefixHeader.pch"; diff --git a/XinjiangProject/XinjiangProject/Define/StatusMacros.h b/XinjiangProject/XinjiangProject/Define/StatusMacros.h index 84e01cc..af9b4bd 100755 --- a/XinjiangProject/XinjiangProject/Define/StatusMacros.h +++ b/XinjiangProject/XinjiangProject/Define/StatusMacros.h @@ -68,10 +68,10 @@ //#define SCHEME @"https" // //正式地址 -#define Http @"https://api-jkglpt.iosp.ydpt.tech"// -#define H5DevHost @"api-jkglpt.iosp.ydpt.tech"// -#define IntervenH5 @"https://console-jkglpt.iosp.ydpt.tech" -#define SCHEME @"https" // +//#define Http @"https://api-jkglpt.iosp.ydpt.tech"// +//#define H5DevHost @"api-jkglpt.iosp.ydpt.tech"// +//#define IntervenH5 @"https://console-jkglpt.iosp.ydpt.tech" +//#define SCHEME @"https" // //卫鑫本地 //#define Http @"https://api-jkglpt.iosp.ydpt.tech"// @@ -84,11 +84,11 @@ // 最新地址 //#define Http @"http://192.168.1.47"//王昊 -//#define Http @"https://xj-api.mcrm.vip:8888"// -////#define Http @"http://192.168.1.47"//王昊 -//#define H5DevHost @"xj-api.mcrm.vip:8888"// -//#define IntervenH5 @"https://xj-admin.mcrm.vip:8888" -//#define SCHEME @"https" // +#define Http @"https://xj-api.mcrm.vip:8888"// +//#define Http @"http://192.168.1.22"//王昊 +#define H5DevHost @"xj-api.mcrm.vip:8888"// +#define IntervenH5 @"https://xj-admin.mcrm.vip:8888" +#define SCHEME @"https" // //新疆项目后期的调试环境由阿里云迁移至公司内部主机服务器,功能联调和测试可用以下的环境地址 //https://api-xj.tri.icdat.cn diff --git a/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.h b/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.h index f0a2d4e..5d9d082 100755 --- a/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.h +++ b/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.h @@ -181,4 +181,9 @@ - (void)getWebNeedEncryptionKey:(NSMutableDictionary *)parmDic; +//绑定手表 +- (void)getBindWatchDevice:(NSMutableDictionary *)parmDic; +//解绑手表 +- (void)getUnBindWatchDevice:(NSMutableDictionary *)parmDic; + @end diff --git a/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.m b/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.m index ee98b90..6d093ad 100755 --- a/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.m +++ b/XinjiangProject/XinjiangProject/Manager/NetworkHelpManager/XJPNetAPI.m @@ -912,4 +912,14 @@ [httpRequest httpGetRequest:[NSString stringWithFormat:@"%@/health-watch/api/watchData/userWatchDataAll",Http] params:parmDic]; } + +- (void)getBindWatchDevice:(NSMutableDictionary *)parmDic { + + [httpRequest httpGetRequest:[NSString stringWithFormat:@"%@/health-watch/watch/watchDevice/app/bindDevice",Http] params:parmDic]; +} +//解绑手表 +- (void)getUnBindWatchDevice:(NSMutableDictionary *)parmDic { + + [httpRequest httpGetRequest:[NSString stringWithFormat:@"%@/health-watch/watch/watchDevice/app/unbundleDevice",Http] params:parmDic]; +} @end diff --git a/XinjiangProject/XinjiangProject/Manager/UserManager/HQUserInfo.m b/XinjiangProject/XinjiangProject/Manager/UserManager/HQUserInfo.m index 574353f..e645a9f 100755 --- a/XinjiangProject/XinjiangProject/Manager/UserManager/HQUserInfo.m +++ b/XinjiangProject/XinjiangProject/Manager/UserManager/HQUserInfo.m @@ -21,9 +21,10 @@ [aCoder encodeObject:self.depart_id forKey:@"depart_id"]; [aCoder encodeObject:self.parentId forKey:@"parentId"]; [aCoder encodeObject:self.departName forKey:@"departName"]; + [aCoder encodeObject:self.workNo forKey:@"workNo"]; [aCoder encodeObject:self.token forKey:@"token"]; [aCoder encodeObject:self.sex_dictText forKey:@"sex_dictText"]; - + } @@ -43,6 +44,8 @@ self.parentId = [aDecoder decodeObjectForKey:@"parentId"]; self.departName = [aDecoder decodeObjectForKey:@"departName"]; self.token = [aDecoder decodeObjectForKey:@"token"]; + self.workNo = [aDecoder decodeObjectForKey:@"workNo"]; + self.sex_dictText = [aDecoder decodeObjectForKey:@"sex_dictText"]; } @@ -74,7 +77,8 @@ self.idCard = safeValue(userInfo[@"idCard"]); self.personType = safeValue(userInfo[@"personType"]); self.sex_dictText = safeValue(userInfo[@"sex_dictText"]); - + self.workNo = safeValue(userInfo[@"workNo"]); + NSDictionary *secondDepart = safeValue(userInfo[@"secondDepart"]); if ([secondDepart isKindOfClass:[NSDictionary class]]) { self.secondDepart = secondDepart; diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/Controllview/XJHomePageV2ViewController.m b/XinjiangProject/XinjiangProject/Project/HomeV2/Controllview/XJHomePageV2ViewController.m index 9d60a22..d9f001b 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/Controllview/XJHomePageV2ViewController.m +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/Controllview/XJHomePageV2ViewController.m @@ -36,6 +36,7 @@ #import "HomeBannerModel.h" #import "SDCycleScrollView.h" #import "BRPickerView.h" +#import "BindWatchPopView.h" static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 @@ -79,6 +80,8 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 //加密后的字符串 @property (nonatomic, copy) NSString * secretString; +//绑定弹窗 +@property (nonatomic, strong) BindWatchPopView * bindPopView; @end @@ -102,6 +105,14 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 return _coverView; } +-(BindWatchPopView *)bindPopView { + + if (!_bindPopView) { + _bindPopView = [[BindWatchPopView alloc] initWithFrame:CGRectZero]; + } + return _bindPopView; +} + - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. @@ -375,7 +386,25 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 [searchApi getWebNeedEncryptionKey:parmDic]; } - +#pragma mark:绑定手表 +- (void)getBindWatchDataWithSerialNum:(NSString *)numNo { + [self showMBProgressHUDWithString:@"绑定中,请稍候..." autoHidden:false]; + NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init]; + [parmDic setObject:numNo forKey:@"watchNo"]; + XJPNetAPI * searchApi = [[XJPNetAPI alloc] init:self tag:@"BINDWATCH" NeedToken:@""]; + + [searchApi getBindWatchDevice:parmDic]; +} +#pragma mark:解除绑定手表 +- (void)getUnBindWatchDataWithSerialNum:(NSString *)numNo { + + [self showMBProgressHUDWithString:@"解绑中,请稍候..." autoHidden:false]; + NSMutableDictionary * parmDic = [[NSMutableDictionary alloc] init]; + [parmDic setObject:numNo forKey:@"watchNo"]; + XJPNetAPI * searchApi = [[XJPNetAPI alloc] init:self tag:@"UNBINDWATCH" NeedToken:@""]; + + [searchApi getUnBindWatchDevice:parmDic]; +} - (void)Failed:(NSString*)message tag:(NSString*)tag { @@ -398,12 +427,10 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 }); } if ([tag isEqualToString:@"WEARWATCH"]) { + self.topView.watchArray = @[]; } - if ([tag isEqualToString:@"WEARWATCH"]) { - self.topView.watchArray = @[]; - } - + [self showMBProgressHUDOnlyWithString:message]; [self hiddenAllMBProgressHUD]; @@ -446,68 +473,7 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 } } - - if ([tag isEqualToString:@"IMAPI"]) { - [self hiddenAllMBProgressHUD]; - - NSDictionary * pamrDic = response; - IMUserInfoModel * model = [IMUserInfoModel modelWithDictionary:pamrDic]; - IMUserInfoModel * iminfoModel = [[IMUserInfoModel alloc] init]; - iminfoModel.IMInfo = pamrDic; - [HQCommonUtils keyedArchiverWithData:iminfoModel key:IMLoginUserInfo]; - // 1. 从即时通信 IM 控制台获取应用 SDKAppID。 - // 2. 初始化 config 对象 - V2TIMSDKConfig *config = [[V2TIMSDKConfig alloc] init]; - // 3. 指定 log 输出级别。 - config.logLevel = V2TIM_LOG_INFO; - // 4. 添加 V2TIMSDKListener 的事件监听器,self 是 id 的实现类,如果您不需要监听 IM SDK 的事件,这个步骤可以忽略。 - [[V2TIMManager sharedInstance] addIMSDKListener:self]; - // 5. 初始化 IM SDK,调用这个接口后,可以立即调用登录接口。 - [[V2TIMManager sharedInstance] initSDK:[model.sdkAppId intValue] config:config]; - config.logLevel = V2TIM_LOG_INFO; - - [TUILogin login:[model.sdkAppId intValue] userID:model.userId userSig:model.userSig succ:^{ - - - } fail:^(int code, NSString *msg) { - - [EasyTextView showErrorText:msg]; - - }]; - - } - if ([tag isEqualToString:@"SMALLHELP"]) { - - [self hiddenAllMBProgressHUD]; - - SmallHelpIMDataModel * model = [SmallHelpIMDataModel modelWithDictionary:response]; - ChatViewController * chatVC = [[ChatViewController alloc] init]; - chatVC.isGroupID = YES; - chatVC.chatID = model.groupId; - chatVC.smallHelp_id = model.small_id; - chatVC.isVideo = false; - chatVC.eableSendReport = YES; - chatVC.eableMapTools = false; - chatVC.navTitle = @"全科医生"; - chatVC.eablehaveHelathData = YES; - chatVC.tfNew = model.tfNew; - [self.navigationController pushViewController:chatVC animated:YES]; - - } - - if ([tag isEqualToString:@"loginIMAPI"]) { - [self hiddenAllMBProgressHUD]; - NSDictionary * pamrDic = response; - - IMUserInfoModel * model = [IMUserInfoModel modelWithDictionary:pamrDic]; - - IMUserInfoModel * iminfoModel = [[IMUserInfoModel alloc] init]; - iminfoModel.IMInfo = pamrDic; - [HQCommonUtils keyedArchiverWithData:iminfoModel key:IMLoginUserInfo]; - [ESCTUIManager loginInitTUISDKAppidWith:[model.sdkAppId intValue] UserID:model.userId userSig:model.userSig]; - [self smallQuestionAction]; - - } + if ([tag isEqualToString:@"loginIMList"]) { [self hiddenAllMBProgressHUD]; NSDictionary * pamrDic = response; @@ -541,8 +507,6 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 [self.navigationController pushViewController:chatVC animated:YES]; } - - if ([tag isEqualToString:@"UPVERSION"]) { NSDictionary * dic = response; @@ -633,7 +597,7 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 [self getWatchDetailData]; }else { - + self.topView.model = nil; self.topView.watchArray = @[]; //没手表直接显示没佩戴 } @@ -680,7 +644,20 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 self.secretString = responseDic[@"encryptData"]; } + } + if ([tag isEqualToString:@"BINDWATCH"]) { + [self hiddenAllMBProgressHUD]; + [EasyTextView showSuccessText:@"绑定成功"]; + [self getUserWatchData]; + } + if ([tag isEqualToString:@"UNBINDWATCH"]) { + [self hiddenAllMBProgressHUD]; + [EasyTextView showSuccessText:@"解绑成功"]; + + + DLog(@"%@",response); + [self getUserWatchData]; } } @@ -725,14 +702,6 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 } - -#pragma mark:小助手的回调 -- (void)loginImAccount { - - XJPNetAPI * proctocolApi = [[XJPNetAPI alloc] init:self tag:@"loginIMAPI" NeedToken:nil]; - [proctocolApi GetIMLoginAccount:nil]; - -} #pragma mark:列表点击回调 - (void)loginImAccountList { @@ -761,26 +730,7 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 [self.navigationController pushViewController:foundVC animated:true]; } -// -//- (void)smallQuestionAction { -// -// if ([ESCTUIManager TUIUserStatus] == false) { -// -// -// [self loginImAccount]; -// return; -// } -// -// NSMutableDictionary * dic = [[NSMutableDictionary alloc] init]; -// -// [self showMBProgressHUDWithString:@"咨询中,请稍候..." autoHidden:NO]; -// XJPNetAPI * searchApi = [[XJPNetAPI alloc] init:self tag:@"SMALLHELP" NeedToken:@""]; -// -// [searchApi postSmallHelpGroup:dic]; -// -// -// -//} + - (void)myQuestionAction { @@ -923,6 +873,35 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 [topView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.mas_offset(0); }]; + + self.topView.bindDeviceBlock = ^(NSString * _Nonnull watchNo) { + + BindWatchPopView *pop = [[BindWatchPopView alloc] init]; + + if (ValidStr(watchNo)) { + pop.type = BindWatchTypeBind; + }else + { + pop.serialNumber = watchNo; + pop.type = BindWatchTypeUnbind; + + } + + pop.actionBlock = ^(BindWatchType type, NSString *serialNumber) { + if (type == BindWatchTypeBind) { //绑定 + [weakSelf getBindWatchDataWithSerialNum:serialNumber]; + + }else //解绑 + { + [weakSelf getUnBindWatchDataWithSerialNum:serialNumber]; + + } + }; + + [pop show]; + + }; + self.homeTable = [[XJHomePageV2QuestionTableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; if (@available(iOS 15.0, *)) { @@ -1005,8 +984,9 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 return; } [weakself myQuestionAction]; - }; + + //初始化一个emptyView LYEmptyView *emptyView = [LYEmptyView emptyViewWithImage:[UIImage imageNamed:@"noQuetionList"] titleStr:@"暂无咨询记录" detailStr:@""]; @@ -1189,7 +1169,7 @@ static CGFloat const kEmptyTableMinHeight = 250; // 或屏幕高度的一半 NSString * urlString; #if DEBUG - urlString = @"https://gstest.superwx.cn/healthbank/index.html?"; + urlString = @"https://gstest.superwx.cn/healthbank/index.html"; #else diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.h b/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.h new file mode 100644 index 0000000..37926bd --- /dev/null +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.h @@ -0,0 +1,29 @@ +// +// BindWatchPopView.h +// XinjiangProject +// +// Created by Apple on 2026/3/12. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, BindWatchType) { + BindWatchTypeBind = 0, // 绑定 + BindWatchTypeUnbind // 解绑 +}; + +@interface BindWatchPopView : UIView + +- (void)show; + +@property (nonatomic, assign) BindWatchType type; + +@property (nonatomic, copy) NSString *serialNumber; + +@property (nonatomic, copy) void(^actionBlock)(BindWatchType type, + NSString *serialNumber); +@end + +NS_ASSUME_NONNULL_END diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.m b/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.m new file mode 100644 index 0000000..b3442ab --- /dev/null +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/BindWatchPopView.m @@ -0,0 +1,289 @@ +// +// 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; +@end + +@implementation BindWatchPopView + +- (instancetype)initWithFrame:(CGRect)frame { + + if (self = [super initWithFrame:frame]) { + + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4]; + + [self createUI]; + [self addGesture]; + [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(342); + }]; + + + /// 拖动条 + 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]; + + 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); + }]; + 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; + [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); + }]; + + + 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); + }]; + + + 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(30); + }]; + +} + +- (void)updateUI { + + if (self.type == BindWatchTypeUnbind) { + + [self.actionBtn setTitle:@"解绑" forState:UIControlStateNormal]; + self.numberField.text = self.serialNumber; + self.numberField.enabled = NO; + + } else { + + [self.actionBtn setTitle:@"绑定" forState:UIControlStateNormal]; + self.numberField.text = @""; + self.numberField.enabled = YES; + + } +} + +- (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; +} + +#pragma mark - 点击背景关闭 + +- (void)addGesture { + +// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(close)]; +// tap.cancelsTouchesInView = NO; +// [self addGestureRecognizer:tap]; +} + +- (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); + }]; +} + +- (void)keyboardHide:(NSNotification *)noti { + + [UIView animateWithDuration:0.25 animations:^{ + self.bottomView.transform = CGAffineTransformIdentity; + }]; +} + +#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 diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h index e2f97e2..3574faf 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.h @@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) NSArray * watchArray; +@property (nonatomic, copy, nullable) void (^bindDeviceBlock)(NSString * watchNo); @end diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m index eac2bdf..49df2ab 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomePageV2HeardView.m @@ -326,6 +326,11 @@ } }; + //绑定手表 + self.watchDataView.bindDeviceBlock = ^(NSString * _Nonnull number) { + + weakSelf.bindDeviceBlock(number); + }; [self addSubview:self.watchDataView]; [self.watchDataView mas_makeConstraints:^(MASConstraintMaker *make) { diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h index 61f7fc5..25fb59e 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.h @@ -27,6 +27,8 @@ typedef void(^watchDataDetailBlick)(); @property (nonatomic, copy, nullable) watchDataDetailBlick watchMoreBlock; +/// "去绑定" 按钮点击回调 +@property (nonatomic, copy, nullable) void (^bindDeviceBlock)(NSString * number); /// 数据源,赋值后自动刷新 CollectionView,空数组时显示占位图 @property (nonatomic, copy) NSArray *dataList; diff --git a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m index 5fe724e..43c6f45 100644 --- a/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m +++ b/XinjiangProject/XinjiangProject/Project/HomeV2/View/XJHomeWatchDataView.m @@ -20,7 +20,7 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距 // ── Private ─────────────────────────────────────────────── @interface XJHomeWatchDataView () -@property (nonatomic, strong) UILabel *watchNumberLabel; // +@property (nonatomic, strong) YYLabel *watchNumberLabel; // @property (nonatomic, strong) UIScrollView *tabScrollView; @@ -28,6 +28,7 @@ static CGFloat const kButtonGap = 10.0; // 按钮间距 @property (nonatomic, strong) NSMutableArray *tabButtons; @property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) UILabel *emptyLabel; // 无数据占位 +@property (nonatomic, strong) UIView *emptyView; // 空状态占位整体容器 @property (nonatomic, strong) UIView *devView; // 紧急开发中占位 @property (nonatomic, assign) NSInteger selectedIndex; // 当前选中的 Tab 下标 @property (nonatomic, assign) NSInteger carouselPage; // collectionView 当前轮播页码(与 Tab 无关) @@ -128,9 +129,9 @@ weekLabel; // make.width.height.mas_offset(20); // }]; // - self.watchNumberLabel = [[UILabel alloc] init]; + self.watchNumberLabel = [[YYLabel alloc] init]; - self.watchNumberLabel.text = @"监测工具编码:--"; + self.watchNumberLabel.text = @""; self.watchNumberLabel.textAlignment = NSTextAlignmentLeft; @@ -145,6 +146,14 @@ weekLabel; make.top.mas_offset(0); make.height.mas_offset(40); }]; + MJWeakSelf + [self.watchNumberLabel setTextTapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { + + if (weakSelf.bindDeviceBlock) { + weakSelf.bindDeviceBlock(weakSelf.watchModel.watchNo); + } + }]; + //日期切换 // self.timeView = [[UIView alloc] init]; // self.timeView.backgroundColor = KWhiteColor; @@ -269,8 +278,9 @@ weekLabel; make.center.equalTo(_devView); }]; - // ── 占位 Label(直接加在 self,不受 collectionView 隐藏影响)──── + // ── 未登录占位 Label ───────────────────────────────────────── _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]; @@ -281,21 +291,90 @@ weekLabel; make.center.equalTo(self.collectionView); }]; + // ── 无设备占位 View(已登录但未绑定设备时显示)──────────────── + _emptyView = [[UIView alloc] init]; + _emptyView.backgroundColor = KWhiteColor; + _emptyView.hidden = YES; + [self addSubview:_emptyView]; + + [_emptyView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(_tabScrollView.mas_bottom); + 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); + }]; + + // 去绑定按钮:宽 80 高 24,medium 13,颜色 #21BEBD,圆角 12,白底边框 1 + UIButton *bindBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + [bindBtn setTitle:@"去绑定" forState:UIControlStateNormal]; + [bindBtn setTitleColor:UIColorHex(#21BEBD) forState:UIControlStateNormal]; + bindBtn.titleLabel.font = MEDIUMFONT(13); + bindBtn.backgroundColor = KWhiteColor; + bindBtn.layer.cornerRadius = 12; + bindBtn.layer.borderWidth = 1; + bindBtn.layer.borderColor = UIColorHex(#21BEBD).CGColor; + bindBtn.layer.masksToBounds = YES; + [bindBtn addTarget:self action:@selector(bindButtonClick) forControlEvents:UIControlEventTouchUpInside]; + [_emptyView addSubview:bindBtn]; + + [bindBtn mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(emptyHintLabel.mas_bottom).offset(8); + make.centerX.equalTo(_emptyView); + make.width.mas_offset(80); + make.height.mas_offset(24); + }]; + if ([HQCommonUtils isLogin]) { // 已登录,等待数据回调 } else { - _emptyLabel.text = @" 暂未登录 "; - _emptyLabel.hidden = NO; - _tabScrollView.hidden = false; - _collectionView.hidden = false; + // 未登录:显示"暂未登录"文字,emptyView 保持隐藏 + _emptyLabel.hidden = NO; + _tabScrollView.hidden = NO; + _collectionView.hidden = NO; + } +} + +- (void)bindButtonClick { + if (self.bindDeviceBlock) { + self.bindDeviceBlock(@""); } } - (void)moreClick { - if (self.watchMoreBlock) { + if (self.watchModel.hasWatch == true) { + if (self.watchMoreBlock) { self.watchMoreBlock(); } + }else { + + if (self.bindDeviceBlock) { + self.bindDeviceBlock(@""); + } + } } - (void)setWatchModel:(XJHomeWatchModel *)watchModel { @@ -308,6 +387,7 @@ weekLabel; }else { + self.watchNumberLabel.text = @""; self.dataList = @[]; } @@ -448,20 +528,24 @@ weekLabel; - (void)setDataList:(NSArray *)dataList { _dataList = [dataList copy]; + // 未登录:显示 emptyLabel,隐藏 emptyView 及内容区 if (![HQCommonUtils isLogin]) { - _emptyLabel.text = @" 暂未登录 "; - _emptyLabel.hidden = NO; + _emptyLabel.text = @" 暂未登录 "; + _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); - _emptyLabel.text = @"您目前未配备智能穿戴设备"; - _emptyLabel.hidden = !isEmpty; + _emptyView.hidden = !isEmpty; [_collectionView reloadData]; diff --git a/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/Contents.json b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/Contents.json new file mode 100644 index 0000000..d639d8a --- /dev/null +++ b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "EquipmentNoData.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "EquipmentNoData@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "EquipmentNoData@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData.png b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData.png new file mode 100644 index 0000000..3ffdeb2 Binary files /dev/null and b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData.png differ diff --git a/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData@2x.png b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData@2x.png new file mode 100644 index 0000000..04a4e5f Binary files /dev/null and b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData@2x.png differ diff --git a/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData@3x.png b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData@3x.png new file mode 100644 index 0000000..d0df55f Binary files /dev/null and b/XinjiangProject/XinjiangProject/Supporting Files/Assets.xcassets/HOMEV2/ic_watch_empty.imageset/EquipmentNoData@3x.png differ