Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b17d74f8
由
cgx
编写于
2022-10-12 18:26:03 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
调试用户删除动态接口
1 个父辈
89a736c7
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
194 行增加
和
87 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Class/CommunityModule/Controller/CommunityController.m
DreamSleep/DreamSleep/Class/CommunityModule/View/CommunityView.h
DreamSleep/DreamSleep/Class/CommunityModule/View/CommunityView.m
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComListViewModel.h
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComListViewModel.m
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/DynamicViewModel.h
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/DynamicViewModel.m
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/PersonDynViewModel.h
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/PersonDynViewModel.m
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
b17d74f
...
@@ -121,6 +121,7 @@
...
@@ -121,6 +121,7 @@
D0691E0E288009D3008BFFAB /* ReadyItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0691E0D288009D3008BFFAB /* ReadyItemCell.m */; };
D0691E0E288009D3008BFFAB /* ReadyItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0691E0D288009D3008BFFAB /* ReadyItemCell.m */; };
D0691E1128801D43008BFFAB /* RelaxItemsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0691E1028801D43008BFFAB /* RelaxItemsView.m */; };
D0691E1128801D43008BFFAB /* RelaxItemsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0691E1028801D43008BFFAB /* RelaxItemsView.m */; };
D0691E1428801EF3008BFFAB /* ReadyTimeMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = D0691E1328801EF3008BFFAB /* ReadyTimeMarker.m */; };
D0691E1428801EF3008BFFAB /* ReadyTimeMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = D0691E1328801EF3008BFFAB /* ReadyTimeMarker.m */; };
D06F2C5128F6AEC50023921E /* PersonDynViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D06F2C5028F6AEC50023921E /* PersonDynViewModel.m */; };
D070509A28071BAF006D72E1 /* DSNetworkTool.m in Sources */ = {isa = PBXBuildFile; fileRef = D070509928071BAF006D72E1 /* DSNetworkTool.m */; };
D070509A28071BAF006D72E1 /* DSNetworkTool.m in Sources */ = {isa = PBXBuildFile; fileRef = D070509928071BAF006D72E1 /* DSNetworkTool.m */; };
D070A78328DEE5C20039C5A7 /* BindMobileController.m in Sources */ = {isa = PBXBuildFile; fileRef = D070A78228DEE5C20039C5A7 /* BindMobileController.m */; };
D070A78328DEE5C20039C5A7 /* BindMobileController.m in Sources */ = {isa = PBXBuildFile; fileRef = D070A78228DEE5C20039C5A7 /* BindMobileController.m */; };
D070A78528DEE6760039C5A7 /* BindMobileController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D070A78428DEE6760039C5A7 /* BindMobileController.storyboard */; };
D070A78528DEE6760039C5A7 /* BindMobileController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D070A78428DEE6760039C5A7 /* BindMobileController.storyboard */; };
...
@@ -531,6 +532,8 @@
...
@@ -531,6 +532,8 @@
D0691E1028801D43008BFFAB /* RelaxItemsView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RelaxItemsView.m; sourceTree = "<group>"; };
D0691E1028801D43008BFFAB /* RelaxItemsView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RelaxItemsView.m; sourceTree = "<group>"; };
D0691E1228801EF3008BFFAB /* ReadyTimeMarker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReadyTimeMarker.h; sourceTree = "<group>"; };
D0691E1228801EF3008BFFAB /* ReadyTimeMarker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ReadyTimeMarker.h; sourceTree = "<group>"; };
D0691E1328801EF3008BFFAB /* ReadyTimeMarker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReadyTimeMarker.m; sourceTree = "<group>"; };
D0691E1328801EF3008BFFAB /* ReadyTimeMarker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReadyTimeMarker.m; sourceTree = "<group>"; };
D06F2C4F28F6AEC50023921E /* PersonDynViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PersonDynViewModel.h; sourceTree = "<group>"; };
D06F2C5028F6AEC50023921E /* PersonDynViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PersonDynViewModel.m; sourceTree = "<group>"; };
D070509828071BAF006D72E1 /* DSNetworkTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DSNetworkTool.h; sourceTree = "<group>"; };
D070509828071BAF006D72E1 /* DSNetworkTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DSNetworkTool.h; sourceTree = "<group>"; };
D070509928071BAF006D72E1 /* DSNetworkTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DSNetworkTool.m; sourceTree = "<group>"; };
D070509928071BAF006D72E1 /* DSNetworkTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DSNetworkTool.m; sourceTree = "<group>"; };
D070A78128DEE5C20039C5A7 /* BindMobileController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BindMobileController.h; sourceTree = "<group>"; };
D070A78128DEE5C20039C5A7 /* BindMobileController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BindMobileController.h; sourceTree = "<group>"; };
...
@@ -1643,6 +1646,8 @@
...
@@ -1643,6 +1646,8 @@
D070A78D28DF02DE0039C5A7 /* DynamicViewModel.m */,
D070A78D28DF02DE0039C5A7 /* DynamicViewModel.m */,
D053D0DA28F3C23200BB2B84 /* ReportViewModel.h */,
D053D0DA28F3C23200BB2B84 /* ReportViewModel.h */,
D053D0DB28F3C23200BB2B84 /* ReportViewModel.m */,
D053D0DB28F3C23200BB2B84 /* ReportViewModel.m */,
D06F2C4F28F6AEC50023921E /* PersonDynViewModel.h */,
D06F2C5028F6AEC50023921E /* PersonDynViewModel.m */,
);
);
path = ViewModel;
path = ViewModel;
sourceTree = "<group>";
sourceTree = "<group>";
...
@@ -2653,6 +2658,7 @@
...
@@ -2653,6 +2658,7 @@
D055BEC828252D8200BC11A4 /* AudioCourseCell.m in Sources */,
D055BEC828252D8200BC11A4 /* AudioCourseCell.m in Sources */,
D0AEFE7C2817D13400230DC6 /* UITableViewCell+CardRadius.m in Sources */,
D0AEFE7C2817D13400230DC6 /* UITableViewCell+CardRadius.m in Sources */,
D01DC957287023C20035B78B /* RankHeadView.m in Sources */,
D01DC957287023C20035B78B /* RankHeadView.m in Sources */,
D06F2C5128F6AEC50023921E /* PersonDynViewModel.m in Sources */,
D0D5BB0D286D7A8D00D0507E /* TaskGroupModel.m in Sources */,
D0D5BB0D286D7A8D00D0507E /* TaskGroupModel.m in Sources */,
D0E3564028F55B50007190EE /* PraiseListController.m in Sources */,
D0E3564028F55B50007190EE /* PraiseListController.m in Sources */,
D053D0DF28F40C6A00BB2B84 /* MessageController.m in Sources */,
D053D0DF28F40C6A00BB2B84 /* MessageController.m in Sources */,
...
...
DreamSleep/DreamSleep/Class/CommunityModule/Controller/CommunityController.m
查看文件 @
b17d74f
...
@@ -7,29 +7,34 @@
...
@@ -7,29 +7,34 @@
#import "CommunityController.h"
#import "CommunityController.h"
#import "CommunityView.h"
#import "CommunityView.h"
#import "ComListViewModel.h"
#import "DynamicController.h"
#import "DynamicController.h"
#import "MessageController.h"
#import "MessageController.h"
#import "ReportController.h"
#import "ReportController.h"
#import "DynamicDetailController.h"
#import "DynamicDetailController.h"
#import "PersonDynViewModel.h"
@interface
CommunityController
()
<
CommunityViewDelegate
,
DynamicControllerDelegate
,
DynamicDetailControllerDelegate
>
@interface
CommunityController
()
<
CommunityViewDelegate
,
DynamicControllerDelegate
,
DynamicDetailControllerDelegate
>
@property
(
nonatomic
,
strong
)
CommunityView
*
communityView
;
@property
(
nonatomic
,
strong
)
CommunityView
*
communityView
;
@property
(
nonatomic
,
assign
)
int
offset
;
@property
(
nonatomic
,
assign
)
int
offset
;
@property
(
nonatomic
,
strong
)
NSURLSessionDataTask
*
likeDataTask
;
@property
(
nonatomic
,
strong
)
NSURLSessionDataTask
*
likeDataTask
;
/// 存储动态id
/// 存储动态id
@property
(
nonatomic
,
assign
)
int
talkID
;
@property
(
nonatomic
,
assign
)
int
talkID
;
@property
(
nonatomic
,
strong
)
ComListViewModel
*
comListViewModel
;
@property
(
nonatomic
,
strong
)
PersonDynViewModel
*
personDynViewModel
;
@end
@end
@implementation
CommunityController
@implementation
CommunityController
-
(
void
)
loadView
{
-
(
void
)
loadView
{
self
.
comListViewModel
=
[
ComListViewModel
new
];
self
.
view
=
self
.
communityView
;
self
.
view
=
self
.
communityView
;
}
}
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
[
self
setupUI
];
[
self
setupUI
];
}
}
...
@@ -53,7 +58,22 @@
...
@@ -53,7 +58,22 @@
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
];
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
];
return
;
return
;
}
}
[
self
.
navigationController
pushViewController
:[
MessageController
new
]
animated
:
YES
];
// [self.navigationController pushViewController:[MessageController new] animated:YES];
#warning - 测试删除接口
[
self
testDynDeleteAPI
];
}
-
(
void
)
testDynDeleteAPI
{
self
.
personDynViewModel
=
[
PersonDynViewModel
new
];
self
.
personDynViewModel
.
oper_type
=
@"dynamic"
;
self
.
personDynViewModel
.
delete_id
=
58
;
[
self
.
personDynViewModel
communityDeleteOperationWithCompletion
:
^
(
PersonDynViewModel
*
_Nonnull
requestModel
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
[
self
.
comListViewModel
deleteComDynWithDynamicID
:
self
.
personDynViewModel
.
delete_id
];
[
self
.
communityView
updateListView
];
}
}];
}
}
#pragma mark - CommunityViewDelegate
#pragma mark - CommunityViewDelegate
...
@@ -69,17 +89,17 @@
...
@@ -69,17 +89,17 @@
-
(
void
)
getDynamicListRequest
:
(
BOOL
)
loadMore
{
-
(
void
)
getDynamicListRequest
:
(
BOOL
)
loadMore
{
if
(
loadMore
==
NO
)
{
self
.
offset
=
1
;
}
if
(
loadMore
==
NO
)
{
self
.
offset
=
1
;
}
[
ComListViewModel
querySleepDynamicListWithO
ffset
:
self
.
offset
completion
:
^
(
ComListViewModel
*
_Nonnull
requestModel
)
{
[
self
.
comListViewModel
querySleepDynamicListWithLoadMore
:
loadMore
o
ffset
:
self
.
offset
completion
:^
(
ComListViewModel
*
_Nonnull
requestModel
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
if
(
loadMore
)
{
if
(
loadMore
)
{
if
(
self
.
offset
>
requestModel
.
totalCount
)
{
if
(
self
.
offset
>
requestModel
.
totalCount
)
{
[
DSProgressHUD
showToast
:
@"无更多动态"
];
[
DSProgressHUD
showToast
:
@"无更多动态"
];
[
self
.
communityView
updateCommunityMoments
:
loadMore
listArr
:@[]
];
[
self
.
communityView
updateCommunityMoments
:
loadMore
];
return
;
return
;
}
}
}
}
self
.
offset
++
;
self
.
offset
++
;
[
self
.
communityView
updateCommunityMoments
:
loadMore
listArr
:
requestModel
.
listArr
];
[
self
.
communityView
updateCommunityMoments
:
loadMore
];
}
else
{
}
else
{
[
DSProgressHUD
showToast
:
requestModel
.
errMessage
];
[
DSProgressHUD
showToast
:
requestModel
.
errMessage
];
[
self
.
communityView
endRefreshing
:
loadMore
];
[
self
.
communityView
endRefreshing
:
loadMore
];
...
@@ -138,28 +158,16 @@
...
@@ -138,28 +158,16 @@
return
;
return
;
}
}
// 1、用户点赞或取消点赞直接响应UI变化
// 1、用户点赞或取消点赞直接响应UI变化
if
(
comDynModel
.
isLike
)
{
[
ComListViewModel
updateLikeData
:
comDynModel
];
comDynModel
.
likeCount
--
;
}
else
{
comDynModel
.
likeCount
++
;
}
comDynModel
.
isLike
=
!
comDynModel
.
isLike
;
[
cell
fireLikeAnimate
];
[
cell
fireLikeAnimate
];
[
cell
updateLikeUI
];
[
cell
updateLikeUI
];
// 2、更新点赞或取消点赞请求
// 2、更新点赞或取消点赞请求
if
(
self
.
likeDataTask
)
{
[
self
.
likeDataTask
cancel
];
}
if
(
self
.
likeDataTask
)
{
[
self
.
likeDataTask
cancel
];
}
self
.
likeDataTask
=
[
ComListViewModel
userDynamicPraiseWith
TalkID
:
comDynModel
.
dynamicID
completion
:
^
(
ComListViewModel
*
_Nonnull
requestModel
)
{
self
.
likeDataTask
=
[
ComListViewModel
userDynamicPraiseWith
ComDynModel
:
comDynModel
completion
:
^
(
ComListViewModel
*
_Nonnull
requestModel
)
{
// 3、如果请求失败,延迟执行回退
// 3、如果请求失败,延迟执行回退
if
(
requestModel
.
resCode
!=
DSResCodeSuccess
)
{
if
(
requestModel
.
resCode
!=
DSResCodeSuccess
)
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
3
.
0
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
3
.
0
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
// 修改数据model
if
(
comDynModel
.
isLike
)
{
comDynModel
.
likeCount
--
;
}
else
{
comDynModel
.
likeCount
++
;
}
comDynModel
.
isLike
=
!
comDynModel
.
isLike
;
[
cell
updateLikeUI
];
[
cell
updateLikeUI
];
[
DSProgressHUD
showToast
:
requestModel
.
errMessage
];
[
DSProgressHUD
showToast
:
requestModel
.
errMessage
];
});
});
...
@@ -169,18 +177,19 @@
...
@@ -169,18 +177,19 @@
#pragma mark - DynamicControllerDelegate
#pragma mark - DynamicControllerDelegate
-
(
void
)
publishSuccessWithData
:
(
id
)
model
{
-
(
void
)
publishSuccessWithData
:
(
id
)
model
{
[
self
.
communityView
insertUserDyModel
:
model
];
[
self
.
comListViewModel
insertUserDyModel
:
model
];
[
self
.
communityView
updateListView
];
}
}
#pragma mark - DynamicDetailControllerDelegate
#pragma mark - DynamicDetailControllerDelegate
-
(
void
)
updateLikeOrRemark
{
-
(
void
)
updateLikeOrRemark
{
[
self
.
communityView
updateLi
keOrRemark
View
];
[
self
.
communityView
updateLi
st
View
];
}
}
#pragma mark - lazy
#pragma mark - lazy
-
(
CommunityView
*
)
communityView
{
-
(
CommunityView
*
)
communityView
{
if
(
!
_communityView
)
{
if
(
!
_communityView
)
{
_communityView
=
[[
CommunityView
alloc
]
initWithDelegate
:
self
];
_communityView
=
[[
CommunityView
alloc
]
initWithDelegate
:
self
comListViewModel
:
self
.
comListViewModel
];
}
}
return
_communityView
;
return
_communityView
;
}
}
...
...
DreamSleep/DreamSleep/Class/CommunityModule/View/CommunityView.h
查看文件 @
b17d74f
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#import "ComDynamicCell.h"
#import "ComDynamicCell.h"
#import "ComListViewModel.h"
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
...
@@ -43,14 +44,10 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -43,14 +44,10 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
weak
)
id
<
CommunityViewDelegate
>
delegate
;
@property
(
nonatomic
,
weak
)
id
<
CommunityViewDelegate
>
delegate
;
-
(
instancetype
)
initWithDelegate
:(
id
<
CommunityViewDelegate
>
)
delegate
;
-
(
instancetype
)
initWithDelegate
:(
id
<
CommunityViewDelegate
>
)
delegate
comListViewModel
:(
ComListViewModel
*
)
comListVM
;
/// 更新社区动态
/// 更新社区动态
-
(
void
)
updateCommunityMoments
:(
BOOL
)
loadMore
listArr
:(
NSArray
*
)
listArr
;
-
(
void
)
updateCommunityMoments
:(
BOOL
)
loadMore
;
/// 临时插入用户动态数据
/// @param dyModel dyModel
-
(
void
)
insertUserDyModel
:(
ComDynModel
*
)
dyModel
;
/// 结束加载动画
/// 结束加载动画
-
(
void
)
endRefreshing
:(
BOOL
)
loadMore
;
-
(
void
)
endRefreshing
:(
BOOL
)
loadMore
;
...
@@ -58,8 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -58,8 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 显示举报、取消弹框
/// 显示举报、取消弹框
-
(
void
)
showInformCancelView
;
-
(
void
)
showInformCancelView
;
/// 更新
社区动态列表点赞或者评论view
/// 更新
列表
-
(
void
)
updateLi
keOrRemark
View
;
-
(
void
)
updateLi
st
View
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/CommunityModule/View/CommunityView.m
查看文件 @
b17d74f
...
@@ -11,17 +11,18 @@
...
@@ -11,17 +11,18 @@
@interface
CommunityView
()
<
UITableViewDelegate
,
UITableViewDataSource
,
InformCancelAlertViewDelegate
>
@interface
CommunityView
()
<
UITableViewDelegate
,
UITableViewDataSource
,
InformCancelAlertViewDelegate
>
@property
(
nonatomic
,
strong
)
UIView
*
headView
;
@property
(
nonatomic
,
strong
)
UIView
*
headView
;
@property
(
nonatomic
,
strong
)
UITableView
*
listView
;
@property
(
nonatomic
,
strong
)
UITableView
*
listView
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
listArr
;
@property
(
nonatomic
,
strong
)
ComListViewModel
*
comListVM
;
@property
(
nonatomic
,
strong
)
InformCancelAlertView
*
informCancelView
;
@property
(
nonatomic
,
strong
)
InformCancelAlertView
*
informCancelView
;
@end
@end
@implementation
CommunityView
@implementation
CommunityView
#pragma mark - 初始化
#pragma mark - 初始化
-
(
instancetype
)
initWithDelegate
:(
id
<
CommunityViewDelegate
>
)
delegate
{
-
(
instancetype
)
initWithDelegate
:(
id
<
CommunityViewDelegate
>
)
delegate
comListViewModel
:(
ComListViewModel
*
)
comListVM
{
if
(
self
=
[
super
init
])
{
if
(
self
=
[
super
init
])
{
self
.
delegate
=
delegate
;
self
.
delegate
=
delegate
;
self
.
listArr
=
[
NSMutableArray
array
];
self
.
comListVM
=
comListVM
;
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
addSubview
:
self
.
listView
];
[
self
addSubview
:
self
.
listView
];
...
@@ -43,24 +44,15 @@
...
@@ -43,24 +44,15 @@
}
}
#pragma mark - public
#pragma mark - public
-
(
void
)
updateCommunityMoments
:
(
BOOL
)
loadMore
listArr
:
(
NSArray
*
)
listArr
{
-
(
void
)
updateCommunityMoments
:
(
BOOL
)
loadMore
{
if
(
loadMore
)
{
if
(
loadMore
)
{
[
self
.
listArr
addObjectsFromArray
:
listArr
];
[
self
.
listView
.
mj_footer
endRefreshing
];
[
self
.
listView
.
mj_footer
endRefreshing
];
}
else
{
}
else
{
self
.
listArr
=
[
NSMutableArray
arrayWithArray
:
listArr
];
[
self
.
listView
.
mj_header
endRefreshing
];
[
self
.
listView
.
mj_header
endRefreshing
];
}
}
[
self
.
listView
reloadData
];
[
self
.
listView
reloadData
];
}
}
-
(
void
)
insertUserDyModel
:
(
ComDynModel
*
)
dyModel
{
if
(
!
dyModel
)
{
return
;
}
// 用户发的说说临时插入到动态列表第一条
[
self
.
listArr
insertObject
:
dyModel
atIndex
:
0
];
[
self
.
listView
reloadData
];
}
-
(
void
)
endRefreshing
:
(
BOOL
)
loadMore
{
-
(
void
)
endRefreshing
:
(
BOOL
)
loadMore
{
loadMore
?
[
self
.
listView
.
mj_footer
endRefreshing
]
:
[
self
.
listView
.
mj_header
endRefreshing
];
loadMore
?
[
self
.
listView
.
mj_footer
endRefreshing
]
:
[
self
.
listView
.
mj_header
endRefreshing
];
}
}
...
@@ -69,7 +61,7 @@
...
@@ -69,7 +61,7 @@
[
self
.
informCancelView
display
];
[
self
.
informCancelView
display
];
}
}
-
(
void
)
updateLi
keOrRemark
View
{
-
(
void
)
updateLi
st
View
{
[
self
.
listView
reloadData
];
[
self
.
listView
reloadData
];
}
}
...
@@ -88,7 +80,7 @@
...
@@ -88,7 +80,7 @@
#pragma mark - UITableViewDelegate, UITableViewDataSource
#pragma mark - UITableViewDelegate, UITableViewDataSource
-
(
NSInteger
)
numberOfSectionsInTableView
:
(
UITableView
*
)
tableView
{
-
(
NSInteger
)
numberOfSectionsInTableView
:
(
UITableView
*
)
tableView
{
return
self
.
listArr
.
count
;
return
self
.
comListVM
.
listArr
.
count
;
}
}
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
...
@@ -96,7 +88,7 @@
...
@@ -96,7 +88,7 @@
}
}
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
ComDynModel
*
model
=
self
.
listArr
[
indexPath
.
section
];
ComDynModel
*
model
=
self
.
comListVM
.
listArr
[
indexPath
.
section
];
return
[
model
cellHeight
:
DynModelTypeCom
];
return
[
model
cellHeight
:
DynModelTypeCom
];
}
}
...
@@ -109,7 +101,7 @@
...
@@ -109,7 +101,7 @@
}
}
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForFooterInSection
:
(
NSInteger
)
section
{
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForFooterInSection
:
(
NSInteger
)
section
{
return
section
==
self
.
listArr
.
count
-
1
?
6
.
5
:
12
;;
return
section
==
self
.
comListVM
.
listArr
.
count
-
1
?
6
.
5
:
12
;;
}
}
-
(
UIView
*
)
tableView
:
(
UITableView
*
)
tableView
viewForFooterInSection
:
(
NSInteger
)
section
{
-
(
UIView
*
)
tableView
:
(
UITableView
*
)
tableView
viewForFooterInSection
:
(
NSInteger
)
section
{
...
@@ -121,7 +113,7 @@
...
@@ -121,7 +113,7 @@
if
(
!
cell
)
{
if
(
!
cell
)
{
cell
=
[[
ComDynamicCell
alloc
]
initWithCellType
:
DynModelTypeCom
style
:
UITableViewCellStyleDefault
reuseIdentifier
:
NSStringFromClass
([
ComDynamicCell
class
])];
cell
=
[[
ComDynamicCell
alloc
]
initWithCellType
:
DynModelTypeCom
style
:
UITableViewCellStyleDefault
reuseIdentifier
:
NSStringFromClass
([
ComDynamicCell
class
])];
}
}
ComDynModel
*
model
=
self
.
listArr
[
indexPath
.
section
];
ComDynModel
*
model
=
self
.
comListVM
.
listArr
[
indexPath
.
section
];
cell
.
model
=
model
;
cell
.
model
=
model
;
WS
(
weakSelf
);
WS
(
weakSelf
);
__weak
ComDynamicCell
*
weakCell
=
(
ComDynamicCell
*
)
cell
;
__weak
ComDynamicCell
*
weakCell
=
(
ComDynamicCell
*
)
cell
;
...
@@ -142,7 +134,7 @@
...
@@ -142,7 +134,7 @@
}
}
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
ComDynModel
*
model
=
self
.
listArr
[
indexPath
.
section
];
ComDynModel
*
model
=
self
.
comListVM
.
listArr
[
indexPath
.
section
];
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSelectItemWithModel
:)])
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSelectItemWithModel
:)])
{
[
self
.
delegate
didSelectItemWithModel
:
model
];
[
self
.
delegate
didSelectItemWithModel
:
model
];
}
}
...
...
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComListViewModel.h
查看文件 @
b17d74f
...
@@ -6,28 +6,42 @@
...
@@ -6,28 +6,42 @@
//
//
#import "DSNetworkTool.h"
#import "DSNetworkTool.h"
#import "ComDynModel.h"
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
/// 社区动态列表、用户点赞
/// 社区动态列表、用户点赞
@interface
ComListViewModel
:
DSNetworkTool
@interface
ComListViewModel
:
DSNetworkTool
@property
(
nonatomic
,
assign
)
int
offset
;
/// 总页数
@property
(
nonatomic
,
assign
)
int
limit
;
@property
(
nonatomic
,
assign
)
int
totalCount
;
@property
(
nonatomic
,
assign
)
int
totalCount
;
/// 社区动态列表数据
@property
(
nonatomic
,
strong
)
NSArray
*
listArr
;
@property
(
nonatomic
,
strong
)
NSArray
*
listArr
;
-
(
void
)
getComListWithCompletion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
;
-
(
void
)
getComListWithCompletion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
;
/// 社区动态查询列表接口
/// 社区动态查询列表接口
/// @param loadMore loadMore
/// @param offset offset
/// @param offset offset
/// @param completion completion
/// @param completion completion
+
(
NSURLSessionDataTask
*
)
querySleepDynamicListWithOffset
:(
int
)
offset
completion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
;
-
(
NSURLSessionDataTask
*
)
querySleepDynamicListWithLoadMore
:(
BOOL
)
loadMore
offset
:(
int
)
offset
completion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
;
/// 删除个人社区动态
/// @param dynamicID 动态id
-
(
void
)
deleteComDynWithDynamicID
:(
int
)
dynamicID
;
/// 临时插入用户动态数据
/// @param dyModel dyModel
-
(
void
)
insertUserDyModel
:(
ComDynModel
*
)
dyModel
;
/// 临时更新点赞数据
/// @param comDynModel comDynModel
+
(
void
)
updateLikeData
:(
ComDynModel
*
)
comDynModel
;
/// 用户点赞、取消点赞接口
/// 用户点赞、取消点赞接口
/// @param
talkID talkID
/// @param
comDynModel comDynModel
/// @param completion completion
/// @param completion completion
+
(
NSURLSessionDataTask
*
)
userDynamicPraiseWith
TalkID
:(
int
)
talkID
completion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
;
+
(
NSURLSessionDataTask
*
)
userDynamicPraiseWith
ComDynModel
:(
ComDynModel
*
)
comDynModel
completion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComListViewModel.m
查看文件 @
b17d74f
...
@@ -6,10 +6,16 @@
...
@@ -6,10 +6,16 @@
//
//
#import "ComListViewModel.h"
#import "ComListViewModel.h"
#import "ComDynModel.h"
@implementation
ComListViewModel
@implementation
ComListViewModel
-
(
instancetype
)
init
{
if
(
self
=
[
super
init
])
{
self
.
listArr
=
[
NSArray
array
];
}
return
self
;
}
-
(
void
)
getComListWithCompletion
:
(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
{
-
(
void
)
getComListWithCompletion
:
(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
{
ComListViewModel
*
requestModel
=
[[
ComListViewModel
alloc
]
init
];
ComListViewModel
*
requestModel
=
[[
ComListViewModel
alloc
]
init
];
NSDictionary
*
apiDic
=
[[
NSDictionary
alloc
]
initWithContentsOfFile
:[[
NSBundle
mainBundle
]
pathForResource
:
@"comList"
ofType
:
@"plist"
]];
NSDictionary
*
apiDic
=
[[
NSDictionary
alloc
]
initWithContentsOfFile
:[[
NSBundle
mainBundle
]
pathForResource
:
@"comList"
ofType
:
@"plist"
]];
...
@@ -26,13 +32,12 @@
...
@@ -26,13 +32,12 @@
completion
(
requestModel
);
completion
(
requestModel
);
}
}
+
(
NSURLSessionDataTask
*
)
querySleepDynamicListWithOffset
:(
int
)
offset
completion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
{
-
(
NSURLSessionDataTask
*
)
querySleepDynamicListWithLoadMore
:
(
BOOL
)
loadMore
offset
:
(
int
)
offset
completion
:
(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
{
ComListViewModel
*
requestModel
=
[[
ComListViewModel
alloc
]
init
];
NSString
*
api
=
@"query_sleep_dynamic_list"
;
NSString
*
api
=
@"query_sleep_dynamic_list"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"query{%@(offset:%d)}"
,
api
,
offset
];
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"query{%@(offset:%d)}"
,
api
,
offset
];
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
return
[
ComListViewModel
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
DSLog
(
@"社区动态查询列表接口apiDic:%@"
,
apiDic
);
DSLog
(
@"社区动态查询列表接口apiDic:%@"
,
apiDic
);
requestModel
.
resCode
=
DSResCodeSuccess
;
self
.
resCode
=
DSResCodeSuccess
;
NSDictionary
*
resultDic
=
apiDic
[
@"result"
];
NSDictionary
*
resultDic
=
apiDic
[
@"result"
];
NSArray
*
data_list
=
resultDic
[
@"data_list"
];
NSArray
*
data_list
=
resultDic
[
@"data_list"
];
NSMutableArray
*
tmpArr
=
[
NSMutableArray
array
];
NSMutableArray
*
tmpArr
=
[
NSMutableArray
array
];
...
@@ -40,22 +45,55 @@
...
@@ -40,22 +45,55 @@
ComDynModel
*
model
=
[
ComDynModel
yy_modelWithDictionary
:
data_list
[
i
]];
ComDynModel
*
model
=
[
ComDynModel
yy_modelWithDictionary
:
data_list
[
i
]];
[
tmpArr
addObject
:
model
];
[
tmpArr
addObject
:
model
];
}
}
requestModel
.
listArr
=
[
tmpArr
copy
];
if
(
loadMore
)
{
requestModel
.
offset
=
[
resultDic
[
@"offset"
]
intValue
];
NSMutableArray
*
tmpDyList
=
[
NSMutableArray
arrayWithArray
:
self
.
listArr
];
requestModel
.
limit
=
[
resultDic
[
@"limit"
]
intValue
];
[
tmpDyList
addObjectsFromArray
:
tmpArr
.
copy
];
requestModel
.
totalCount
=
[
resultDic
[
@"count"
]
intValue
];
self
.
listArr
=
tmpDyList
.
copy
;
completion
(
requestModel
);
}
else
{
self
.
listArr
=
tmpArr
.
copy
;
}
self
.
totalCount
=
[
resultDic
[
@"count"
]
intValue
];
completion
(
self
);
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
requestModel
.
resCode
=
[
failureInfo
[
@"errorCode"
]
integerValue
];
self
.
resCode
=
[
failureInfo
[
@"errorCode"
]
integerValue
];
requestModel
.
errMessage
=
failureInfo
[
@"errMessage"
];
self
.
errMessage
=
failureInfo
[
@"errMessage"
];
completion
(
requestModel
);
completion
(
self
);
}];
}];
}
}
+
(
NSURLSessionDataTask
*
)
userDynamicPraiseWithTalkID
:(
int
)
talkID
completion
:(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
{
-
(
void
)
deleteComDynWithDynamicID
:
(
int
)
dynamicID
{
NSMutableArray
*
tmpListArr
=
[
NSMutableArray
arrayWithArray
:
self
.
listArr
];
[
tmpListArr
enumerateObjectsUsingBlock
:
^
(
ComDynModel
*
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
if
(
obj
.
dynamicID
==
dynamicID
)
{
*
stop
=
YES
;
[
tmpListArr
removeObject
:
obj
];
}
}];
self
.
listArr
=
tmpListArr
.
copy
;
}
-
(
void
)
insertUserDyModel
:
(
ComDynModel
*
)
dyModel
{
if
(
!
dyModel
)
{
return
;
}
// 用户发的说说临时插入到动态列表第一条
NSMutableArray
*
tmpListArr
=
[
NSMutableArray
arrayWithArray
:
self
.
listArr
];
[
tmpListArr
insertObject
:
dyModel
atIndex
:
0
];
self
.
listArr
=
tmpListArr
.
copy
;
}
+
(
void
)
updateLikeData
:
(
ComDynModel
*
)
comDynModel
{
if
(
comDynModel
.
isLike
)
{
comDynModel
.
likeCount
--
;
}
else
{
comDynModel
.
likeCount
++
;
}
comDynModel
.
isLike
=
!
comDynModel
.
isLike
;
}
+
(
NSURLSessionDataTask
*
)
userDynamicPraiseWithComDynModel
:
(
ComDynModel
*
)
comDynModel
completion
:
(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
{
ComListViewModel
*
requestModel
=
[[
ComListViewModel
alloc
]
init
];
ComListViewModel
*
requestModel
=
[[
ComListViewModel
alloc
]
init
];
NSString
*
api
=
@"user_dynamic_praise"
;
NSString
*
api
=
@"user_dynamic_praise"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(talk_id:%d)}"
,
api
,
talk
ID
];
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(talk_id:%d)}"
,
api
,
comDynModel
.
dynamic
ID
];
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
DSLog
(
@"用户动态点赞、取消点赞接口apiDic:%@"
,
apiDic
);
DSLog
(
@"用户动态点赞、取消点赞接口apiDic:%@"
,
apiDic
);
requestModel
.
resCode
=
DSResCodeSuccess
;
requestModel
.
resCode
=
DSResCodeSuccess
;
...
@@ -63,6 +101,15 @@
...
@@ -63,6 +101,15 @@
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
requestModel
.
resCode
=
[
failureInfo
[
@"errorCode"
]
integerValue
];
requestModel
.
resCode
=
[
failureInfo
[
@"errorCode"
]
integerValue
];
requestModel
.
errMessage
=
failureInfo
[
@"errMessage"
];
requestModel
.
errMessage
=
failureInfo
[
@"errMessage"
];
// 回滚数据model
if
(
comDynModel
.
isLike
)
{
comDynModel
.
likeCount
--
;
}
else
{
comDynModel
.
likeCount
++
;
}
comDynModel
.
isLike
=
!
comDynModel
.
isLike
;
completion
(
requestModel
);
completion
(
requestModel
);
}];
}];
}
}
...
...
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/DynamicViewModel.h
查看文件 @
b17d74f
...
@@ -38,9 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
...
@@ -38,9 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
/// @param completion 完成回调
/// @param completion 完成回调
-
(
NSURLSessionDataTask
*
)
publishDynamicWithCompletion
:(
void
(
^
)(
DynamicViewModel
*
viewModel
))
completion
;
-
(
NSURLSessionDataTask
*
)
publishDynamicWithCompletion
:(
void
(
^
)(
DynamicViewModel
*
viewModel
))
completion
;
/// 用户-删除动态,评论,回复接口
/// @param completion completion
-
(
NSURLSessionDataTask
*
)
communityDeleteOperationWithCompletion
:(
void
(
^
)(
DynamicViewModel
*
viewModel
))
completion
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/DynamicViewModel.m
查看文件 @
b17d74f
...
@@ -36,18 +36,4 @@
...
@@ -36,18 +36,4 @@
}];
}];
}
}
-
(
NSURLSessionDataTask
*
)
communityDeleteOperationWithCompletion
:
(
void
(
^
)(
DynamicViewModel
*
viewModel
))
completion
{
NSString
*
api
=
@"community_delete_operation"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(oper_type:%@,delete_id:%d)}"
,
api
,
self
.
oper_type
,
self
.
delete_id
];
return
[
DynamicViewModel
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
DSLog
(
@"用户删除动态、评论、回复接口apiDic:%@"
,
apiDic
);
self
.
resCode
=
DSResCodeSuccess
;
completion
(
self
);
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
self
.
resCode
=
[
failureInfo
[
@"errorCode"
]
integerValue
];
self
.
errMessage
=
failureInfo
[
@"errMessage"
];
completion
(
self
);
}];
}
@end
@end
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/PersonDynViewModel.h
0 → 100644
查看文件 @
b17d74f
//
// PersonDynViewModel.h
// DreamSleep
//
// Created by peter on 2022/10/12.
//
#import "DSNetworkTool.h"
NS_ASSUME_NONNULL_BEGIN
/// 个人中心动态相关viewModel
@interface
PersonDynViewModel
:
DSNetworkTool
/*
删除操作选项类别
dynamic:删除动态 comment:删除评论 reply:删除回复
*/
@property
(
nonatomic
,
copy
)
NSString
*
oper_type
;
/*
被删除对象id
动态Id 评论Id 回复Id
*/
@property
(
nonatomic
,
assign
)
int
delete_id
;
/// 用户-删除动态,评论,回复接口
/// @param completion completion
-
(
NSURLSessionDataTask
*
)
communityDeleteOperationWithCompletion
:(
void
(
^
)(
PersonDynViewModel
*
requestModel
))
completion
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/PersonDynViewModel.m
0 → 100644
查看文件 @
b17d74f
//
// PersonDynViewModel.m
// DreamSleep
//
// Created by peter on 2022/10/12.
//
#import "PersonDynViewModel.h"
@implementation
PersonDynViewModel
-
(
NSURLSessionDataTask
*
)
communityDeleteOperationWithCompletion
:(
void
(
^
)(
PersonDynViewModel
*
requestModel
))
completion
{
NSString
*
api
=
@"community_delete_operation"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(oper_type:
\"
%@
\"
,delete_id:%d)}"
,
api
,
self
.
oper_type
,
self
.
delete_id
];
return
[
PersonDynViewModel
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
DSLog
(
@"用户-删除动态,评论,回复接口apiDic:%@"
,
apiDic
);
self
.
resCode
=
DSResCodeSuccess
;
completion
(
self
);
}
failure
:^
(
id
_Nonnull
failureInfo
)
{
self
.
resCode
=
[
failureInfo
[
@"errorCode"
]
integerValue
];
self
.
errMessage
=
failureInfo
[
@"errMessage"
];
completion
(
self
);
}];
}
@end
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论