CNMainView.swift
42 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
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
//
// CNMainView.swift
// metaCode
//
// Created by daojian on 2023/5/31.
// 认证--中间屏主视图
import Foundation
import UIKit
import Kingfisher
///旋转动画时间
let KTransformAnimationTime:CGFloat = 0.75;
///正面View
class CNFrontMainView : UIView{
///点击反转事件
var tapTransformAciton:closureBlock?
let delegate = UIApplication.shared.delegate as! AppDelegate
var standInfoSubTitleModel:MineStandInfoSubTitleModel?//17时弹窗的跳转model
var btnClickAuthType:CNLiveMineInputAuthType = .person
override init(frame: CGRect) {
super.init(frame: frame)
self.initUI()
let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapAction))
self.addGestureRecognizer(tap)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
///视图总容器
lazy var frontTotolContentView : UIView = {
let frontTotolContentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height ))
frontTotolContentView.backgroundColor = UIColor.white
frontTotolContentView.clipsToBounds = true
frontTotolContentView.layer.cornerRadius = 20
return frontTotolContentView
}()
///未认证-前置视图身份描述容器
lazy var frontDescContentView : UIView = {
let frontDescContentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height ))
frontDescContentView.backgroundColor = UIColor.white
frontDescContentView.clipsToBounds = true
frontDescContentView.layer.cornerRadius = 20
frontDescContentView.addSubview(self.textViewBgImgView)
textViewBgImgView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalToSuperview()
make.right.equalToSuperview()
make.bottom.equalToSuperview()
}
frontDescContentView.addSubview(self.agencyTipsLabel)
agencyTipsLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(-62-36-8)
make.width.equalTo(self.width-60)
}
frontDescContentView.addSubview(self.enterpriseTipsLabel)
enterpriseTipsLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalTo(self.agencyTipsLabel.snp.top).offset(-2)
make.width.equalTo(self.agencyTipsLabel.snp.width)
}
frontDescContentView.addSubview(self.addStandBtn)
addStandBtn.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(-62)
make.width.equalTo(150)
make.height.equalTo(36)
}
frontDescContentView.addSubview(self.personalStandBtn)
personalStandBtn.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-self.width/2)
make.bottom.equalTo(self.addStandBtn.snp.bottom)
make.width.equalTo(120)
make.height.equalTo(self.addStandBtn.snp.height)
}
frontDescContentView.addSubview(self.enterpriseStandBtn)
enterpriseStandBtn.snp.makeConstraints { make in
make.left.equalTo(self.personalStandBtn.snp.right)
make.bottom.equalTo(self.addStandBtn.snp.bottom)
make.width.equalTo(120)
make.height.equalTo(self.addStandBtn.snp.height)
}
frontDescContentView.addSubview(self.unStandBtnBgView)
unStandBtnBgView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(30)
make.bottom.equalTo(self.addStandBtn.snp.bottom)
make.width.equalTo(self.width-60)
make.height.equalTo(self.addStandBtn.snp.height)
}
frontDescContentView.addSubview(self.textView)
textView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(40)
make.left.equalToSuperview().offset(30)
make.right.equalToSuperview().offset(-30)
make.bottom.equalTo(enterpriseStandBtn.snp.top).offset(-30)
}
return frontDescContentView
}()
//未认证下 textview
lazy var textView: UITextView = {
let textView = UITextView.init()
textView.textColor = HexColor("#333333")
textView.font = UIFont.init(name: "PingFangSC-Medium", size: 13)
textView.textAlignment = .left
textView.contentMode = .scaleAspectFill
textView.sizeToFit()
textView.backgroundColor = HexColor("#004FE0", alpha: 0.1)
textView.clipsToBounds = true
textView.layer.cornerRadius = 14
textView.isUserInteractionEnabled = false
textView.backgroundColor = .clear
return textView
}()
///未认证-企业认证提示
lazy var enterpriseTipsLabel: UILabel = {
let enterpriseTipsLabel = UILabel.init(frame: CGRectMake(0, 0, 0, 0))
enterpriseTipsLabel.textColor = .white
enterpriseTipsLabel.textAlignment = .center
enterpriseTipsLabel.font = Font(9)
enterpriseTipsLabel.text = "企业认证适合企业、个体工商户申请"
enterpriseTipsLabel.adjustsFontSizeToFitWidth=true
enterpriseTipsLabel.isHidden = true
return enterpriseTipsLabel
}()
///未认证-机构认证提示
lazy var agencyTipsLabel: UILabel = {
let agencyTipsLabel = UILabel.init(frame: CGRectMake(0, 0, 0, 0))
agencyTipsLabel.textColor = .white
agencyTipsLabel.textAlignment = .center
agencyTipsLabel.font = Font(9)
agencyTipsLabel.text = "机构认证适合国家机构、社会组织、高校等申请"
agencyTipsLabel.adjustsFontSizeToFitWidth=true
agencyTipsLabel.isHidden = true
return agencyTipsLabel
}()
///未认证-店铺认证 按钮(一个按钮时)
lazy var addStandBtn: UIButton = {
let addStandBtn = UIButton(type: .custom)
addStandBtn.clipsToBounds = true
addStandBtn.layer.cornerRadius = 19.5
addStandBtn.backgroundColor = HexColor("#004FE0")
addStandBtn.setTitle("店铺认证", for: .normal)
addStandBtn.setTitleColor(.white, for: .normal)
addStandBtn.titleLabel?.font = UIFont.init(name: "PingFangSC-Medium", size: 14)
addStandBtn.addTarget(self, action: #selector(addStandBtnAction), for: .touchUpInside)
return addStandBtn
}()
///未认证-个人认证 按钮(两个按钮时第一个)
lazy var personalStandBtn: UIButton = {
let personalStandBtn = UIButton(type: .custom)
personalStandBtn.layer.cornerRadius = 19.5
personalStandBtn.layer.maskedCorners = [.layerMinXMinYCorner, .layerMinXMaxYCorner]
personalStandBtn.setTitle("个人认证", for: .normal)
personalStandBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
personalStandBtn.titleLabel?.font = UIFont.init(name: "PingFangSC-Medium", size: 14)
personalStandBtn.addTarget(self, action: #selector(personalStandBtnAction), for: .touchUpInside)
personalStandBtn.isHidden = true
return personalStandBtn
}()
///未认证-企业认证 按钮(两个按钮时第二个)
lazy var enterpriseStandBtn: UIButton = {
let enterpriseStandBtn = UIButton(type: .custom)
enterpriseStandBtn.layer.cornerRadius = 19.5
enterpriseStandBtn.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMaxXMaxYCorner]
enterpriseStandBtn.setTitle("企业认证", for: .normal)
enterpriseStandBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
enterpriseStandBtn.titleLabel?.font = UIFont.init(name: "PingFangSC-Medium", size: 14)
enterpriseStandBtn.addTarget(self, action: #selector(enterpriseStandBtnAction), for: .touchUpInside)
enterpriseStandBtn.isHidden = true
return enterpriseStandBtn
}()
///未认证-3个认证按钮的 第1个
lazy var StandBtn1: UIButton = {
//第1个按钮
let StandBtn1 = UIButton(type: .custom)
StandBtn1.setTitle("个人认证", for: .normal)
StandBtn1.setTitleColor(HexColor("#FFFFFF"), for: .normal)
StandBtn1.titleLabel?.font = UIFont.init(name: "PingFangSC-Medium", size: 14)
StandBtn1.addTarget(self, action: #selector(StandBtn1Action), for: .touchUpInside)
return StandBtn1
}()
///未认证-3个认证按钮的 第2个
lazy var StandBtn2: UIButton = {
//第2个按钮
let StandBtn2 = UIButton(type: .custom)
StandBtn2.setTitle("企业认证", for: .normal)
StandBtn2.setTitleColor(HexColor("#FFFFFF"), for: .normal)
StandBtn2.titleLabel?.font = UIFont.init(name: "PingFangSC-Medium", size: 14)
StandBtn2.addTarget(self, action: #selector(StandBtn2Action), for: .touchUpInside)
return StandBtn2
}()
///未认证-3个认证按钮的 第3个
lazy var StandBtn3: UIButton = {
//第3个按钮
let StandBtn3 = UIButton(type: .custom)
StandBtn3.setTitle("机构认证", for: .normal)
StandBtn3.setTitleColor(HexColor("#FFFFFF"), for: .normal)
StandBtn3.titleLabel?.font = UIFont.init(name: "PingFangSC-Medium", size: 14)
StandBtn3.addTarget(self, action: #selector(StandBtn3Action), for: .touchUpInside)
return StandBtn3
}()
lazy var line1View :UIView = {
let line1View = UIView(frame: CGRect(x: 0, y: 0, width: 0.5, height: 10))
line1View.backgroundColor = HexColor("#FEFFFF")
return line1View
}()
lazy var line2View :UIView = {
let line2View = UIView(frame: CGRect(x: 0, y: 0, width: 0.5, height: 10))
line2View.backgroundColor = HexColor("#FEFFFF")
return line2View
}()
//未认证-3个认证按钮背景图
lazy var unStandBtnBgView :UIView = {
let unStandBtnBgView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
unStandBtnBgView.layer.cornerRadius = 18
unStandBtnBgView.clipsToBounds = true
unStandBtnBgView.addSubview(self.StandBtn1)
StandBtn1.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalToSuperview()
make.width.equalTo((self.width-60)/3)
make.height.equalToSuperview()
}
unStandBtnBgView.addSubview(self.StandBtn2)
StandBtn2.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalToSuperview()
make.width.equalTo(self.StandBtn1.snp.width)
make.height.equalToSuperview()
}
unStandBtnBgView.addSubview(self.StandBtn3)
StandBtn3.snp.makeConstraints { make in
make.right.equalToSuperview()
make.top.equalToSuperview()
make.width.equalTo(self.StandBtn1.snp.width)
make.height.equalToSuperview()
}
unStandBtnBgView.addSubview(self.line1View)
line1View.snp.makeConstraints { make in
make.centerX.equalTo(self.StandBtn1.snp.right)
make.centerY.equalToSuperview()
make.width.equalTo(0.5)
make.height.equalTo(10)
}
unStandBtnBgView.addSubview(self.line2View)
line2View.snp.makeConstraints { make in
make.centerX.equalTo(self.StandBtn2.snp.right)
make.centerY.equalToSuperview()
make.width.equalTo(0.5)
make.height.equalTo(10)
}
return unStandBtnBgView
}()
/// 未认证-inputType17时弹窗背景图
lazy var alertBgImgView:UIImageView = {
let alertBgImgView:UIImageView = UIImageView()
alertBgImgView.tag = 20001
alertBgImgView.isUserInteractionEnabled = true
let ges = UITapGestureRecognizer(target: self, action: #selector(alertBgImgViewClickAction))
alertBgImgView.addGestureRecognizer(ges)
return alertBgImgView
}()
/// 未认证-inputType17时弹窗背景图蒙版
lazy var alertBgView:UIView = {
let alertBgView:UIView = UIView(frame: CGRect(x: 0, y: 0, width: KSreenWidth, height: KSreenHeight))
alertBgView.backgroundColor = HexColor("#000000")
alertBgView.alpha = 0.6
alertBgView.isUserInteractionEnabled = true
alertBgView.tag = 20000
let ges = UITapGestureRecognizer(target: self, action: #selector(alertBgViewClickAction))
alertBgView.addGestureRecognizer(ges)
return alertBgView
}()
//上滑更多Gif
lazy var upMoreGIF: UIImageView = {
let upMoreGIF = UIImageView()
upMoreGIF.frame = CGRect(x: self.width - 50, y: 0, width: 50, height: 30)
upMoreGIF.contentMode = .scaleAspectFit
return upMoreGIF
}()
//下滑更多Gif
lazy var downMoreGIF: UIImageView = {
let downMoreGIF = UIImageView()
downMoreGIF.frame = CGRect(x: self.width - 50, y: 0, width: 96, height: 30)
downMoreGIF.contentMode = .scaleAspectFit
return downMoreGIF
}()
///已认证-前置视图卡片容器
lazy var frontCardContentView : UIView = {
let frontCardContentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height ))
frontCardContentView.backgroundColor = UIColor.white
frontCardContentView.clipsToBounds = true
frontCardContentView.layer.cornerRadius = 20
frontCardContentView.addSubview(self.cardViewBgImgView)
cardViewBgImgView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalToSuperview()
make.right.equalToSuperview()
make.bottom.equalToSuperview()
}
frontCardContentView.addSubview(self.iDCardView)
iDCardView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(-62)
make.width.equalTo(262*KSreenWidth/375)
make.height.equalTo(0.52*262*KSreenWidth/375)
}
return frontCardContentView
}()
/// 已认证-身份卡片
lazy var iDCardView:CNIDCardView = {
let iDCardView:CNIDCardView = CNIDCardView(frame: CGRect(x: 0, y: 0, width: 262*KSreenWidth/375, height: 0.52*262*KSreenWidth/375))
return iDCardView
}()
/// 已认证-身份卡片
lazy var textViewBgImgView:UIImageView = {
let textViewBgImgView:UIImageView = UIImageView()
textViewBgImgView.clipsToBounds = true
textViewBgImgView.layer.cornerRadius = 20
return textViewBgImgView
}()
/// 已认证-卡片后的背景图
lazy var cardViewBgImgView:UIImageView = {
let cardViewBgImgView:UIImageView = UIImageView()
cardViewBgImgView.clipsToBounds = true
cardViewBgImgView.layer.cornerRadius = 20
return cardViewBgImgView
}()
//IDmodel
var _idModel : StandListModel?
var idModel : StandListModel? {
get{
_idModel
}
set{
_idModel = newValue
let auth = newValue!.auth
if(auth == true){
//已认证身份
//显示证件View
frontCardContentView.isHidden = false
self.addStandBtn.isHidden = true
self.iDCardView.idModel = newValue!
cardViewBgImgView.kf.setImage(with: URL(string: _idModel!.cardBackgroundImg), placeholder: UIImage(named: "homepage_cardBGImg"))
//隐藏textview
textView.isHidden = true
unStandBtnBgView.isHidden = true
if frontCardContentView.contains(self.upMoreGIF){
self.upMoreGIF.removeFromSuperview()
}
frontCardContentView.addSubview(self.upMoreGIF)
if frontCardContentView.contains(self.downMoreGIF){
self.downMoreGIF.removeFromSuperview()
}
frontCardContentView.addSubview(self.downMoreGIF)
self.setUpMoreGIFAndDownMoreGIF()
//上滑 下滑引导gif
upMoreGIF.kf.setImage(with: URL(string: newValue!.upGuideImg))
downMoreGIF.kf.setImage(with: URL(string: newValue!.downGuideImg))
if idModel?.id == 9{
//电商 ,隐藏上滑下滑gif
upMoreGIF.isHidden = true
downMoreGIF.isHidden = true
}else{
//非电商 ,显示上滑下滑gif
upMoreGIF.isHidden = false
downMoreGIF.isHidden = false
}
}else
{//未认证身份
textView.isHidden = false
if idModel?.id == 9{
//电商
//隐藏上滑下滑gif
self.agencyTipsLabel.isHidden = true
self.enterpriseTipsLabel.isHidden = true
upMoreGIF.isHidden = true
downMoreGIF.isHidden = true
self.addStandBtn.isHidden = false
self.personalStandBtn.isHidden = true
self.enterpriseStandBtn.isHidden = true
self.unStandBtnBgView.isHidden = true
self.addStandBtn.isUserInteractionEnabled = true
if idModel?.shopInfoModel?.state == "0" || idModel?.shopInfoModel?.state == "4"{
//0未申请 //4闭店
//未认证->店铺认证
self.addStandBtn.setTitle("店铺认证", for: .normal)
}else if idModel?.shopInfoModel?.state == "1"{
//开店
//已认证->显示卡片 不会走到这里
}else if idModel?.shopInfoModel?.state == "2"{
//申请中
//"资料审核中"
self.addStandBtn.setTitle("资料审核中", for: .normal)
self.addStandBtn.isUserInteractionEnabled = false
}else if idModel?.shopInfoModel?.state == "3"{
//已拒绝
//"重新修改提交"
addStandBtn.setTitle("重新修改提交", for: .normal)
}
}else{
//非电商
//显示上滑下滑gif
upMoreGIF.isHidden = false
downMoreGIF.isHidden = false
if idModel!.userAuth && idModel!.enterpriseAuth && !idModel!.agencyAuth{
self.addStandBtn.isHidden = true
self.personalStandBtn.isHidden = false
self.enterpriseStandBtn.isHidden = false
unStandBtnBgView.isHidden = true
//个人+企业
self.personalStandBtn.setTitle("个人认证", for: .normal)
self.enterpriseStandBtn.setTitle("企业认证", for: .normal)
}else if idModel!.userAuth && idModel!.agencyAuth && !idModel!.enterpriseAuth{
self.addStandBtn.isHidden = true
self.personalStandBtn.isHidden = false
self.enterpriseStandBtn.isHidden = false
unStandBtnBgView.isHidden = true
//个人+机构
self.personalStandBtn.setTitle("个人认证", for: .normal)
self.enterpriseStandBtn.setTitle("机构认证", for: .normal)
}else if idModel!.enterpriseAuth && idModel!.agencyAuth && !idModel!.userAuth{
self.addStandBtn.isHidden = true
self.personalStandBtn.isHidden = false
self.enterpriseStandBtn.isHidden = false
unStandBtnBgView.isHidden = true
//企业+机构
self.personalStandBtn.setTitle("企业认证", for: .normal)
self.enterpriseStandBtn.setTitle("机构认证", for: .normal)
}else if idModel!.userAuth && !idModel!.enterpriseAuth && !idModel!.agencyAuth{
//个人
self.addStandBtn.isHidden = false
self.addStandBtn.setTitle("个人认证", for: .normal)
self.personalStandBtn.isHidden = true
self.enterpriseStandBtn.isHidden = true
self.unStandBtnBgView.isHidden = true
}else if !idModel!.userAuth && idModel!.enterpriseAuth && !idModel!.agencyAuth{
//企业
self.addStandBtn.isHidden = false
self.addStandBtn.setTitle("企业认证", for: .normal)
self.personalStandBtn.isHidden = true
self.enterpriseStandBtn.isHidden = true
self.unStandBtnBgView.isHidden = true
}else if !idModel!.userAuth && !idModel!.enterpriseAuth && idModel!.agencyAuth{
//机构
self.addStandBtn.isHidden = false
self.addStandBtn.setTitle("机构认证", for: .normal)
self.personalStandBtn.isHidden = true
self.enterpriseStandBtn.isHidden = true
self.unStandBtnBgView.isHidden = true
}else if idModel!.userAuth && idModel!.enterpriseAuth && idModel!.agencyAuth{
//个人+企业+机构
self.addStandBtn.isHidden = true
self.personalStandBtn.isHidden = true
self.enterpriseStandBtn.isHidden = true
self.unStandBtnBgView.isHidden = false
self.setUnStandBtnBgViewLayer(startHex: newValue!.atPersonageColour, endHex: newValue!.backgroundColor)
}else if !idModel!.userAuth && !idModel!.enterpriseAuth && !idModel!.agencyAuth{
//无企业和个人
//不显示认证按钮
self.addStandBtn.isHidden = true
self.personalStandBtn.isHidden = true
self.enterpriseStandBtn.isHidden = true
self.unStandBtnBgView.isHidden = true
}
//有企业认证显示提示lbl
if idModel!.enterpriseAuth{
self.enterpriseTipsLabel.isHidden = false
self.enterpriseTipsLabel.textColor = HexColor(newValue!.tipsColour)
}else{
self.enterpriseTipsLabel.isHidden = true
}
//有机构认证显示提示lbl
if idModel!.agencyAuth{
self.agencyTipsLabel.isHidden = false
self.agencyTipsLabel.textColor = HexColor(newValue!.tipsColour)
}else{
self.agencyTipsLabel.isHidden = false
}
}
self.addStandBtn.backgroundColor = HexColor(newValue!.backgroundColor)
frontCardContentView.isHidden = true
//显示textview 添加身份
textView.text = newValue!.description
if frontDescContentView.contains(self.upMoreGIF){
self.upMoreGIF.removeFromSuperview()
}
frontDescContentView.addSubview(self.upMoreGIF)
if frontDescContentView.contains(self.downMoreGIF){
self.downMoreGIF.removeFromSuperview()
}
frontDescContentView.addSubview(self.downMoreGIF)
self.setUpMoreGIFAndDownMoreGIF()
//上滑 下滑引导gif
upMoreGIF.kf.setImage(with: URL(string: newValue!.upGuideImg))
downMoreGIF.kf.setImage(with: URL(string: newValue!.downGuideImg))
//个人认证,企业认证
personalStandBtn.backgroundColor = HexColor(newValue!.atPersonageColour)
enterpriseStandBtn.backgroundColor = HexColor(newValue!.backgroundColor)
textViewBgImgView.kf.setImage(with: URL(string: _idModel!.descBackgroundImg), placeholder: UIImage(named: "homepage_desc_bgImg"))
}
}
}
func setUpMoreGIFAndDownMoreGIF(){
upMoreGIF.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20)
make.centerX.equalToSuperview()
make.width.equalTo(96)
make.height.equalTo(30)
}
downMoreGIF.snp.makeConstraints { make in
make.bottom.equalToSuperview().offset(-19)
make.centerX.equalToSuperview()
make.width.equalTo(96)
make.height.equalTo(30)
}
}
let unStandBtnBgViewLayer = "unStandBtnBgViewLayer"
func setUnStandBtnBgViewLayer(startHex:String,endHex:String){
let payLayer = self.subLayer(name: unStandBtnBgViewLayer, viewLayer: self.unStandBtnBgView.layer)
if (payLayer != nil){
//已添加layer
payLayer?.removeFromSuperlayer()
}
//添加新layer
let gradient = CAGradientLayer()
gradient.frame = self.bounds
gradient.colors = [HexColor(startHex)!.cgColor, HexColor(endHex)!.cgColor]
gradient.locations = [0, 1]
gradient.startPoint = CGPoint(x: 0, y: 0.43)
gradient.endPoint = CGPoint(x: 0.43, y: 0.43)
gradient.name = unStandBtnBgViewLayer
self.unStandBtnBgView.layer.insertSublayer(gradient, at: 0)
self.unStandBtnBgView.backgroundColor = .clear
}
func subLayer(name:String,viewLayer:CALayer) -> CALayer?{
if let subLayer = viewLayer.sublayers?.first(where: { $0.name == name }) {
// 这里可以对获取到的子图层进行操作或者访问其属性等
return subLayer
} else {
// print("未找到指定名称的图层")
return nil
}
}
func initUI()
{
self.addSubview(self.frontTotolContentView)
self.frontTotolContentView.addSubview(self.frontDescContentView)
self.frontTotolContentView.addSubview(self.frontCardContentView)
self.makeConstraints()
}
func makeConstraints(){
}
// MARK: -按钮点击事件
@objc func tapAction(){
//翻转到反面
// tapTransformAciton!()
}
@objc func addStandBtnAction() {
//跳转到 1按钮时认证页面 电商 / 个人 / 企业 / 机构
if _idModel!.id == 9 {
self.pushStandVC(authType: .person)
}else{
var type: CNLiveMineInputAuthType = .person
if self.idModel!.userAuth{
type = .person
}else if self.idModel!.enterpriseAuth{
type = .enterprise
}else if self.idModel!.agencyAuth{
type = .agency
}
self.btnClickAuthType = type
self.getStandInfo(identityId:String(self.idModel!.id))
}
}
@objc func personalStandBtnAction() {
//跳转到 2个按钮时 第一个认证页面
//个人+企业 个人+机构 企业+机构
var type: CNLiveMineInputAuthType = .person
if self.idModel!.userAuth{
type = .person
}else if self.idModel!.enterpriseAuth{
type = .enterprise
}
self.btnClickAuthType = type
self.getStandInfo(identityId:String(self.idModel!.id))
}
@objc func enterpriseStandBtnAction() {
//跳转到 2个按钮时 第二个认证页面
//个人+企业 个人+机构 企业+机构
var type: CNLiveMineInputAuthType = .enterprise
if self.idModel!.enterpriseAuth{
type = .enterprise
}else if self.idModel!.agencyAuth{
type = .agency
}
self.btnClickAuthType = type
self.getStandInfo(identityId:String(self.idModel!.id))
}
@objc func StandBtn1Action() {
//跳转到 个人认证页面
self.btnClickAuthType = .person
self.getStandInfo(identityId:String(self.idModel!.id))
}
@objc func StandBtn2Action() {
//跳转到 企业认证页面
self.btnClickAuthType = .enterprise
self.getStandInfo(identityId:String(self.idModel!.id))
}
@objc func StandBtn3Action() {
//跳转到 机构认证页面
self.btnClickAuthType = .agency
self.getStandInfo(identityId:String(self.idModel!.id))
}
// MARK: - 点击弹窗,按类型跳转
@objc func alertBgImgViewClickAction() {
//点击弹窗,按类型跳转
if self.standInfoSubTitleModel?.jumpType == UpDownTypeH5{
let webVC = CNWebViewController()
webVC.url = URL(string: self.standInfoSubTitleModel?.jumpPath ?? "")
navigationViewController().pushViewController(webVC, animated: pushAnimated)
}else if self.standInfoSubTitleModel?.jumpType == UpDownTypePage{
let upSlideVC = CNUpSlideViewController()
upSlideVC.downPath = self.standInfoSubTitleModel?.jumpPath ?? ""
navigationViewController().pushViewController(upSlideVC, animated: pushAnimated)
}else if self.standInfoSubTitleModel?.jumpType == UpDownTypeShopDetail{
}else if self.standInfoSubTitleModel?.jumpType == UpDownTypeShopControlConsole{
let shopConsoleVC = CNLiveShopConsoleController()
navigationViewController().pushViewController(shopConsoleVC, animated: pushAnimated)
}else if self.standInfoSubTitleModel?.jumpType == UpDownTypeAuthAlertUp{
let customIndexView = ((self.superview as! CNMainView).superview as! UIScrollView).superview as! CNCustomIndexView
let baseScrollView = customIndexView.baseScrollView
baseScrollView.setContentOffset(CGPoint(x: 0, y: 0), animated: true)
let result:Dictionary = ["AuthVNumPage":1]
NotificationCenter.default.post(name: Notification.Name.AuthVNumPageManage.kAuthVNumPageChangedNotification, object: nil, userInfo: result)
currentViewController()?.tabBarController?.tabBar.isHidden = false
customIndexView.superScrollView?.isScrollEnabled = true
let time = DispatchTime.now() + 0.5
DispatchQueue.main.asyncAfter(deadline:time, execute: DispatchWorkItem(block: {
//下滑提醒View回到初始位置
customIndexView.downSlideViewRemindView.top = -((customIndexView.downSlideViewRemindView.height) + 50)
}))
}else if self.standInfoSubTitleModel?.jumpType == UpDownTypeAuthAlertDown{
let customIndexView = ((self.superview as! CNMainView).superview as! UIScrollView).superview as! CNCustomIndexView
let baseScrollView = customIndexView.baseScrollView
baseScrollView.setContentOffset(CGPoint(x: 0, y: (baseScrollView.height*2)), animated: true)
let result:Dictionary = ["AuthVNumPage":3]
NotificationCenter.default.post(name: Notification.Name.AuthVNumPageManage.kAuthVNumPageChangedNotification, object: nil, userInfo: result)
currentViewController()?.tabBarController?.tabBar.isHidden = false
customIndexView.superScrollView?.isScrollEnabled = true
let time = DispatchTime.now() + 0.5
DispatchQueue.main.asyncAfter(deadline:time, execute: DispatchWorkItem(block: {
//下滑提醒View回到初始位置
customIndexView.downSlideViewRemindView.top = -((customIndexView.downSlideViewRemindView.height) + 50)
}))
}
self.hiden17Alert()
}
@objc func alertBgViewClickAction() {
//点击蒙版隐藏view
self.hiden17Alert()
}
// MARK: - 通用跳转认证页面 isPersonOrEnterprise 1个人 2企业 3机构
func pushStandVC(authType:CNLiveMineInputAuthType){
//跳转到 个人认证&企业认证 页面
if _idModel!.id == 9 {
showLoading(message: "")
CNLiveMineViewModel.requestApplyShopInfo { [weak self] result, respStatue in
if respStatue == .success {
navigationViewController().pushViewController(CNLiveMineShopViewController.init(showType: .one, listModel: (self?.idModel)!, tempArray: []), animated: pushAnimated)
}
}
}else{
if authType == .person{
//个人
navigationViewController().pushViewController(CNLiveMineInputViewController.init(listModel: self._idModel!, authType: .person), animated: pushAnimated)
}else if authType == .enterprise{
//企业
navigationViewController().pushViewController(CNLiveMineInputViewController.init(listModel: self._idModel!, authType: .enterprise), animated: pushAnimated)
}else if authType == .agency{
//机构
navigationViewController().pushViewController(CNLiveMineInputViewController.init(listModel: self._idModel!, authType: .agency), animated: pushAnimated)
}
}
}
// MARK: - 获取身份信息是个人认证还是企业认证,机构认证
func getStandInfo(identityId:String){
showLoading(message: "")
CNLiveMineViewModel.requestsStandInfo(identityId: identityId, type: .effect, authType: .person) { [self] result, respStatue in
hiddenLoading()
if respStatue == .success{
let standInfoBaseModel = result as! MineStandInfoBaseModel
self.idModel?.standInfoBaseModel = standInfoBaseModel
if standInfoBaseModel.authInfos.first?.inputType == 17 && self.btnClickAuthType == .person{
//弹窗
self.show17Alert(index: 1)
}else if standInfoBaseModel.enterpriseAuthInfos.first?.inputType == 17 && self.btnClickAuthType == .enterprise{
self.show17Alert(index: 2)
}else if standInfoBaseModel.agencyAuthInfos.first?.inputType == 17 && self.btnClickAuthType == .agency{
self.show17Alert(index: 3)
}else{
//没有弹窗类型,跳转身份认证
self.pushStandVC(authType: self.btnClickAuthType)
}
}else{
//网络请求失败
showMessage(message: "请求失败")
}
}
}
//弹出弹窗
func show17Alert(index:Int){
//test
navigationViewController().pushViewController(CNLiveDigitalAuthController(), animated: true)
delegate.window?.addSubview(self.alertBgView)
delegate.window?.addSubview(self.alertBgImgView)
alertBgImgView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalToSuperview()
make.width.equalTo(KSreenWidth-80)
make.height.equalTo((KSreenWidth-80)*170.5/295)
}
var alertBgImgStr = ""
var subTitleModel:MineStandInfoSubTitleModel = MineStandInfoSubTitleModel()
if index == 1{
let subTitle = self.idModel?.standInfoBaseModel?.authInfos.first?.subTitle
subTitleModel = jsonToModel(subTitle ?? "", MineStandInfoSubTitleModel.self) as! MineStandInfoSubTitleModel
alertBgImgStr = subTitleModel.image ?? ""
}else if index == 2{
let subTitle = self.idModel?.standInfoBaseModel?.enterpriseAuthInfos.first?.subTitle
subTitleModel = jsonToModel(subTitle ?? "", MineStandInfoSubTitleModel.self) as! MineStandInfoSubTitleModel
alertBgImgStr = subTitleModel.image ?? ""
}else if index == 3{
let subTitle = self.idModel?.standInfoBaseModel?.agencyAuthInfos.first?.subTitle
subTitleModel = jsonToModel(subTitle ?? "", MineStandInfoSubTitleModel.self) as! MineStandInfoSubTitleModel
alertBgImgStr = subTitleModel.image ?? ""
}
self.alertBgImgView.kf.setImage(with: URL(string: alertBgImgStr))
self.standInfoSubTitleModel = subTitleModel
}
func hiden17Alert(){
delegate.window?.subviews.forEach({ view in
if view.tag >= 20000{
view.removeFromSuperview()
}
})
}
}
///反面View
class CNBackMainView : UIView{
///点击反转事件
var tapTransformAciton:closureBlock?
// MARK: - 懒加载
lazy var imageView:UIImageView = {
let tempImageView:UIImageView = UIImageView(frame: CGRect(x: 10, y: 10, width: self.width-20, height: self.height - 20))
tempImageView.image = UIImage(named: "")
return tempImageView
}()
lazy var contentView : UIView = {
let contentView = UIView.init(frame: CGRect(x: 0, y: 0, width: self.width, height: self.height))
contentView.backgroundColor = UIColor.white
contentView.clipsToBounds = true
contentView.layer.cornerRadius = 20
return contentView
}()
lazy var bottomBackBtn : UIButton = {
let bottomBackBtn = UIButton(type: .custom)
bottomBackBtn.frame = CGRectMake(0, 0, 90, 40)
bottomBackBtn.centerX = self.contentView.width/2
bottomBackBtn.bottom = self.contentView.height - 15
bottomBackBtn.setTitle("回到首页", for: .normal)
bottomBackBtn.setTitleColor(UIColor("#333333"), for: .normal)
bottomBackBtn.setImage(UIImage(named: "homePage_backBtn_icon"), for: .normal)
bottomBackBtn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8)
bottomBackBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15)
bottomBackBtn.addTarget(self, action: #selector(tapAction), for: .touchUpInside)
return bottomBackBtn
}()
//MARK: - 初始化
override init(frame: CGRect) {
super.init(frame: frame)
self.initUI()
let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tapAction))
self.addGestureRecognizer(tap)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func initUI()
{
// self.addSubview(self.imageView)
self.addSubview(self.contentView)
self.contentView.addSubview(self.bottomBackBtn)
}
//MARK: - 事件
@objc func tapAction(){
tapTransformAciton!()
}
}
///中间主VIew
class CNMainView : UIView{
override init(frame: CGRect) {
super.init(frame: frame)
self.initUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
//IDmodel
var _idModel : StandListModel?
var idModel : StandListModel? {
get{
_idModel
}
set{
self.frontView.idModel = newValue!
_idModel = newValue
}
}
///正面View
lazy var frontView:CNFrontMainView = {
let frontView = CNFrontMainView.init(frame: self.bounds)
frontView.tapTransformAciton = { [weak self] in
self?.transformToBacnkView();
}
return frontView
}()
///背面View
lazy var backView:CNBackMainView = {
let backView = CNBackMainView.init(frame: self.bounds)
backView.tapTransformAciton = { [weak self] in
self?.transformToFrontView()
}
return backView
}()
func initUI()
{
self.addSubview(self.frontView)
self.addSubview(self.backView)
self.backView.isHidden = true;
}
// MARK: -设置前置视图容器
func isHiddenMainFrontContentView(isHidden:Bool){
self.frontView.frontTotolContentView.isHidden = isHidden
}
// MARK: - 事件
///旋转到反面
func transformToBacnkView()
{
//旋转动画
UIView.animate(withDuration: KTransformAnimationTime) {
self.layer.transform = CATransform3DMakeRotation(.pi, 0, 1, 0);
}
//让背面也旋转180度
self.backView.layer.transform = CATransform3DMakeRotation(.pi, 0, 1, 0);
//在中间时刻进行正反面view的隐藏显示处理
let deadline = DispatchTime.now() - DispatchTimeInterval.milliseconds(50) + DispatchTimeInterval.milliseconds(Int (KTransformAnimationTime*1000/2))
DispatchQueue.main.asyncAfter(deadline: deadline, execute: DispatchWorkItem(block: {
UIView.animate(withDuration: 0.05) {
self.frontView.isHidden = true;
self.backView.isHidden = false;
}
}))
}
///旋转到正面
func transformToFrontView()
{
//旋转动画
UIView.animate(withDuration: KTransformAnimationTime) {
self.layer.transform = CATransform3DMakeRotation(0, 0, 1, 0);
} completion: { _ in
//背面恢复旋转
self.backView.layer.transform = CATransform3DMakeRotation(0, 0, 1, 0);
}
//在中间时刻进行正反面view的隐藏显示处理
let deadline = DispatchTime.now() - DispatchTimeInterval.milliseconds(50) + DispatchTimeInterval.milliseconds(Int (KTransformAnimationTime*1000/2))
DispatchQueue.main.asyncAfter(deadline: deadline, execute: DispatchWorkItem(block: {
UIView.animate(withDuration: 0.05) {
self.frontView.isHidden = false;
self.backView.isHidden = true;
}
}))
}
///缩放
open func scaledView(scale:CGFloat)
{
// self.frontView.imageView.transform = CGAffineTransformMakeScale(scale, scale);
}
}