Commit e53aaad6c57191e3be443678bd3a0e75f7ce4917
Merge branch 'master' of http://bj.gitlab.cnlive.com/ios-team/CNLiveMateCode
Showing
16 changed files
with
205 additions
and
41 deletions
metaCode/Classes/Config/CNLiveConfigUserInfo.swift
| ... | ... | @@ -182,7 +182,7 @@ class StandSortManager: NSObject { |
| 182 | 182 | static let shared = StandSortManager() |
| 183 | 183 | |
| 184 | 184 | //根据用户信息设置key |
| 185 | - static let sort_key: String = "mateCode_stand_sort_key_"+UserInfoManager.shared.userInfo.uid | |
| 185 | +// static let sort_key: String = "mateCode_stand_sort_key_"+UserInfoManager.shared.userInfo.uid | |
| 186 | 186 | fileprivate var _indexs : Array<String>? |
| 187 | 187 | private(set) var indexs: Array<String> { |
| 188 | 188 | set { |
| ... | ... | @@ -194,6 +194,10 @@ class StandSortManager: NSObject { |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | + static var sort_key: String { | |
| 198 | + return "mateCode_stand_sort_key_"+UserInfoManager.shared.userInfo.uid | |
| 199 | + } | |
| 200 | + | |
| 197 | 201 | /// 存储排序信息 |
| 198 | 202 | /// - Parameter indexs: 排序的index |
| 199 | 203 | static private func cacheStandSort(indexs: NSArray) { | ... | ... |
metaCode/Classes/Main/MinePage/View/CNLiveMineBodyListView.swift
| ... | ... | @@ -603,7 +603,7 @@ class MineBodyFourViewCell: UITableViewCell { |
| 603 | 603 | nameLabel.text = listModel.title ?? "" |
| 604 | 604 | descLabel.text = "积分值+\(listModel.score ?? "")" |
| 605 | 605 | if _listModel.taskId!.contains("check_in") { |
| 606 | - if _listModel.status!.contains("true") { | |
| 606 | + if !_listModel.checkInStatus! { | |
| 607 | 607 | shareBtn.setTitle("去签到", for: .normal) |
| 608 | 608 | }else{ |
| 609 | 609 | shareBtn.titleEdgeInsets = UIEdgeInsets.zero | ... | ... |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineBaseModel.swift
| ... | ... | @@ -322,6 +322,9 @@ class MineTaskCheckListModel: BaseModel { |
| 322 | 322 | var title: String? = "" |
| 323 | 323 | var totalCount: String? = "" |
| 324 | 324 | var url: String? = "" |
| 325 | + | |
| 326 | + /**最外面的参数 表示是不是进行过签到**/ | |
| 327 | + var checkInStatus: Bool? = false | |
| 325 | 328 | } |
| 326 | 329 | // !!!: /Daren/transaction/getTransactionRecord.action 余额交易记录 |
| 327 | 330 | ... | ... |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
| ... | ... | @@ -714,6 +714,7 @@ class CNLiveMineViewModel: NSObject { |
| 714 | 714 | for item in array { |
| 715 | 715 | let listModel = dictionaryToModel(item as! [String : Any], MineTaskCheckListModel.self,"") as! MineTaskCheckListModel |
| 716 | 716 | if listModel.taskId!.contains("check_in") { |
| 717 | + listModel.checkInStatus = dict["checkInStatus"] as? Bool | |
| 717 | 718 | tempArray.add(listModel) |
| 718 | 719 | } |
| 719 | 720 | } | ... | ... |
metaCode/Classes/Main/VideoPage/Model/CNLiveShortVideoHomeModel.swift
| ... | ... | @@ -21,6 +21,7 @@ class ShortVideoHomeCommentListModel: BaseModel { |
| 21 | 21 | var replyData = ShortVideoHomeCommentRListModel() |
| 22 | 22 | |
| 23 | 23 | var cell_h: CGFloat! = 0.0 |
| 24 | + var tableView_top: CGFloat! = 0.0 | |
| 24 | 25 | var tableView_h: CGFloat! = 0.0 |
| 25 | 26 | override func didFinishMapping() { |
| 26 | 27 | super.didFinishMapping() |
| ... | ... | @@ -30,7 +31,9 @@ class ShortVideoHomeCommentListModel: BaseModel { |
| 30 | 31 | for replyModel in replyData.replys { |
| 31 | 32 | tableView_h += replyModel.cellH |
| 32 | 33 | } |
| 33 | - if replyData.total_hd ?? 0 > 2 { | |
| 34 | + if replyData.replyCount ?? 0 > 2 { | |
| 35 | + print("回复数=>\(replyData.replyCount ?? 0)") | |
| 36 | + tableView_top += 30.0 | |
| 34 | 37 | cell_h += 30 |
| 35 | 38 | } |
| 36 | 39 | cell_h += tableView_h |
| ... | ... | @@ -80,7 +83,7 @@ class ShortVideoHomeCommentFListModel: BaseModel { |
| 80 | 83 | } |
| 81 | 84 | //回复数据 |
| 82 | 85 | class ShortVideoHomeCommentRListModel: BaseModel { |
| 83 | - var total_hd: Int? = 0 //总数 | |
| 86 | + var replyCount: Int? = 0 //总数 | |
| 84 | 87 | var replys = [ShortVideoHomeCommentRListItemModel]() |
| 85 | 88 | |
| 86 | 89 | } |
| ... | ... | @@ -110,7 +113,7 @@ class ShortVideoHomeCommentRListItemModel: BaseModel { |
| 110 | 113 | override func didFinishMapping() { |
| 111 | 114 | super.didFinishMapping() |
| 112 | 115 | |
| 113 | - let modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: semibold_adapt_font(pointSize: 14), paddingTop: 0, paddingBottom: 0, lineHeightMultiple: 1.5) | |
| 116 | + let modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: medium_adapt_font(pointSize: 16), paddingTop: 0, paddingBottom: 0, lineHeightMultiple: 1.5) | |
| 114 | 117 | let comment = NSMutableAttributedString.init(string: self.content ?? "") |
| 115 | 118 | // let comment = CNLiveBusinessTools.replaceQQemoji(withCustomText: self.content ?? "") |
| 116 | 119 | let temp_string = CNLiveShortVideoMateCodeLinePositionModifier.replaceEmotions(textAttributedString: comment, mainString: self.content ?? "") |
| ... | ... | @@ -190,7 +193,7 @@ class CNLiveShortVideoMateCodeLinePositionModifier: NSObject, YYTextLinePosition |
| 190 | 193 | |
| 191 | 194 | for j in 0..<emojiArr.count { |
| 192 | 195 | if mainString.substring(with: Range(result.range, in: mainString)!) == emojiArr[j].displayName { |
| 193 | - let attachText = NSAttributedString.yy_attachmentString(withContent: emojiArr[j].image, contentMode: .scaleAspectFit, attachmentSize: CGSize(width: adapt_length(length: 18), height: adapt_length(length: 18)), alignTo: semibold_adapt_font(pointSize: 16), alignment: .center) | |
| 196 | + let attachText = NSAttributedString.yy_attachmentString(withContent: emojiArr[j].image, contentMode: .scaleAspectFit, attachmentSize: CGSize(width: adapt_length(length: 25), height: adapt_length(length: 25)), alignTo: semibold_adapt_font(pointSize: 16), alignment: .center) | |
| 194 | 197 | |
| 195 | 198 | textAttributedString.replaceCharacters(in: result.range, with: attachText) |
| 196 | 199 | } | ... | ... |
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoCommentListView.swift
| ... | ... | @@ -17,6 +17,8 @@ typealias CloseCommentListResultBlock = (_ commentModel: Any) ->Void |
| 17 | 17 | typealias ReloadCommentListResultBlock = (_ commentModel: Any) ->Void |
| 18 | 18 | typealias ChangeCommentListResultBlock = (_ commentModel: Any) ->Void |
| 19 | 19 | typealias DeleteCommentListResultBlock = (_ commentModel: Any) ->Void |
| 20 | +typealias ReloadItemCommentListResultBlock = (_ commentModel: Any) ->Void | |
| 21 | +typealias ReloadRowCommentListResultBlock = (_ viewCell: CNLiveShortVideoCommentListTableViewCell, _ cell_h: CGFloat) ->Void | |
| 20 | 22 | class CNLiveShortVideoCommentListView: UIView, UITableViewDelegate, UITableViewDataSource, EmptyDataSetSource, EmptyDataSetDelegate { |
| 21 | 23 | |
| 22 | 24 | lazy var grayMaskView: UIView = { |
| ... | ... | @@ -272,9 +274,22 @@ extension CNLiveShortVideoCommentListView { |
| 272 | 274 | guard let cell = tableView.dequeueReusableCell(withIdentifier: kShortVideoCommentListTableViewCellIdentifier) as? CNLiveShortVideoCommentListTableViewCell else { |
| 273 | 275 | return CNLiveShortVideoCommentListTableViewCell() |
| 274 | 276 | } |
| 275 | - 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) | |
| 277 | + 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, pageNumber: self.pageNum) | |
| 278 | + cell.reloadRowBlock = {[weak self] viewCell, cell_h in | |
| 279 | + guard let self = self else { return } | |
| 280 | + let commentModel_temp = self.dataArray[viewCell.indexPath_current.row] as! ShortVideoHomeCommentListModel | |
| 281 | + commentModel_temp.cell_h += cell_h | |
| 282 | + commentModel_temp.cell_h -= 30 | |
| 283 | + commentModel_temp.tableView_h += cell_h | |
| 284 | + commentModel_temp.tableView_top = 0.0 | |
| 285 | + commentModel_temp.replyData.replys = viewCell.dataSource as! [ShortVideoHomeCommentRListItemModel] | |
| 286 | + self.tableView.beginUpdates() | |
| 287 | + self.tableView.reloadRows(at: [viewCell.indexPath_current], with: .automatic) | |
| 288 | + self.tableView.endUpdates() | |
| 289 | + } | |
| 276 | 290 | cell.reloadBlcok = {[weak self] commentModel in |
| 277 | 291 | guard let self = self else { return } |
| 292 | + showMessage(message: "") | |
| 278 | 293 | self.tableView.mj_header?.beginRefreshing() |
| 279 | 294 | } |
| 280 | 295 | cell.changeBlock = {[weak self] commentModel in |
| ... | ... | @@ -283,9 +298,8 @@ extension CNLiveShortVideoCommentListView { |
| 283 | 298 | } |
| 284 | 299 | cell.deleteBlock = {[weak self] commentModel in |
| 285 | 300 | guard let self = self else { return } |
| 286 | - self.pageNum = 0 | |
| 287 | - showLoading(message: "") | |
| 288 | - self.requestDataSource() | |
| 301 | + showMessage(message: "") | |
| 302 | + self.tableView.mj_header?.beginRefreshing() | |
| 289 | 303 | // let tempArray = NSMutableArray(array: self.dataArray) |
| 290 | 304 | // let tempModel = commentModel as! ShortVideoHomeCommentFListModel |
| 291 | 305 | // tempArray.forEach { itemModel in |
| ... | ... | @@ -311,10 +325,6 @@ extension CNLiveShortVideoCommentListView { |
| 311 | 325 | let model: ShortVideoHomeCommentListModel = dataArray[indexPath.row] as! ShortVideoHomeCommentListModel |
| 312 | 326 | return model.cell_h |
| 313 | 327 | } |
| 314 | -// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
| 315 | -// let model: ShortVideoHomeCommentFListModel = ((dataArray[indexPath.row] as! ShortVideoHomeCommentListModel).comment) | |
| 316 | -// self.resultBlock(model) | |
| 317 | -// } | |
| 318 | 328 | func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? { |
| 319 | 329 | return UIImage(named: "short_video_comment_empty") |
| 320 | 330 | } |
| ... | ... | @@ -392,6 +402,22 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 392 | 402 | return replyButton |
| 393 | 403 | }() |
| 394 | 404 | |
| 405 | + lazy var replyUnfoldButton: UIButton = { | |
| 406 | + let button = QMUIButton() | |
| 407 | + button.imagePosition = .right | |
| 408 | + button.spacingBetweenImageAndTitle = 3 | |
| 409 | + button.backgroundColor = .clear | |
| 410 | + button.isHidden = true | |
| 411 | + button.setTitle(" ── 展开回复", for: .normal) | |
| 412 | + button.setTitleColor(HexColor("#969696"), for: .normal) | |
| 413 | + button.titleLabel?.font = regular_adapt_font(pointSize: 13) | |
| 414 | + button.imageView?.contentMode = .scaleAspectFit | |
| 415 | + button.setImage(UIImage(named: "short_video_reply_open"), for: .normal) | |
| 416 | + button.setImage(UIImage(named: "short_video_reply_close"), for: .selected) | |
| 417 | + button.addTarget(self, action: #selector(replyUnfoldMethod), for: .touchUpInside) | |
| 418 | + return button | |
| 419 | + }() | |
| 420 | + | |
| 395 | 421 | lazy var likeButton: QMUIButton = { |
| 396 | 422 | let button = QMUIButton() |
| 397 | 423 | button.imagePosition = .left |
| ... | ... | @@ -417,18 +443,27 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 417 | 443 | tableView.tableFooterView = UIView.init() |
| 418 | 444 | tableView.separatorStyle = .none |
| 419 | 445 | tableView.scrollsToTop = false |
| 446 | + tableView.translatesAutoresizingMaskIntoConstraints = false | |
| 420 | 447 | tableView.register(CNLiveShortVideoCommentListTableViewCell.self, forCellReuseIdentifier: kShortVideoReplyListTableViewCellIdentifier) |
| 421 | 448 | return tableView |
| 422 | 449 | }() |
| 423 | 450 | |
| 451 | + lazy var dataSource: NSMutableArray = { | |
| 452 | + let array = NSMutableArray() | |
| 453 | + return array | |
| 454 | + }() | |
| 455 | + | |
| 424 | 456 | var videoId: String! |
| 425 | 457 | var contentSid: String! |
| 458 | + var tableView_height: CGFloat! = 0.0 | |
| 459 | + var indexPath_current: IndexPath! | |
| 426 | 460 | var changeBlock: ChangeCommentListResultBlock! |
| 427 | 461 | var deleteBlock: DeleteCommentListResultBlock! |
| 428 | 462 | var reloadBlcok: ReloadCommentListResultBlock! |
| 429 | 463 | var deleteItemBlock: DeleteCommentListResultBlock! |
| 430 | 464 | var commentModel: ShortVideoHomeCommentFListModel! |
| 431 | - var replyModel: ShortVideoHomeCommentRListModel! | |
| 465 | + var reloadRowBlock: ReloadRowCommentListResultBlock! | |
| 466 | + var reloadItemBlock: ReloadItemCommentListResultBlock! | |
| 432 | 467 | var replyItemModel: ShortVideoHomeCommentRListItemModel! |
| 433 | 468 | |
| 434 | 469 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
| ... | ... | @@ -482,11 +517,22 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 482 | 517 | make.width.equalTo(40) |
| 483 | 518 | make.top.equalTo(commentLabel.snp.bottom).offset(10) |
| 484 | 519 | } |
| 520 | + contentView.addSubview(replyUnfoldButton) | |
| 521 | + replyUnfoldButton.snp.makeConstraints { make in | |
| 522 | + make.top.equalTo(timeLabel.snp.bottom).offset(5) | |
| 523 | + make.left.equalTo(titleLabel.snp.left) | |
| 524 | + make.height.equalTo(20) | |
| 525 | + } | |
| 485 | 526 | contentView.addSubview(tableView) |
| 486 | 527 | } |
| 487 | 528 | |
| 488 | - func setupWithDataSource(commentData: ShortVideoHomeCommentFListModel, replyData: ShortVideoHomeCommentRListModel, tableView_h: CGFloat) { | |
| 489 | - replyModel = replyData | |
| 529 | + func setupWithDataSource(commentData: ShortVideoHomeCommentFListModel, replyData: ShortVideoHomeCommentRListModel, tableView_h: CGFloat, tableView_top: CGFloat, indexPath: IndexPath, pageNumber: Int) { | |
| 530 | + if pageNumber == 0 { | |
| 531 | + dataSource.removeAllObjects() | |
| 532 | + } | |
| 533 | + dataSource.addObjects(from: replyData.replys) | |
| 534 | + tableView_height = tableView_h | |
| 535 | + indexPath_current = indexPath | |
| 490 | 536 | commentModel = commentData |
| 491 | 537 | iconView.kf.indicatorType = .activity |
| 492 | 538 | iconView.kf.setImage(with: URL(string: commentData.icon!), placeholder: UIImage(named: "short_video_default")) |
| ... | ... | @@ -495,6 +541,12 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 495 | 541 | likeButton.setTitle("\(commentData.praiseCount ?? 0)", for: .normal) |
| 496 | 542 | timeLabel.text = commentData.created_at |
| 497 | 543 | owerView.isHidden = !(contentSid == commentData.uid) |
| 544 | + if tableView_top > 0.0 { | |
| 545 | + replyUnfoldButton.isHidden = replyData.replyCount! <= 2 | |
| 546 | + replyUnfoldButton.setTitle(" ── 展开\(replyData.replyCount! - 2)条回复", for: .normal) | |
| 547 | + } else { | |
| 548 | + replyUnfoldButton.isHidden = true | |
| 549 | + } | |
| 498 | 550 | if ((contentSid == UserInfoManager.shared.userInfo.uid) || (commentData.uid == UserInfoManager.shared.userInfo.uid)) { |
| 499 | 551 | replyButton.setTitle("删除", for: .normal) |
| 500 | 552 | } else { |
| ... | ... | @@ -510,20 +562,22 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 510 | 562 | make.height.equalTo(commentData.textLayout.textBoundingRect.size.height) |
| 511 | 563 | } |
| 512 | 564 | self.tableView.removeFromSuperview() |
| 513 | - if replyData.replys.count > 0 { | |
| 565 | + if replyData.replyCount ?? 0 > 2 { | |
| 514 | 566 | self.contentView.addSubview(self.tableView) |
| 515 | 567 | self.tableView.snp.makeConstraints { make in |
| 516 | 568 | make.left.equalToSuperview().offset(60) |
| 517 | 569 | make.right.equalToSuperview().offset(-10) |
| 518 | - make.top.equalTo(self.timeLabel.snp.bottom).offset(10) | |
| 519 | - make.height.equalTo(tableView_h) | |
| 570 | + make.top.equalTo(self.timeLabel.snp.bottom).offset(10+tableView_top) | |
| 571 | + make.height.equalTo(self.tableView_height) | |
| 520 | 572 | } |
| 573 | + self.tableView.reloadData() | |
| 521 | 574 | } |
| 522 | 575 | } |
| 523 | 576 | } |
| 524 | 577 | |
| 525 | - func setupWithReplyModel(replyModel: ShortVideoHomeCommentRListItemModel) { | |
| 578 | + func setupWithReplyModel(commentData: ShortVideoHomeCommentFListModel,replyModel: ShortVideoHomeCommentRListItemModel) { | |
| 526 | 579 | replyItemModel = replyModel |
| 580 | + commentModel = commentData | |
| 527 | 581 | iconView.kf.indicatorType = .activity |
| 528 | 582 | iconView.kf.setImage(with: URL(string: replyModel.fromFace!), placeholder: UIImage(named: "short_video_default")) |
| 529 | 583 | titleLabel.text = replyModel.fromNick |
| ... | ... | @@ -551,11 +605,15 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 551 | 605 | if button.titleLabel?.text == "回复" { |
| 552 | 606 | CNLiveContentToolTextView.showCommentViewForCustom(withCommType: .reply, fromNick: commentModel == nil ? replyItemModel.fromNick : commentModel.nick, firstRespFace: false, successBlcok: {[weak self] commentString, toolbarView in |
| 553 | 607 | guard let self = self else { return } |
| 554 | - CNLiveShortVideoViewModel.requestCommentWithReply(commentId: self.commentModel.commentId!, comment: commentString ?? "", toSid: commentModel.uid!, fromSid: UserInfoManager.shared.userInfo.uid, level: "1") {[weak self] result, respStatue in | |
| 608 | + CNLiveShortVideoViewModel.requestCommentWithReply(commentId: self.commentModel.commentId!, comment: commentString ?? "", toSid: self.commentModel.uid!, fromSid: UserInfoManager.shared.userInfo.uid, level: "1") {[weak self] result, respStatue in | |
| 555 | 609 | guard let self = self else { return } |
| 556 | 610 | if respStatue == .success { |
| 557 | 611 | showMessage(message: result as! String) |
| 558 | - self.reloadBlcok(self.commentModel == nil ? replyItemModel! : commentModel!) | |
| 612 | + if self.replyItemModel != nil { | |
| 613 | + self.reloadItemBlock(self.commentModel == nil ? replyItemModel! : commentModel!) | |
| 614 | + } else { | |
| 615 | + self.reloadBlcok(self.commentModel == nil ? replyItemModel! : commentModel!) | |
| 616 | + } | |
| 559 | 617 | } |
| 560 | 618 | } |
| 561 | 619 | }, dissBlock: { toolbarView in}) |
| ... | ... | @@ -564,21 +622,20 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 564 | 622 | AlertTool.systemAlert(title: "确认删除该条\(commentModel != nil ? "评论" : "回复")吗?", message: "", cancelTitle: "取消", confirmTitle: "确定") {[weak self] index in |
| 565 | 623 | guard let self = self else { return } |
| 566 | 624 | if index == 1 { |
| 567 | - if commentModel != nil { | |
| 625 | + if replyItemModel != nil { | |
| 568 | 626 | showLoading(message: "") |
| 569 | - CNLiveShortVideoViewModel.requestCommentDelete(videoId: commentModel.topicId!, commentId: commentModel.commentId!) {[weak self] result, respStatue in | |
| 627 | + CNLiveShortVideoViewModel.requestCommentReplyDelete(replyId: replyItemModel.replyId!, commentId: replyItemModel.commentId!) {[weak self] result, respStatue in | |
| 570 | 628 | guard let self = self else { return } |
| 571 | 629 | if respStatue == .success { |
| 572 | - self.deleteBlock(self.commentModel!) | |
| 630 | + self.deleteItemBlock(self.replyItemModel!) | |
| 573 | 631 | } |
| 574 | 632 | } |
| 575 | - } | |
| 576 | - if replyItemModel != nil { | |
| 633 | + } else { | |
| 577 | 634 | showLoading(message: "") |
| 578 | - CNLiveShortVideoViewModel.requestCommentReplyDelete(replyId: replyItemModel.replyId!, commentId: replyItemModel.commentId!) {[weak self] result, respStatue in | |
| 635 | + CNLiveShortVideoViewModel.requestCommentDelete(videoId: commentModel.topicId!, commentId: commentModel.commentId!) {[weak self] result, respStatue in | |
| 579 | 636 | guard let self = self else { return } |
| 580 | 637 | if respStatue == .success { |
| 581 | - self.deleteItemBlock(self.replyItemModel!) | |
| 638 | + self.deleteBlock(self.commentModel!) | |
| 582 | 639 | } |
| 583 | 640 | } |
| 584 | 641 | } |
| ... | ... | @@ -636,6 +693,26 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel |
| 636 | 693 | } |
| 637 | 694 | } |
| 638 | 695 | |
| 696 | + @objc func replyUnfoldMethod(button: UIButton) { | |
| 697 | + showLoading(message: "") | |
| 698 | + let replyModel: ShortVideoHomeCommentRListItemModel = self.dataSource.lastObject as! ShortVideoHomeCommentRListItemModel | |
| 699 | + CNLiveShortVideoViewModel.requestcommentWithReplyList(commentId: commentModel.commentId!, seqId: replyModel.seqId!) {[weak self] result, respStatue in | |
| 700 | + guard let self = self else { return } | |
| 701 | + if respStatue == .success { | |
| 702 | + let tempArray = result as! [ShortVideoHomeCommentRListItemModel] | |
| 703 | + let dataArray_temp = NSMutableArray(array: self.dataSource) | |
| 704 | + self.dataSource.removeAllObjects() | |
| 705 | + var cell_h: CGFloat = 0.0 | |
| 706 | + tempArray.forEach { item in | |
| 707 | + dataArray_temp.add(item) | |
| 708 | + cell_h += item.cellH | |
| 709 | + } | |
| 710 | + self.dataSource.addObjects(from: dataArray_temp as! [ShortVideoHomeCommentRListItemModel]) | |
| 711 | + self.reloadRowBlock(self, cell_h) | |
| 712 | + } | |
| 713 | + } | |
| 714 | + } | |
| 715 | + | |
| 639 | 716 | required init?(coder: NSCoder) { |
| 640 | 717 | fatalError("init(coder:) has not been implemented") |
| 641 | 718 | } |
| ... | ... | @@ -647,13 +724,17 @@ extension CNLiveShortVideoCommentListTableViewCell { |
| 647 | 724 | return 1 |
| 648 | 725 | } |
| 649 | 726 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| 650 | - return replyModel == nil ? 0 : replyModel.replys.count | |
| 727 | + return dataSource.count | |
| 651 | 728 | } |
| 652 | 729 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| 653 | 730 | guard let cell = tableView.dequeueReusableCell(withIdentifier: kShortVideoReplyListTableViewCellIdentifier) as? CNLiveShortVideoCommentListTableViewCell else { |
| 654 | 731 | return CNLiveShortVideoCommentListTableViewCell() |
| 655 | 732 | } |
| 656 | - cell.setupWithReplyModel(replyModel: replyModel.replys[indexPath.row]) | |
| 733 | + cell.setupWithReplyModel(commentData: commentModel,replyModel: dataSource[indexPath.row] as! ShortVideoHomeCommentRListItemModel) | |
| 734 | + cell.reloadItemBlock = {[weak self] commentModel in | |
| 735 | + guard let self = self else { return } | |
| 736 | + self.reloadBlcok(commentModel) | |
| 737 | + } | |
| 657 | 738 | cell.deleteItemBlock = {[weak self] commentModel in |
| 658 | 739 | guard let self = self else { return } |
| 659 | 740 | self.deleteBlock(commentModel) |
| ... | ... | @@ -677,7 +758,7 @@ extension CNLiveShortVideoCommentListTableViewCell { |
| 677 | 758 | return cell |
| 678 | 759 | } |
| 679 | 760 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| 680 | - let model: ShortVideoHomeCommentRListItemModel = replyModel.replys[indexPath.row] | |
| 761 | + let model: ShortVideoHomeCommentRListItemModel = dataSource[indexPath.row] as! ShortVideoHomeCommentRListItemModel | |
| 681 | 762 | return model.cellH |
| 682 | 763 | } |
| 683 | 764 | } | ... | ... |
metaCode/Classes/Main/VideoPage/ViewModel/CNLiveShortVideoViewModel.swift
| ... | ... | @@ -374,10 +374,13 @@ class CNLiveShortVideoViewModel: NSObject { |
| 374 | 374 | /// - commentId: 评论 id |
| 375 | 375 | /// - page: 页数 |
| 376 | 376 | /// - reultShortVideoBlock: 返回 |
| 377 | - static func requestcommentWithReplyList(commentId: String,page: NSInteger,reultShortVideoBlock: @escaping resultShortVideoBlock) { | |
| 377 | + static func requestcommentWithReplyList(commentId: String,seqId: Int,reultShortVideoBlock: @escaping resultShortVideoBlock) { | |
| 378 | 378 | let param = NSMutableDictionary() |
| 379 | 379 | param.setValue(commentId, forKey: "commentId") |
| 380 | - param.setValue("\(page)", forKey: "seqId")//从 0 开始 | |
| 380 | + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid") | |
| 381 | + param.setValue(CNLiveEnvironmentManager.shared.appId, forKey: "appId") | |
| 382 | + param.setValue("i", forKey: "plat") | |
| 383 | + param.setValue("\(seqId)", forKey: "seqId")//从 时间戳 开始 | |
| 381 | 384 | param.setValue("10", forKey: "count") |
| 382 | 385 | let custom_param = NSMutableDictionary() |
| 383 | 386 | custom_param.setValue(CNLiveEnvironmentManager.shared.appId, forKey: "appId") |
| ... | ... | @@ -396,13 +399,16 @@ class CNLiveShortVideoViewModel: NSObject { |
| 396 | 399 | } else { |
| 397 | 400 | let resp_dict = resp["data"] as! NSDictionary |
| 398 | 401 | let resp_reply_dict = resp_dict["replyData"] as! NSDictionary |
| 399 | - let array = resp_reply_dict["replys"] as! NSArray | |
| 400 | - let tempArray = NSMutableArray() | |
| 401 | - for item in array { | |
| 402 | - let listModel = dictionaryToModel(item as! [String : Any], ShortVideoHomeCommentRListItemModel.self,"") as! ShortVideoHomeCommentRListItemModel | |
| 403 | - tempArray.add(listModel) | |
| 402 | + if resp_reply_dict["replys"] != nil { | |
| 403 | + let array = resp_reply_dict["replys"] as! NSArray | |
| 404 | + let tempArray = NSMutableArray() | |
| 405 | + for item in array { | |
| 406 | + let listModel = dictionaryToModel(item as! [String : Any], ShortVideoHomeCommentRListItemModel.self,"") as! ShortVideoHomeCommentRListItemModel | |
| 407 | + tempArray.add(listModel) | |
| 408 | + } | |
| 409 | + reultShortVideoBlock(tempArray, .success) | |
| 404 | 410 | } |
| 405 | - reultShortVideoBlock(tempArray, .success) | |
| 411 | + reultShortVideoBlock(Array<Any>(), .success) | |
| 406 | 412 | } |
| 407 | 413 | } else { |
| 408 | 414 | showMessage(message: resp["errorMessage"] as! String) | ... | ... |
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_close.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "short_video_close@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "short_video_close@3x.png", | |
| 14 | + "idiom" : "universal", | |
| 15 | + "scale" : "3x" | |
| 16 | + } | |
| 17 | + ], | |
| 18 | + "info" : { | |
| 19 | + "author" : "xcode", | |
| 20 | + "version" : 1 | |
| 21 | + } | |
| 22 | +} | ... | ... |
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_close.imageset/short_video_close@2x.png
0 → 100644
240 Bytes
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_close.imageset/short_video_close@3x.png
0 → 100644
451 Bytes
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_name.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "short_video_reply_name@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "short_video_reply_name@3x.png", | |
| 14 | + "idiom" : "universal", | |
| 15 | + "scale" : "3x" | |
| 16 | + } | |
| 17 | + ], | |
| 18 | + "info" : { | |
| 19 | + "author" : "xcode", | |
| 20 | + "version" : 1 | |
| 21 | + } | |
| 22 | +} | ... | ... |
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_name.imageset/short_video_reply_name@2x.png
0 → 100644
281 Bytes
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_name.imageset/short_video_reply_name@3x.png
0 → 100644
453 Bytes
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_open.imageset/Contents.json
0 → 100644
| 1 | +{ | |
| 2 | + "images" : [ | |
| 3 | + { | |
| 4 | + "idiom" : "universal", | |
| 5 | + "scale" : "1x" | |
| 6 | + }, | |
| 7 | + { | |
| 8 | + "filename" : "short_video_open@2x.png", | |
| 9 | + "idiom" : "universal", | |
| 10 | + "scale" : "2x" | |
| 11 | + }, | |
| 12 | + { | |
| 13 | + "filename" : "short_video_open@3x.png", | |
| 14 | + "idiom" : "universal", | |
| 15 | + "scale" : "3x" | |
| 16 | + } | |
| 17 | + ], | |
| 18 | + "info" : { | |
| 19 | + "author" : "xcode", | |
| 20 | + "version" : 1 | |
| 21 | + } | |
| 22 | +} | ... | ... |
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_open.imageset/short_video_open@2x.png
0 → 100644
234 Bytes
metaCode/Supporting Files/Assets.xcassets/Video/short_video_reply_open.imageset/short_video_open@3x.png
0 → 100644
450 Bytes