diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 6b391573..fa1f303b 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -168,7 +168,6 @@ E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */; }; E84B0E422727EE0A008818C6 /* XPRoomMessageHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */; }; E84B0E462727EF9D008818C6 /* XPRoomMessageParser.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E452727EF9D008818C6 /* XPRoomMessageParser.m */; }; - E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = E865963E27015A9C00846EBD /* XPMineUserTableView.m */; }; E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596412701611A00846EBD /* UIImage+ImageEffects.m */; }; E86596512701A1C000846EBD /* StatisticsService.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596502701A1C000846EBD /* StatisticsService.m */; }; E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596532701A55500846EBD /* StatisticsServiceHelper.m */; }; @@ -625,8 +624,6 @@ E84B0E442727EF9D008818C6 /* XPRoomMessageParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageParser.h; sourceTree = ""; }; E84B0E452727EF9D008818C6 /* XPRoomMessageParser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageParser.m; sourceTree = ""; }; E84B0E4927280289008818C6 /* XPRoomMessageConstant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageConstant.h; sourceTree = ""; }; - E865963D27015A9C00846EBD /* XPMineUserTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineUserTableView.h; sourceTree = ""; }; - E865963E27015A9C00846EBD /* XPMineUserTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineUserTableView.m; sourceTree = ""; }; E86596412701611A00846EBD /* UIImage+ImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ImageEffects.m"; sourceTree = ""; }; E86596422701611A00846EBD /* UIImage+ImageEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ImageEffects.h"; sourceTree = ""; }; E865964F2701A1C000846EBD /* StatisticsService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatisticsService.h; sourceTree = ""; }; @@ -1981,8 +1978,6 @@ E88B5CC426FB42B000DA9178 /* XPMineUserInfoHeaderView.m */, E8EEB91B26FC9D58007C6EBA /* XPMineUserInfoDateView.h */, E8EEB91C26FC9D58007C6EBA /* XPMineUserInfoDateView.m */, - E865963D27015A9C00846EBD /* XPMineUserTableView.h */, - E865963E27015A9C00846EBD /* XPMineUserTableView.m */, ); path = MineInfo; sourceTree = ""; @@ -2662,7 +2657,6 @@ E8C6FFD42754AA87004DC9F0 /* XPNoteView.m in Sources */, E82325F9274E2E42003A3332 /* Api+UserCard.m in Sources */, E82109B026F1D83500FC3319 /* LoginBindPhonePresent.m in Sources */, - E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */, E8B825C726EA0D9A009E8E9F /* LoginVerifCodeProtocol.h in Sources */, E824544E26F5BC1A00BE8163 /* XPMineModifPayPwdView.m in Sources */, E8B825CA26EA1231009E8E9F /* LoginVerifCodeViewController.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/Contents.json b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/Contents.json new file mode 100644 index 00000000..7130e4f1 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "mine_user_info_bottom_attention_normal@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "mine_user_info_bottom_attention_normal@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/mine_user_info_bottom_attention_normal@2x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/mine_user_info_bottom_attention_normal@2x.png new file mode 100644 index 00000000..ca9643d7 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/mine_user_info_bottom_attention_normal@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/mine_user_info_bottom_attention_normal@3x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/mine_user_info_bottom_attention_normal@3x.png new file mode 100644 index 00000000..c69481ce Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_normal.imageset/mine_user_info_bottom_attention_normal@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/Contents.json b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/Contents.json new file mode 100644 index 00000000..e4ce0f4a --- /dev/null +++ b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "mine_user_info_bottom_attention_select@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "mine_user_info_bottom_attention_select@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/mine_user_info_bottom_attention_select@2x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/mine_user_info_bottom_attention_select@2x.png new file mode 100644 index 00000000..3b51a081 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/mine_user_info_bottom_attention_select@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/mine_user_info_bottom_attention_select@3x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/mine_user_info_bottom_attention_select@3x.png new file mode 100644 index 00000000..851f8a9d Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_attention_select.imageset/mine_user_info_bottom_attention_select@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/Contents.json b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/Contents.json new file mode 100644 index 00000000..967476cf --- /dev/null +++ b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "mine_user_info_bottom_chat@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "mine_user_info_bottom_chat@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/mine_user_info_bottom_chat@2x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/mine_user_info_bottom_chat@2x.png new file mode 100644 index 00000000..6864c3cb Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/mine_user_info_bottom_chat@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/mine_user_info_bottom_chat@3x.png b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/mine_user_info_bottom_chat@3x.png new file mode 100644 index 00000000..c3eeaede Binary files /dev/null and b/xplan-ios/Assets.xcassets/Mine/mine_user_info_bottom_chat.imageset/mine_user_info_bottom_chat@3x.png differ diff --git a/xplan-ios/Base/MVP/Model/UserInfoModel.h b/xplan-ios/Base/MVP/Model/UserInfoModel.h index e9ea15ca..d1e0ff55 100644 --- a/xplan-ios/Base/MVP/Model/UserInfoModel.h +++ b/xplan-ios/Base/MVP/Model/UserInfoModel.h @@ -56,6 +56,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy) NSString *nameplatePic; ///铭牌名称 @property (nonatomic, copy) NSString *nameplateWord; +///如果在房间有直播中字段 +@property(nonatomic, copy) NSString * roomUid; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/Model/HomeSearchResultModel.h b/xplan-ios/Main/Home/Model/HomeSearchResultModel.h index 71c8329e..40c21991 100644 --- a/xplan-ios/Main/Home/Model/HomeSearchResultModel.h +++ b/xplan-ios/Main/Home/Model/HomeSearchResultModel.h @@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,assign) BOOL valid; ///性别 @property (nonatomic,assign) GenderType gender; +///搜索用户的时候 如果用户在房间中的话 就有roomUid +@property (nonatomic,copy) NSString *roomUid; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m b/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m index 727260ba..04be731c 100644 --- a/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m +++ b/xplan-ios/Main/Home/Presenter/XPHomeSearchPresenter.m @@ -20,7 +20,7 @@ [Api searchComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { NSArray * array = [HomeSearchResultModel modelsWithArray:data.data]; [[self getView] searchRoomSuccess:array]; - }] key:key type:type page:@"1" pageSize:@"50"]; + } showLoading:YES] key:key type:type page:@"1" pageSize:@"50"]; } @end diff --git a/xplan-ios/Main/Home/View/Cell/XPSearchListTableViewCell.m b/xplan-ios/Main/Home/View/Cell/XPSearchListTableViewCell.m index d0a81907..57d68f4b 100644 --- a/xplan-ios/Main/Home/View/Cell/XPSearchListTableViewCell.m +++ b/xplan-ios/Main/Home/View/Cell/XPSearchListTableViewCell.m @@ -53,15 +53,16 @@ self.nickLabel.text = type == SearchType_Room ? resultModel.title : resultModel.nick; self.idLabel.text = [NSString stringWithFormat:@"%@号:%@",AppName, resultModel.erbanNo]; self.sexImageView.image = resultModel.gender == GenderType_Female ? [UIImage imageNamed:@"common_female"] : [UIImage imageNamed:@"common_male"]; - self.numberView.hidden = !resultModel.valid; if (type == SearchType_Users) { self.numberLabel.text = @"直播中"; + self.numberView.hidden = resultModel.roomUid.length <= 0; } else { if (resultModel.onlineNum > 100) { self.numberLabel.text = [NSString stringWithFormat:@"%ld", resultModel.onlineNum]; } else { self.numberLabel.text = [NSString stringWithFormat:@" %ld ", resultModel.onlineNum]; } + self.numberView.hidden = !resultModel.valid; } } } diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.h b/xplan-ios/Main/Mine/Api/Api+Mine.h index e0f075dc..5973a0b5 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.h +++ b/xplan-ios/Main/Mine/Api/Api+Mine.h @@ -136,6 +136,33 @@ NS_ASSUME_NONNULL_BEGIN + (void)logoutCurrentAccount:(HttpRequestHelperCompletion)complection access_token:(NSString *)access_token; +/// 查询两个人的关注状态 +/// @param complection 完成 +/// @param uid 自己的uid +/// @param isLikeUid 要查询的那个人的uid ++ (void)attentionStatusComplection:(HttpRequestHelperCompletion)complection + uid:(NSString *)uid + isLikeUid:(NSString *)isLikeUid; + +/// 关注某人 +/// @param complection 完成 +/// @param uid 发起关注的人 +/// @param likedUid 被关注的人 +/// @param ticket ticket +/// @param type l类型默认1 ++ (void)attentionComplection:(HttpRequestHelperCompletion)complection + uid:(NSString *)uid + likedUid:(NSString *)likedUid + ticket:(NSString *)ticket + type:(NSString *)type; + +/// 获取用户详情 +/// @param complection 完成 +/// @param uid 发起关注的人 +/// @param page page +/// @param pageSize pagesize ++ (void)userDetailInfoComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid page:(NSString *)page pageSize:(NSString *)pageSize; + @end diff --git a/xplan-ios/Main/Mine/Api/Api+Mine.m b/xplan-ios/Main/Mine/Api/Api+Mine.m index b8296756..f31f11d5 100644 --- a/xplan-ios/Main/Mine/Api/Api+Mine.m +++ b/xplan-ios/Main/Mine/Api/Api+Mine.m @@ -138,5 +138,31 @@ [self makeRequest:@"acc/logout" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, access_token, nil]; } +/// 查询两个人的关注状态 +/// @param complection 完成 +/// @param uid 自己的uid +/// @param isLikeUid 要查询的那个人的uid ++ (void)attentionStatusComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid isLikeUid:(NSString *)isLikeUid { + [self makeRequest:@"fans/islike" method:HttpRequestHelperMethodGET completion:complection,__FUNCTION__, uid, isLikeUid, nil]; +} + +/// 关注某人 +/// @param complection 完成 +/// @param uid 发起关注的人 +/// @param likedUid 被关注的人 +/// @param ticket ticket +/// @param type 1 关注 2取消关注 ++ (void)attentionComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid likedUid:(NSString *)likedUid ticket:(NSString *)ticket type:(NSString *)type { + [self makeRequest:@"fans/like" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, uid, likedUid, ticket, type, nil]; +} + +/// 获取用户详情 +/// @param complection 完成 +/// @param uid 发起关注的人 +/// @param page page +/// @param pageSize pagesize ++ (void)userDetailInfoComplection:(HttpRequestHelperCompletion)complection uid:(NSString *)uid page:(NSString *)page pageSize:(NSString *)pageSize { + [self makeRequest:@"user/detail/get" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, uid, page, pageSize, nil]; +} @end diff --git a/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.h b/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.h index f18a5440..0d1ef7ac 100644 --- a/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.h +++ b/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.h @@ -12,6 +12,16 @@ NS_ASSUME_NONNULL_BEGIN @interface XPMineUserInfoPresenter : BaseMvpPresenter // 获取用户信息 - (void)getUserInfoWithUid:(NSString *)uid; +// 获取用户详细信息 +- (void)getUserDetailInfoWithUid:(NSString *)uid; +/// 两个人的关注状态 +/// @param targetUid 对方的uid +- (void)getUserAttentionState:(NSString *)targetUid; + +/// 关注用户 /取消该关注 +/// @param targetUid 目标用户的uid +/// @param state 是否关注 yes 关注 NO 取消关注 +- (void)attentionUser:(NSString *)targetUid state:(BOOL)state; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.m b/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.m index 188d01bd..3d5a348d 100644 --- a/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.m +++ b/xplan-ios/Main/Mine/Presenter/XPMineUserInfoPresenter.m @@ -6,8 +6,9 @@ // #import "XPMineUserInfoPresenter.h" -///Api +///Tool #import "Api+Mine.h" +#import "AccountInfoStorage.h" ///Model #import "UserInfoModel.h" ///P @@ -25,5 +26,35 @@ }] uid:uid]; } +// 获取用户详细信息 +- (void)getUserDetailInfoWithUid:(NSString *)uid { + [Api userDetailInfoComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data]; + [[self getView] ongetDetailInfoSuccess:infoModel]; + }] uid:uid page:@"1" pageSize:@"20"]; +} + +/// 两个人的关注状态 +/// @param targetUid 对方的uid +- (void)getUserAttentionState:(NSString *)targetUid; { + NSString * uid = [[AccountInfoStorage instance] getUid]; + [Api attentionStatusComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + BOOL isLike = ((NSNumber *)data.data).boolValue; + [[self getView] getAttentionStateSuccess:isLike]; + }] uid:uid isLikeUid:targetUid]; +} + + +/// 关注用户 /取消该关注 +/// @param targetUid 目标用户的uid +/// @param state 是否关注 yes 关注 NO 取消关注 +- (void)attentionUser:(NSString *)targetUid state:(BOOL)state { + NSString * uid = [[AccountInfoStorage instance] getUid]; + NSString * ticket = [[AccountInfoStorage instance] getTicket]; + NSString * type = state ? @"1" : @"2"; + [Api attentionComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] attentionUserSuccess:state]; + }] uid:uid likedUid:targetUid ticket:ticket type:type]; +} @end diff --git a/xplan-ios/Main/Mine/Protocol/XPMineUserInfoProtocol.h b/xplan-ios/Main/Mine/Protocol/XPMineUserInfoProtocol.h index 4469d93d..383867c2 100644 --- a/xplan-ios/Main/Mine/Protocol/XPMineUserInfoProtocol.h +++ b/xplan-ios/Main/Mine/Protocol/XPMineUserInfoProtocol.h @@ -12,6 +12,12 @@ NS_ASSUME_NONNULL_BEGIN @protocol XPMineUserInfoProtocol ///获取用户信息成功 - (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo; +///获取用户详细信息成功 +- (void)ongetDetailInfoSuccess:(UserInfoModel *)userInfo; +///关注/取消关注 +- (void)attentionUserSuccess:(BOOL)status; +///获取关注状态 +- (void)getAttentionStateSuccess:(BOOL)status; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoTableViewCell.m b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoTableViewCell.m index e5caffb7..79054a40 100644 --- a/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoTableViewCell.m +++ b/xplan-ios/Main/Mine/View/Cell/MineInfo/XPMineUserInfoTableViewCell.m @@ -24,6 +24,8 @@ @property (nonatomic,strong) UILabel *idLabel; ///签名 @property (nonatomic,strong) UILabel *signLabel; +///正在直播中 +@property (nonatomic,strong) UIButton *onlineButton; @end @implementation XPMineUserInfoTableViewCell @@ -46,6 +48,7 @@ [self.backView addSubview:self.sexImageView]; [self.backView addSubview:self.idLabel]; [self.backView addSubview:self.signLabel]; + [self.backView addSubview:self.onlineButton]; } - (void)initSubViewConstraints { @@ -73,6 +76,12 @@ make.left.mas_equalTo(self.nameLabel); make.top.mas_equalTo(self.idLabel.mas_bottom).offset(18); }]; + + [self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(55, 18)); + make.right.mas_equalTo(self.backView).offset(-15); + make.top.mas_equalTo(self.backView).offset(10); + }]; } #pragma mark - Getters And Setters @@ -137,5 +146,22 @@ return _signLabel; } +- (UIButton *)onlineButton { + if (!_onlineButton) { + _onlineButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_onlineButton setTitle:@"直播中" forState:UIControlStateNormal]; + [_onlineButton setImage:[UIImage imageNamed:@"home_search_user_online"] forState:UIControlStateNormal]; + [_onlineButton setTitleColor:[ThemeColor appMainColor] forState:UIControlStateNormal]; + _onlineButton.backgroundColor = [UIColor clearColor]; + _onlineButton.titleLabel.font = [UIFont systemFontOfSize:10]; + _onlineButton.layer.masksToBounds = YES; + _onlineButton.layer.cornerRadius = 18/2; + _onlineButton.layer.borderColor = [ThemeColor appMainColor].CGColor; + _onlineButton.layer.borderWidth = 1; + [_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _onlineButton; +} + @end diff --git a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m index aa2b55ad..34ba718d 100644 --- a/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m +++ b/xplan-ios/Main/Mine/View/MineInfo/XPMineUserInfoViewController.m @@ -16,29 +16,35 @@ #import "AccountInfoStorage.h" #import "TTPopup.h" #import "XPHtmlUrl.h" +#import "UIImage+Utils.h" ///View #import "XPMineUserInfoTableViewCell.h" #import "XPMineUserInfoHeaderView.h" #import "XPMineUserInfoCustomNavView.h" -#import "XPMineUserTableView.h" ///P #import "XPMineUserInfoPresenter.h" #import "XPMineUserInfoProtocol.h" ///VC #import "XPMineUserInfoEditViewController.h" #import "XPWebViewController.h" +#import "SessionViewController.h" +#import "XPRoomViewController.h" -@interface XPMineUserInfoViewController () +@interface XPMineUserInfoViewController () ///列别 -@property (nonatomic,strong) XPMineUserTableView *tableView; +@property (nonatomic,strong) UITableView *tableView; ///头部视图 @property (nonatomic,strong) XPMineUserInfoHeaderView *headView; -///table的顶部视图 -@property (nonatomic,strong) UIView * tableViewHeadView; ///自定义的导航栏 @property (nonatomic,strong) XPMineUserInfoCustomNavView *navView; ///用户信息 @property (nonatomic,strong) UserInfoModel *userInfo; +///底部的容器 +@property (nonatomic,strong) UIStackView *bottomStackView; +///私聊 +@property (nonatomic,strong) UIButton *chatButton; +///关注 +@property (nonatomic,strong) UIButton *attentionButton; @end @implementation XPMineUserInfoViewController @@ -55,6 +61,7 @@ [super viewDidLoad]; [self initSubViews]; [self initSubViewConstraints]; + [self initHttpRequest]; } - (void)viewWillAppear:(BOOL)animated { @@ -72,19 +79,24 @@ #pragma mark - Private Method - (void)initSubViews { - [self.view addSubview:self.headView]; [self.view addSubview:self.tableView]; [self.view addSubview:self.navView]; - self.tableView.tableHeaderView = self.tableViewHeadView; - self.tableView.userInfoVC = self; + + self.tableView.tableHeaderView = self.headView; + if (self.uid != [AccountInfoStorage instance].getUid.integerValue) { + [self.view addSubview:self.bottomStackView]; + [self.bottomStackView addArrangedSubview:self.chatButton]; + [self.bottomStackView addArrangedSubview:self.attentionButton]; + + [self.bottomStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view).inset(25); + make.height.mas_equalTo(36); + make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 15); + }]; + } } - (void)initSubViewConstraints { - [self.headView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self.view); - make.height.mas_equalTo(250 + kSafeAreaTopHeight); - }]; - [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self.view); }]; @@ -93,6 +105,16 @@ make.left.right.top.mas_equalTo(self.view); make.height.mas_equalTo(kNavigationHeight); }]; + + +} + +- (void)initHttpRequest { + NSString *uid = [NSString stringWithFormat:@"%ld", self.uid]; + [self.presenter getUserAttentionState:uid]; + + //获取用户详细信息 跟随进房目前使用的这个接口 + [self.presenter getUserDetailInfoWithUid:uid]; } #pragma mark - 拉黑 移除黑名单 @@ -157,12 +179,9 @@ } #pragma mark - UITableViewDelegate And UITableViewDataSource -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; -} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 1; + return 0; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -192,13 +211,42 @@ [self.navigationController popViewControllerAnimated:YES]; } +#pragma mark - XPMineUserInfoHeaderViewDelegate +- (void)xPMineUserInfoHeaderView:(XPMineUserInfoHeaderView *)view didClickGoToRoom:(NSString *)roomUid { + [XPRoomViewController openRoom:roomUid viewController:self]; +} + #pragma mark - XPMineUserInfoProtocol - (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo { self.userInfo = userInfo; - self.headView.userInfo = userInfo; [self.tableView reloadData]; } +- (void)ongetDetailInfoSuccess:(UserInfoModel *)userInfo { + self.headView.userInfo = userInfo; +} + +- (void)getAttentionStateSuccess:(BOOL)status { + self.attentionButton.selected = status; +} + +- (void)attentionUserSuccess:(BOOL)status { + self.attentionButton.selected = status; +} + +#pragma mark - Event Response +- (void)chatButtonAction:(UIButton *)sender { + NSString * sessionId = [NSString stringWithFormat:@"%ld",self.uid]; + NIMSession * session = [NIMSession session:sessionId type:NIMSessionTypeP2P]; + SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session]; + [self.navigationController pushViewController:sessionVC animated:YES]; +} + +- (void)attentionButtonAction:(UIButton *)sender { + NSString *uid = [NSString stringWithFormat:@"%ld", self.uid]; + [self.presenter attentionUser:uid state:!sender.selected]; +} + #pragma mark - Getters And Setters - (void)setUid:(NSInteger)uid { _uid = uid; @@ -216,9 +264,9 @@ } } -- (XPMineUserTableView *)tableView { +- (UITableView *)tableView { if (!_tableView) { - _tableView = [[XPMineUserTableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.tableFooterView = [UIView new]; @@ -235,19 +283,12 @@ - (XPMineUserInfoHeaderView *)headView { if (!_headView) { _headView = [[XPMineUserInfoHeaderView alloc] init]; + _headView.frame = CGRectMake(0, 0, KScreenWidth, 270 + kSafeAreaTopHeight); + _headView.delegate = self; } return _headView; } -- (UIView *)tableViewHeadView { - if (!_tableViewHeadView) { - _tableViewHeadView = [[UIView alloc] init]; - _tableViewHeadView.frame = CGRectMake(0, 0, KScreenWidth, 179 + kSafeAreaTopHeight); - _tableViewHeadView.backgroundColor = [UIColor clearColor]; - } - return _tableViewHeadView; -} - - (XPMineUserInfoCustomNavView *)navView { if (!_navView) { _navView = [[XPMineUserInfoCustomNavView alloc] init]; @@ -256,4 +297,50 @@ return _navView; } +- (UIStackView *)bottomStackView { + if (!_bottomStackView) { + _bottomStackView = [[UIStackView alloc] init]; + _bottomStackView.axis = UILayoutConstraintAxisHorizontal; + _bottomStackView.distribution = UIStackViewDistributionFillEqually; + _bottomStackView.alignment = UIStackViewAlignmentFill; + _bottomStackView.spacing = 25; + } + return _bottomStackView; +} + +- (UIButton *)chatButton { + if (!_chatButton) { + _chatButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_chatButton setTitle:@"私信" forState:UIControlStateNormal]; + [_chatButton setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateNormal]; + [_chatButton setImage:[UIImage imageNamed:@"mine_user_info_bottom_chat"] forState:UIControlStateNormal]; + _chatButton.titleLabel.font = [UIFont systemFontOfSize:15]; + [_chatButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor], [ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal]; + _chatButton.layer.masksToBounds = YES; + _chatButton.layer.cornerRadius = 36/2; + [_chatButton addTarget:self action:@selector(chatButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _chatButton; +} + +- (UIButton *)attentionButton { + if (!_attentionButton) { + _attentionButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_attentionButton setTitle:@"关注" forState:UIControlStateNormal]; + [_attentionButton setTitle:@"已关注" forState:UIControlStateSelected]; + [_attentionButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal]; + [_attentionButton setTitleColor:[ThemeColor cancelButtonTextColor] forState:UIControlStateSelected]; + [_attentionButton setImage:[UIImage imageNamed:@"mine_user_info_bottom_attention_normal"] forState:UIControlStateNormal]; + [_attentionButton setImage:[UIImage imageNamed:@"mine_user_info_bottom_attention_select"] forState:UIControlStateSelected]; + _attentionButton.titleLabel.font = [UIFont systemFontOfSize:15]; + [_attentionButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal]; + [_attentionButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor cancelButtonGradientStartColor], [ThemeColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateSelected]; + _attentionButton.layer.masksToBounds = YES; + _attentionButton.layer.cornerRadius = 36/2; + [_attentionButton addTarget:self action:@selector(attentionButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _attentionButton; +} + + @end diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h index 562b2f28..273539fa 100644 --- a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h +++ b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.h @@ -8,12 +8,19 @@ #import NS_ASSUME_NONNULL_BEGIN -@class UserInfoModel, SDCycleScrollView; +@class UserInfoModel, SDCycleScrollView,XPMineUserInfoHeaderView; +@protocol XPMineUserInfoHeaderViewDelegate + +- (void)xPMineUserInfoHeaderView:(XPMineUserInfoHeaderView *)view didClickGoToRoom:(NSString *)roomUid; + +@end + @interface XPMineUserInfoHeaderView : UIView -/// @property (nonatomic,strong) UserInfoModel *userInfo; ///轮播图 @property (nonatomic,strong, readonly) SDCycleScrollView *cycleScrollView; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m index ed7618ea..a9fa23d4 100644 --- a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m +++ b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserInfoHeaderView.m @@ -71,6 +71,18 @@ @property (nonatomic,strong) UILabel *pageLabel; ///图片数组 @property (nonatomic,strong) NSArray *imageUrls; +///背景 +@property (nonatomic,strong) UIView * backView; +///名字 +@property (nonatomic,strong) UILabel *nameLabel; +///sex +@property (nonatomic,strong) UIImageView *sexImageView; +///id +@property (nonatomic,strong) UILabel *idLabel; +///签名 +@property (nonatomic,strong) UILabel *signLabel; +///正在直播中 +@property (nonatomic,strong) UIButton *onlineButton; @end @implementation XPMineUserInfoHeaderView @@ -84,17 +96,7 @@ return self; } -- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { - UIView * view = [self.cycleScrollView hitTest:point withEvent:event]; - return view; -} - #pragma mark - Private Method -- (void)initSubViews { - [self addSubview:self.cycleScrollView]; - [self addSubview:self.pageLabel]; -} - - (void)initSubViewConstraints { [self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self); @@ -106,7 +108,51 @@ make.height.mas_equalTo(16); make.top.mas_equalTo(self).offset(148 + kSafeAreaTopHeight); }]; + + [self.backView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self).inset(15); + make.bottom.mas_equalTo(self).offset(20); + make.height.mas_equalTo(100); + }]; + + [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.backView).offset(15); + make.top.mas_equalTo(self.backView).offset(15); + }]; + + [self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.nameLabel.mas_right).offset(5); + make.centerY.mas_equalTo(self.nameLabel); + }]; + + [self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.nameLabel); + make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10); + }]; + + [self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.nameLabel); + make.top.mas_equalTo(self.idLabel.mas_bottom).offset(18); + }]; + + [self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(55, 18)); + make.right.mas_equalTo(self.backView).offset(-15); + make.top.mas_equalTo(self.backView).offset(10); + }]; } + +- (void)initSubViews { + [self addSubview:self.cycleScrollView]; + [self addSubview:self.pageLabel]; + [self addSubview:self.backView]; + [self.backView addSubview:self.nameLabel]; + [self.backView addSubview:self.sexImageView]; + [self.backView addSubview:self.idLabel]; + [self.backView addSubview:self.signLabel]; + [self.backView addSubview:self.onlineButton]; +} + #pragma mark - SDPhotoBrowserDelegate - (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index { NSString * photoUrl = [self.imageUrls objectAtIndex:index]; @@ -130,7 +176,7 @@ } -(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index { - self.pageLabel.text = [NSString stringWithFormat:@"%d/%lu",(index + 1), (unsigned long)self.imageUrls.count]; + self.pageLabel.text = [NSString stringWithFormat:@"%ld/%lu",(index + 1), (unsigned long)self.imageUrls.count]; } // 轮播图点击 @@ -144,30 +190,114 @@ browser.isMe = NO; [browser show]; } + +#pragma mark - Event Response +- (void)onlineButtonAction:(UIButton *)sender { + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineUserInfoHeaderView:didClickGoToRoom:)]) { + [self.delegate xPMineUserInfoHeaderView:self didClickGoToRoom:self.userInfo.roomUid]; + } +} #pragma mark - Getters And Setters - (void)setUserInfo:(UserInfoModel *)userInfo { _userInfo = userInfo; - // 轮播图 - NSMutableArray * imageUrls; - if (self.userInfo.privatePhoto.count > 0) { - imageUrls = [[[self.userInfo.privatePhoto.rac_sequence map:^id _Nullable(UserPhoto * _Nullable value) { - return value.photoUrl; - }] array] mutableCopy] ; - } - if (self.userInfo.avatar.length > 0) { - if (imageUrls.count >0) { - [imageUrls addObject:self.userInfo.avatar]; + if (_userInfo) { + self.nameLabel.text = _userInfo.nick; + self.idLabel.text = [NSString stringWithFormat:@"%@号:%ld",AppName, (long)_userInfo.erbanNo]; + self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : @"我是个默认签名"; + NSString * sexStr; + if (_userInfo.gender == GenderType_Male) { + sexStr = @"common_male"; } else { - imageUrls = [NSMutableArray array]; - [imageUrls addObject:self.userInfo.avatar]; + sexStr = @"common_female"; } + self.sexImageView.image = [UIImage imageNamed:sexStr]; + self.onlineButton.hidden = _userInfo.roomUid.length <=0; + + // 轮播图 + NSMutableArray * imageUrls; + if (self.userInfo.privatePhoto.count > 0) { + imageUrls = [[[self.userInfo.privatePhoto.rac_sequence map:^id _Nullable(UserPhoto * _Nullable value) { + return value.photoUrl; + }] array] mutableCopy] ; + } + if (self.userInfo.avatar.length > 0) { + if (imageUrls.count >0) { + [imageUrls addObject:self.userInfo.avatar]; + } else { + imageUrls = [NSMutableArray array]; + [imageUrls addObject:self.userInfo.avatar]; + } + } + if (imageUrls.count > 0) { + self.imageUrls = imageUrls; + self.cycleScrollView.imageURLStringsGroup = imageUrls; + self.pageLabel.text = [NSString stringWithFormat:@"1/%lu",(unsigned long)imageUrls.count]; + } } - if (imageUrls.count > 0) { - self.imageUrls = imageUrls; - self.cycleScrollView.imageURLStringsGroup = imageUrls; - self.pageLabel.text = [NSString stringWithFormat:@"1/%lu",(unsigned long)imageUrls.count]; +} + +- (UIView *)backView { + if (!_backView) { + _backView = [[UIView alloc] init]; + _backView.backgroundColor = [ThemeColor appCellBackgroundColor]; + _backView.layer.masksToBounds = YES; + _backView.layer.cornerRadius = 12; } + return _backView; +} + +- (UILabel *)nameLabel { + if (!_nameLabel) { + _nameLabel = [[UILabel alloc] init]; + _nameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15]; + _nameLabel.textColor = [ThemeColor mainTextColor]; + } + return _nameLabel; +} + +- (UIImageView *)sexImageView { + if (!_sexImageView) { + _sexImageView = [[UIImageView alloc] init]; + _sexImageView.userInteractionEnabled = YES; + } + return _sexImageView; +} + +- (UILabel *)idLabel { + if (!_idLabel) { + _idLabel = [[UILabel alloc] init]; + _idLabel.font = [UIFont systemFontOfSize:11]; + _idLabel.textColor = [ThemeColor textThirdColor]; + } + return _idLabel; +} + +- (UILabel *)signLabel { + if (!_signLabel) { + _signLabel = [[UILabel alloc] init]; + _signLabel.font = [UIFont systemFontOfSize:11];; + _signLabel.textColor = [ThemeColor secondTextColor]; + } + return _signLabel; +} + +- (UIButton *)onlineButton { + if (!_onlineButton) { + _onlineButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_onlineButton setTitle:@"直播中" forState:UIControlStateNormal]; + [_onlineButton setImage:[UIImage imageNamed:@"home_search_user_online"] forState:UIControlStateNormal]; + [_onlineButton setTitleColor:[ThemeColor appMainColor] forState:UIControlStateNormal]; + _onlineButton.backgroundColor = [UIColor clearColor]; + _onlineButton.titleLabel.font = [UIFont systemFontOfSize:10]; + _onlineButton.layer.masksToBounds = YES; + _onlineButton.layer.cornerRadius = 18/2; + _onlineButton.layer.borderColor = [ThemeColor appMainColor].CGColor; + _onlineButton.layer.borderWidth = 1; + _onlineButton.hidden = YES; + [_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _onlineButton; } - (SDCycleScrollView *)cycleScrollView { diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.h b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.h deleted file mode 100644 index ed213766..00000000 --- a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// XPMineUserTableView.h -// xplan-ios -// -// Created by 冯硕 on 2021/9/27. -// - -#import - -NS_ASSUME_NONNULL_BEGIN -@interface XPMineUserTableView : UITableView -/// -@property (nonatomic,weak) UIViewController *userInfoVC; -@end - -NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.m b/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.m deleted file mode 100644 index c1f7a34a..00000000 --- a/xplan-ios/Main/Mine/View/SubViews/MineInfo/XPMineUserTableView.m +++ /dev/null @@ -1,24 +0,0 @@ -// -// XPMineUserTableView.m -// xplan-ios -// -// Created by 冯硕 on 2021/9/27. -// - -#import "XPMineUserTableView.h" -#import "XPMacro.h" -#import "XPMineUserInfoViewController.h" - -@implementation XPMineUserTableView - -- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { - if (point.y > (250 + kSafeAreaTopHeight)) { - return self; - } else { - UIView* topView= [(XPMineUserInfoViewController *)self.userInfoVC getHeadHitView]; - UIView * View = [topView hitTest:point withEvent:event]; - return View; - } -} - -@end