Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 6701105a
由
cgx
编写于
2022-10-15 11:13:15 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
用户点赞、发布评论接口添加user_id并且优化网络异常下点赞逻辑
1 个父辈
c54ebf24
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
22 行增加
和
18 行删除
DreamSleep/DreamSleep/Class/CommunityModule/Controller/DynamicDetailController.m
DreamSleep/DreamSleep/Class/CommunityModule/View/DynamicDetailView.h
DreamSleep/DreamSleep/Class/CommunityModule/View/DynamicDetailView.m
DreamSleep/DreamSleep/Class/CommunityModule/View/InteractView.h
DreamSleep/DreamSleep/Class/CommunityModule/View/InteractView.m
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComDetailViewModel.h
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComDetailViewModel.m
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComListViewModel.m
DreamSleep/DreamSleep/Class/CommunityModule/Controller/DynamicDetailController.m
查看文件 @
6701105
...
...
@@ -36,7 +36,7 @@
[
self
.
detailView
updateBottomView
:
self
.
comDynModel
];
[
self
.
detailView
updateDetailView
:
requestModel
.
groupDatas
];
}
else
{
[
DSProgressHUD
showToast
:
requestModel
.
errMessage
];
}
}];
}
...
...
@@ -45,7 +45,7 @@
-
(
void
)
fireCommentOrReply
:
(
NSInteger
)
tag
content
:
(
NSString
*
)
content
{
if
(
tag
==
1
)
{
// 发布评论
[
DSProgressHUD
showProgressHUDWithInfo
:
@""
];
[
self
.
comDetailViewModel
userCommentDynamicWith
TalkID
:
self
.
comDynModel
.
dynamicID
content
:
content
completion
:^
(
ComDetailViewModel
*
_Nonnull
requestModel
)
{
[
self
.
comDetailViewModel
userCommentDynamicWith
ComDynModel
:
self
.
comDynModel
content
:
content
completion
:^
(
ComDetailViewModel
*
_Nonnull
requestModel
)
{
[
DSProgressHUD
dissmissProgressHUD
];
if
(
requestModel
.
resCode
==
DSResCodeSuccess
)
{
// 更新评论数
...
...
@@ -57,7 +57,7 @@
[
self
.
detailView
updateCommentSection
:
requestModel
.
groupDatas
];
}
else
{
[
DSProgressHUD
showToast
:
requestModel
.
errMessage
];
}
}];
}
...
...
@@ -72,7 +72,7 @@
-
(
void
)
fireTapDetailLikeBtn
{
// 1、用户点赞或取消点赞直接响应UI变化
[
ComListViewModel
updateLikeData
:
self
.
comDynModel
];
[
self
.
detailView
updateLikeStateAndLikeCount
:
self
.
comDynModel
];
[
self
.
detailView
updateLikeStateAndLikeCount
:
self
.
comDynModel
animate
:
YES
];
// 2、更新点赞或取消点赞请求
if
(
self
.
likeDataTask
)
{
[
self
.
likeDataTask
cancel
];
}
...
...
@@ -85,7 +85,7 @@
}
else
{
// 4、如果请求失败,延迟执行回退
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
3
.
0
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
[
self
.
detailView
updateLikeStateAndLikeCount
:
self
.
comDynModel
];
[
self
.
detailView
updateLikeStateAndLikeCount
:
self
.
comDynModel
animate
:
NO
];
[
DSProgressHUD
showToast
:
requestModel
.
errMessage
];
});
}
...
...
DreamSleep/DreamSleep/Class/CommunityModule/View/DynamicDetailView.h
查看文件 @
6701105
...
...
@@ -35,7 +35,8 @@ NS_ASSUME_NONNULL_BEGIN
/// 更新点赞状态和点赞数
/// @param model model
-
(
void
)
updateLikeStateAndLikeCount
:(
ComDynModel
*
)
model
;
/// @param animate 是否执行动画
-
(
void
)
updateLikeStateAndLikeCount
:(
ComDynModel
*
)
model
animate
:(
BOOL
)
animate
;
/// 更新评论数
/// @param remarkCount remarkCount
...
...
DreamSleep/DreamSleep/Class/CommunityModule/View/DynamicDetailView.m
查看文件 @
6701105
...
...
@@ -49,8 +49,8 @@
[
self
.
interactView
updateLikeBtnState
:
model
.
isLike
likeCount
:
model
.
likeCount
remarkCount
:
model
.
remarkCount
];
}
-
(
void
)
updateLikeStateAndLikeCount
:(
ComDynModel
*
)
model
{
[
self
.
interactView
updateLikeBtnState
:
model
.
isLike
likeCount
:
model
.
likeCount
];
-
(
void
)
updateLikeStateAndLikeCount
:(
ComDynModel
*
)
model
animate
:(
BOOL
)
animate
{
[
self
.
interactView
updateLikeBtnState
:
model
.
isLike
likeCount
:
model
.
likeCount
animate
:
animate
];
}
-
(
void
)
updateRemarkCount
:(
int
)
remarkCount
{
...
...
@@ -102,7 +102,7 @@
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
if
(
indexPath
.
section
==
0
)
{
ComDynModel
*
model
=
self
.
detailListArr
[
0
];
return
[
model
cellHeight
:
DynModelTypeDetail
];
return
[
model
cellHeight
];
}
else
{
NSArray
*
comment_reply_arr
=
self
.
detailListArr
[
indexPath
.
section
];
ComReplyModel
*
comReplyModel
=
comment_reply_arr
[
indexPath
.
row
];
...
...
@@ -151,7 +151,8 @@
if
(
!
cell
)
{
cell
=
[[
ComDynamicCell
alloc
]
initWithCellType
:
DynModelTypeDetail
style
:
UITableViewCellStyleDefault
reuseIdentifier
:
NSStringFromClass
([
ComDynamicCell
class
])];
}
cell
.
model
=
self
.
detailListArr
[
indexPath
.
section
];
ComDynModel
*
model
=
self
.
detailListArr
[
indexPath
.
section
];
cell
.
model
=
model
;
return
cell
;
}
else
{
WS
(
weakSelf
);
...
...
DreamSleep/DreamSleep/Class/CommunityModule/View/InteractView.h
查看文件 @
6701105
...
...
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
weak
)
id
<
InteractViewDelegate
>
delegate
;
-
(
void
)
updateLikeBtnState
:(
BOOL
)
isLike
likeCount
:(
int
)
likeCount
remarkCount
:(
int
)
remarkCount
;
-
(
void
)
updateLikeBtnState
:(
BOOL
)
isLike
likeCount
:(
int
)
likeCount
;
-
(
void
)
updateLikeBtnState
:(
BOOL
)
isLike
likeCount
:(
int
)
likeCount
animate
:(
BOOL
)
animate
;
-
(
void
)
updateRemarkCount
:(
int
)
remarkCount
;
/// 弹出回复输入框(第一版暂不考虑)
...
...
DreamSleep/DreamSleep/Class/CommunityModule/View/InteractView.m
查看文件 @
6701105
...
...
@@ -63,8 +63,8 @@
[
self
.
remarkCountBtn
setTitle
:[
NSString
stringWithFormat
:
@"%d"
,
remarkCount
]
forState
:
UIControlStateNormal
];
}
-
(
void
)
updateLikeBtnState
:
(
BOOL
)
isLike
likeCount
:
(
int
)
likeCount
{
[
self
.
likeBtn
executeAnimation
];
-
(
void
)
updateLikeBtnState
:
(
BOOL
)
isLike
likeCount
:
(
int
)
likeCount
animate
:
(
BOOL
)
animate
{
if
(
animate
)
{
[
self
.
likeBtn
executeAnimation
];
}
[
self
.
likeBtn
updateLikeBtnState
:
isLike
likeCount
:
likeCount
];
}
...
...
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComDetailViewModel.h
查看文件 @
6701105
...
...
@@ -6,6 +6,7 @@
//
#import "DSNetworkTool.h"
@class
ComDynModel
;
NS_ASSUME_NONNULL_BEGIN
...
...
@@ -24,10 +25,10 @@ NS_ASSUME_NONNULL_BEGIN
-
(
NSURLSessionDataTask
*
)
queryDynamicCommentListWithTalkID
:(
int
)
talkID
completion
:(
void
(
^
)(
ComDetailViewModel
*
requestModel
))
completion
;
/// 用户-发布评论接口
/// @param
talkID 动态id
/// @param
model model
/// @param content 评论内容
/// @param completion completion
-
(
NSURLSessionDataTask
*
)
userCommentDynamicWith
TalkID
:(
int
)
talkID
content
:(
NSString
*
)
content
completion
:(
void
(
^
)(
ComDetailViewModel
*
requestModel
))
completion
;
-
(
NSURLSessionDataTask
*
)
userCommentDynamicWith
ComDynModel
:(
ComDynModel
*
)
model
content
:(
NSString
*
)
content
completion
:(
void
(
^
)(
ComDetailViewModel
*
requestModel
))
completion
;
/// 查询评论回复列表
/// @param commentID 动态评论id
...
...
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComDetailViewModel.m
查看文件 @
6701105
...
...
@@ -28,6 +28,7 @@
self
.
resCode
=
DSResCodeSuccess
;
NSDictionary
*
resultDic
=
apiDic
[
@"result"
];
ComDynModel
*
talkModel
=
[
ComDynModel
yy_modelWithDictionary
:
resultDic
[
@"talk"
]];
talkModel
.
modelType
=
DynModelTypeDetail
;
NSArray
*
comment_list
=
resultDic
[
@"comment_list"
];
NSMutableArray
*
tmpArr
=
[
NSMutableArray
array
];
for
(
int
i
=
0
;
i
<
comment_list
.
count
;
i
++
)
{
...
...
@@ -44,9 +45,9 @@
}];
}
-
(
NSURLSessionDataTask
*
)
userCommentDynamicWith
TalkID
:
(
int
)
talkID
content
:
(
NSString
*
)
content
completion
:
(
void
(
^
)(
ComDetailViewModel
*
requestModel
))
completion
{
-
(
NSURLSessionDataTask
*
)
userCommentDynamicWith
ComDynModel
:
(
ComDynModel
*
)
model
content
:
(
NSString
*
)
content
completion
:
(
void
(
^
)(
ComDetailViewModel
*
requestModel
))
completion
{
NSString
*
api
=
@"user_comment_dynamic"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(talk_id:%d,
content:
\"
%@
\"
)}"
,
api
,
talk
ID
,
content
];
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(talk_id:%d,
user_id:%d,content:
\"
%@
\"
)}"
,
api
,
model
.
dynamicID
,
model
.
user
ID
,
content
];
return
[
ComDetailViewModel
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
DSLog
(
@"用户-发布评论接口apiDic:%@"
,
apiDic
);
self
.
resCode
=
DSResCodeSuccess
;
...
...
DreamSleep/DreamSleep/Class/CommunityModule/ViewModel/ComListViewModel.m
查看文件 @
6701105
...
...
@@ -107,7 +107,7 @@
+
(
NSURLSessionDataTask
*
)
userDynamicPraiseWithComDynModel
:
(
ComDynModel
*
)
comDynModel
completion
:
(
void
(
^
)(
ComListViewModel
*
requestModel
))
completion
{
ComListViewModel
*
requestModel
=
[[
ComListViewModel
alloc
]
init
];
NSString
*
api
=
@"user_dynamic_praise"
;
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(talk_id:%d
)}"
,
api
,
comDynModel
.
dynamic
ID
];
NSString
*
argStr
=
[
NSString
stringWithFormat
:
@"mutation{%@(talk_id:%d
,user_id:%d)}"
,
api
,
comDynModel
.
dynamicID
,
comDynModel
.
user
ID
];
return
[
self
httpPostBodyRequestWithAPI
:
api
params
:@{
@"query"
:
argStr
}
view
:
nil
hasNetActivity
:
YES
loadingInfo
:
nil
hasFailInfo
:
NO
success
:^
(
NSDictionary
*
_Nonnull
apiDic
)
{
DSLog
(
@"用户动态点赞、取消点赞接口apiDic:%@"
,
apiDic
);
requestModel
.
resCode
=
DSResCodeSuccess
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论