宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
//  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)"))
        }
    }
 
}