CNLiveRealNameCell.swift
4.87 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// CNLiveRealNameCell.swift
// metaCode
//
// Created by zx on 2024/6/7.
// 实名认证cell
import Foundation
import Kingfisher
import SnapKit
import QMUIKit
typealias TFReturnBlock = () -> Void//
typealias TFTextUpdateBlock = (_ currentCell: CNLiveRealNameCell ,_ type:Int ,_ textStr:String) -> Void//type: 10姓名 11证件号码
class CNLiveRealNameCell: UITableViewCell, QMUITextFieldDelegate {
var tfTextUpdateBlock:TFTextUpdateBlock?
var tfReturnBlock:TFReturnBlock?
lazy var nameLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#333333")
titleLabel.text = "本人姓名"
titleLabel.font = BoldFont_16
titleLabel.adjustsFontSizeToFitWidth = true
return titleLabel
}()
lazy var nameTF :QMUITextField = {
let searchTF = QMUITextField()
searchTF.backgroundColor = HexColor("#F7F7F7")
searchTF.qmui_borderWidth = 0.5
searchTF.qmui_borderColor = HexColor("#DCDCDC")
searchTF.textInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15)
searchTF.clearButtonMode = .always
searchTF.textColor = HexColor("#999999")
searchTF.font = Font_16
searchTF.delegate = self
searchTF.returnKeyType = .done
return searchTF
}()
lazy var nameDescLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.textColor = HexColor("#999999")
titleLabel.text = "按本人有效身份证件填写"
titleLabel.font = Font_12
return titleLabel
}()
var _type:Int = 0//100姓名 101类型 102号码
var type:Int{
get{
_type
}
set{
_type = newValue
if _type == 100{//100姓名
self.nameLabel.text = "本人姓名"
let attributedPlaceholder = NSAttributedString(string: "请输入本人姓名", attributes: [.foregroundColor: HexColor("#999999")!, .font: self.nameTF.font!])
self.nameTF.attributedPlaceholder = attributedPlaceholder
self.nameTF.isUserInteractionEnabled = true
self.nameDescLabel.text = "按本人有效身份证件填写"
}else if _type == 101{//101类型
self.nameLabel.text = "证件类型"
let attributedPlaceholder = NSAttributedString(string: "居民身份证", attributes: [.foregroundColor: HexColor("#999999")!, .font: self.nameTF.font!])
self.nameTF.attributedPlaceholder = attributedPlaceholder
self.nameTF.isUserInteractionEnabled = false
self.nameDescLabel.text = "中国大陆地区用户推荐设置居民身份证"
}else if _type == 102{//102号码
self.nameLabel.text = "证件号码"
let attributedPlaceholder = NSAttributedString(string: "请输入证件号码", attributes: [.foregroundColor: HexColor("#999999")!, .font: self.nameTF.font!])
self.nameTF.attributedPlaceholder = attributedPlaceholder
self.nameTF.isUserInteractionEnabled = true
self.nameDescLabel.text = "请认真核对您的证件号码,证件号码一经提交"
}else{
}
}
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.contentView.addSubview(self.nameLabel)
self.contentView.addSubview(self.nameTF)
self.contentView.addSubview(self.nameDescLabel)
self.nameLabel.snp.makeConstraints { make in
make.top.equalTo(10)
make.left.equalTo(20)
make.height.equalTo(23)
}
self.nameTF.snp.makeConstraints { make in
make.top.equalTo(self.nameLabel.snp.bottom).offset(5)
make.left.equalTo(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(53)
}
self.nameDescLabel.snp.makeConstraints { make in
make.top.equalTo(self.nameTF.snp.bottom).offset(5)
make.left.equalTo(20)
make.right.equalToSuperview().offset(-20)
make.height.equalTo(17)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - UITextFieldDelegate
func textFieldDidEndEditing(_ textField: UITextField) {
if self.nameLabel.text == "本人姓名"{
self.tfTextUpdateBlock?(self, 10, self.nameTF.text ?? "")
}else if self.nameLabel.text == "证件号码"{
self.tfTextUpdateBlock?(self, 11, self.nameTF.text ?? "")
}else{
}
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.tfReturnBlock?()
return true
}
}