CNLiveShopBodyTransListView.swift
6.8 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//
// CNLiveShopTransListView.swift
// metaCode
//
// Created by open on 2023/11/15.
//
import Foundation
import Kingfisher
typealias clickTransListHeaderCallBack = (_ headerView: ShopBodyTransListHeaderView) -> Void
class ShopBodyTransListHeaderView: UIView {
lazy var dateLab: UILabel = {
let dateLab = UILabel.init()
dateLab.textColor = HexColor("#333333")
dateLab.font = medium_adapt_font(pointSize: 16)
dateLab.text = NSDate.timeIntervalChangeToTimeStr(timeInterval: NSDate().timeIntervalSince1970, "YYYY年M月")
return dateLab
}()
lazy var downArrowImageView: UIImageView = {
let downArrowImageView = UIImageView.init(image: UIImage(named: "ye_xl"))
downArrowImageView.contentMode = .scaleAspectFit
downArrowImageView.clipsToBounds = true
return downArrowImageView
}()
lazy var priceLab: UILabel = {
let priceLab = UILabel.init()
priceLab.textColor = HexColor("#9d9d9d")
priceLab.font = medium_adapt_font(pointSize: 14)
priceLab.text = "支出 ¥0.00 收入 ¥0.00"
return priceLab
}()
var clickBlcok: clickTransListHeaderCallBack!
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = HexColor("#f6f6f6")
addSubview(dateLab)
dateLab.snp.makeConstraints { make in
make.left.top.equalToSuperview().offset(adapt_length(length: 20))
make.height.equalTo(adapt_length(length: 23))
make.width.lessThanOrEqualTo(adapt_length(length: 300))
}
addSubview(downArrowImageView)
downArrowImageView.snp.makeConstraints { make in
make.left.equalTo(dateLab.snp.right).offset(adapt_length(length: 5))
make.centerY.equalTo(dateLab)
make.size.equalTo(CGSize(width: adapt_length(length: 10), height: adapt_length(length: 10)))
}
addSubview(priceLab)
priceLab.snp.makeConstraints { make in
make.left.equalToSuperview().offset(adapt_length(length: 20))
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.top.equalTo(dateLab.snp.bottom).offset(adapt_length(length: 5))
make.height.equalTo(adapt_length(length: 20))
}
isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(selfTap))
addGestureRecognizer(tap)
}
@objc func selfTap() {
if (clickBlcok != nil) {
clickBlcok(self)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class ShopBodyTransListViewCell: UITableViewCell {
lazy var iconImageView: UIImageView = {
let iconImageView = UIImageView.init(frame: CGRectMake(0, 0, adapt_length(length: 40), adapt_length(length: 40)))
iconImageView.contentMode = .scaleAspectFill
iconImageView.layer.cornerRadius = adapt_length(length: 20)
iconImageView.layer.masksToBounds = true
return iconImageView
}()
lazy var titleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.textColor = HexColor("#333333")
titleLabel.font = medium_adapt_font(pointSize: 15)
return titleLabel
}()
lazy var timeLabel: UILabel = {
let timeLabel = UILabel.init()
timeLabel.textColor = HexColor("#999999")
timeLabel.font = regular_adapt_font(pointSize: 12)
return timeLabel
}()
lazy var payTypeImageView: UIImageView = {
let payTypeImageView = UIImageView.init(frame: CGRectMake(0, 0, adapt_length(length: 54), adapt_length(length: 16)))
payTypeImageView.contentMode = .scaleAspectFit
return payTypeImageView
}()
lazy var priceLab: UILabel = {
let priceLab = UILabel.init()
priceLab.textColor = HexColor("#333333")
priceLab.font = medium_adapt_font(pointSize: 18)
priceLab.textAlignment = .right
return priceLab
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .clear
selectionStyle = .none
addSubview(iconImageView)
iconImageView.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(20)
make.size.equalTo(adapt_length(length: 40))
}
addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(iconImageView.snp.right).offset(adapt_length(length: 15))
make.right.equalToSuperview().offset(-adapt_length(length: 75))
make.top.equalTo(iconImageView.snp.top)
make.height.equalTo(adapt_length(length: 21))
}
addSubview(timeLabel)
timeLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel.snp.left)
make.top.equalTo(titleLabel.snp.bottom).offset(adapt_length(length: 5))
make.size.equalTo(CGSize(width: adapt_length(length: 130), height: 17))
}
addSubview(payTypeImageView)
payTypeImageView.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.top.equalToSuperview().offset(adapt_length(length: 17))
make.size.equalTo(payTypeImageView.size)
}
addSubview(priceLab)
priceLab.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.left.equalTo(timeLabel.snp.right).offset(adapt_length(length: 15))
make.top.equalTo(payTypeImageView.snp.bottom).offset(4)
make.height.equalTo(adapt_length(length: 25))
}
}
func setupWithDataSource(listModel: ShopOrderTransListDataModel) {
iconImageView.kf.setImage(with: URL(string: listModel.img!), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: adapt_length(length: 40), height: adapt_length(length: 40))))
titleLabel.text = listModel.username
timeLabel.text = listModel.addtime
if listModel.payment == "1" {
payTypeImageView.image = UIImage(named: "tsq_zhifubaozf")
}
if listModel.payment == "2" {
payTypeImageView.image = UIImage(named: "tsq_wweixinzf")
}
if listModel.payment == "3" {
payTypeImageView.image = UIImage(named: "tsq_yinlianzf")
}
if listModel.payment == "4" {
payTypeImageView.image = UIImage(named: "ye_wjjzf")
}
priceLab.text = listModel.price
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}