diff --git a/xplan-ios/Main/Monents/Api/Api+Monents.h b/xplan-ios/Main/Monents/Api/Api+Monents.h index 3fb82fd9..e72cf6c8 100644 --- a/xplan-ios/Main/Monents/Api/Api+Monents.h +++ b/xplan-ios/Main/Monents/Api/Api+Monents.h @@ -59,6 +59,16 @@ NS_ASSUME_NONNULL_BEGIN /// @param shareUid 分享者的uid + (void)userShareMonents:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid worldId:(NSString *)worldId shareUid:(NSString *)shareUid; + +/// 点赞动态 +/// @param completion 完成 +/// @param dynamicId 动态的id +/// @param uid 用户的uid +/// @param status 0 取消点赞 1 点赞 +/// @param likedUid 点赞人的uid +/// @param worldId 世界的id ++ (void)monentsLike:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid status:(NSString *)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId; + /// 动态详情 /// @param completion 完成 /// @param dynamicId 动态的id diff --git a/xplan-ios/Main/Monents/Api/Api+Monents.m b/xplan-ios/Main/Monents/Api/Api+Monents.m index 12ba16f5..e5e32a3e 100644 --- a/xplan-ios/Main/Monents/Api/Api+Monents.m +++ b/xplan-ios/Main/Monents/Api/Api+Monents.m @@ -76,6 +76,17 @@ [self makeRequest:@"dynamic/share" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, worldId, shareUid, nil]; } +/// 点赞动态 +/// @param completion 完成 +/// @param dynamicId 动态的id +/// @param uid 用户的uid +/// @param status 0 取消点赞 1 点赞 +/// @param likedUid 点赞人的uid +/// @param worldId 世界的id ++ (void)monentsLike:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid status:(NSString *)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId { + [self makeRequest:@"dynamic/like" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, status, likedUid, worldId, nil]; +} + /// 动态详情 /// @param completion 完成 /// @param dynamicId 动态的id @@ -114,4 +125,6 @@ [self makeRequest:@"dynamic/comment/reply/list" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, dynamicId, uid, pageSize, commentId, timestamp, nil]; } + + @end diff --git a/xplan-ios/Main/Monents/Model/MonentsCommentModel.h b/xplan-ios/Main/Monents/Model/MonentsCommentModel.h index 6df97954..66694add 100644 --- a/xplan-ios/Main/Monents/Model/MonentsCommentModel.h +++ b/xplan-ios/Main/Monents/Model/MonentsCommentModel.h @@ -9,6 +9,8 @@ #import "MonentsCommentReplyModel.h" NS_ASSUME_NONNULL_BEGIN @interface MonentsCommentModel : NSObject +///是否刷新高度 +@property (nonatomic,assign) BOOL isReloadHeight; ///评论的高度 @property (nonatomic,assign) CGFloat commentRowHeight; /// 昵称 diff --git a/xplan-ios/Main/Monents/Model/MonentsCommentModel.m b/xplan-ios/Main/Monents/Model/MonentsCommentModel.m index 32a9df57..76472502 100644 --- a/xplan-ios/Main/Monents/Model/MonentsCommentModel.m +++ b/xplan-ios/Main/Monents/Model/MonentsCommentModel.m @@ -6,12 +6,9 @@ // #import "MonentsCommentModel.h" -#import "NSString+Utils.h" + @implementation MonentsCommentModel -- (NSString *)publishTime { - return [NSString stringWithTimeStamp:_publishTime]; -} @end diff --git a/xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.m b/xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.m index 9a7e3704..0925eb82 100644 --- a/xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.m +++ b/xplan-ios/Main/Monents/Model/MonentsCommentReplyModel.m @@ -6,7 +6,6 @@ // #import "MonentsCommentReplyModel.h" -#import "NSString+Utils.h" #import "ThemeColor.h" @implementation MonentsCommentReplyModel @@ -17,11 +16,6 @@ @implementation MonentsReplyModel - -- (NSString *)publishTime { - return [NSString stringWithTimeStamp:_publishTime]; -} - - (void)createContentAttribute { if (self.contentAttribute == nil) { NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; diff --git a/xplan-ios/Main/Monents/Model/MonentsInfoModel.m b/xplan-ios/Main/Monents/Model/MonentsInfoModel.m index 2f2a3525..bf58b38d 100644 --- a/xplan-ios/Main/Monents/Model/MonentsInfoModel.m +++ b/xplan-ios/Main/Monents/Model/MonentsInfoModel.m @@ -19,12 +19,6 @@ + (NSDictionary *)objectClassInArray { return @{@"dynamicResList":MonentsPicInfoModel.class}; } - - -- (NSString *)publishTime { - return [NSString stringWithTimeStamp:_publishTime]; -} - @end diff --git a/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.h b/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.h index 62be750b..3a706e56 100644 --- a/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.h +++ b/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.h @@ -15,6 +15,19 @@ NS_ASSUME_NONNULL_BEGIN - (void)getMonentsDetail:(NSString *)dynamicId; - (void)getMonentsCommentList:(NSString *)dynamicId timestamp:(NSString *)timestamp status:(int)state; + +/// 获取评论的回复列表 +/// @param dynamicId 动态id +/// @param commentId 评论id +/// @param timestamp 最后一条评论的时间戳 +- (void)getMonentsCommentReplyList:(NSString *)dynamicId commentId:(NSString *)commentId timestamp:(NSString *)timestamp; + +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.m b/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.m index d82500f7..d22f02af 100644 --- a/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.m +++ b/xplan-ios/Main/Monents/Presenter/XPMonentDetailPresenter.m @@ -11,6 +11,7 @@ #import "XPMonentsDetailProtocol.h" #import "MonentsInfoModel.h" #import "MonentsCommentModel.h" +#import "MonentsCommentReplyModel.h" @implementation XPMonentDetailPresenter /// 获取动态相亲 @@ -23,6 +24,11 @@ }] dynamicId:dynamicId worldId:@"" uid:uid]; } + +/// 获取评论列表 +/// @param dynamicId 动态id +/// @param timestamp 上一条的时间戳 +/// @param state 状态 - (void)getMonentsCommentList:(NSString *)dynamicId timestamp:(NSString *)timestamp status:(int)state{ NSString * uid = [AccountInfoStorage instance].getUid; [Api monentsCommentList:[self createHttpCompletion:^(BaseModel * _Nonnull data) { @@ -31,4 +37,31 @@ }] dynamicId:dynamicId uid:uid pageSize:@"10" timestamp:timestamp]; } + +/// 获取评论的回复列表 +/// @param dynamicId 动态id +/// @param commentId 评论id +/// @param timestamp 最后一条评论的时间戳 +- (void)getMonentsCommentReplyList:(NSString *)dynamicId commentId:(NSString *)commentId timestamp:(NSString *)timestamp { + NSString * uid = [AccountInfoStorage instance].getUid; + [Api monentsCommentReplyList:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + MonentsCommentReplyModel * replyInfo = [MonentsCommentReplyModel modelWithDictionary:data.data]; + [[self getView] getMonentsCommentReplyListSuccess:replyInfo commentId:commentId]; + }] dynamicId:dynamicId uid:uid pageSize:@"5" commentId:commentId timestamp:timestamp]; +} + +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * statusStr = status ? @"1" : @"0"; + [Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] likeMonentsSuccess:dynamicId status:status]; + } showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId]; +} + + @end diff --git a/xplan-ios/Main/Monents/Presenter/XPMonentsLayoutConfig.m b/xplan-ios/Main/Monents/Presenter/XPMonentsLayoutConfig.m index 6426c883..b876659e 100644 --- a/xplan-ios/Main/Monents/Presenter/XPMonentsLayoutConfig.m +++ b/xplan-ios/Main/Monents/Presenter/XPMonentsLayoutConfig.m @@ -112,7 +112,7 @@ ///计算评论的高度 + (CGFloat)commentCommentRowHeight:(MonentsCommentModel * )comment { - if (comment.commentRowHeight > 0) { + if (comment.commentRowHeight > 0 && !comment.isReloadHeight) { return comment.commentRowHeight; } __block CGFloat rowHeight = 0; diff --git a/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.h b/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.h index 04d76640..af8ad2ed 100644 --- a/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.h +++ b/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.h @@ -20,6 +20,13 @@ NS_ASSUME_NONNULL_BEGIN /// @param page 当前的页数 /// @param pageSize 一页多少个 - (void)getMonentsTopicList:(NSInteger)page pageSize:(NSInteger)pageSize; + +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.m b/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.m index cf9bc939..1cf61884 100644 --- a/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.m +++ b/xplan-ios/Main/Monents/Presenter/XPMonentsRecommendPresenter.m @@ -43,5 +43,17 @@ }] uid:uid page:pageStr pageSize:pageSizeStr worldTypeId:@"0"]; } +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * statusStr = status ? @"1" : @"0"; + [Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] likeMonentsSuccess:dynamicId status:status]; + } showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId]; +} @end diff --git a/xplan-ios/Main/Monents/Protocol/XPMonentsDetailProtocol.h b/xplan-ios/Main/Monents/Protocol/XPMonentsDetailProtocol.h index b1b53b23..d955647e 100644 --- a/xplan-ios/Main/Monents/Protocol/XPMonentsDetailProtocol.h +++ b/xplan-ios/Main/Monents/Protocol/XPMonentsDetailProtocol.h @@ -8,7 +8,7 @@ #import NS_ASSUME_NONNULL_BEGIN -@class MonentsInfoModel, MonentsCommentListModel; +@class MonentsInfoModel, MonentsCommentListModel, MonentsCommentReplyModel; @protocol XPMonentsDetailProtocol ///获取动态详情成功 - (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo; @@ -16,6 +16,11 @@ NS_ASSUME_NONNULL_BEGIN ///获取动态 评论的列表 - (void)getMonentsCommentListSuccess:(MonentsCommentListModel *)replyList state:(int)state; +///评论回复成功 +- (void)getMonentsCommentReplyListSuccess:(MonentsCommentReplyModel *)replyInfo commentId:(NSString *)commentId; + +///点赞/取消动态成功 +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/Protocol/XPMonentsRecommendProtocol.h b/xplan-ios/Main/Monents/Protocol/XPMonentsRecommendProtocol.h index ff25c377..a06a9d5b 100644 --- a/xplan-ios/Main/Monents/Protocol/XPMonentsRecommendProtocol.h +++ b/xplan-ios/Main/Monents/Protocol/XPMonentsRecommendProtocol.h @@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)getMonentsRecommendListFail:(NSString *)msg state:(int)state; ///获取话题列表成功 - (void)monentsTopicListSuccess:(NSArray *)array; +///点赞/取消动态成功 +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status; @end diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.h b/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.h index 7eb7b9d4..460ab6fc 100644 --- a/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.h +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.h @@ -8,9 +8,18 @@ #import NS_ASSUME_NONNULL_BEGIN -@class MonentsCommentModel; +@class MonentsCommentModel, XPMonentsCommentTableViewCell; + +@protocol XPMonentsCommentTableViewCellDelegate +///点击了查看更多 +- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickMoreReply:(MonentsCommentModel *)commentInfo; + +@end + @interface XPMonentsCommentTableViewCell : UITableViewCell @property (nonatomic,strong) MonentsCommentModel *commentInfo; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.m b/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.m index e1336985..9f40f484 100644 --- a/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.m +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsCommentTableViewCell.m @@ -12,13 +12,14 @@ #import "NetImageView.h" #import "ThemeColor.h" #import "XPMonentsLayoutConfig.h" +#import "NSString+Utils.h" ///Model #import "MonentsCommentModel.h" ///View #import "XPMonentsReplyTableViewCell.h" #import "XPMonentsReplyMoreTableViewCell.h" -@interface XPMonentsCommentTableViewCell () +@interface XPMonentsCommentTableViewCell () ///容器 @property (nonatomic,strong) UIStackView *stackView; ///评论者 @@ -139,10 +140,18 @@ XPMonentsReplyMoreTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsReplyMoreTableViewCell class])]; cell.leftCount = self.commentInfo.replyInfo.leftCount; + cell.delegate = self; return cell; } +#pragma mark - XPMonentsReplyMoreTableViewCellDelegate +- (void)xPMonentsReplyMoreTableViewCellDidClickMoreReply:(XPMonentsReplyMoreTableViewCell *)view { + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsCommentTableViewCell:didClickMoreReply:)]) { + [self.delegate xPMonentsCommentTableViewCell:self didClickMoreReply:self.commentInfo]; + } +} + #pragma mark - Getters And Setters - (void)setCommentInfo:(MonentsCommentModel *)commentInfo { _commentInfo = commentInfo; @@ -154,7 +163,7 @@ } self.commentLabel.text = _commentInfo.content; self.commentNickLabel.text = nick; - self.commentDateLabel.text = _commentInfo.publishTime; + self.commentDateLabel.text = [NSString stringWithTimeStamp:_commentInfo.publishTime]; self.tableView.hidden = _commentInfo.replyInfo.replyList.count <=0; self.datasource = _commentInfo.replyInfo.replyList; [self.tableView reloadData]; diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsReplyTableViewCell.m b/xplan-ios/Main/Monents/View/Cell/XPMonentsReplyTableViewCell.m index 126b814e..bfe0082d 100644 --- a/xplan-ios/Main/Monents/View/Cell/XPMonentsReplyTableViewCell.m +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsReplyTableViewCell.m @@ -14,6 +14,7 @@ #import "NetImageView.h" #import "XPMacro.h" #import "XPMonentsLayoutConfig.h" +#import "NSString+Utils.h" ///Model #import "MonentsCommentReplyModel.h" @@ -96,7 +97,7 @@ nick = [nick substringToIndex:8]; } self.nickLabel.text = nick; - self.dateLabel.text = _replyInfo.publishTime; + self.dateLabel.text = [NSString stringWithTimeStamp:_replyInfo.publishTime]; self.contentLabel.attributedText = _replyInfo.contentAttribute; } } diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.h b/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.h index 6d6adb87..d1041327 100644 --- a/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.h +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.h @@ -8,9 +8,18 @@ #import NS_ASSUME_NONNULL_BEGIN -@class MonentsInfoModel; +@class MonentsInfoModel, XPMonentsTableViewCell; + +@protocol XPMonentsTableViewCellDelegate + +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo; + +@end + @interface XPMonentsTableViewCell : UITableViewCell @property (nonatomic,strong) MonentsInfoModel *monentsInfo; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m b/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m index 3d95a6d2..14b89f68 100644 --- a/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m @@ -22,7 +22,7 @@ #import "XPMoentsTopicView.h" #import "XPMonentsContentView.h" #import "XPMonentsLayoutConfig.h" -@interface XPMonentsTableViewCell () +@interface XPMonentsTableViewCell () ///显示颜色的 有的时候stackView 不能显示颜色 @property (nonatomic,strong) UIView * backView; ///容器 @@ -91,6 +91,13 @@ }]; } +#pragma mark - XPMonentsTooBarViewDelegate +- (void)xPMonentsTooBarView:(XPMonentsTooBarView *)view didClickLike:(MonentsInfoModel *)monentsInfo { + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsTableViewCell:didClickLike:)]) { + [self.delegate xPMonentsTableViewCell:self didClickLike:monentsInfo]; + } +} + #pragma mark - Getters And Setters - (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo { _monentsInfo = monentsInfo; @@ -170,6 +177,7 @@ - (XPMonentsTooBarView *)toolBarView { if (!_toolBarView) { _toolBarView = [[XPMonentsTooBarView alloc] init]; + _toolBarView.delegate = self; } return _toolBarView; } diff --git a/xplan-ios/Main/Monents/View/SubViews/XPMoentsTopicView.m b/xplan-ios/Main/Monents/View/SubViews/XPMoentsTopicView.m index bd0cc649..fe5199b7 100644 --- a/xplan-ios/Main/Monents/View/SubViews/XPMoentsTopicView.m +++ b/xplan-ios/Main/Monents/View/SubViews/XPMoentsTopicView.m @@ -11,6 +11,7 @@ ///Tool #import "ThemeColor.h" #import "UIImage+Utils.h" +#import "NSString+Utils.h" ///Model #import "MonentsInfoModel.h" @@ -77,7 +78,7 @@ } else { self.topicImageView.hidden = YES; } - self.timeLabel.text = _monentsInfo.publishTime; + self.timeLabel.text = [NSString stringWithTimeStamp:_monentsInfo.publishTime]; } } diff --git a/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.h b/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.h index ecb4e151..5846d0cb 100644 --- a/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.h +++ b/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.h @@ -8,9 +8,17 @@ #import NS_ASSUME_NONNULL_BEGIN -@class MonentsInfoModel; +@class MonentsInfoModel, XPMonentsTooBarView; +@protocol XPMonentsTooBarViewDelegate + +- (void)xPMonentsTooBarView:(XPMonentsTooBarView *)view didClickLike:(MonentsInfoModel *)monentsInfo; + +@end + @interface XPMonentsTooBarView : UIView @property (nonatomic,strong) MonentsInfoModel *monentsInfo; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m b/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m index ee974773..7c48157b 100644 --- a/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m +++ b/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m @@ -10,10 +10,18 @@ #import ///Tool #import "ThemeColor.h" +#import "TTPopup.h" +#import "XPHtmlUrl.h" +#import "XPShareView.h" +#import "XCHUDTool.h" +#import "XPMacro.h" ///Model #import "MonentsInfoModel.h" +///View +#import "XPWebViewController.h" +#import "XCCurrentVCStackManager.h" -@interface XPMonentsTooBarView () +@interface XPMonentsTooBarView () ///举报 @property (nonatomic,strong) UIButton *reportButton; ///喜欢的容器 @@ -113,20 +121,54 @@ [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self).inset(16); make.bottom.mas_equalTo(self); - make.height.mas_equalTo(1); + make.height. mas_equalTo(1); }]; } #pragma mark - Event Response - (void)likeButtonAction:(UIButton *)sender { - //TODO: 喜欢 + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsTooBarView:didClickLike:)]) { + [self.delegate xPMonentsTooBarView:self didClickLike:self.monentsInfo]; + } } - (void)reportButtonAction:(UIButton *)sender { -//TODO: 分享 + TTActionSheetConfig *report = [TTActionSheetConfig normalTitle:@"举报" clickAction:^{ + NSString * url= [NSString stringWithFormat:@"%@?reportUid=%@&source=%@", URLWithType(kReportRoomURL),self.monentsInfo.uid, @"WORLDDYNAMIC"]; + XPWebViewController * webVC = [[XPWebViewController alloc] init]; + webVC.url = url; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; + }]; + + [TTPopup actionSheetWithItems:@[report]]; } - (void)shareButtonAction:(UIButton *)sender { - //TODO: 分享 + XPShareItem *friend = [XPShareItem itemWitTag:XPShareItemTagMoments title:@"好友" imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"]; + XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagMoments title:@"朋友圈" imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"]; + XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagWeChat title:@"微信好友" imageName:@"share_wechat_normal" disableImageName:@"share_wechat_disable"]; + XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagQQ title:@"QQ好友" imageName:@"share_qq_normal" disableImageName:@"share_qq_disable"]; + XPShareItem *qqzone = [XPShareItem itemWitTag:XPShareItemTagQQZone title:@"QQ空间" imageName:@"share_qqzone_normal" disableImageName:@"share_qqzone_disable"]; + NSArray * items = @[friend,wechat,cycle, qq, qqzone]; + CGFloat margin = 15; + CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65); + XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init]; + XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo]; + shareView.delegate = self; + [TTPopup popupView:shareView style:TTPopupStyleActionSheet]; +} + +#pragma mark - #pragma mark - XCShareViewDelegate +- (void)shareView:(XPShareView *)shareView shareFail:(NSString *)message { + [TTPopup dismiss]; + [XCHUDTool showErrorWithMessage:message]; +} + +- (void)shareView:(XPShareView *)shareView didSuccess:(XPShareInfoModel *)shareInfo{ + [TTPopup dismiss]; +} + +- (void)shareViewDidClickCancel:(XPShareView *)shareView { + [TTPopup dismiss]; } #pragma mark - Getters And Setters @@ -181,6 +223,7 @@ [_commentButton setImage:[UIImage imageNamed:@"monents_info_comment_count"] forState:UIControlStateNormal]; [_commentButton setImage:[UIImage imageNamed:@"monents_info_comment_count"] forState:UIControlStateSelected]; [_commentButton addTarget:self action:@selector(likeButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + _commentButton.userInteractionEnabled = NO; } return _commentButton; } diff --git a/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.h b/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.h index 5b111352..c241ee2e 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.h +++ b/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.h @@ -17,6 +17,13 @@ NS_ASSUME_NONNULL_BEGIN /// @param state 状态 - (void)getMonentsAttentionListPageSize:(NSInteger)pageSize dynamicId:(NSString *)dynamicId state:(int)state; +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.m b/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.m index 13c0d9bf..dc4deadd 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.m +++ b/xplan-ios/Main/Monents/View/XPMonentsAttentionPresenter.m @@ -9,6 +9,7 @@ #import "Api+Monents.h" #import "MonentsListInfoModel.h" #import "XPMonentsAttentionProtocol.h" +#import "AccountInfoStorage.h" @implementation XPMonentsAttentionPresenter /// 获取朋友圈动态推荐列表 @@ -28,4 +29,17 @@ }] dynamicId:dynamicId pageSize:pageSizeStr types:@"0,2"]; } +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * statusStr = status ? @"1" : @"0"; + [Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] likeMonentsSuccess:dynamicId status:status]; + } showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId]; +} + @end diff --git a/xplan-ios/Main/Monents/View/XPMonentsAttentionProtocol.h b/xplan-ios/Main/Monents/View/XPMonentsAttentionProtocol.h index 62822e9c..26bee81c 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsAttentionProtocol.h +++ b/xplan-ios/Main/Monents/View/XPMonentsAttentionProtocol.h @@ -14,6 +14,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)getMonentsAttentionListSuccess:(MonentsListInfoModel *)listInfo state:(int)state; ///获取最新列表失败 - (void)getMonentsAttentionListFail:(NSString *)msg state:(int)state; + +///点赞/取消动态成功 +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m b/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m index d511d2dd..4d4760c8 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m @@ -23,11 +23,15 @@ #import "XPMonentDetailPresenter.h" #import "XPMonentsDetailProtocol.h" -@interface XPMonentsDetailViewController () +@interface XPMonentsDetailViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 -@property (nonatomic,strong) NSMutableArray *datasource; +@property (nonatomic,strong) NSMutableArray *datasource; +///头部view +@property (nonatomic,strong) UIView * sectionView; +///评论的个数 +@property (nonatomic,strong) UILabel *commentLabel; @end @implementation XPMonentsDetailViewController @@ -71,7 +75,7 @@ MonentsCommentModel * commentInfo = [self.datasource lastObject]; timestamp = commentInfo.publishTime; } - [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:timestamp status:0]; + [self.presenter getMonentsCommentList:self.monentsInfo.dynamicId timestamp:timestamp status:1]; } @@ -79,12 +83,18 @@ - (void)initSubViews { self.title = @"详情"; [self.view addSubview:self.tableView]; + [self.sectionView addSubview:self.commentLabel]; } - (void)initSubViewConstraints { [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self.view); }]; + + [self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.sectionView).offset(15); + make.centerY.mas_equalTo(self.sectionView); + }]; } #pragma mark - UITableViewDelegate And UITableViewDataSource @@ -114,6 +124,26 @@ return 0; } +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + if (section == 1) { + return 44; + } + return 0.0;; +} + +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { + self.commentLabel.text = [NSString stringWithFormat:@"所有评论(%@)", self.monentsInfo.commentCount]; + return self.sectionView; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { + return 0.0f; +} + +- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { + return [UIView new]; +} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ==0) { XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; @@ -123,6 +153,7 @@ if (self.datasource.count > 0) { XPMonentsCommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])]; cell.commentInfo = [self.datasource objectAtIndex:indexPath.row]; + cell.delegate = self; return cell; } else { XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; @@ -131,6 +162,11 @@ } } +#pragma mark - XPMonentsCommentTableViewCellDelegate +- (void)xPMonentsCommentTableViewCell:(XPMonentsCommentTableViewCell *)view didClickMoreReply:(MonentsCommentModel *)commentInfo { + [self.presenter getMonentsCommentReplyList:self.monentsInfo.dynamicId commentId:commentInfo.commentId timestamp:commentInfo.replyInfo.nextTimestamp]; +} + #pragma mark - XPMonentsDetailProtocol - (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo { self.monentsInfo = commentInfo; @@ -151,13 +187,36 @@ [self.tableView reloadData]; } +- (void)getMonentsCommentReplyListSuccess:(MonentsCommentReplyModel *)replyInfo commentId:(nonnull NSString *)commentId { + if (commentId) { + __block MonentsCommentModel * commentInfo; + [self.datasource enumerateObjectsUsingBlock:^(MonentsCommentModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.commentId isEqualToString:commentId]) { + commentInfo = obj; + *stop = YES; + } + }]; + + if (commentInfo) { + NSMutableArray * replyList= commentInfo.replyInfo.replyList.mutableCopy; + [replyList addObjectsFromArray:replyInfo.replyList]; + commentInfo.replyInfo.replyList = replyList.copy; + commentInfo.replyInfo.leftCount = replyInfo.leftCount; + commentInfo.replyInfo.nextTimestamp = replyInfo.nextTimestamp; + commentInfo.isReloadHeight = YES; + } + [self.tableView reloadData]; + } +} + #pragma mark - Getters And Setters - (UITableView *)tableView { if (!_tableView) { - _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.tableFooterView = [UIView new]; + _tableView.tableFooterView = [UIView new]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.backgroundColor = [UIColor clearColor]; if (@available(iOS 11.0, *)) { @@ -166,10 +225,27 @@ [_tableView registerClass:[XPMonentsTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; [_tableView registerClass:[XPMonentsCommentTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsCommentTableViewCell class])]; [_tableView registerClass:[XPMonentsEmptyTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; - } + } return _tableView; } +- (UIView *)sectionView { + if (!_sectionView) { + _sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 44)]; + _sectionView.backgroundColor = [UIColor clearColor]; + } + return _sectionView; +} + +- (UILabel *)commentLabel { + if (!_commentLabel) { + _commentLabel = [[UILabel alloc] init]; + _commentLabel.font = [UIFont systemFontOfSize:14]; + _commentLabel.textColor = [ThemeColor mainTextColor]; + } + return _commentLabel; +} + - (NSMutableArray *)datasource { if (!_datasource) { _datasource = [NSMutableArray array]; diff --git a/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.h b/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.h index b781e29b..12ea6b90 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.h +++ b/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.h @@ -16,6 +16,13 @@ NS_ASSUME_NONNULL_BEGIN /// @param pageSize 一页的个数 /// @param state 状态 - (void)getMonentsLatestListPageSize:(NSInteger)pageSize dynamicId:(NSString *)dynamicId state:(int)state; + +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.m b/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.m index bbc8aaf9..cae6b88e 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.m +++ b/xplan-ios/Main/Monents/View/XPMonentsLatestPresenter.m @@ -9,6 +9,7 @@ #import "Api+Monents.h" #import "MonentsListInfoModel.h" #import "XPMonentsLatestProtocol.h" +#import "AccountInfoStorage.h" @implementation XPMonentsLatestPresenter /// 获取朋友圈动态推荐列表 @@ -28,5 +29,17 @@ }] dynamicId:dynamicId pageSize:pageSizeStr types:@"0,2"]; } +/// 动态点赞 +/// @param dynamicId 动态id +/// @param status yes 点赞 NO 取消 +/// @param likedUid 点赞人的uid +/// @param worldId 话题的id +- (void)likeMonent:(NSString *)dynamicId status:(BOOL)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * statusStr = status ? @"1" : @"0"; + [Api monentsLike:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] likeMonentsSuccess:dynamicId status:status]; + } showLoading:YES] dynamicId:dynamicId uid:uid status:statusStr likedUid:likedUid worldId:worldId]; +} @end diff --git a/xplan-ios/Main/Monents/View/XPMonentsLatestProtocol.h b/xplan-ios/Main/Monents/View/XPMonentsLatestProtocol.h index 8e198a66..f3527da1 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsLatestProtocol.h +++ b/xplan-ios/Main/Monents/View/XPMonentsLatestProtocol.h @@ -14,6 +14,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)getMonentsLatestListSuccess:(MonentsListInfoModel *)listInfo state:(int)state; ///获取最新列表从失败 - (void)getMonentsLatestListFail:(NSString *)msg state:(int)state; + +///点赞/取消动态成功 +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status;; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m b/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m index 609687ae..92900389 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m @@ -23,7 +23,7 @@ #import "XPMonentsEmptyTableViewCell.h" #import "XPMonentsDetailViewController.h" -@interface XPMonentsLatestViewController () +@interface XPMonentsLatestViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 @@ -116,6 +116,7 @@ XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row]; cell.monentsInfo = monentsInfo; + cell.delegate = self; return cell; } XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; @@ -131,6 +132,11 @@ [self.navigationController pushViewController:detailVC animated:YES]; } } +#pragma mark - XPMonentsTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.like likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; +} + #pragma mark -JXCategoryListContainerViewDelegate - (UIView *)listView { return self.view; @@ -168,6 +174,20 @@ } } +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + if (status) { + obj.like += 1; + } else { + obj.like -= 1; + } + *stop = YES; + } + }]; + [self.tableView reloadData]; +} + #pragma mark - Getters And Setters - (UITableView *)tableView { if (!_tableView) { diff --git a/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m b/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m index e5841dec..c67b6702 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m @@ -24,7 +24,7 @@ #import "XPMonentsRecommendHeaderView.h" #import "XPMonentsDetailViewController.h" -@interface XPMonentsRecommendViewController () +@interface XPMonentsRecommendViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 @@ -119,6 +119,7 @@ XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row]; cell.monentsInfo = monentsInfo; + cell.delegate = self; return cell; } XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; @@ -134,6 +135,11 @@ [self.navigationController pushViewController:detailVC animated:YES]; } } +#pragma mark - XPMonentsTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.like likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; +} + #pragma mark -JXCategoryListContainerViewDelegate - (UIView *)listView { return self.view; @@ -174,6 +180,20 @@ self.headerView.topicList = array; } +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + if (status) { + obj.like += 1; + } else { + obj.like -= 1; + } + *stop = YES; + } + }]; + [self.tableView reloadData]; +} + #pragma mark - Getters And Setters - (UITableView *)tableView { if (!_tableView) {