//
|
// CommentReplyTCell.swift
|
// OKProject
|
//
|
// Created by 无故事王国 on 2022/5/11.
|
// Copyright © 2022 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
import RxSwift
|
|
class CommentReplyTCell: UITableViewCell {
|
|
@IBOutlet weak var profileImg: UIImageView!
|
@IBOutlet weak var nameL: UILabel!
|
@IBOutlet weak var contentL: UILabel!
|
@IBOutlet weak var timeL: UILabel!
|
|
var replyUser:String?
|
private var commentModel:CommentModel?
|
var replyDelegate = Delegate<Void,Void>()
|
var cellDisposeBag = DisposeBag()
|
|
override func awakeFromNib() {
|
super.awakeFromNib()
|
selectionStyle = .none
|
}
|
|
@IBAction func replyAction(_ sender: UIButton) {
|
let commentView = PublishCommentView.show({[weak self] text in
|
guard let weakSelf = self else { return }
|
let id = weakSelf.commentModel!.commentId
|
let type = weakSelf.commentModel!.type.rawValue
|
let orderId = weakSelf.commentModel!.orderId
|
let replyUserId = weakSelf.commentModel!.userId
|
|
APIManager.shared.provider.rx.request(.insertComment(commentId: id, content: text, orderId: orderId, type: type, replyUserId: replyUserId)).map(YYModel<Nothing>.self).validate().subscribe(onSuccess: {data in
|
weakSelf.replyDelegate.call()
|
}) { error in
|
alert(text: "回复失败")
|
}.disposed(by: weakSelf.cellDisposeBag)
|
})
|
|
commentView.textView.placeholder = "回复@\(commentModel!.userName)"
|
}
|
|
func setCommentModel(_ m:CommentModel){
|
self.commentModel = m
|
profileImg.load(url: m.userAvatar,placeHolder: UIImage(named: "logo")!)
|
nameL.text = m.userName.isEmpty ? "佚名":m.userName
|
contentL.text = m.content
|
|
var attribute = AttributedStringbuilder.build()
|
attribute = attribute.add(string: "回复", withFont: UIFont.systemFont(ofSize: 12,weight: .medium), withColor: .black.withAlphaComponent(0.8))
|
attribute = attribute.add(string: m.replyUserName, withFont: UIFont.systemFont(ofSize: 12), withColor: .black)
|
attribute = attribute.add(string: ":\(m.content)", withFont: UIFont.systemFont(ofSize: 12), withColor: .black)
|
contentL.attributedText = attribute.mutableAttributedString
|
|
|
//74184 [招聘详情]评论时间显示与需求不符
|
let createTime = DateClass.timeStringToDate(m.createTime)
|
let diffday = DateClass.dateDifference(Date(), from: createTime)
|
if diffday > 1.0{
|
timeL.text = String(format: "%@", DateClass.dateToDateString(createTime, dateFormat: "yyyy/MM/dd"))
|
}else{
|
let time = DateClass.timeStringToDate(m.createTime).timeIntervalSince1970 * 1000
|
timeL.text = String(format: "%@", DateClass.compareCurrentTime(str: "\(time)"))
|
}
|
}
|
|
}
|