Commit 104186d4 cgx

完成消息中心回复接口功能、点赞列表

1 个父辈 84d2d2b2
正在显示 25 个修改的文件 包含 242 行增加79 行删除
...@@ -133,6 +133,7 @@ ...@@ -133,6 +133,7 @@
D07257F0286BE5510080F458 /* GoodSleepHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257EF286BE5510080F458 /* GoodSleepHeadView.m */; }; D07257F0286BE5510080F458 /* GoodSleepHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257EF286BE5510080F458 /* GoodSleepHeadView.m */; };
D07257F3286BF99F0080F458 /* DailyTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F2286BF99F0080F458 /* DailyTaskView.m */; }; D07257F3286BF99F0080F458 /* DailyTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F2286BF99F0080F458 /* DailyTaskView.m */; };
D07257F6286C2F110080F458 /* SignCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F5286C2F110080F458 /* SignCollectionViewCell.m */; }; D07257F6286C2F110080F458 /* SignCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F5286C2F110080F458 /* SignCollectionViewCell.m */; };
D07827FC28FE424700C8D612 /* PraiseListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D07827FB28FE424700C8D612 /* PraiseListViewModel.m */; };
D07A4B27280E9BAA00BA0EC0 /* AccountController.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B26280E9BAA00BA0EC0 /* AccountController.m */; }; D07A4B27280E9BAA00BA0EC0 /* AccountController.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B26280E9BAA00BA0EC0 /* AccountController.m */; };
D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B29280EA6B600BA0EC0 /* UserInfoTableView.m */; }; D07A4B2A280EA6B600BA0EC0 /* UserInfoTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B29280EA6B600BA0EC0 /* UserInfoTableView.m */; };
D07A4B2D280EA73B00BA0EC0 /* UserInfoView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B2C280EA73B00BA0EC0 /* UserInfoView.m */; }; D07A4B2D280EA73B00BA0EC0 /* UserInfoView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07A4B2C280EA73B00BA0EC0 /* UserInfoView.m */; };
...@@ -557,6 +558,8 @@ ...@@ -557,6 +558,8 @@
D07257F2286BF99F0080F458 /* DailyTaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DailyTaskView.m; sourceTree = "<group>"; }; D07257F2286BF99F0080F458 /* DailyTaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DailyTaskView.m; sourceTree = "<group>"; };
D07257F4286C2F110080F458 /* SignCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SignCollectionViewCell.h; sourceTree = "<group>"; }; D07257F4286C2F110080F458 /* SignCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SignCollectionViewCell.h; sourceTree = "<group>"; };
D07257F5286C2F110080F458 /* SignCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignCollectionViewCell.m; sourceTree = "<group>"; }; D07257F5286C2F110080F458 /* SignCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignCollectionViewCell.m; sourceTree = "<group>"; };
D07827FA28FE424700C8D612 /* PraiseListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PraiseListViewModel.h; sourceTree = "<group>"; };
D07827FB28FE424700C8D612 /* PraiseListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PraiseListViewModel.m; sourceTree = "<group>"; };
D07A4B25280E9BAA00BA0EC0 /* AccountController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountController.h; sourceTree = "<group>"; }; D07A4B25280E9BAA00BA0EC0 /* AccountController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountController.h; sourceTree = "<group>"; };
D07A4B26280E9BAA00BA0EC0 /* AccountController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccountController.m; sourceTree = "<group>"; }; D07A4B26280E9BAA00BA0EC0 /* AccountController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccountController.m; sourceTree = "<group>"; };
D07A4B28280EA6B600BA0EC0 /* UserInfoTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserInfoTableView.h; sourceTree = "<group>"; }; D07A4B28280EA6B600BA0EC0 /* UserInfoTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserInfoTableView.h; sourceTree = "<group>"; };
...@@ -1652,6 +1655,8 @@ ...@@ -1652,6 +1655,8 @@
D053D0DB28F3C23200BB2B84 /* ReportViewModel.m */, D053D0DB28F3C23200BB2B84 /* ReportViewModel.m */,
D003140428FD449E00E01A6A /* MessageCenterViewModel.h */, D003140428FD449E00E01A6A /* MessageCenterViewModel.h */,
D003140528FD449E00E01A6A /* MessageCenterViewModel.m */, D003140528FD449E00E01A6A /* MessageCenterViewModel.m */,
D07827FA28FE424700C8D612 /* PraiseListViewModel.h */,
D07827FB28FE424700C8D612 /* PraiseListViewModel.m */,
D06F2C4F28F6AEC50023921E /* PersonDynViewModel.h */, D06F2C4F28F6AEC50023921E /* PersonDynViewModel.h */,
D06F2C5028F6AEC50023921E /* PersonDynViewModel.m */, D06F2C5028F6AEC50023921E /* PersonDynViewModel.m */,
); );
...@@ -2625,6 +2630,7 @@ ...@@ -2625,6 +2630,7 @@
D07DACA42810557D0067A1BF /* CGGeometry+RSKImageCropper.m in Sources */, D07DACA42810557D0067A1BF /* CGGeometry+RSKImageCropper.m in Sources */,
D09D0E96280D3FE9008DEDAB /* NSDate+Extras.m in Sources */, D09D0E96280D3FE9008DEDAB /* NSDate+Extras.m in Sources */,
D0878F4C280BEFF9005F1B7F /* UILabel+YBAttributeTextTapAction.m in Sources */, D0878F4C280BEFF9005F1B7F /* UILabel+YBAttributeTextTapAction.m in Sources */,
D07827FC28FE424700C8D612 /* PraiseListViewModel.m in Sources */,
D0F80907280431100097899F /* UILabel+Extras.m in Sources */, D0F80907280431100097899F /* UILabel+Extras.m in Sources */,
D003154C284DF46F00CFE94D /* RelaxTrainCell.m in Sources */, D003154C284DF46F00CFE94D /* RelaxTrainCell.m in Sources */,
D04B3DAC27F6EEB50022F8DF /* DSTabBarController.m in Sources */, D04B3DAC27F6EEB50022F8DF /* DSTabBarController.m in Sources */,
......
...@@ -26,6 +26,8 @@ typedef void (^DealBlock)(void); ...@@ -26,6 +26,8 @@ typedef void (^DealBlock)(void);
- (void)updateExceptionViewWithType:(ExceptionType)type; - (void)updateExceptionViewWithType:(ExceptionType)type;
- (void)showErrorInfo:(ExceptionType)type;
- (void)showServerErrInfo:(NSString *)errInfo; - (void)showServerErrInfo:(NSString *)errInfo;
@end @end
......
...@@ -77,6 +77,12 @@ ...@@ -77,6 +77,12 @@
[self.dealBtn setTitle:[self getDealBtnTitleWithType:self.type] forState:UIControlStateNormal]; [self.dealBtn setTitle:[self getDealBtnTitleWithType:self.type] forState:UIControlStateNormal];
} }
- (void)showErrorInfo:(ExceptionType)type {
self.exceptionIV.image = [UIImage imageNamed:[self getExceptionImgWithType:type]];
self.exceptLab.text = [self getExceptionInfoWithType:type];
self.dealBtn.hidden = YES;
}
- (void)showServerErrInfo:(NSString *)errInfo { - (void)showServerErrInfo:(NSString *)errInfo {
self.exceptLab.text = (errInfo && [errInfo isKindOfClass:[NSString class]]) ? errInfo : @"服务器异常"; self.exceptLab.text = (errInfo && [errInfo isKindOfClass:[NSString class]]) ? errInfo : @"服务器异常";
} }
......
...@@ -49,6 +49,18 @@ ...@@ -49,6 +49,18 @@
} }
} }
- (void)replyContent:(NSString *)content userMessageModel:(id)userMessageModel {
[DSProgressHUD showProgressHUDWithInfo:@""];
[MessageCenterViewModel userReplyCommentWithContent:content userMessageModel:userMessageModel completion:^(MessageCenterViewModel * _Nonnull requestModel) {
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
[self.messageNotiView dismissKeyBoard];
} else {
[DSProgressHUD showToast:requestModel.errMessage];
}
}];
}
#pragma mark - lazy #pragma mark - lazy
- (MessageNotiView *)messageNotiView { - (MessageNotiView *)messageNotiView {
if (!_messageNotiView) { if (!_messageNotiView) {
......
...@@ -7,9 +7,13 @@ ...@@ -7,9 +7,13 @@
#import "PraiseListController.h" #import "PraiseListController.h"
#import "PraiseCell.h" #import "PraiseCell.h"
#import "PraiseListViewModel.h"
@interface PraiseListController () @interface PraiseListController ()
@property (nonatomic, strong) DSDataSource *dataSource; @property (nonatomic, strong) DSDataSource *dataSource;
@property (nonatomic, assign) int offset;
@property (nonatomic, strong) NSMutableArray *praiseList;
@property (nonatomic, strong) ExceptionDefaultView *exceptionView;
@end @end
@implementation PraiseListController @implementation PraiseListController
...@@ -17,24 +21,58 @@ ...@@ -17,24 +21,58 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
[self initUI];
[self.tableView.mj_header beginRefreshing];
}
#pragma mark - init
- (void)initUI {
self.navigationItem.title = @"收到的赞"; self.navigationItem.title = @"收到的赞";
self.offset = 1;
NSMutableArray *tmpArr = [NSMutableArray array]; self.praiseList = [NSMutableArray array];
for (int i = 0; i < 10; i++) { [self.dataSource addDataArray:self.praiseList];
PraiseModel *model = [PraiseModel new];
model.user_profile = @"https://img2.ydniu.com/sleep_ssmain/face_img/1657350090882_1BORX6.jpg";
model.nick_name = @"叽叽歪歪";
model.publish_time = @"2022-09-11";
model.content = @"好高好高好高好高好高好高好";
[tmpArr addObject:model];
}
[self.dataSource addDataArray:tmpArr.copy];
self.tableView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.tableView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.tableView.showsVerticalScrollIndicator = NO; self.tableView.showsVerticalScrollIndicator = NO;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.tableView registerClass:[PraiseCell class] forCellReuseIdentifier:NSStringFromClass([PraiseCell class])]; [self.tableView registerClass:[PraiseCell class] forCellReuseIdentifier:NSStringFromClass([PraiseCell class])];
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
WS(weakSelf);
self.tableView.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
[weakSelf getPraiseList:NO];
}];
self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
[weakSelf getPraiseList:YES];
}];
}
- (void)getPraiseList:(BOOL)loadMore {
if (loadMore == NO) { self.offset = 1; }
[PraiseListViewModel queryUserDynamicPraiseWithOffset:self.offset completion:^(PraiseListViewModel * _Nonnull viewModel) {
[self.tableView.mj_footer endRefreshing];
[self.tableView.mj_header endRefreshing];
if (viewModel.resCode == DSResCodeSuccess) {
if (self.praiseList.count == 0 && viewModel.resultArr.count == 0) {
[self dealErrorWithType:ExceptionTypeNoData errInfo:@""];
return;
}
if (loadMore) {
[self.praiseList addObjectsFromArray:viewModel.resultArr];
} else {
self.offset++;
self.praiseList = [NSMutableArray arrayWithArray:viewModel.resultArr];
}
self.exceptionView.hidden = YES;
[self.dataSource addDataArray:self.praiseList];
[self.tableView reloadData];
} else {
[self dealErrorWithType:ExceptionTypeNet errInfo:viewModel.errMessage];
}
}];
} }
#pragma mark - UITableViewDelegate, UITableViewDataSource #pragma mark - UITableViewDelegate, UITableViewDataSource
...@@ -54,9 +92,25 @@ ...@@ -54,9 +92,25 @@
return _dataSource; return _dataSource;
} }
- (ExceptionDefaultView *)exceptionView {
if (!_exceptionView) {
_exceptionView = [[ExceptionDefaultView alloc] initWithType:ExceptionTypeNet block:^{
} superView:self.view];
}
return _exceptionView;
}
#pragma mark - 品牌模式 #pragma mark - 品牌模式
- (NaviStyle)navigationBarStyle { - (NaviStyle)navigationBarStyle {
return NaviStyleDefault; return NaviStyleDefault;
} }
- (void)dealErrorWithType:(ExceptionType)type errInfo:(NSString *)errInfo {
self.exceptionView.hidden = NO;
[self.exceptionView showErrorInfo:type];
if (type == ExceptionTypeNet) {
[self.exceptionView showServerErrInfo:errInfo];
}
}
@end @end
...@@ -11,8 +11,10 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -11,8 +11,10 @@ NS_ASSUME_NONNULL_BEGIN
/// 消息中心评论和回复数据model /// 消息中心评论和回复数据model
@interface MessageComReplyModel : NSObject @interface MessageComReplyModel : NSObject
/// 动态或评论 id /// 动态id
@property (nonatomic, assign) NSInteger identifier; @property (nonatomic, assign) NSInteger talkID;
/// 评论id
@property (nonatomic, assign) NSInteger commentID;
/// 0:动态评论 1 评论回复 /// 0:动态评论 1 评论回复
@property (nonatomic, assign) NSInteger type; @property (nonatomic, assign) NSInteger type;
/// 发布评论或回复的用户 Id /// 发布评论或回复的用户 Id
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
#pragma mark - YYModel #pragma mark - YYModel
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper { + (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper {
return @{@"identifier" : @"id", return @{@"talkID" : @"talk_id",
@"commentID" : @"comment_id",
@"userID" : @"user_id", @"userID" : @"user_id",
@"preUserID" : @"pre_user_id", @"preUserID" : @"pre_user_id",
@"preContent" : @"pre_content", @"preContent" : @"pre_content",
......
...@@ -28,10 +28,6 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -28,10 +28,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateLikeBtnState:(BOOL)isLike likeCount:(int)likeCount animate:(BOOL)animate; - (void)updateLikeBtnState:(BOOL)isLike likeCount:(int)likeCount animate:(BOOL)animate;
- (void)updateRemarkCount:(int)remarkCount; - (void)updateRemarkCount:(int)remarkCount;
/// 弹出回复输入框(第一版暂不考虑)
/// @param commentUser @评论者
- (void)popReplyInputBoxWithCommentUser:(NSString *)commentUser;
- (void)dismissKeyboard; - (void)dismissKeyboard;
@end @end
......
...@@ -72,10 +72,6 @@ ...@@ -72,10 +72,6 @@
[self.remarkCountBtn setTitle:[NSString stringWithFormat:@"%d", remarkCount] forState:UIControlStateNormal]; [self.remarkCountBtn setTitle:[NSString stringWithFormat:@"%d", remarkCount] forState:UIControlStateNormal];
} }
- (void)popReplyInputBoxWithCommentUser:(NSString *)commentUser {
[self.textInputAlertView showReplyTextAlertWithCommentUser:commentUser];
}
- (void)dismissKeyboard { - (void)dismissKeyboard {
[self.textInputAlertView dismiss]; [self.textInputAlertView dismiss];
} }
......
...@@ -12,6 +12,11 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -12,6 +12,11 @@ NS_ASSUME_NONNULL_BEGIN
@protocol MessageNotiViewDelegate <NSObject> @protocol MessageNotiViewDelegate <NSObject>
- (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath; - (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
/// 消息中心回复评论
/// @param content 回复内容
/// @param userMessageModel 用户消息数据model
- (void)replyContent:(NSString *)content userMessageModel:(id)userMessageModel;
@end @end
/// 消息通知view /// 消息通知view
...@@ -21,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -21,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithDelegate:(id<MessageNotiViewDelegate>)messageDelegate viewModel:(MessageCenterViewModel *)vm; - (instancetype)initWithDelegate:(id<MessageNotiViewDelegate>)messageDelegate viewModel:(MessageCenterViewModel *)vm;
- (void)dismissKeyBoard;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -8,12 +8,14 @@ ...@@ -8,12 +8,14 @@
#import "MessageNotiView.h" #import "MessageNotiView.h"
#import "MessageOfficialNotiCell.h" #import "MessageOfficialNotiCell.h"
#import "MessageComReplyCell.h" #import "MessageComReplyCell.h"
#import "TextInputAlertView.h"
static int secHeaderHeight = 52; static int secHeaderHeight = 52;
static int secFooterHeight = 8; static int secFooterHeight = 8;
@interface MessageNotiView () <UITableViewDelegate, UITableViewDataSource> @interface MessageNotiView () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) MessageCenterViewModel *messageCenterVM; @property (nonatomic, strong) MessageCenterViewModel *messageCenterVM;
@property (nonatomic, strong) TextInputAlertView *textInputAlertView;
@end @end
@implementation MessageNotiView @implementation MessageNotiView
...@@ -38,6 +40,11 @@ static int secFooterHeight = 8; ...@@ -38,6 +40,11 @@ static int secFooterHeight = 8;
return self; return self;
} }
#pragma mark - public
- (void)dismissKeyBoard {
[self.textInputAlertView dismiss];
}
#pragma mark - UITableViewDelegate, UITableViewDataSource #pragma mark - UITableViewDelegate, UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.messageCenterVM.messageListArr.count; return self.messageCenterVM.messageListArr.count;
...@@ -100,12 +107,13 @@ static int secFooterHeight = 8; ...@@ -100,12 +107,13 @@ static int secFooterHeight = 8;
cell.officialModel = officialNotiList[indexPath.row]; cell.officialModel = officialNotiList[indexPath.row];
return cell; return cell;
} else { } else {
WS(weakSelf);
MessageComReplyCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MessageComReplyCell class]) forIndexPath:indexPath]; MessageComReplyCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MessageComReplyCell class]) forIndexPath:indexPath];
NSArray *userNotiList = self.messageCenterVM.messageListArr[indexPath.section]; NSArray *userNotiList = self.messageCenterVM.messageListArr[indexPath.section];
cell.comReplyModel = userNotiList[indexPath.row]; MessageComReplyModel *model = userNotiList[indexPath.row];
cell.comReplyModel = model;
cell.tapReplyBtnBlock = ^{ cell.tapReplyBtnBlock = ^{
#warning 回复功能逻辑未完成... [weakSelf.textInputAlertView showReplyTextAlertWithCommentUser:model.nickName model:model];
}; };
return cell; return cell;
} }
...@@ -117,4 +125,18 @@ static int secFooterHeight = 8; ...@@ -117,4 +125,18 @@ static int secFooterHeight = 8;
} }
} }
#pragma mark - lazy
- (TextInputAlertView *)textInputAlertView {
if (!_textInputAlertView) {
WS(weakSelf);
_textInputAlertView = [[TextInputAlertView alloc] initWithFrame:[UIScreen mainScreen].bounds];
_textInputAlertView.tapReplyBlock = ^(NSString * _Nonnull content, id _Nonnull model) {
if (weakSelf.messageDelegate && [weakSelf.messageDelegate respondsToSelector:@selector(replyContent:userMessageModel:)]) {
[weakSelf.messageDelegate replyContent:content userMessageModel:model];
}
};
}
return _textInputAlertView;
}
@end @end
...@@ -9,19 +9,24 @@ ...@@ -9,19 +9,24 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/// 发布获取回复block /// 发布评论回调block
typedef void(^TapFinishBlock)(NSInteger tag, NSString * content); typedef void(^TapFinishBlock)(NSInteger tag, NSString * content);
/// 回复评论回调block
typedef void(^TapReplyBlock)(NSString * content, id model);
/// 文本评论弹框 /// 文本评论弹框
@interface TextInputAlertView : UIView @interface TextInputAlertView : UIView
@property (nonatomic, copy) TapFinishBlock tapFinishBlock; @property (nonatomic, copy) TapFinishBlock tapFinishBlock;
@property (nonatomic, copy) TapReplyBlock tapReplyBlock;
- (void)showTextInputAlertView; - (void)showTextInputAlertView;
- (void)showReplyTextAlertWithCommentUser:(NSString *)commentUser; - (void)showReplyTextAlertWithCommentUser:(NSString *)commentUser model:(id)model;
- (void)dismiss; - (void)dismiss;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
@property (nonatomic, strong) UIButton *replyBtn; @property (nonatomic, strong) UIButton *replyBtn;
@property (nonatomic, assign) CGFloat duration; @property (nonatomic, assign) CGFloat duration;
@property (nonatomic, copy) NSString *commentUserFlag; @property (nonatomic, copy) NSString *commentUserFlag;
@property (nonatomic, strong) id userMessageModel;
@end @end
@implementation TextInputAlertView @implementation TextInputAlertView
...@@ -90,11 +91,12 @@ ...@@ -90,11 +91,12 @@
[self.replyBtn setTitle:@"发布" forState:UIControlStateNormal]; [self.replyBtn setTitle:@"发布" forState:UIControlStateNormal];
} }
- (void)showReplyTextAlertWithCommentUser:(NSString *)commentUser { - (void)showReplyTextAlertWithCommentUser:(NSString *)commentUser model:(id)model {
[self showTextInputAlertView]; [self showTextInputAlertView];
self.replyBtn.tag = 2; self.replyBtn.tag = 2;
self.userMessageModel = model;
[self.replyBtn setTitle:@"回复" forState:UIControlStateNormal]; [self.replyBtn setTitle:@"回复" forState:UIControlStateNormal];
self.commentUserFlag = [NSString stringWithFormat:@"@%@,", commentUser]; self.commentUserFlag = commentUser ? [NSString stringWithFormat:@"@%@,", commentUser] : @"";
self.textView.text = self.commentUserFlag; self.textView.text = self.commentUserFlag;
} }
...@@ -110,17 +112,28 @@ ...@@ -110,17 +112,28 @@
- (void)replyAction:(UIButton *)sender { - (void)replyAction:(UIButton *)sender {
NSString *content = self.textView.text; NSString *content = self.textView.text;
NSString *toast = @"请输入评论内容";
if (sender.tag == 2) { // 回复 if (sender.tag == 2) { // 回复
content = [content componentsSeparatedByString:self.commentUserFlag].lastObject; if ([content hasPrefix:self.commentUserFlag]) {
content = [content componentsSeparatedByString:self.commentUserFlag].lastObject;
}
toast = @"请输入回复内容";
} }
NSString *triStr = [NSString trimString:content]; NSString *triStr = [NSString trimString:content];
if (triStr.length == 0) { if (triStr.length == 0) {
[DSProgressHUD showToast:@"请输入评论内容"]; [DSProgressHUD showToast:toast];
return; return;
} }
content = [NSString transferSpecialCharacters:content]; content = [NSString transferSpecialCharacters:content];
if (self.tapFinishBlock) { if (sender.tag == 1) { // 评论
self.tapFinishBlock(sender.tag, content); if (self.tapFinishBlock) {
self.tapFinishBlock(sender.tag, content);
}
} else if (sender.tag == 2) { // 回复
if (self.tapReplyBlock) {
self.tapReplyBlock(content, self.userMessageModel);
}
} }
} }
......
...@@ -19,6 +19,11 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -19,6 +19,11 @@ NS_ASSUME_NONNULL_BEGIN
/// @param completion completion /// @param completion completion
- (void)muiltiRequestWithCompletion:(void (^)(BOOL isSuccess))completion; - (void)muiltiRequestWithCompletion:(void (^)(BOOL isSuccess))completion;
/// 消息中心用户回复评论接口
/// @param content 回复内容
/// @param userMessageModel 消息model
/// @param completion completion
+ (NSURLSessionDataTask *)userReplyCommentWithContent:(NSString *)content userMessageModel:(id)userMessageModel completion:(void (^)(MessageCenterViewModel *requestModel))completion;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -77,6 +77,22 @@ ...@@ -77,6 +77,22 @@
}); });
} }
+ (NSURLSessionDataTask *)userReplyCommentWithContent:(NSString *)content userMessageModel:(id)userMessageModel completion:(void (^)(MessageCenterViewModel *requestModel))completion {
MessageComReplyModel *model = userMessageModel;
MessageCenterViewModel * requestModel = [[MessageCenterViewModel alloc] init];
NSString *api = @"user_reply_comment";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(user_id:%ld,talk_id:%ld,comment_id:%ld,content:\"%@\")}", api, model.userID, model.talkID, model.commentID, content];
return [MessageCenterViewModel httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户-回复评论接口apiDic:%@", apiDic);
requestModel.resCode = DSResCodeSuccess;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
requestModel.resCode = [failureInfo[@"errorCode"] integerValue];
requestModel.errMessage = failureInfo[@"errMessage"];
completion(requestModel);
}];
}
#pragma mark - private #pragma mark - private
- (NSURLSessionDataTask *)queryUserMessageCountWithCompletion:(void (^)(MessageCenterViewModel *requestModel))completion { - (NSURLSessionDataTask *)queryUserMessageCountWithCompletion:(void (^)(MessageCenterViewModel *requestModel))completion {
MessageCenterViewModel *requestModel = [MessageCenterViewModel new]; MessageCenterViewModel *requestModel = [MessageCenterViewModel new];
......
//
// PraiseListViewModel.h
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
/// 用户点赞列表
@interface PraiseListViewModel : DSNetworkTool
@property (nonatomic, strong) NSArray *resultArr;
/// 查询用户点赞列表数据
/// @param offset 页码
/// @param completion completion
+ (NSURLSessionDataTask *)queryUserDynamicPraiseWithOffset:(int)offset completion:(void (^)(PraiseListViewModel *viewModel))completion;
@end
NS_ASSUME_NONNULL_END
//
// PraiseListViewModel.m
// DreamSleep
//
// Created by peter on 2022/10/18.
//
#import "PraiseListViewModel.h"
#import "PraiseModel.h"
@interface ResultModel : NSObject
@property (nonatomic, assign) int count;
@property (nonatomic, assign) int offset;
@property (nonatomic, strong) NSArray<PraiseModel *> * data_list;
@end
@implementation ResultModel
+ (NSDictionary *)modelContainerPropertyGenericClass {
return @{@"data_list":[PraiseModel class]};
}
@end
@implementation PraiseListViewModel
+ (NSURLSessionDataTask *)queryUserDynamicPraiseWithOffset:(int)offset completion:(void (^)(PraiseListViewModel *viewModel))completion {
PraiseListViewModel *viewModel = [PraiseListViewModel new];
NSString *api = @"query_user_dynamic_praise";
NSString *argStr = [NSString stringWithFormat:@"query{%@(offset:%d)}", api, offset];
return [PraiseListViewModel httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"社区动态消息中心接口apiDic:%@", apiDic);
ResultModel *resultModel = [ResultModel yy_modelWithDictionary:apiDic[@"result"]];
viewModel.resCode = DSResCodeSuccess;
viewModel.resultArr = resultModel.data_list;
completion(viewModel);
} failure:^(id _Nonnull failureInfo) {
viewModel.resCode = [failureInfo[@"errorCode"] integerValue];
viewModel.errMessage = failureInfo[@"errMessage"];
completion(viewModel);
}];
}
@end
{
"images" : [
{
"filename" : "dk_ic_shequ_pinlun.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dk_ic_shequ_pinlun@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dk_ic_shequ_pinlun@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_shequ_pinlun.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_shequ_pinlun@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_shequ_pinlun@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!