Commit dfcd45e0ae9edd6094d039592187e40d01f6951e
1 parent
ee7e9e82
修复评论长按识别是否是本人错误的问题
Showing
1 changed file
with
37 additions
and
4 deletions
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoCommentListView.swift
| @@ -117,6 +117,8 @@ class CNLiveShortVideoCommentListView: UIView, UITableViewDelegate, UITableViewD | @@ -117,6 +117,8 @@ class CNLiveShortVideoCommentListView: UIView, UITableViewDelegate, UITableViewD | ||
| 117 | var resultBlock: CloseCommentListResultBlock! | 117 | var resultBlock: CloseCommentListResultBlock! |
| 118 | var closeBlock: CloseCommentListCloseBlock! | 118 | var closeBlock: CloseCommentListCloseBlock! |
| 119 | 119 | ||
| 120 | +// var currentCommentSeleIndex = 0 | ||
| 121 | + | ||
| 120 | func requestDataSource() { | 122 | func requestDataSource() { |
| 121 | CNLiveShortVideoViewModel.requestCommentList(pid: self.videoId, page: self.pageNum) {[weak self] result, respStatue in | 123 | CNLiveShortVideoViewModel.requestCommentList(pid: self.videoId, page: self.pageNum) {[weak self] result, respStatue in |
| 122 | guard let self = self else { return } | 124 | guard let self = self else { return } |
| @@ -302,6 +304,9 @@ extension CNLiveShortVideoCommentListView { | @@ -302,6 +304,9 @@ extension CNLiveShortVideoCommentListView { | ||
| 302 | return CNLiveShortVideoCommentListTableViewCell() | 304 | return CNLiveShortVideoCommentListTableViewCell() |
| 303 | } | 305 | } |
| 304 | cell.setupWithDataSource(commentData: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).comment, replyData: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).replyData, tableView_h: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).tableView_h, tableView_top: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).tableView_top, indexPath: indexPath, isReset: isReset) | 306 | cell.setupWithDataSource(commentData: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).comment, replyData: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).replyData, tableView_h: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).tableView_h, tableView_top: (dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).tableView_top, indexPath: indexPath, isReset: isReset) |
| 307 | + cell.currentIsComment = true | ||
| 308 | + cell.currentCommentSeleIndex = indexPath.row | ||
| 309 | + | ||
| 305 | cell.reloadRowBlock = {[weak self] viewCell, cell_h in | 310 | cell.reloadRowBlock = {[weak self] viewCell, cell_h in |
| 306 | guard let self = self else { return } | 311 | guard let self = self else { return } |
| 307 | let commentModel_temp = self.dataArray[viewCell.indexPath_current.row] as! ShortVideoHomeCommentListModel | 312 | let commentModel_temp = self.dataArray[viewCell.indexPath_current.row] as! ShortVideoHomeCommentListModel |
| @@ -515,6 +520,11 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | @@ -515,6 +520,11 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | ||
| 515 | var reloadItemBlock: ReloadItemCommentListResultBlock! | 520 | var reloadItemBlock: ReloadItemCommentListResultBlock! |
| 516 | var replyItemModel: ShortVideoHomeCommentRListItemModel! | 521 | var replyItemModel: ShortVideoHomeCommentRListItemModel! |
| 517 | 522 | ||
| 523 | + var currentIsComment = false//默认是2级评论 | ||
| 524 | + var currentReplySeleIndex = 0//默认0 | ||
| 525 | + var currentCommentSeleIndex = 0//默认0 | ||
| 526 | + | ||
| 527 | + | ||
| 518 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | 528 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
| 519 | super.init(style: style, reuseIdentifier: reuseIdentifier) | 529 | super.init(style: style, reuseIdentifier: reuseIdentifier) |
| 520 | contentView.backgroundColor = HexColor("#FEFFFF") | 530 | contentView.backgroundColor = HexColor("#FEFFFF") |
| @@ -583,6 +593,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | @@ -583,6 +593,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | ||
| 583 | } | 593 | } |
| 584 | 594 | ||
| 585 | func setupWithDataSource(commentData: ShortVideoHomeCommentFListModel, replyData: ShortVideoHomeCommentRListModel, tableView_h: CGFloat, tableView_top: CGFloat, indexPath: IndexPath, isReset: Bool) { | 595 | func setupWithDataSource(commentData: ShortVideoHomeCommentFListModel, replyData: ShortVideoHomeCommentRListModel, tableView_h: CGFloat, tableView_top: CGFloat, indexPath: IndexPath, isReset: Bool) { |
| 596 | + | ||
| 586 | dataSource.removeAllObjects() | 597 | dataSource.removeAllObjects() |
| 587 | dataSource.addObjects(from: replyData.replys) | 598 | dataSource.addObjects(from: replyData.replys) |
| 588 | tableView_height = tableView_h | 599 | tableView_height = tableView_h |
| @@ -638,6 +649,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | @@ -638,6 +649,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | ||
| 638 | } | 649 | } |
| 639 | 650 | ||
| 640 | func setupWithReplyModel(commentData: ShortVideoHomeCommentFListModel,replyModel: ShortVideoHomeCommentRListItemModel) { | 651 | func setupWithReplyModel(commentData: ShortVideoHomeCommentFListModel,replyModel: ShortVideoHomeCommentRListItemModel) { |
| 652 | + | ||
| 641 | replyItemModel = replyModel | 653 | replyItemModel = replyModel |
| 642 | commentModel = commentData | 654 | commentModel = commentData |
| 643 | iconView.kf.indicatorType = .activity | 655 | iconView.kf.indicatorType = .activity |
| @@ -646,6 +658,9 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | @@ -646,6 +658,9 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | ||
| 646 | likeButton.isSelected = replyModel.isPraised! | 658 | likeButton.isSelected = replyModel.isPraised! |
| 647 | likeButton.setTitle("\(replyModel.praiseCount ?? 0)", for: .normal) | 659 | likeButton.setTitle("\(replyModel.praiseCount ?? 0)", for: .normal) |
| 648 | timeLabel.text = replyModel.created_at | 660 | timeLabel.text = replyModel.created_at |
| 661 | + let contentSidStr = contentSid | ||
| 662 | + let uidStr = UserInfoManager.shared.userInfo.uid | ||
| 663 | + let replyFromSidStr = replyItemModel.fromSid | ||
| 649 | if ((contentSid == UserInfoManager.shared.userInfo.uid) || (replyItemModel.fromSid == UserInfoManager.shared.userInfo.uid)) { | 664 | if ((contentSid == UserInfoManager.shared.userInfo.uid) || (replyItemModel.fromSid == UserInfoManager.shared.userInfo.uid)) { |
| 650 | replyButton.setTitle("删除", for: .normal) | 665 | replyButton.setTitle("删除", for: .normal) |
| 651 | } else { | 666 | } else { |
| @@ -716,11 +731,16 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | @@ -716,11 +731,16 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel | ||
| 716 | 731 | ||
| 717 | @objc func longPressGestureRecognizerAction(gestureRecognizer: UIGestureRecognizer) { | 732 | @objc func longPressGestureRecognizerAction(gestureRecognizer: UIGestureRecognizer) { |
| 718 | if gestureRecognizer.state == .began { | 733 | if gestureRecognizer.state == .began { |
| 719 | - let commentModelUid = commentModel.uid | 734 | +// let commentModelUid = commentModel.uid |
| 720 | let uid = UserInfoManager.shared.userInfo.uid | 735 | let uid = UserInfoManager.shared.userInfo.uid |
| 721 | - let contentsid = contentSid | ||
| 722 | - print("\(commentModelUid),\(uid),\(contentsid)") | ||
| 723 | - if commentModel.uid == UserInfoManager.shared.userInfo.uid || contentSid == UserInfoManager.shared.userInfo.uid { | 736 | +// let contentsid = contentSid |
| 737 | + var currFromSid:String? | ||
| 738 | + if self.currentIsComment{ | ||
| 739 | + currFromSid = commentModel.uid | ||
| 740 | + }else{ | ||
| 741 | + currFromSid = replyItemModel.fromSid | ||
| 742 | + } | ||
| 743 | + if currFromSid == uid{// || contentSid == UserInfoManager.shared.userInfo.uid { | ||
| 724 | AlertTool.systemActionSheet(title: "请选择", message: "", actionTitles: ["删除该条评论","举报"], cancelTitle: "取消") {[weak self] index in | 744 | AlertTool.systemActionSheet(title: "请选择", message: "", actionTitles: ["删除该条评论","举报"], cancelTitle: "取消") {[weak self] index in |
| 725 | guard let self = self else { return } | 745 | guard let self = self else { return } |
| 726 | if index == 1 { | 746 | if index == 1 { |
| @@ -831,7 +851,20 @@ extension CNLiveShortVideoCommentListTableViewCell { | @@ -831,7 +851,20 @@ extension CNLiveShortVideoCommentListTableViewCell { | ||
| 831 | guard let cell = tableView.dequeueReusableCell(withIdentifier: kShortVideoReplyListTableViewCellIdentifier) as? CNLiveShortVideoCommentListTableViewCell else { | 851 | guard let cell = tableView.dequeueReusableCell(withIdentifier: kShortVideoReplyListTableViewCellIdentifier) as? CNLiveShortVideoCommentListTableViewCell else { |
| 832 | return CNLiveShortVideoCommentListTableViewCell() | 852 | return CNLiveShortVideoCommentListTableViewCell() |
| 833 | } | 853 | } |
| 854 | + | ||
| 834 | cell.setupWithReplyModel(commentData: commentModel,replyModel: dataSource[indexPath.row] as! ShortVideoHomeCommentRListItemModel) | 855 | cell.setupWithReplyModel(commentData: commentModel,replyModel: dataSource[indexPath.row] as! ShortVideoHomeCommentRListItemModel) |
| 856 | + | ||
| 857 | + cell.currentIsComment = false | ||
| 858 | + cell.currentReplySeleIndex = indexPath.row | ||
| 859 | + | ||
| 860 | +// print("11111111:currentReplySeleIndex\(currentReplySeleIndex) ,currentIsComment:\(currentIsComment),indexPath.row:\(indexPath.row),commentModeluid:\(commentModel.uid)") | ||
| 861 | +// if currentIsComment{ | ||
| 862 | +// print("11111111\(currentReplySeleIndex)") | ||
| 863 | +// }else{ | ||
| 864 | +// currentReplySeleIndex = indexPath.row | ||
| 865 | +// } | ||
| 866 | +// currentReplySeleIndex = indexPath.row | ||
| 867 | + | ||
| 835 | cell.reloadItemBlock = {[weak self] commentModel in | 868 | cell.reloadItemBlock = {[weak self] commentModel in |
| 836 | guard let self = self else { return } | 869 | guard let self = self else { return } |
| 837 | self.reloadBlcok(commentModel) | 870 | self.reloadBlcok(commentModel) |