|
@@ -7,6 +7,7 @@
|
|
//
|
|
//
|
|
|
|
|
|
import UIKit
|
|
import UIKit
|
|
|
|
+import Kingfisher
|
|
|
|
|
|
class CommunityRecommendController: BaseViewController {
|
|
class CommunityRecommendController: BaseViewController {
|
|
|
|
|
|
@@ -16,6 +17,8 @@ class CommunityRecommendController: BaseViewController {
|
|
if observe != nil {
|
|
if observe != nil {
|
|
NotificationCenter.default.removeObserver(observe!)
|
|
NotificationCenter.default.removeObserver(observe!)
|
|
}
|
|
}
|
|
|
|
+ KingfisherManager.shared.cache.clearDiskCache()
|
|
|
|
+ KingfisherManager.shared.cache.clearMemoryCache()
|
|
}
|
|
}
|
|
weak var observe : NSObjectProtocol?
|
|
weak var observe : NSObjectProtocol?
|
|
|
|
|
|
@@ -170,7 +173,7 @@ class CommunityRecommendController: BaseViewController {
|
|
}).disposed(by: disposeBag)
|
|
}).disposed(by: disposeBag)
|
|
//用户昵称
|
|
//用户昵称
|
|
nameButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
nameButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
-
|
|
|
|
|
|
+
|
|
if UserModel.isTokenNil() {
|
|
if UserModel.isTokenNil() {
|
|
kAppDelegate.setLogin()
|
|
kAppDelegate.setLogin()
|
|
}else {
|
|
}else {
|
|
@@ -206,7 +209,7 @@ class CommunityRecommendController: BaseViewController {
|
|
kAppDelegate.setLogin()
|
|
kAppDelegate.setLogin()
|
|
}else {
|
|
}else {
|
|
self?.share()
|
|
self?.share()
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}).disposed(by: disposeBag)
|
|
}).disposed(by: disposeBag)
|
|
tableView.addHeader(withBeginRefresh: true, animation: true) {
|
|
tableView.addHeader(withBeginRefresh: true, animation: true) {
|
|
@@ -225,15 +228,15 @@ class CommunityRecommendController: BaseViewController {
|
|
case BottomClickType.typeComment:
|
|
case BottomClickType.typeComment:
|
|
self?.showKeyBoardCommentView(placeholder: "添加评论...")
|
|
self?.showKeyBoardCommentView(placeholder: "添加评论...")
|
|
case BottomClickType.typeLike:
|
|
case BottomClickType.typeLike:
|
|
- VirusViewModel.shared.virueRecordAddApiPraise(communityPostDetailModel: self?.communityPostDetailModel,commentView: (self?.commentView)!)
|
|
|
|
|
|
+ VirusViewModel.shared.virueRecordAddApiPraise(communityPostDetailModel: self?.communityPostDetailModel,commentView: self?.commentView)
|
|
case BottomClickType.typeCollect:
|
|
case BottomClickType.typeCollect:
|
|
- VirusViewModel.shared.virueRecordAddApiCollection(communityPostDetailModel: self?.communityPostDetailModel,commentView: (self?.commentView)!)
|
|
|
|
|
|
+ VirusViewModel.shared.virueRecordAddApiCollection(communityPostDetailModel: self?.communityPostDetailModel,commentView: self?.commentView)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("followApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("followApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
let followStatusModel = notification.object as? FollowStatusModel
|
|
let followStatusModel = notification.object as? FollowStatusModel
|
|
-
|
|
|
|
|
|
+
|
|
if self?.communityPostDetailModel?.uid == followStatusModel?.uid {
|
|
if self?.communityPostDetailModel?.uid == followStatusModel?.uid {
|
|
self?.communityPostDetailModel?.isFollow = followStatusModel?.isFollowStatus
|
|
self?.communityPostDetailModel?.isFollow = followStatusModel?.isFollowStatus
|
|
self?.communityPostDetailTableViewHeaderView.communityPostDetailModel = self?.communityPostDetailModel
|
|
self?.communityPostDetailTableViewHeaderView.communityPostDetailModel = self?.communityPostDetailModel
|
|
@@ -249,14 +252,14 @@ class CommunityRecommendController: BaseViewController {
|
|
self?.tableView.reloadData()
|
|
self?.tableView.reloadData()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("islikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("islikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
let followStatusModel = notification.object as? FollowStatusModel
|
|
let followStatusModel = notification.object as? FollowStatusModel
|
|
if self?.communityPostDetailModel?.id == followStatusModel?.postId {
|
|
if self?.communityPostDetailModel?.id == followStatusModel?.postId {
|
|
self?.communityPostDetailModel?.isDislike = followStatusModel?.isFollowStatus
|
|
self?.communityPostDetailModel?.isDislike = followStatusModel?.isFollowStatus
|
|
self?.commentView.communityPostDetailModel = self?.communityPostDetailModel
|
|
self?.commentView.communityPostDetailModel = self?.communityPostDetailModel
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if !(self?.communityPostCommentModels.isEmpty ?? true) {
|
|
if !(self?.communityPostCommentModels.isEmpty ?? true) {
|
|
for communityPostDataModel in (self?.communityPostDataModels)! {
|
|
for communityPostDataModel in (self?.communityPostDataModels)! {
|
|
if communityPostDataModel.uid == followStatusModel?.uid {
|
|
if communityPostDataModel.uid == followStatusModel?.uid {
|
|
@@ -266,7 +269,7 @@ class CommunityRecommendController: BaseViewController {
|
|
}
|
|
}
|
|
self?.tableView.reloadData()
|
|
self?.tableView.reloadData()
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCollectApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCollectApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
let followStatusModel = notification.object as? FollowStatusModel
|
|
let followStatusModel = notification.object as? FollowStatusModel
|
|
if self?.communityPostDetailModel?.id == followStatusModel?.postId {
|
|
if self?.communityPostDetailModel?.id == followStatusModel?.postId {
|
|
@@ -307,7 +310,8 @@ class CommunityRecommendController: BaseViewController {
|
|
sharedDetailTitle: kCommunityPostShareDetailTitle,
|
|
sharedDetailTitle: kCommunityPostShareDetailTitle,
|
|
shareCommunityViewType: ShareCommunityViewType.postDetail,
|
|
shareCommunityViewType: ShareCommunityViewType.postDetail,
|
|
completion: {
|
|
completion: {
|
|
- VirusViewModel.shared.forwarVirueRecordAddApi(postId: self.communityPostDetailModel?.id, postAuthorUid: "\(self.communityPostDetailModel?.uid ?? 0)", title: self.communityPostDetailModel?.title, content: self.communityPostDetailModel?.content, postType: self.communityPostDetailModel?.type, postCover: self.communityPostDetailModel?.img)
|
|
|
|
|
|
+ [weak self] in
|
|
|
|
+ VirusViewModel.shared.forwarVirueRecordAddApi(postId: self?.communityPostDetailModel?.id, postAuthorUid: "\(self?.communityPostDetailModel?.uid ?? 0)", title: self?.communityPostDetailModel?.title, content: self?.communityPostDetailModel?.content, postType: self?.communityPostDetailModel?.type, postCover: self?.communityPostDetailModel?.img)
|
|
})
|
|
})
|
|
shareCommunityView.saveCompletion = {
|
|
shareCommunityView.saveCompletion = {
|
|
[weak self] in
|
|
[weak self] in
|
|
@@ -345,15 +349,17 @@ extension CommunityRecommendController {
|
|
|
|
|
|
/// 帖子内容
|
|
/// 帖子内容
|
|
func communityPostDetailApi() {
|
|
func communityPostDetailApi() {
|
|
- SwiftMoyaNetWorkServiceCommunity.shared().communityPostDetailApi(id: id, completion: { [weak self] (communityPostDetailModel) -> (Void) in
|
|
|
|
|
|
+ SwiftMoyaNetWorkServiceCommunity.shared().communityPostDetailApi(id: id, completion: {
|
|
|
|
+ [weak self] (communityPostDetailModel) -> (Void) in
|
|
|
|
|
|
- self?.tableView.snp.remakeConstraints { (make) in
|
|
|
|
|
|
+ self?.tableView.snp.remakeConstraints {[weak self] (make) in
|
|
make.top.equalToSuperview().offset(kNavBarTotalHeight)
|
|
make.top.equalToSuperview().offset(kNavBarTotalHeight)
|
|
make.left.right.equalToSuperview()
|
|
make.left.right.equalToSuperview()
|
|
make.bottom.equalTo((self?.commentView.snp_top)!).offset(0)
|
|
make.bottom.equalTo((self?.commentView.snp_top)!).offset(0)
|
|
}
|
|
}
|
|
|
|
|
|
DIYEmptyView.emptyNoDataActionTableView(tableView: self?.tableView, imageStr: .three, detailStr: .three, btnTitleStr: .two, btnClickBlock: {
|
|
DIYEmptyView.emptyNoDataActionTableView(tableView: self?.tableView, imageStr: .three, detailStr: .three, btnTitleStr: .two, btnClickBlock: {
|
|
|
|
+ [weak self] in
|
|
self?.tabBarController?.selectedIndex = 0
|
|
self?.tabBarController?.selectedIndex = 0
|
|
self?.navigationController?.popToRootViewController(animated: true)
|
|
self?.navigationController?.popToRootViewController(animated: true)
|
|
})
|
|
})
|
|
@@ -366,7 +372,7 @@ extension CommunityRecommendController {
|
|
}else {
|
|
}else {
|
|
self?.followButton.isHidden = false
|
|
self?.followButton.isHidden = false
|
|
}
|
|
}
|
|
- CommunityFollowUserViewModel.setFollowType(followButton: (self?.followButton)!, followType: FollowType(rawValue: self?.communityPostDetailModel?.isFollow ?? 0) ?? .futureFollow)
|
|
|
|
|
|
+ CommunityFollowUserViewModel.setFollowType(followButton: self?.followButton, followType: FollowType(rawValue: self?.communityPostDetailModel?.isFollow ?? 0) ?? .futureFollow)
|
|
self?.commentView.communityPostDetailModel = self?.communityPostDetailModel
|
|
self?.commentView.communityPostDetailModel = self?.communityPostDetailModel
|
|
self?.count = self?.communityPostDetailModel?.commentCount ?? 0
|
|
self?.count = self?.communityPostDetailModel?.commentCount ?? 0
|
|
|
|
|
|
@@ -380,29 +386,18 @@ extension CommunityRecommendController {
|
|
}else {
|
|
}else {
|
|
self?.followButton.isHidden = true
|
|
self?.followButton.isHidden = true
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth)
|
|
|
|
+
|
|
if !(self?.communityPostDetailModel?.imgs?.isEmpty ?? true) {
|
|
if !(self?.communityPostDetailModel?.imgs?.isEmpty ?? true) {
|
|
- let height = getImageHeight(imgStr: (self?.communityPostDetailModel?.imgs?[0])!)
|
|
|
|
- let width = getImageWidth(imgStr: (self?.communityPostDetailModel?.imgs?[0])!)
|
|
|
|
- let scaleHeight = kScreenWidth*height/width
|
|
|
|
- if scaleHeight >= (500 * kScaleWidth) {
|
|
|
|
- self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: 500 * kScaleWidth)
|
|
|
|
- }else {
|
|
|
|
- self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth*height/width)
|
|
|
|
- }
|
|
|
|
- self?.communityPostDetailTableViewHeaderView.tableView = self?.tableView
|
|
|
|
self?.tableView.tableHeaderView = self?.communityPostDetailTableViewHeaderView
|
|
self?.tableView.tableHeaderView = self?.communityPostDetailTableViewHeaderView
|
|
-
|
|
|
|
}else {
|
|
}else {
|
|
if self?.communityPostDetailModel?.img != nil || self?.communityPostDetailModel?.img != "" {
|
|
if self?.communityPostDetailModel?.img != nil || self?.communityPostDetailModel?.img != "" {
|
|
- let height = getImageHeight(imgStr: (self?.communityPostDetailModel?.img)!)
|
|
|
|
- let width = getImageWidth(imgStr: (self?.communityPostDetailModel?.img)!)
|
|
|
|
- self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth*height/width)
|
|
|
|
- self?.communityPostDetailTableViewHeaderView.tableView = self?.tableView
|
|
|
|
self?.tableView.tableHeaderView = self?.communityPostDetailTableViewHeaderView
|
|
self?.tableView.tableHeaderView = self?.communityPostDetailTableViewHeaderView
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- self?.communityPostDetailTableViewHeaderView.communityPostDetailModel = self?.communityPostDetailModel
|
|
|
|
|
|
|
|
|
|
+ self?.communityPostDetailTableViewHeaderView.communityPostDetailModel = self?.communityPostDetailModel
|
|
}
|
|
}
|
|
self?.setupLayouts()
|
|
self?.setupLayouts()
|
|
self?.tableView.reloadData()
|
|
self?.tableView.reloadData()
|
|
@@ -665,12 +660,7 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
switch indexPath.section {
|
|
switch indexPath.section {
|
|
case 0:
|
|
case 0:
|
|
-
|
|
|
|
- if PostType(rawValue: communityPostDetailModel?.type ?? "html") == .html {
|
|
|
|
-
|
|
|
|
- }else {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ break
|
|
case 1:
|
|
case 1:
|
|
if communityPostCommentModels.isEmpty {
|
|
if communityPostCommentModels.isEmpty {
|
|
break
|
|
break
|