|
@@ -11,6 +11,9 @@ import RxSwift
|
|
|
|
|
|
class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
let disposeBag = DisposeBag()
|
|
|
|
|
|
typealias LikeSelectBlock = (_ isLiked: Int) -> Void
|
|
@@ -144,14 +147,14 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
return nameButton
|
|
|
}()
|
|
|
|
|
|
- private lazy var likeBtn: UIButton = {
|
|
|
+ lazy var likeBtn: UIButton = {
|
|
|
let likeBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
likeBtn.setTitleColor(k999999Color, for: UIControl.State.normal)
|
|
|
likeBtn.setImage(kImage(name: "btn_praise"), for: UIControl.State.normal)
|
|
|
likeBtn.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
|
|
|
likeBtn.titleLabel?.font = kRegularFont12
|
|
|
likeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
- self?.virueRecordAddApi(communityPostDataModel: (self?.communityPostDataModel!)!)
|
|
|
+ VirusViewModel.shared.virueRecordAddApi(communityPostDataModel: (self?.communityPostDataModel!)!, cell: self!)
|
|
|
}).disposed(by: disposeBag)
|
|
|
return likeBtn
|
|
|
}()
|
|
@@ -198,44 +201,3 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-extension SearchContentListCollectionCell {
|
|
|
- func virueRecordAddApi(communityPostDataModel:CommunityPostDataModel) {
|
|
|
- let virueRecordAddParameterModel = VirueRecordAddParameterModel()
|
|
|
- virueRecordAddParameterModel.behaviorId = (ConfigModel.shared.object()?.virus?.like ?? "")
|
|
|
- virueRecordAddParameterModel.behaviorFlag = BehaviorFlagType.like.rawValue
|
|
|
- if communityPostDataModel.isLike == 0 {
|
|
|
- virueRecordAddParameterModel.behaviorValue = 1
|
|
|
- }else {
|
|
|
- virueRecordAddParameterModel.behaviorValue = 0
|
|
|
- }
|
|
|
- virueRecordAddParameterModel.postId = communityPostDataModel.id
|
|
|
- virueRecordAddParameterModel.postAuthorUid = "\(communityPostDataModel.uid!)"
|
|
|
- virueRecordAddParameterModel.postDesc = communityPostDataModel.title
|
|
|
- virueRecordAddParameterModel.postCover = communityPostDataModel.img
|
|
|
- virueRecordAddParameterModel.actionId = "\(communityPostDataModel.id!)"
|
|
|
- virueRecordAddParameterModel.targetId = "\((UserModel.shared().getModel()?.uid)!)"
|
|
|
- virueRecordAddParameterModel.postType = communityPostDataModel.type
|
|
|
-
|
|
|
- SwiftMoyaNetWorkServiceVirus.shared().virueRecordAddApi(virueRecordAddParameterModel: virueRecordAddParameterModel, completion: {
|
|
|
- [weak self] (data) -> (Void) in
|
|
|
- if communityPostDataModel.isLike == 0 {
|
|
|
- self?.communityPostDataModel?.isLike = 1
|
|
|
- self?.likeBtn.isSelected = true
|
|
|
- let praiseCount = (communityPostDataModel.praiseCount ?? 0) + 1
|
|
|
- self?.likeBtn.setTitle("\(praiseCount)", for: UIControl.State.normal)
|
|
|
- self?.communityPostDataModel?.praiseCount = praiseCount
|
|
|
-
|
|
|
- }else {
|
|
|
- self?.communityPostDataModel?.isLike = 0
|
|
|
- self?.likeBtn.isSelected = false
|
|
|
- let praiseCount = (communityPostDataModel.praiseCount ?? 0) - 1
|
|
|
-
|
|
|
- self?.likeBtn.setTitle("\(praiseCount)", for: UIControl.State.normal)
|
|
|
- self?.communityPostDataModel?.praiseCount = praiseCount
|
|
|
-
|
|
|
- }
|
|
|
- self?.likeBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
-}
|