Commit c9a6d172 authored by Steven杜宇's avatar Steven杜宇

// 信封查看

parent 96c6429b
......@@ -12,6 +12,8 @@ class YHPrincipleEnvelopeCell: UITableViewCell {
static let cellReuseIdentifier = "YHPrincipleEnvelopeCell"
var itemModel:YHPrincipleEnvelopeModel?
var viewModel = YHPrincleViewModel()
var expandClick:((Bool)->())?
lazy var titleLabel: UILabel = {
......@@ -32,6 +34,9 @@ class YHPrincipleEnvelopeCell: UITableViewCell {
view.backgroundColor = .white
view.layer.cornerRadius = 6.0
view.clipsToBounds = true
view.isUserInteractionEnabled = true
let gap = UITapGestureRecognizer(target: self, action: #selector(didWatchClicked))
view.addGestureRecognizer(gap)
return view
}()
......@@ -48,19 +53,25 @@ class YHPrincipleEnvelopeCell: UITableViewCell {
view.addSubview(self.nameLabel)
nameLabel.snp.makeConstraints { make in
make.top.equalTo(58.0)
make.centerX.equalToSuperview()
make.height.equalTo(25)
make.left.equalTo(50)
make.right.equalTo(-20)
}
return view
}()
lazy var nameLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 2
label.font = UIFont.PFSC_M(ofSize: 18)
label.textColor = UIColor(hex: 0xB75E24)
return label
}()
lazy var previewFileTool:YHFilePreviewTool = {
let tool = YHFilePreviewTool(targetVC: UIViewController.current)
return tool
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
......@@ -75,6 +86,28 @@ class YHPrincipleEnvelopeCell: UITableViewCell {
expandClick?(!model.isUnfold)
}
@objc func didWatchClicked() {
guard let model = itemModel else { return }
if !model.url.isEmpty {
self.viewModel.getPublicImageUrl(model.url) { success, error in
if let success = success {
self.previewFileTool.openXLSXRemoteFile(urlString: success, fileName:model.name)
}
}
let key = self.getUrlKey(model)
UserDefaults.standard.set(true, forKey: key)
UserDefaults.standard.synchronize()
self.updateModel(model)
}
}
func getUrlKey(_ model: YHPrincipleEnvelopeModel) -> String {
let key = "CustomerServiceFile_" + model.url
return key
}
func updateModel(_ model:YHPrincipleEnvelopeModel) {
itemModel = model
......@@ -83,6 +116,14 @@ class YHPrincipleEnvelopeCell: UITableViewCell {
expandBtn.setImage(UIImage(named: imgName), for: .normal)
nameLabel.text = model.name
let key = self.getUrlKey(model)
if let isWatch = UserDefaults.standard.value(forKey: key) as? Bool, isWatch == true {
envelopImgView.image = UIImage(named: "principle_envelope_see")
} else {
envelopImgView.image = UIImage(named: "principle_envelope_unsee")
}
if !model.isUnfold {
whiteView.removeSubviews()
whiteView.snp.remakeConstraints { make in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment