feat: 添加点赞功能支持及 Swift API Helper 集成
主要变更: 1. 在 EPMomentAPISwiftHelper 中新增点赞/取消点赞功能,支持动态 ID 和用户 UID。 2. 更新 EPMomentCell 以使用新的 Swift API Helper 进行点赞操作,简化点赞逻辑。 3. 优化点赞状态和数量的更新逻辑,确保用户界面及时反映点赞结果。 此更新旨在提升用户互动体验,简化点赞操作流程。
This commit is contained in:
@@ -74,5 +74,38 @@ import Foundation
|
||||
}
|
||||
}, uid: uid, type: type, worldId: "", content: content, resList: resList)
|
||||
}
|
||||
|
||||
/// 点赞/取消点赞动态
|
||||
/// - Parameters:
|
||||
/// - dynamicId: 动态 ID
|
||||
/// - isLike: true=点赞,false=取消点赞
|
||||
/// - likedUid: 动态发布者 UID
|
||||
/// - worldId: 话题 ID
|
||||
/// - completion: 成功回调
|
||||
/// - failure: 失败回调 (错误码, 错误信息)
|
||||
@objc func likeMoment(
|
||||
dynamicId: String,
|
||||
isLike: Bool,
|
||||
likedUid: String,
|
||||
worldId: Int,
|
||||
completion: @escaping () -> Void,
|
||||
failure: @escaping (Int, String) -> Void
|
||||
) {
|
||||
guard let uid = AccountInfoStorage.instance().getUid() else {
|
||||
failure(-1, "用户未登录")
|
||||
return
|
||||
}
|
||||
|
||||
let status = isLike ? "1" : "0"
|
||||
let worldIdStr = String(format: "%ld", worldId)
|
||||
|
||||
Api.momentsLike({ (data, code, msg) in
|
||||
if code == 200 {
|
||||
completion()
|
||||
} else {
|
||||
failure(Int(code), msg ?? "点赞操作失败")
|
||||
}
|
||||
}, dynamicId: dynamicId, uid: uid, status: status, likedUid: likedUid, worldId: worldIdStr)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user