CNLiveShopBodyExpressView.swift
7.51 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
//
// CNLiveShopBodyExpressView.swift
// metaCode
//
// Created by open on 2023/11/8.
//
import Foundation
class ShopBodyOrderExpressListTableViewCell: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegate{
lazy var logoImageView: UIImageView = {
let logoImageView = UIImageView.init()
logoImageView.backgroundColor = .white
return logoImageView
}()
lazy var expressName: UILabel = {
let expressName = UILabel.init()
expressName.textColor = HexColor("#333333")
expressName.font = medium_font(pointSize: 14)
return expressName
}()
lazy var expressNo: UILabel = {
let expressNo = UILabel.init()
expressNo.textColor = HexColor("#b4b4b4")
expressNo.font = regular_font(pointSize: 12)
return expressNo
}()
lazy var expressCopy: UIButton = {
let expressCopy = UIButton.init(type: .custom)
expressCopy.backgroundColor = .white
expressCopy.setTitle("复制单号", for: .normal)
expressCopy.layer.cornerRadius = 4
expressCopy.titleLabel?.font = medium_font(pointSize: 14)
expressCopy.setTitleColor(HexColor("#28c1c6"), for: .normal)
expressCopy.contentHorizontalAlignment = .center
expressCopy.layer.borderWidth = 1
expressCopy.layer.borderColor = HexColor("#28c1c6")?.cgColor
expressCopy.addTarget(self, action: #selector(actionClick), for: .touchUpInside)
return expressCopy
}()
lazy var expressTime: UILabel = {
let expressTime = UILabel.init()
expressTime.font = regular_font(pointSize: 12)
expressTime.textColor = HexColor("#333333")
return expressTime
}()
lazy var expressAddress: UILabel = {
let expressAddress = UILabel.init()
expressAddress.font = regular_font(pointSize: 12)
expressAddress.textColor = HexColor("#333333")
expressAddress.numberOfLines = 0
return expressAddress
}()
let kShopBodyOrderExpressListCollectionViewCellIdentifier = "kShopBodyOrderExpressListCollectionViewCellIdentifier"
lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout.init()
layout.itemSize = CGSizeMake(adapt_length(length: 65), adapt_length(length: 65))
layout.minimumLineSpacing = adapt_length(length: 5)
layout.scrollDirection = .horizontal
let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: layout)
collectionView.dataSource = self
collectionView.delegate = self
collectionView.backgroundColor = .white
collectionView.register(ShopBodyOrderExpressListCollectionViewCell.self, forCellWithReuseIdentifier: kShopBodyOrderExpressListCollectionViewCellIdentifier)
return collectionView
}()
lazy var totleExpress: UILabel = {
let totleExpress = UILabel.init()
totleExpress.textColor = HexColor("#9b9b9b")
totleExpress.font = regular_adapt_font(pointSize: 12)
return totleExpress
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .clear
selectionStyle = .none
addSubview(logoImageView)
logoImageView.snp.makeConstraints { make in
make.left.top.equalToSuperview().offset(adapt_length(length: 15))
make.size.equalTo(adapt_length(length: 39.68))
}
addSubview(expressName)
expressName.snp.makeConstraints { make in
make.top.equalTo(logoImageView.snp.top).offset(adapt_length(length: 0.5))
make.left.equalTo(logoImageView.snp.right).offset(adapt_length(length: 15))
}
addSubview(expressCopy)
expressCopy.snp.makeConstraints { make in
make.top.equalToSuperview().offset(adapt_length(length: 20))
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.width.equalTo(adapt_length(length: 77))
make.height.equalTo(adapt_length(length: 30))
}
addSubview(expressNo)
expressNo.snp.makeConstraints { make in
make.top.equalTo(expressName.snp.bottom).offset(adapt_length(length: 2.5))
make.left.equalTo(expressName.snp.left)
make.right.equalTo(expressCopy.snp.left).offset(adapt_length(length: 5))
}
addSubview(expressTime)
expressTime.snp.makeConstraints { make in
make.top.equalTo(logoImageView.snp.bottom).offset(adapt_length(length: 5))
make.left.equalTo(logoImageView.snp.left)
}
addSubview(expressAddress)
expressAddress.snp.makeConstraints { make in
make.top.equalTo(expressTime.snp.bottom).offset(adapt_length(length: 2))
make.left.equalTo(expressTime.snp.left)
make.right.equalToSuperview().offset(-adapt_length(length: 15))
}
addSubview(collectionView)
collectionView.snp.makeConstraints { make in
make.top.equalTo(expressAddress.snp.bottom).offset(adapt_length(length: 15))
make.left.equalToSuperview().offset(adapt_length(length: 15))
make.right.equalToSuperview().offset(-adapt_length(length: 15))
make.height.equalTo(adapt_length(length: 65))
}
addSubview(totleExpress)
totleExpress.snp.makeConstraints { make in
make.left.equalToSuperview().offset(adapt_length(length: 15))
make.bottom.equalToSuperview().offset(-adapt_length(length: 15))
}
}
var _listModel: ShopOrderExpressListModel!
func setupDataSource(listModel: ShopOrderExpressListModel) {
_listModel = listModel
}
@objc func actionClick(sender: UIButton) {
if !_listModel.express_num!.isNotBlank() {
return
}
let pasteboard = UIPasteboard.general
pasteboard.string = _listModel.express_num
showMessage(message: "复制成功")
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return _listModel.detail_goods.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
return UICollectionViewCell.init()
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class ShopBodyOrderExpressListCollectionViewCell: UICollectionViewCell {
lazy var goodsImage: UIImageView = {
let goodsImage = UIImageView.init()
goodsImage.contentMode = .scaleAspectFill
goodsImage.layer.cornerRadius = 6
return goodsImage
}()
lazy var expressNum: UILabel = {
let expressNum = UILabel.init()
expressNum.font = regular_adapt_font(pointSize: 9)
expressNum.textColor = HexColor("#ffffff")
expressNum.backgroundColor = HexColor("#000000")
expressNum.textAlignment
return expressNum
}()
override init(frame: CGRect) {
super.init(frame: frame)
contentView.backgroundColor = .white
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}