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 | 117 | var resultBlock: CloseCommentListResultBlock! |
| 118 | 118 | var closeBlock: CloseCommentListCloseBlock! |
| 119 | 119 | |
| 120 | +// var currentCommentSeleIndex = 0 | |
| 121 | + | |
| 120 | 122 | func requestDataSource() { |
| 121 | 123 | CNLiveShortVideoViewModel.requestCommentList(pid: self.videoId, page: self.pageNum) {[weak self] result, respStatue in |
| 122 | 124 | guard let self = self else { return } |
| ... | ... | @@ -302,6 +304,9 @@ extension CNLiveShortVideoCommentListView { |
| 302 | 304 | return CNLiveShortVideoCommentListTableViewCell() |
| 303 | 305 | } |
| 304 | 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 | 310 | cell.reloadRowBlock = {[weak self] viewCell, cell_h in |
| 306 | 311 | guard let self = self else { return } |
| 307 | 312 | let commentModel_temp = self.dataArray[viewCell.indexPath_current.row] as! ShortVideoHomeCommentListModel |
| ... | ... | @@ -515,6 +520,11 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 515 | 520 | var reloadItemBlock: ReloadItemCommentListResultBlock! |
| 516 | 521 | var replyItemModel: ShortVideoHomeCommentRListItemModel! |
| 517 | 522 | |
| 523 | + var currentIsComment = false//默认是2级评论 | |
| 524 | + var currentReplySeleIndex = 0//默认0 | |
| 525 | + var currentCommentSeleIndex = 0//默认0 | |
| 526 | + | |
| 527 | + | |
| 518 | 528 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
| 519 | 529 | super.init(style: style, reuseIdentifier: reuseIdentifier) |
| 520 | 530 | contentView.backgroundColor = HexColor("#FEFFFF") |
| ... | ... | @@ -583,6 +593,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 583 | 593 | } |
| 584 | 594 | |
| 585 | 595 | func setupWithDataSource(commentData: ShortVideoHomeCommentFListModel, replyData: ShortVideoHomeCommentRListModel, tableView_h: CGFloat, tableView_top: CGFloat, indexPath: IndexPath, isReset: Bool) { |
| 596 | + | |
| 586 | 597 | dataSource.removeAllObjects() |
| 587 | 598 | dataSource.addObjects(from: replyData.replys) |
| 588 | 599 | tableView_height = tableView_h |
| ... | ... | @@ -638,6 +649,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 638 | 649 | } |
| 639 | 650 | |
| 640 | 651 | func setupWithReplyModel(commentData: ShortVideoHomeCommentFListModel,replyModel: ShortVideoHomeCommentRListItemModel) { |
| 652 | + | |
| 641 | 653 | replyItemModel = replyModel |
| 642 | 654 | commentModel = commentData |
| 643 | 655 | iconView.kf.indicatorType = .activity |
| ... | ... | @@ -646,6 +658,9 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 646 | 658 | likeButton.isSelected = replyModel.isPraised! |
| 647 | 659 | likeButton.setTitle("\(replyModel.praiseCount ?? 0)", for: .normal) |
| 648 | 660 | timeLabel.text = replyModel.created_at |
| 661 | + let contentSidStr = contentSid | |
| 662 | + let uidStr = UserInfoManager.shared.userInfo.uid | |
| 663 | + let replyFromSidStr = replyItemModel.fromSid | |
| 649 | 664 | if ((contentSid == UserInfoManager.shared.userInfo.uid) || (replyItemModel.fromSid == UserInfoManager.shared.userInfo.uid)) { |
| 650 | 665 | replyButton.setTitle("删除", for: .normal) |
| 651 | 666 | } else { |
| ... | ... | @@ -716,11 +731,16 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 716 | 731 | |
| 717 | 732 | @objc func longPressGestureRecognizerAction(gestureRecognizer: UIGestureRecognizer) { |
| 718 | 733 | if gestureRecognizer.state == .began { |
| 719 | - let commentModelUid = commentModel.uid | |
| 734 | +// let commentModelUid = commentModel.uid | |
| 720 | 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 | 744 | AlertTool.systemActionSheet(title: "请选择", message: "", actionTitles: ["删除该条评论","举报"], cancelTitle: "取消") {[weak self] index in |
| 725 | 745 | guard let self = self else { return } |
| 726 | 746 | if index == 1 { |
| ... | ... | @@ -831,7 +851,20 @@ extension CNLiveShortVideoCommentListTableViewCell { |
| 831 | 851 | guard let cell = tableView.dequeueReusableCell(withIdentifier: kShortVideoReplyListTableViewCellIdentifier) as? CNLiveShortVideoCommentListTableViewCell else { |
| 832 | 852 | return CNLiveShortVideoCommentListTableViewCell() |
| 833 | 853 | } |
| 854 | + | |
| 834 | 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 | 868 | cell.reloadItemBlock = {[weak self] commentModel in |
| 836 | 869 | guard let self = self else { return } |
| 837 | 870 | self.reloadBlcok(commentModel) | ... | ... |