CNLiveShopBodyExpressView.swift
28.2 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
//
// CNLiveShopBodyExpressView.swift
// metaCode
//
// Created by open on 2023/11/8.
//
import Foundation
import EmptyDataSet_Swift
import Kingfisher
class ShopBodyOrderExpressListTableViewCell: UITableViewCell, UICollectionViewDataSource {
lazy var logoImageView: UIImageView = {
let logoImageView = UIImageView.init()
logoImageView.backgroundColor = .white
logoImageView.layer.cornerRadius = 4
logoImageView.layer.masksToBounds = true
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.backgroundColor = .white
collectionView.register(ShopBodyOrderExpressListCollectionViewCell.self, forCellWithReuseIdentifier: kShopBodyOrderExpressListCollectionViewCellIdentifier)
let tap = UITapGestureRecognizer.init(target: self, action: #selector(pushExpressDetail))
collectionView.addGestureRecognizer(tap)
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))
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var _listModel: ShopOrderExpressListModel!
func setupDataSource(listModel: ShopOrderExpressListModel) {
_listModel = listModel
logoImageView.kf.setImage(with: URL(string: listModel.simg!), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: adapt_length(length: 39.68), height: adapt_length(length: 39.68))))
expressName.text = listModel.express
expressName.sizeToFit()
expressNo.text = "快递编号:\(listModel.express_num ?? "0")"
totleExpress.text = "共\(listModel.detail_goods.count)件商品"
totleExpress.sizeToFit()
expressTime.text = listModel.expressNew.AcceptTime
expressTime.sizeToFit()
var address : String = ""
if listModel.expressNew.AcceptStation!.isNotBlank() {
address = listModel.expressNew.AcceptStation!
} else {
address = "包裹正在等待揽收"
}
expressAddress.text = address
expressAddress.sizeToFit()
collectionView.reloadData()
setNeedsLayout()
}
@objc func pushExpressDetail() {
currentViewController()?.navigationController?.pushViewController(CNLiveShopOrderExpressDetailViewController.init(orderId: _listModel.order_id! as NSString, expId: _listModel.id! as NSString, express_num: _listModel.express_num! as NSString, show_type: .orderExpress, progress: .Zero), animated: true)
}
@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 {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kShopBodyOrderExpressListCollectionViewCellIdentifier, for: indexPath) as? ShopBodyOrderExpressListCollectionViewCell else {
return ShopBodyOrderExpressListCollectionViewCell()
}
let goodsModel = _listModel.detail_goods[indexPath.row]
cell.goodsImage.kf.setImage(with: URL(string: goodsModel.simg!))
cell.expressNum.text = "\(goodsModel.num ?? 0)件"
return cell
}
}
class ShopBodyOrderExpressListCollectionViewCell: UICollectionViewCell {
lazy var goodsImage: UIImageView = {
let goodsImage = UIImageView.init()
goodsImage.contentMode = .scaleAspectFill
goodsImage.layer.cornerRadius = 6
goodsImage.layer.masksToBounds = true
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 = .center
expressNum.alpha = 0.5
expressNum.layer.cornerRadius = 6
return expressNum
}()
override init(frame: CGRect) {
super.init(frame: frame)
contentView.backgroundColor = .white
contentView.addSubview(goodsImage)
goodsImage.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
contentView.addSubview(expressNum)
expressNum.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview()
make.height.equalTo(adapt_length(length: 15))
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class ShopBodyOrderExpressDetailTableViewCell: UITableViewCell, UITextViewDelegate {
lazy var lineLabel: UILabel = {
let lineLabel = UILabel.init()
lineLabel.backgroundColor = HexColor("#EAEAEA")
return lineLabel
}()
lazy var pointImageView: UIImageView = {
let pointImageView = UIImageView.init()
return pointImageView
}()
lazy var titleTextView: UITextView = {
let titleTextView = UITextView.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth - adapt_length(length: 48) - adapt_length(length: 20), height: 0))
titleTextView.isEditable = false
titleTextView.isScrollEnabled = false
titleTextView.delegate = self
titleTextView.linkTextAttributes = [.foregroundColor:HexColor("#28c1c6")!]
return titleTextView
}()
lazy var timeLabel: UILabel = {
let timeLabel = UILabel.init()
timeLabel.textColor = HexColor("#b4b4b4")
timeLabel.font = regular_adapt_font(pointSize: 12)
return timeLabel
}()
lazy var bottomLine: UIImageView = {
let bottomLine = UIImageView.init()
bottomLine.backgroundColor = HexColor("#e4e4e4")
return bottomLine
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
contentView.backgroundColor = .white
selectionStyle = .none
addSubview(lineLabel)
addSubview(pointImageView)
addSubview(titleTextView)
addSubview(timeLabel)
addSubview(bottomLine)
}
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
if URL.absoluteString.contains("tel://") {
let phone = URL.absoluteString.components(separatedBy: "tel://").last
ConfigAlertManager.shared.presentAlert(title: phone!, message: "", actionTitles: ["取消","呼叫"]) { index in
if index == 1 {
UIApplication.shared.open(NSURL(string: phone!)! as URL)
}
}
} else {
let webVC = CNWebViewController.init()
webVC.url = URL
currentViewController()?.navigationController?.pushViewController(webVC, animated: true)
}
return false
}
var _dataModel: ShopOrderExpressDetailDateModel!
var _row: NSInteger!
var _isLastRow: Bool!
var _type: CNLiveShopOrderExpressDetailShowType!
var _address: NSString!
var _express_state: NSString!
func setupDataSource(dataModel: ShopOrderExpressDetailDateModel, row: NSInteger, isLastRow: Bool, type: CNLiveShopOrderExpressDetailShowType, address: NSString, express_state: NSString) {
_dataModel = dataModel
_row = row
_isLastRow = isLastRow
_type = type
_address = address
_express_state = express_state
if _type == .orderExpress || _type == .refundExpress {
let para = NSMutableParagraphStyle()
para.lineSpacing = adapt_length(length: 3)
if row == 0 {
let title = NSMutableAttributedString.init(string: "[收货地址]\(address)", attributes: [.font:medium_adapt_font(pointSize: 14),.foregroundColor:HexColor("#999999")!,.paragraphStyle:para.copy()])
titleTextView.attributedText = setHyperlinksAttrStr(attrStr: title)
timeLabel.text = ""
pointImageView.image = nil
pointImageView.backgroundColor = HexColor("#d2d2d2")
pointImageView.size = CGSizeMake(adapt_length(length: 5), adapt_length(length: 5))
pointImageView.layer.cornerRadius = adapt_length(length: 2.5)
pointImageView.layer.masksToBounds = true
} else if (_row == 1) {
let state = _express_state == "3" ? "已签收" : "运输中"
let title = NSMutableAttributedString.init(string: "\(state)\n\(dataModel.AcceptStation!)", attributes: [.font:medium_adapt_font(pointSize: 12),.foregroundColor:HexColor("#b4b4b4")!,.paragraphStyle:para.copy()])
para.lineSpacing = adapt_length(length: 5)
title.addAttributes([.font:medium_adapt_font(pointSize: 14),.foregroundColor:HexColor("#28c1c6")!,.paragraphStyle:para.copy()], range: NSMakeRange(0, state.count+1))
titleTextView.attributedText = setHyperlinksAttrStr(attrStr: title)
timeLabel.text = dataModel.AcceptTime
pointImageView.image = UIImage(named: "DS_express_current")
pointImageView.backgroundColor = .clear
pointImageView.size = CGSizeMake(adapt_length(length: 15), adapt_length(length: 15))
pointImageView.layer.cornerRadius = adapt_length(length: 7.5)
pointImageView.layer.masksToBounds = true
} else {
let title = NSMutableAttributedString.init(string: dataModel.AcceptStation!, attributes: [.font:medium_adapt_font(pointSize: 12),.foregroundColor:HexColor("#b4b4b4")!,.paragraphStyle:para.copy()])
titleTextView.attributedText = setHyperlinksAttrStr(attrStr: title)
timeLabel.text = dataModel.AcceptTime
pointImageView.image = nil
pointImageView.backgroundColor = backgroundColor
pointImageView.size = CGSize(width: adapt_length(length: 5), height: adapt_length(length: 5))
pointImageView.layer.cornerRadius = adapt_length(length: 2.5)
pointImageView.layer.masksToBounds = true
pointImageView.layer.borderColor = HexColor("#d2d2d2")?.cgColor
pointImageView.layer.borderWidth = adapt_length(length: 1)
}
} else {
titleTextView.font = medium_adapt_font(pointSize: 14)
if _row == 0 {
titleTextView.textColor = HexColor("#28c1c6")
pointImageView.image = UIImage(named: "DS_express_current")
pointImageView.backgroundColor = .clear
pointImageView.size = CGSizeMake(adapt_length(length: 15), adapt_length(length: 15))
pointImageView.layer.cornerRadius = adapt_length(length: 7.5)
pointImageView.layer.masksToBounds = false
} else {
titleTextView.textColor = HexColor("#999999")
pointImageView.image = UIImage(named: "DS_express_current")
pointImageView.backgroundColor = .clear
pointImageView.size = CGSizeMake(adapt_length(length: 15), adapt_length(length: 15))
pointImageView.layer.cornerRadius = adapt_length(length: 7.5)
pointImageView.layer.masksToBounds = true
pointImageView.layer.borderColor = HexColor("#d2d2d2")?.cgColor
pointImageView.layer.borderWidth = adapt_length(length: 1)
}
titleTextView.text = dataModel.AcceptStation
timeLabel.text = dataModel.AcceptTime
}
titleTextView.snp.removeConstraints()
pointImageView.snp.removeConstraints()
lineLabel.snp.removeConstraints()
titleTextView.sizeToFit()
setupLayout()
}
func setupLayout() {
if _row == 0 {
lineLabel.snp.makeConstraints { make in
make.centerX.equalTo(pointImageView)
make.top.equalTo(pointImageView.snp.bottom)
make.bottom.equalToSuperview()
make.width.equalTo(adapt_length(length: 1))
}
} else if _isLastRow {
lineLabel.snp.makeConstraints { make in
make.centerX.equalTo(pointImageView)
make.top.equalToSuperview()
make.bottom.equalTo(pointImageView.snp.top)
make.width.equalTo(adapt_length(length: 1))
}
}
else {
lineLabel.snp.makeConstraints { make in
make.centerX.equalTo(pointImageView)
make.top.bottom.equalToSuperview()
make.width.equalTo(adapt_length(length: 1))
}
}
if ((_type == .orderExpress || _type == .refundExpress) && _row == 1) || (_type == .byYourself && _row == 0) {
pointImageView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(adapt_length(length: 16))
make.left.equalTo(adapt_length(length: 20))
make.size.equalTo(pointImageView.size)
}
} else {
pointImageView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(adapt_length(length: 21))
make.left.equalTo(adapt_length(length: 25))
make.size.equalTo(pointImageView.size)
}
}
titleTextView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(adapt_length(length: 15))
make.left.equalToSuperview().offset(adapt_length(length: 48))
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.height.equalTo(titleTextView.size)
}
let top = timeLabel.text!.isNotBlank() ? adapt_length(length: 15) : 0
timeLabel.snp.makeConstraints { make in
make.top.equalTo(titleTextView.snp.bottom).offset(adapt_length(length: top))
make.left.equalTo(titleTextView.snp.left)
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.bottom.equalToSuperview().offset(-adapt_length(length: 15))
}
bottomLine.snp.makeConstraints { make in
make.left.equalTo(titleTextView.snp.left)
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.bottom.equalToSuperview()
make.height.equalTo(adapt_length(length: 1))
}
}
func setHyperlinksAttrStr(attrStr: NSMutableAttributedString) -> NSAttributedString {
do {
let dataDetector = try NSDataDetector(types: NSTextCheckingTypes(NSTextCheckingResult.CheckingType.phoneNumber.rawValue) | NSTextCheckingTypes(NSTextCheckingResult.CheckingType.link.rawValue))
let res = dataDetector.matches(in: attrStr.string, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, attrStr.string.count))
for checkingRes in res {
if (checkingRes.phoneNumber != nil) {
attrStr.addAttribute(.link, value: "tel://\(checkingRes.phoneNumber!)", range: checkingRes.range)
} else {
attrStr.addAttribute(.link, value: checkingRes.url!, range: checkingRes.range)
}
}
return attrStr.copy() as! NSAttributedString
} catch {
print(error)
}
return attrStr.copy() as! NSAttributedString
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
class ShopBodyOrderExpressDetailHeaderView: UIView {
lazy var iconImageView: UIImageView = {
let iconImageView = UIImageView.init(frame: CGRectMake(0, 0, adapt_length(length: 40), adapt_length(length: 40)))
iconImageView.contentMode = .scaleAspectFill
return iconImageView
}()
lazy var titleLabel: UILabel = {
let titleLabel = UILabel.init()
titleLabel.textColor = HexColor("#333333")
titleLabel.font = medium_adapt_font(pointSize: 14)
return titleLabel
}()
lazy var descLabel: UILabel = {
let descLabel = UILabel.init()
descLabel.textColor = HexColor("#b4b4b4")
descLabel.font = regular_adapt_font(pointSize: 12)
descLabel.isHidden = !(_show_type == .orderExpress || _show_type == .refundExpress)
return descLabel
}()
lazy var editBtn: UIButton = {
let editBtn = UIButton.init(type: .custom)
editBtn.size = CGSizeMake(adapt_length(length: 47), adapt_length(length: 30))
editBtn.setTitle("修改", for: .normal)
editBtn.setTitleColor(HexColor("#28c1c6"), for: .normal)
editBtn.titleLabel?.font = medium_adapt_font(pointSize: 14)
editBtn.layer.cornerRadius = adapt_length(length: 4)
editBtn.layer.masksToBounds = true
editBtn.layer.borderColor = HexColor("#28c1c6")?.cgColor
editBtn.layer.borderWidth = adapt_length(length: 1)
editBtn.isHidden = !(_show_type == .orderExpress || _show_type == .refundExpress)
editBtn.addTarget(self, action: #selector(editBtnClick), for: .touchUpInside)
return editBtn
}()
lazy var enCopyBtn: UIButton = {
let enCopyBtn = UIButton.init(type: .custom)
enCopyBtn.size = CGSizeMake(adapt_length(length: 77), adapt_length(length: 30))
enCopyBtn.setTitle("复制单号", for: .normal)
enCopyBtn.setTitleColor(HexColor("#28c1c6"), for: .normal)
enCopyBtn.titleLabel?.font = medium_adapt_font(pointSize: 14)
enCopyBtn.layer.cornerRadius = adapt_length(length: 4)
enCopyBtn.layer.masksToBounds = true
enCopyBtn.layer.borderColor = HexColor("#28c1c6")?.cgColor
enCopyBtn.layer.borderWidth = adapt_length(length: 1)
enCopyBtn.isHidden = !(_show_type == .orderExpress || _show_type == .refundExpress)
enCopyBtn.addTarget(self, action: #selector(enCopyBtnClick), for: .touchUpInside)
return enCopyBtn
}()
lazy var lineLabel: UILabel = {
let lineLabel = UILabel.init()
lineLabel.backgroundColor = HexColor("#f6f6f6")
return lineLabel
}()
// 自取进度 (自取有用)
var _TBY_progress: CNLiveShopOrderExpressDetailYBYProgress!
var TBY_progress: CNLiveShopOrderExpressDetailYBYProgress? {
set {
_TBY_progress = newValue
if _TBY_progress == .Zero {
titleLabel.text = "备货完成"
} else {
titleLabel.text = "自取完毕"
}
}
get {
_TBY_progress
}
}
// 快递公司信息 (快递有用)
var _expressModel: ShopOrderExpressModel!
var expressModel: ShopOrderExpressModel? {
set {
_expressModel = newValue
iconImageView.kf.setImage(with: URL(string: _expressModel.simg!), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: adapt_length(length: 40), height: adapt_length(length: 40))))
titleLabel.text = _expressModel.com
}
get {
_expressModel
}
}
// 快递编号 (快递有用)
var _express_num: String!
var express_num: String {
set {
_express_num = newValue
descLabel.text = "快递编号:\(_express_num ?? "")"
}
get {
_express_num
}
}
var _orderId: String! // 快递订单号 (快递有用)
var _expId: String! // 发货单id (多物流快递有用)
var _show_type: CNLiveShopOrderExpressDetailShowType!
init(frame: CGRect,show_type: CNLiveShopOrderExpressDetailShowType) {
_show_type = show_type
super.init(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: (_show_type == .orderExpress || _show_type == .refundExpress) ? adapt_length(length: 80) : adapt_length(length: 58)))
backgroundColor = UIColor.white
addSubview(iconImageView)
iconImageView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(adapt_length(length: 20))
make.top.equalToSuperview().offset(adapt_length(length: 15))
make.size.equalTo(adapt_length(length: 40))
}
addSubview(enCopyBtn)
enCopyBtn.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-adapt_length(length: 20))
make.top.equalToSuperview().offset(adapt_length(length: 6))
make.size.equalTo(enCopyBtn.size)
}
addSubview(editBtn)
editBtn.snp.makeConstraints { make in
make.right.equalTo(enCopyBtn.snp.left).offset(-adapt_length(length: 10))
make.centerY.equalTo(enCopyBtn)
make.size.equalTo(editBtn.size)
}
addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(iconImageView.snp.right).offset(adapt_length(length: 16))
if _show_type == .orderExpress || _show_type == .refundExpress {
make.right.equalTo(enCopyBtn.snp.left).offset(-adapt_length(length: 16))
make.top.equalToSuperview().offset(adapt_length(length: 16))
make.height.equalTo(adapt_length(length: 17))
} else {
make.centerY.equalTo(iconImageView)
make.right.equalToSuperview().offset(-adapt_length(length: 16))
}
}
addSubview(descLabel)
descLabel.snp.makeConstraints { make in
make.left.equalTo(iconImageView.snp.right).offset(adapt_length(length: 16))
if _show_type == .orderExpress || _show_type == .refundExpress {
make.right.equalTo(enCopyBtn.snp.left).offset(-adapt_length(length: 16))
} else {
make.right.equalToSuperview().offset(-adapt_length(length: 16))
}
make.top.equalTo(titleLabel.snp.bottom).offset(adapt_length(length: 10))
make.height.equalTo(adapt_length(length: 17))
}
addSubview(lineLabel)
lineLabel.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(adapt_length(length: 10))
}
}
@objc func editBtnClick(sender: UIButton) {
if _show_type == .orderExpress || _show_type == .refundExpress {
let vc = CNLiveShopOrderExpressViewController.init(orderId: _orderId! as NSString, isExp: (_expId != nil), goods_arr: [])
vc.expressModel = _expressModel
vc.express_num = _express_num
vc.expId = _expId
vc.hiddenShop = true
currentViewController()?.navigationController?.pushViewController(vc, animated: true)
}
}
@objc func enCopyBtnClick(sender: UIButton) {
if !_express_num.isNotBlank() {
return
}
let pasteboard = UIPasteboard.general
pasteboard.string = _express_num
showMessage(message: "复制成功")
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}