Commit 5e494916 authored by David黄金龙's avatar David黄金龙

Merge commit 'efbbafcd' into davidhuang

* commit 'efbbafcd':
  图片选择器弹窗
  // 选择器
  暂存
  // 护照选择器
  地址选择器
  时间选择器
  // 家庭成员信息model 更新
parents ded1848f efbbafcd
...@@ -51,6 +51,14 @@ ...@@ -51,6 +51,14 @@
0468D44F2B634E8B00CFB916 /* YHMainApplicantInformationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D44E2B634E8A00CFB916 /* YHMainApplicantInformationViewModel.swift */; }; 0468D44F2B634E8B00CFB916 /* YHMainApplicantInformationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D44E2B634E8A00CFB916 /* YHMainApplicantInformationViewModel.swift */; };
0468D4512B67721700CFB916 /* YHMainInformationCardTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4502B67721700CFB916 /* YHMainInformationCardTableViewCell.swift */; }; 0468D4512B67721700CFB916 /* YHMainInformationCardTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4502B67721700CFB916 /* YHMainInformationCardTableViewCell.swift */; };
0468D4532B6782BE00CFB916 /* YHCardExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4522B6782BE00CFB916 /* YHCardExampleView.swift */; }; 0468D4532B6782BE00CFB916 /* YHCardExampleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4522B6782BE00CFB916 /* YHCardExampleView.swift */; };
0468D4552B6889A500CFB916 /* YHDatePickView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4542B6889A500CFB916 /* YHDatePickView.swift */; };
0468D4772B68A08600CFB916 /* area.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0468D4712B68A08600CFB916 /* area.plist */; };
0468D4782B68A08600CFB916 /* YHAddressModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4722B68A08600CFB916 /* YHAddressModel.swift */; };
0468D4792B68A08600CFB916 /* YHAddressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4732B68A08600CFB916 /* YHAddressViewController.swift */; };
0468D47A2B68A08600CFB916 /* YHAddressPickViewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4742B68A08600CFB916 /* YHAddressPickViewTableViewCell.swift */; };
0468D47B2B68A08600CFB916 /* YHAddressPresentAnimated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4752B68A08600CFB916 /* YHAddressPresentAnimated.swift */; };
0468D47C2B68A08600CFB916 /* YHAddressPickView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4762B68A08600CFB916 /* YHAddressPickView.swift */; };
0468D47E2B68CEA200CFB916 /* YHImagePickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D47D2B68CEA200CFB916 /* YHImagePickerView.swift */; };
04808C062B4686510056D53C /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04808C042B4686510056D53C /* ATAuthSDK.bundle */; }; 04808C062B4686510056D53C /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04808C042B4686510056D53C /* ATAuthSDK.bundle */; };
04808C082B4686C10056D53C /* ATAuthSDK_D.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04808C032B4686510056D53C /* ATAuthSDK_D.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 04808C082B4686C10056D53C /* ATAuthSDK_D.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04808C032B4686510056D53C /* ATAuthSDK_D.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; }; 049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; };
...@@ -247,6 +255,14 @@ ...@@ -247,6 +255,14 @@
0468D44E2B634E8A00CFB916 /* YHMainApplicantInformationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMainApplicantInformationViewModel.swift; sourceTree = "<group>"; }; 0468D44E2B634E8A00CFB916 /* YHMainApplicantInformationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMainApplicantInformationViewModel.swift; sourceTree = "<group>"; };
0468D4502B67721700CFB916 /* YHMainInformationCardTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMainInformationCardTableViewCell.swift; sourceTree = "<group>"; }; 0468D4502B67721700CFB916 /* YHMainInformationCardTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMainInformationCardTableViewCell.swift; sourceTree = "<group>"; };
0468D4522B6782BE00CFB916 /* YHCardExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardExampleView.swift; sourceTree = "<group>"; }; 0468D4522B6782BE00CFB916 /* YHCardExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCardExampleView.swift; sourceTree = "<group>"; };
0468D4542B6889A500CFB916 /* YHDatePickView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHDatePickView.swift; sourceTree = "<group>"; };
0468D4712B68A08600CFB916 /* area.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = area.plist; sourceTree = "<group>"; };
0468D4722B68A08600CFB916 /* YHAddressModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHAddressModel.swift; sourceTree = "<group>"; };
0468D4732B68A08600CFB916 /* YHAddressViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHAddressViewController.swift; sourceTree = "<group>"; };
0468D4742B68A08600CFB916 /* YHAddressPickViewTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHAddressPickViewTableViewCell.swift; sourceTree = "<group>"; };
0468D4752B68A08600CFB916 /* YHAddressPresentAnimated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHAddressPresentAnimated.swift; sourceTree = "<group>"; };
0468D4762B68A08600CFB916 /* YHAddressPickView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHAddressPickView.swift; sourceTree = "<group>"; };
0468D47D2B68CEA200CFB916 /* YHImagePickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHImagePickerView.swift; sourceTree = "<group>"; };
04808C032B4686510056D53C /* ATAuthSDK_D.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ATAuthSDK_D.framework; sourceTree = "<group>"; }; 04808C032B4686510056D53C /* ATAuthSDK_D.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ATAuthSDK_D.framework; sourceTree = "<group>"; };
04808C042B4686510056D53C /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = ATAuthSDK.bundle; sourceTree = "<group>"; }; 04808C042B4686510056D53C /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = ATAuthSDK.bundle; sourceTree = "<group>"; };
049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; }; 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; };
...@@ -534,12 +550,15 @@ ...@@ -534,12 +550,15 @@
0468D4402B61F6C400CFB916 /* V */ = { 0468D4402B61F6C400CFB916 /* V */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
0468D4702B68A08600CFB916 /* YHAddressPicker */,
0468D4442B62064700CFB916 /* YHStepView.swift */, 0468D4442B62064700CFB916 /* YHStepView.swift */,
0468D4462B624AF000CFB916 /* YHBottomNextView.swift */, 0468D4462B624AF000CFB916 /* YHBottomNextView.swift */,
0468D4482B6258A900CFB916 /* YHItemView.swift */, 0468D4482B6258A900CFB916 /* YHItemView.swift */,
0468D44C2B62643700CFB916 /* YHMainInformationTableViewCell.swift */, 0468D44C2B62643700CFB916 /* YHMainInformationTableViewCell.swift */,
0468D4502B67721700CFB916 /* YHMainInformationCardTableViewCell.swift */, 0468D4502B67721700CFB916 /* YHMainInformationCardTableViewCell.swift */,
0468D4522B6782BE00CFB916 /* YHCardExampleView.swift */, 0468D4522B6782BE00CFB916 /* YHCardExampleView.swift */,
0468D4542B6889A500CFB916 /* YHDatePickView.swift */,
0468D47D2B68CEA200CFB916 /* YHImagePickerView.swift */,
); );
path = V; path = V;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -552,6 +571,19 @@ ...@@ -552,6 +571,19 @@
path = VM; path = VM;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
0468D4702B68A08600CFB916 /* YHAddressPicker */ = {
isa = PBXGroup;
children = (
0468D4712B68A08600CFB916 /* area.plist */,
0468D4722B68A08600CFB916 /* YHAddressModel.swift */,
0468D4732B68A08600CFB916 /* YHAddressViewController.swift */,
0468D4742B68A08600CFB916 /* YHAddressPickViewTableViewCell.swift */,
0468D4752B68A08600CFB916 /* YHAddressPresentAnimated.swift */,
0468D4762B68A08600CFB916 /* YHAddressPickView.swift */,
);
path = YHAddressPicker;
sourceTree = "<group>";
};
04808C022B4686510056D53C /* Frameworks */ = { 04808C022B4686510056D53C /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1155,6 +1187,7 @@ ...@@ -1155,6 +1187,7 @@
04808C062B4686510056D53C /* ATAuthSDK.bundle in Resources */, 04808C062B4686510056D53C /* ATAuthSDK.bundle in Resources */,
A5C5B2EE2B4F9B8800A7C5D1 /* Localizable.xcstrings in Resources */, A5C5B2EE2B4F9B8800A7C5D1 /* Localizable.xcstrings in Resources */,
A58951C52B398D1000225C19 /* Launch Screen.storyboard in Resources */, A58951C52B398D1000225C19 /* Launch Screen.storyboard in Resources */,
0468D4772B68A08600CFB916 /* area.plist in Resources */,
A51044182B493675006B60BB /* README.md in Resources */, A51044182B493675006B60BB /* README.md in Resources */,
A5573EDB2B317C0000D98EC0 /* Assets.xcassets in Resources */, A5573EDB2B317C0000D98EC0 /* Assets.xcassets in Resources */,
); );
...@@ -1265,6 +1298,7 @@ ...@@ -1265,6 +1298,7 @@
A5FD63C52B637EE000D1D9DA /* YHSubmitAllInfoCheckView.swift in Sources */, A5FD63C52B637EE000D1D9DA /* YHSubmitAllInfoCheckView.swift in Sources */,
A5ACE9442B4564F7002C94D2 /* Array+Extension.swift in Sources */, A5ACE9442B4564F7002C94D2 /* Array+Extension.swift in Sources */,
0468D4282B50D4AF00CFB916 /* YHPrivacyAlertView.swift in Sources */, 0468D4282B50D4AF00CFB916 /* YHPrivacyAlertView.swift in Sources */,
0468D47A2B68A08600CFB916 /* YHAddressPickViewTableViewCell.swift in Sources */,
0468D4342B56587B00CFB916 /* YHOSSManager.swift in Sources */, 0468D4342B56587B00CFB916 /* YHOSSManager.swift in Sources */,
A5C382D12B5FAAB300C5E65C /* YHContactItemModel.swift in Sources */, A5C382D12B5FAAB300C5E65C /* YHContactItemModel.swift in Sources */,
A5FD63EF2B68902400D1D9DA /* YHPersonInfoCellView.swift in Sources */, A5FD63EF2B68902400D1D9DA /* YHPersonInfoCellView.swift in Sources */,
...@@ -1286,6 +1320,7 @@ ...@@ -1286,6 +1320,7 @@
A5F78C822B68F39600EEA170 /* YHPersonInfoCommonCell.swift in Sources */, A5F78C822B68F39600EEA170 /* YHPersonInfoCommonCell.swift in Sources */,
A5ACE94B2B4564F7002C94D2 /* BsHUDRotatingImageView.swift in Sources */, A5ACE94B2B4564F7002C94D2 /* BsHUDRotatingImageView.swift in Sources */,
041B52DD2B60A889007EBCEB /* YHTest.swift in Sources */, 041B52DD2B60A889007EBCEB /* YHTest.swift in Sources */,
0468D47E2B68CEA200CFB916 /* YHImagePickerView.swift in Sources */,
A5ACE94F2B4564F7002C94D2 /* YhOverlayView.swift in Sources */, A5ACE94F2B4564F7002C94D2 /* YhOverlayView.swift in Sources */,
A53026902B4E6F2700F35102 /* YHHomeCustomCell.swift in Sources */, A53026902B4E6F2700F35102 /* YHHomeCustomCell.swift in Sources */,
0468D44F2B634E8B00CFB916 /* YHMainApplicantInformationViewModel.swift in Sources */, 0468D44F2B634E8B00CFB916 /* YHMainApplicantInformationViewModel.swift in Sources */,
...@@ -1298,6 +1333,7 @@ ...@@ -1298,6 +1333,7 @@
0468D4432B61F76800CFB916 /* YHMainApplicantInformationViewController.swift in Sources */, 0468D4432B61F76800CFB916 /* YHMainApplicantInformationViewController.swift in Sources */,
0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */, 0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */,
A5C5B32D2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift in Sources */, A5C5B32D2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift in Sources */,
0468D47C2B68A08600CFB916 /* YHAddressPickView.swift in Sources */,
A5FD63D82B6603A500D1D9DA /* YHScoreResultView.swift in Sources */, A5FD63D82B6603A500D1D9DA /* YHScoreResultView.swift in Sources */,
A5ACE9342B4564F7002C94D2 /* YHAllApiName.swift in Sources */, A5ACE9342B4564F7002C94D2 /* YHAllApiName.swift in Sources */,
A5ACE9502B4564F7002C94D2 /* YhCacheTool.swift in Sources */, A5ACE9502B4564F7002C94D2 /* YhCacheTool.swift in Sources */,
...@@ -1349,7 +1385,9 @@ ...@@ -1349,7 +1385,9 @@
042FBBBD2B63519C00F9DE23 /* YHFormItemSelectSheetCell.swift in Sources */, 042FBBBD2B63519C00F9DE23 /* YHFormItemSelectSheetCell.swift in Sources */,
A5FD63C32B63438A00D1D9DA /* YHContactMainItemStatusModel.swift in Sources */, A5FD63C32B63438A00D1D9DA /* YHContactMainItemStatusModel.swift in Sources */,
041B52982B5E8EA0007EBCEB /* YHFamilyMemberFormVC.swift in Sources */, 041B52982B5E8EA0007EBCEB /* YHFamilyMemberFormVC.swift in Sources */,
0468D47B2B68A08600CFB916 /* YHAddressPresentAnimated.swift in Sources */,
A5C382CF2B5F9A9100C5E65C /* YHServiceCenterMainViewModel.swift in Sources */, A5C382CF2B5F9A9100C5E65C /* YHServiceCenterMainViewModel.swift in Sources */,
0468D4782B68A08600CFB916 /* YHAddressModel.swift in Sources */,
A5C5B2EA2B4ECA4D00A7C5D1 /* YHDavidModel0.swift in Sources */, A5C5B2EA2B4ECA4D00A7C5D1 /* YHDavidModel0.swift in Sources */,
A5ACE9572B4564F7002C94D2 /* YHBasicContentView.swift in Sources */, A5ACE9572B4564F7002C94D2 /* YHBasicContentView.swift in Sources */,
042FBBC92B64DC8900F9DE23 /* YHFormItemExpireDateCell.swift in Sources */, 042FBBC92B64DC8900F9DE23 /* YHFormItemExpireDateCell.swift in Sources */,
...@@ -1359,11 +1397,13 @@ ...@@ -1359,11 +1397,13 @@
A5ACE9582B4564F7002C94D2 /* YHNoDataTipView.swift in Sources */, A5ACE9582B4564F7002C94D2 /* YHNoDataTipView.swift in Sources */,
042FBBBB2B62806D00F9DE23 /* YHCertificateViewController.swift in Sources */, 042FBBBB2B62806D00F9DE23 /* YHCertificateViewController.swift in Sources */,
042FBBC72B64CFBF00F9DE23 /* YHChildInitialInfoVC.swift in Sources */, 042FBBC72B64CFBF00F9DE23 /* YHChildInitialInfoVC.swift in Sources */,
0468D4792B68A08600CFB916 /* YHAddressViewController.swift in Sources */,
A5ACE9562B4564F7002C94D2 /* YHBouncesContentView.swift in Sources */, A5ACE9562B4564F7002C94D2 /* YHBouncesContentView.swift in Sources */,
042FBBCB2B65058000F9DE23 /* YHChildBasicInfoVC.swift in Sources */, 042FBBCB2B65058000F9DE23 /* YHChildBasicInfoVC.swift in Sources */,
A5ACE9302B4564F7002C94D2 /* Algorithm.swift in Sources */, A5ACE9302B4564F7002C94D2 /* Algorithm.swift in Sources */,
A5C5B32B2B57D17600A7C5D1 /* YHDavidCell5.swift in Sources */, A5C5B32B2B57D17600A7C5D1 /* YHDavidCell5.swift in Sources */,
A5ACE92D2B4564F7002C94D2 /* YHLoginPrivacyView.swift in Sources */, A5ACE92D2B4564F7002C94D2 /* YHLoginPrivacyView.swift in Sources */,
0468D4552B6889A500CFB916 /* YHDatePickView.swift in Sources */,
A5C5B3272B57C8D500A7C5D1 /* YHDavidCell2.swift in Sources */, A5C5B3272B57C8D500A7C5D1 /* YHDavidCell2.swift in Sources */,
A5FD63D62B65FCA400D1D9DA /* YHScoreTitleView.swift in Sources */, A5FD63D62B65FCA400D1D9DA /* YHScoreTitleView.swift in Sources */,
A5FD63DA2B66060800D1D9DA /* YHScoreOptionsView.swift in Sources */, A5FD63DA2B66060800D1D9DA /* YHScoreOptionsView.swift in Sources */,
......
...@@ -141,8 +141,8 @@ extension YHServiceCenterMainViewController : UITableViewDelegate,UITableViewDat ...@@ -141,8 +141,8 @@ extension YHServiceCenterMainViewController : UITableViewDelegate,UITableViewDat
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true) tableView.deselectRow(at: indexPath, animated: true)
printLog("点击了 tableView Cell \(indexPath.row)") printLog("点击了 tableView Cell \(indexPath.row)")
// let vc = YHServiceCenterSecondViewController() let vc = YHServiceCenterSecondViewController()
let vc = YHPersonInformMainViewController() //for test hjl // let vc = YHPersonInformMainViewController() //for test hjl
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHBrotherInfoVC: YHBaseViewController { class YHBrotherInfoVC: YHBaseViewController {
var brotherInfo:YHBrother? var brotherInfo:YHFamilyMember?
var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHCertificateViewController: YHBaseViewController { class YHCertificateViewController: YHBaseViewController {
var spouse:YHSpouse? var spouse:YHFamilyMember?
var cardInfo: YHCNIdentityCard? var cardInfo: YHCNIdentityCard?
...@@ -42,7 +42,7 @@ class YHCertificateViewController: YHBaseViewController { ...@@ -42,7 +42,7 @@ class YHCertificateViewController: YHBaseViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
gk_navTitle = "配偶信息填写".local gk_navTitle = "证件信息填写".local
createUI() createUI()
loadCertificateInfo() loadCertificateInfo()
} }
...@@ -187,6 +187,31 @@ extension YHCertificateViewController : UITableViewDelegate, UITableViewDataSour ...@@ -187,6 +187,31 @@ extension YHCertificateViewController : UITableViewDelegate, UITableViewDataSour
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.section >= items.count { return }
let arr:[YHFormItemProtocol] = items[indexPath.section]
if indexPath.row >= arr.count || indexPath.row < 0 { return }
let item = arr[indexPath.row]
if item is YHFormTitleItem {
return
}
if item is YHFormDetailItem {
let detailItem = item as! YHFormDetailItem
if detailItem.type == .certificateValidDate ||
detailItem.type == .certificateSignDate { // 届满日期 签发日期
YHDatePickView.show(type: .yyyymmdd) { date in
let arr = date.components(separatedBy: YHDatePickView.separator)
// [yyyy, mm, dd] eg ["2024", "01", "20"]
print(date)
}
}
return
}
let vc = YHSpouseBasicInfoVC() let vc = YHSpouseBasicInfoVC()
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHChildBasicInfoVC: YHBaseViewController { class YHChildBasicInfoVC: YHBaseViewController {
var child:YHChild? var child:YHFamilyMember?
var cardInfo: YHCNIdentityCard? var cardInfo: YHCNIdentityCard?
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHChildInitialInfoVC: YHBaseViewController { class YHChildInitialInfoVC: YHBaseViewController {
var child:YHChild? var child:YHFamilyMember?
lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
......
...@@ -17,7 +17,7 @@ enum YHFormTitleItemEditType:Int { ...@@ -17,7 +17,7 @@ enum YHFormTitleItemEditType:Int {
class YHFamilyMemberFormVC: YHBaseViewController { class YHFamilyMemberFormVC: YHBaseViewController {
var familyMemberInfo: YHFamilyMemberInfo? var familyMemberInfo: YHFamilyMemberGroupInfo?
var isChildsEditMode: YHFormTitleItemEditType = .none var isChildsEditMode: YHFormTitleItemEditType = .none
var isBrothersEditMode: YHFormTitleItemEditType = .none var isBrothersEditMode: YHFormTitleItemEditType = .none
...@@ -141,7 +141,7 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -141,7 +141,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
"is_handled": 0, "is_handled": 0,
"finish_follow": 0, "finish_follow": 0,
"step": 0, "step": 0,
"not_fill_num": -1, "not_fill_num": 7,
"certificates": [], "certificates": [],
"is_live_oversea_year": 0 "is_live_oversea_year": 0
], ],
...@@ -180,7 +180,7 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -180,7 +180,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
"is_handled": 0, "is_handled": 0,
"finish_follow": 0, "finish_follow": 0,
"step": 0, "step": 0,
"not_fill_num": -1, "not_fill_num": 5,
"certificates": [], "certificates": [],
"is_live_oversea_year": 0 "is_live_oversea_year": 0
], ],
...@@ -269,7 +269,7 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -269,7 +269,7 @@ class YHFamilyMemberFormVC: YHBaseViewController {
] ]
] as [String : Any] ] as [String : Any]
familyMemberInfo = YHFamilyMemberInfo.deserialize(dict: dic) familyMemberInfo = YHFamilyMemberGroupInfo.deserialize(dict: dic)
loadFamilyMember() loadFamilyMember()
} }
...@@ -280,6 +280,8 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -280,6 +280,8 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 配偶section // 配偶section
if let sponse = familyMemberInfo?.spouse { if let sponse = familyMemberInfo?.spouse {
// 信息未填写时服务器返回的relation=0
sponse.relation = String(format: "%d", YHFamilyMemberType.spouse.rawValue)
let sponseArray:[YHFormItemProtocol] = [YHFormTitleItem(type: .sponse), sponse] let sponseArray:[YHFormItemProtocol] = [YHFormTitleItem(type: .sponse), sponse]
items.append(sponseArray) items.append(sponseArray)
} }
...@@ -287,9 +289,13 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -287,9 +289,13 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 父母section // 父母section
var parents = [YHFormItemProtocol]() var parents = [YHFormItemProtocol]()
if let father = familyMemberInfo?.father { if let father = familyMemberInfo?.father {
// 信息未填写时服务器返回的relation=0
father.relation = String(format: "%d", YHFamilyMemberType.father.rawValue)
parents.append(father) parents.append(father)
} }
if let mother = familyMemberInfo?.mother { if let mother = familyMemberInfo?.mother {
// 信息未填写时服务器返回的relation=0
mother.relation = String(format: "%d", YHFamilyMemberType.mother.rawValue)
parents.append(mother) parents.append(mother)
} }
if !parents.isEmpty { if !parents.isEmpty {
...@@ -308,6 +314,10 @@ class YHFamilyMemberFormVC: YHBaseViewController { ...@@ -308,6 +314,10 @@ class YHFamilyMemberFormVC: YHBaseViewController {
// 兄妹section // 兄妹section
var brotherArr:[YHFormItemProtocol] = [YHFormTitleItem(type: .brother), YHFormAddItem(type: .addBrother)] var brotherArr:[YHFormItemProtocol] = [YHFormTitleItem(type: .brother), YHFormAddItem(type: .addBrother)]
if let brothers = familyMemberInfo?.brother, !brothers.isEmpty { if let brothers = familyMemberInfo?.brother, !brothers.isEmpty {
for brother in brothers {
// 信息未填写时服务器返回的relation=0
brother.relation = String(format: "%d", YHFamilyMemberType.brother.rawValue)
}
brotherArr.insert(contentsOf: brothers, at:1) brotherArr.insert(contentsOf: brothers, at:1)
} }
items.append(brotherArr) items.append(brotherArr)
...@@ -391,7 +401,7 @@ extension YHFamilyMemberFormVC { ...@@ -391,7 +401,7 @@ extension YHFamilyMemberFormVC {
"certificates": [] "certificates": []
] as [String : Any] ] as [String : Any]
let brother:YHBrother = YHBrother.deserialize(dict: dict)! let brother:YHFamilyMember = YHFamilyMember.deserialize(dict: dict)!
if var brothers = familyMemberInfo?.brother { if var brothers = familyMemberInfo?.brother {
brothers.append(brother) brothers.append(brother)
...@@ -466,7 +476,7 @@ extension YHFamilyMemberFormVC { ...@@ -466,7 +476,7 @@ extension YHFamilyMemberFormVC {
"certificates":[] "certificates":[]
] as [String : Any] ] as [String : Any]
let child = YHChild.deserialize(dict: dict)! let child = YHFamilyMember.deserialize(dict: dict)!
if var childs = familyMemberInfo?.child { if var childs = familyMemberInfo?.child {
childs.append(child) childs.append(child)
familyMemberInfo!.child = childs familyMemberInfo!.child = childs
...@@ -534,22 +544,26 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -534,22 +544,26 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
} }
// 配偶父母子女兄妹具体条目 // 配偶父母子女兄妹具体条目
if item is YHParent || item is YHChild || item is YHSpouse || item is YHBrother { if item is YHFamilyMember {
let detailItem = item as! YHFamilyMember
let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell let cell = tableView.dequeueReusableCell(withIdentifier: YHFormItemEnterDetailCell.cellReuseIdentifier, for: indexPath) as! YHFormItemEnterDetailCell
cell.title = detailItem.getTitle()
cell.detailLabel.text = String(format: "有%d项未填写".local, detailItem.notFillNum)
cell.isShowDeleteBtn = false cell.isShowDeleteBtn = false
cell.deleteBlock = nil cell.deleteBlock = nil
if item is YHChild || item is YHBrother { if detailItem.relationType == .child || detailItem.relationType == .brother {
if item is YHChild { if detailItem.relationType == .child {
cell.isShowDeleteBtn = (isChildsEditMode == .canCancel) cell.isShowDeleteBtn = (isChildsEditMode == .canCancel)
} else if item is YHBrother {
} else if detailItem.relationType == .brother {
cell.isShowDeleteBtn = (isBrothersEditMode == .canCancel) cell.isShowDeleteBtn = (isBrothersEditMode == .canCancel)
} }
// 删除子女兄妹处理 // 删除子女兄妹处理
cell.deleteBlock = { [weak self] in cell.deleteBlock = { [weak self] in
if item is YHChild { if detailItem.relationType == .child {
let childCount = self?.familyMemberInfo?.child?.count ?? 0 let childCount = self?.familyMemberInfo?.child?.count ?? 0
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
if (indexPath.row-1 < childCount) { if (indexPath.row-1 < childCount) {
...@@ -557,7 +571,7 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -557,7 +571,7 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
self?.isChildsEditMode = .none self?.isChildsEditMode = .none
self?.isBrothersEditMode = .none self?.isBrothersEditMode = .none
} }
} else if item is YHBrother { } else if detailItem.relationType == .brother {
let brotherCount = self?.familyMemberInfo?.brother?.count ?? 0 let brotherCount = self?.familyMemberInfo?.brother?.count ?? 0
// 因为子女兄妹section第一行都是标题所以row-1 // 因为子女兄妹section第一行都是标题所以row-1
...@@ -629,12 +643,6 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -629,12 +643,6 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
IQKeyboardManager.shared.enable = true
let caseList = YHFormTitleItemType.allCases.map({ "\($0)" }).joined(separator: ", ")
print(caseList)
let arr = items[indexPath.section] let arr = items[indexPath.section]
let item:YHFormItemProtocol = arr[indexPath.row] let item:YHFormItemProtocol = arr[indexPath.row]
...@@ -652,40 +660,40 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource { ...@@ -652,40 +660,40 @@ extension YHFamilyMemberFormVC : UITableViewDelegate, UITableViewDataSource {
} }
return return
} }
// 父母
if item is YHParent {
let parent = item as! YHParent
let vc = YHParentInfoVC()
vc.parentInfo = parent
self.navigationController?.pushViewController(vc)
return
}
// 配偶
if item is YHSpouse {
let spouse = item as! YHSpouse
let vc = YHSpouseInitialInfoVC()
vc.spouse = spouse
self.navigationController?.pushViewController(vc)
return
}
// 子女
if item is YHChild {
let child = item as! YHChild
let vc = YHChildInitialInfoVC()
vc.child = child
self.navigationController?.pushViewController(vc)
return
}
// 兄弟姐妹 if item is YHFamilyMember {
if item is YHBrother { let detailItem = item as! YHFamilyMember
let brother = item as! YHBrother // 父母
let vc = YHBrotherInfoVC() if detailItem.relationType == .father || detailItem.relationType == .mother {
vc.brotherInfo = brother let vc = YHParentInfoVC()
self.navigationController?.pushViewController(vc) vc.parentInfo = detailItem
return self.navigationController?.pushViewController(vc)
return
}
// 配偶
if detailItem.relationType == .spouse {
let vc = YHSpouseInitialInfoVC()
vc.spouse = detailItem
self.navigationController?.pushViewController(vc)
return
}
// 子女
if detailItem.relationType == .child {
let vc = YHChildInitialInfoVC()
vc.child = detailItem
self.navigationController?.pushViewController(vc)
return
}
// 兄弟姐妹
if detailItem.relationType == .brother {
let vc = YHBrotherInfoVC()
vc.brotherInfo = detailItem
self.navigationController?.pushViewController(vc)
return
}
} }
} }
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHParentInfoVC: YHBaseViewController { class YHParentInfoVC: YHBaseViewController {
var parentInfo: YHParent? var parentInfo: YHFamilyMember?
var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
...@@ -72,7 +72,7 @@ class YHParentInfoVC: YHBaseViewController { ...@@ -72,7 +72,7 @@ class YHParentInfoVC: YHBaseViewController {
// 父母亲信息 // 父母亲信息
var arr1 = [YHFormItemProtocol]() var arr1 = [YHFormItemProtocol]()
if parentInfo.sex == -1 { // 父亲 if parentInfo.relationType == .father { // 父亲
let title1:YHFormItemProtocol = YHFormTitleItem(type: .fatherInfo) let title1:YHFormItemProtocol = YHFormTitleItem(type: .fatherInfo)
let item10:YHFormItemProtocol = YHFormDetailItem(type: .fatherName) let item10:YHFormItemProtocol = YHFormDetailItem(type: .fatherName)
arr1.append(contentsOf: [title1, item10]) arr1.append(contentsOf: [title1, item10])
......
...@@ -24,7 +24,7 @@ enum HKFormItemCellType: Int { ...@@ -24,7 +24,7 @@ enum HKFormItemCellType: Int {
class YHSpouseBasicInfoVC: YHBaseViewController { class YHSpouseBasicInfoVC: YHBaseViewController {
var spouse:YHSpouse? var spouse:YHFamilyMember?
var cardInfo: YHCNIdentityCard? var cardInfo: YHCNIdentityCard?
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
// //
import UIKit import UIKit
import SmartCodable
class YHSpouseInitialInfoVC: YHBaseViewController { class YHSpouseInitialInfoVC: YHBaseViewController {
var spouse:YHSpouse? var spouse:YHFamilyMember?
lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]() lazy var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
...@@ -93,13 +94,32 @@ class YHSpouseInitialInfoVC: YHBaseViewController { ...@@ -93,13 +94,32 @@ class YHSpouseInitialInfoVC: YHBaseViewController {
let arr1:[YHFormItemProtocol] = [title1, item10] let arr1:[YHFormItemProtocol] = [title1, item10]
// 居住信息 // 居住信息
var arr2 = [YHFormItemProtocol]()
let title2 = YHFormTitleItem(type: .liveInfo) let title2 = YHFormTitleItem(type: .liveInfo)
let item20 = YHFormDetailItem(type: .isLiveTother) let item20 = YHFormDetailItem(type: .isLiveTother)
item20.isLiveTogether = (spouse.finishFollow == 1) item20.isLiveTogether = (spouse.finishFollow == 1)
let item21 = YHFormDetailItem(type: .nationOrArea) arr2.append(title2)
let item22 = YHFormDetailItem(type: .liveCity) arr2.append(item20)
let item23 = YHFormDetailItem(type: .detailAddress)
let arr2:[YHFormItemProtocol] = [title2, item20, item21, item22, item23] if !item20.isLiveTogether { // 不同住 才需填写国家/地区
let item21 = YHFormDetailItem(type: .nationOrArea)
arr2.append(item21)
// 国家/地区已填写 才显示现居住城市和详细地址两行
if let dict = spouse.address {
if dict.peel is [String: Any] {
let dict = dict.peel as! [String: Any]
let address = YHAddress.deserialize(dict: dict)
if address?.area != nil || address?.country != nil {
let item22 = YHFormDetailItem(type: .liveCity)
let item23 = YHFormDetailItem(type: .detailAddress)
arr2.append(item22)
arr2.append(item23)
}
}
}
}
// 港澳通信证 // 港澳通信证
let title3 = YHFormTitleItem(type: .hkAndMacaoPassport) let title3 = YHFormTitleItem(type: .hkAndMacaoPassport)
......
...@@ -427,9 +427,9 @@ class YHFormDetailItem : YHFormItemProtocol { ...@@ -427,9 +427,9 @@ class YHFormDetailItem : YHFormItemProtocol {
// MARK: - YHWelcome // MARK: - YHWelcome
class YHWelcome: SmartCodable { class YHWelcome: SmartCodable {
var code: Int = -1 var code: Int = 0
var msg: String = "" var msg: String = ""
var data: YHFamilyMemberInfo? var data: YHFamilyMemberGroupInfo?
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case code = "code" case code = "code"
...@@ -443,164 +443,110 @@ class YHWelcome: SmartCodable { ...@@ -443,164 +443,110 @@ class YHWelcome: SmartCodable {
} }
// MARK: - 家庭成员 YHData // MARK: - 家庭成员 YHData
class YHFamilyMemberInfo: SmartCodable { class YHFamilyMemberGroupInfo: SmartCodable {
var father: YHParent?
var mother: YHParent?
var spouse: YHSpouse?
var child: [YHChild]?
var brother: [YHBrother]?
enum CodingKeys: String, CodingKey {
case father = "father"
case mother = "mother"
case spouse = "spouse"
case brother = "brother"
case child = "child"
}
required init() {
}
}
// MARK: - 子女初始信息 YHChild
class YHChild: SmartCodable, YHFormItemProtocol {
var id: Int = -1 var father: YHFamilyMember?
var deceased: Int = -1 var mother: YHFamilyMember?
var custody: Int = -1 var spouse: YHFamilyMember?
var nationality: String? var child: [YHFamilyMember]?
var orderId: Int = -1 var brother: [YHFamilyMember]?
var relation: String?
var hasDegree: String?
var hasDegreeJson: [SmartAny]?
var follow: Int = -1
var statement: Int = -1
var subsetName: String?
var subsetNamePinyin: YHSubsetNamePinyin?
var usedName: String?
var birthday: String?
var birthPlaceAboard: Int = -1
var birthPlace: YHAddress?
var occupation: String?
var occupationName: String?
var operatorAme: SmartAny?
var childHasHkId: YHChildStepchildClass?
var hkIdentityCard: String?
var sex: Int = -1
var married: String?
var nows: Int = -1
var address: YHAddress?
var childStepchild: YHChildStepchildClass?
var childInHk: YHChildStepchildClass?
var countryIdentity: [SmartAny]?
var hkIdentity: String?
var hkIdentityOther: String?
var liveCountry: String?
var isHandled: Int = -1
var finishFollow: Int = -1
var step: Int = -1
var notFillNum: Int = -1
var isLiveOverseaYear: Int = -1
var surname: String?
var certificates: [SmartAny]?
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case id = "id" case father = "father"
case deceased = "deceased" case mother = "mother"
case custody = "custody" case spouse = "spouse"
case nationality = "nationality" case brother = "brother"
case orderId = "order_id" case child = "child"
case relation = "relation"
case hasDegree = "has_degree"
case hasDegreeJson = "has_degree_json"
case follow = "follow"
case statement = "statement"
case subsetName = "subset_name"
case subsetNamePinyin = "subset_name_pinyin"
case usedName = "used_name"
case birthday = "birthday"
case birthPlaceAboard = "birth_place_aboard"
case birthPlace = "birth_place"
case occupation = "occupation"
case occupationName = "occupation_name"
case operatorAme = "operator_ame"
case childHasHkId = "child_has_hk_id"
case hkIdentityCard = "hk_identity_card"
case sex = "sex"
case married = "married"
case nows = "nows"
case address = "address"
case childStepchild = "child_stepchild"
case childInHk = "child_in_hk"
case countryIdentity = "country_identity"
case hkIdentity = "hk_identity"
case hkIdentityOther = "hk_identity_other"
case liveCountry = "live_country"
case isHandled = "is_handled"
case finishFollow = "finish_follow"
case step = "step"
case notFillNum = "not_fill_num"
case isLiveOverseaYear = "is_live_oversea_year"
case surname = "surname"
case certificates = "certificates"
} }
required init() { required init() {
} }
// YHFamilyMemberProtocol
func getTitle() -> String {
return "配偶".local
}
func getSubTitle() -> String {
return ""
}
} }
// MARK: - YHBrother enum YHFamilyMemberType: Int {
class YHBrother: SmartCodable, YHFormItemProtocol { // 与后台relation字段一致
var id: Int? = -1 // 1父亲 2母亲 3配偶 4子女 5兄弟姐妹
var deceased: Int? = -1 case none = 0
var custody: Int? = -1 case father = 1
case mother = 2
case spouse = 3
case child = 4
case brother = 5
}
class YHFamilyMember: SmartCodable, YHFormItemProtocol {
var id: Int = 0
var deceased: Int = 0
var custody: Int = 0
var nationality: String? var nationality: String?
var orderId: Int? = -1 var orderId: Int = 0
var relation: String? var relation: String?
var hasDegree: String? var hasDegree: String?
var hasDegreeJson: [SmartAny]?
var follow: Int? = -1 // mark any
var statement: Int? = -1 // var hasDegreeJson: [YHHasDegreeJson]?
var hasDegreeJson: SmartAny?
var follow: Int = 0
var statement: Int = 0
var subsetName: String? var subsetName: String?
var subsetNamePinyin: YHSubsetNamePinyin?
// mark any
// var subsetNamePinyin: YHSubsetNamePinyin?
var subsetNamePinyin: SmartAny?
var usedName: String? var usedName: String?
var birthday: String? var birthday: String?
var birthPlaceAboard: Int? = -1 var birthPlaceAboard: Int = 0
var birthPlace: YHAddress?
// mark any
// var birthPlace: YHAddress?
var birthPlace: SmartAny?
var occupation: String? var occupation: String?
var occupationName: String? var occupationName: String?
// mark any
var operatorAme: SmartAny? var operatorAme: SmartAny?
var childHasHkId: YHChildStepchildClass?
// mark any
// var childHasHkId: YHChildStepchildClass?
var childHasHkId: SmartAny?
var hkIdentityCard: String? var hkIdentityCard: String?
var sex: Int? = -1 var sex: Int = 0
var married: String? var married: String?
var nows: Int? = -1 var nows: Int = 0
var address: YHAddress?
var childStepchild: YHChildStepchildClass? // mark any
var childInHk: YHChildStepchildClass? // var address: YHAddress?
var countryIdentity: [SmartAny]? var address: SmartAny?
// mark any
// var childStepchild: YHChildStepchildClass?
var childStepchild: SmartAny?
// mark any
// var childInHk: YHChildStepchildClass?
var childInHk: SmartAny?
// mark any
var countryIdentity: SmartAny?
var hkIdentity: String? var hkIdentity: String?
var hkIdentityOther: String? var hkIdentityOther: String?
var liveCountry: String? var liveCountry: String?
var isHandled: Int? = -1 var isHandled: Int = 0
var finishFollow: Int? = -1 var finishFollow: Int = 0
var step: Int? = -1 var step: Int = 0
var notFillNum: Int? = -1 var notFillNum: Int = 0
var isLiveOverseaYear: Int? = -1 var isLiveOverseaYear: Int = 0
var surname: String? var surname: String?
var certificates: [SmartAny]?
// mark any
// var certificates: YHCertificates?
var certificates: SmartAny?
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case id = "id" case id = "id"
...@@ -647,9 +593,40 @@ class YHBrother: SmartCodable, YHFormItemProtocol { ...@@ -647,9 +593,40 @@ class YHBrother: SmartCodable, YHFormItemProtocol {
} }
var relationType:YHFamilyMemberType {
if relation == "1" {
return .father
} else if relation == "2" {
return .mother
} else if relation == "3" {
return .spouse
} else if relation == "4" {
return .child
} else if relation == "5" {
return .brother
}
return .none
}
// YHFamilyMemberProtocol // YHFamilyMemberProtocol
func getTitle() -> String { func getTitle() -> String {
return "兄弟姐妹".local // 1父亲 2 母亲 3 配偶 4子女 5兄弟姐妹
if let relation = relation {
if relation == "1" {
return "父亲".local
} else if relation == "2" {
return "母亲".local
} else if relation == "3" {
return "配偶".local
} else if relation == "4" {
return "子女".local
} else if relation == "5" {
return "兄弟姐妹".local
}
}
return ""
} }
func getSubTitle() -> String { func getSubTitle() -> String {
...@@ -659,6 +636,7 @@ class YHBrother: SmartCodable, YHFormItemProtocol { ...@@ -659,6 +636,7 @@ class YHBrother: SmartCodable, YHFormItemProtocol {
// MARK: - 居住地址信息 YHAddress // MARK: - 居住地址信息 YHAddress
class YHAddress: SmartCodable { class YHAddress: SmartCodable {
var area: [String]? var area: [String]?
var country: String? var country: String?
var details: String? var details: String?
...@@ -706,199 +684,6 @@ class YHSubsetNamePinyin: SmartCodable { ...@@ -706,199 +684,6 @@ class YHSubsetNamePinyin: SmartCodable {
} }
} }
// MARK: - 父母信息 YHParent
class YHParent: SmartCodable, YHFormItemProtocol {
var id: Int = -1
var deceased: Int = -1
var custody: Int = -1
var nationality: String?
var orderId: Int = -1
var relation: Int = -1
var hasDegree: Int = -1
var hasDegreeJson: [SmartAny]?
var follow: Int = -1
var statement: Int = -1
var subsetName: String?
var subsetNamePinyin: String?
var usedName: String?
var birthday: String?
var birthPlaceAboard: Int = -1
var birthPlace: [SmartAny]?
var occupation: String?
var occupationName: String?
var operatorAme: String?
var childHasHkId: [SmartAny]?
var hkIdentityCard: String?
var sex: Int = -1
var married: Int = -1
var nows: Int = -1
var address: [SmartAny]?
var childStepchild: [SmartAny]?
var childInHk: [SmartAny]?
var countryIdentity: [SmartAny]?
var hkIdentity: String?
var hkIdentityOther: String?
var liveCountry: String?
var isHandled: Int = -1
var finishFollow: Int = -1
var step: Int = -1
var notFillNum: Int = -1
var certificates: [SmartAny]?
var isLiveOverseaYear: Int = -1
enum CodingKeys: String, CodingKey {
case id = "id"
case deceased = "deceased"
case custody = "custody"
case nationality = "nationality"
case orderId = "order_id"
case relation = "relation"
case hasDegree = "has_degree"
case hasDegreeJson = "has_degree_json"
case follow = "follow"
case statement = "statement"
case subsetName = "subset_name"
case subsetNamePinyin = "subset_name_pinyin"
case usedName = "used_name"
case birthday = "birthday"
case birthPlaceAboard = "birth_place_aboard"
case birthPlace = "birth_place"
case occupation = "occupation"
case occupationName = "occupation_name"
case operatorAme = "operator_ame"
case childHasHkId = "child_has_hk_id"
case hkIdentityCard = "hk_identity_card"
case sex = "sex"
case married = "married"
case nows = "nows"
case address = "address"
case childStepchild = "child_stepchild"
case childInHk = "child_in_hk"
case countryIdentity = "country_identity"
case hkIdentity = "hk_identity"
case hkIdentityOther = "hk_identity_other"
case liveCountry = "live_country"
case isHandled = "is_handled"
case finishFollow = "finish_follow"
case step = "step"
case notFillNum = "not_fill_num"
case certificates = "certificates"
case isLiveOverseaYear = "is_live_oversea_year"
}
required init() {
}
// YHFamilyMemberProtocol
func getTitle() -> String {
if sex == 0 {
return "父亲".local
}
return "母亲".local
}
func getSubTitle() -> String {
return ""
}
}
// MARK: - 配偶 YHSpouse
class YHSpouse: SmartCodable, YHFormItemProtocol {
var id: Int = -1
var deceased: Int = -1
var custody: Int = -1
var nationality: String?
var orderId: Int = -1
var relation: String?
var hasDegree: String?
var hasDegreeJson: [YHHasDegreeJson]?
var follow: Int = -1
var statement: Int = -1
var subsetName: String?
var subsetNamePinyin: YHSubsetNamePinyin?
var usedName: String?
var birthday: String?
var birthPlaceAboard: Int = -1
var birthPlace: YHAddress?
var occupation: String?
var occupationName: String?
var operatorAme: SmartAny?
var childHasHkId: YHPurpleChild?
var hkIdentityCard: String?
var sex: Int = -1
var married: String?
var nows: Int = -1
var address: YHAddress?
var childStepchild: YHChildStepchildClass?
var childInHk: YHPurpleChild?
var countryIdentity: [SmartAny]?
var hkIdentity: String?
var hkIdentityOther: String?
var liveCountry: String?
var isHandled: Int = -1
var finishFollow: Int = -1
var step: Int = -1
var notFillNum: Int = -1
var isLiveOverseaYear: Int = -1
var surname: String?
var certificates: YHCertificates?
enum CodingKeys: String, CodingKey {
case id = "id"
case deceased = "deceased"
case custody = "custody"
case nationality = "nationality"
case orderId = "order_id"
case relation = "relation"
case hasDegree = "has_degree"
case hasDegreeJson = "has_degree_json"
case follow = "follow"
case statement = "statement"
case subsetName = "subset_name"
case subsetNamePinyin = "subset_name_pinyin"
case usedName = "used_name"
case birthday = "birthday"
case birthPlaceAboard = "birth_place_aboard"
case birthPlace = "birth_place"
case occupation = "occupation"
case occupationName = "occupation_name"
case operatorAme = "operator_ame"
case childHasHkId = "child_has_hk_id"
case hkIdentityCard = "hk_identity_card"
case sex = "sex"
case married = "married"
case nows = "nows"
case address = "address"
case childStepchild = "child_stepchild"
case childInHk = "child_in_hk"
case countryIdentity = "country_identity"
case hkIdentity = "hk_identity"
case hkIdentityOther = "hk_identity_other"
case liveCountry = "live_country"
case isHandled = "is_handled"
case finishFollow = "finish_follow"
case step = "step"
case notFillNum = "not_fill_num"
case isLiveOverseaYear = "is_live_oversea_year"
case surname = "surname"
case certificates = "certificates"
}
required init() {
}
// YHFamilyMemberProtocol
func getTitle() -> String {
return "配偶".local
}
func getSubTitle() -> String {
return ""
}
}
// MARK: - YHCertificates // MARK: - YHCertificates
class YHCertificates: SmartCodable { class YHCertificates: SmartCodable {
...@@ -921,14 +706,14 @@ class YHCNIdentityCard: SmartCodable { ...@@ -921,14 +706,14 @@ class YHCNIdentityCard: SmartCodable {
} }
var id: Int = -1 var id: Int = 0
var number: String? var number: String?
var issueAt: String? var issueAt: String?
var issueDateStartAt: String? var issueDateStartAt: String?
var issueDateEndAt: String? var issueDateEndAt: String?
var imgFront: String? var imgFront: String?
var imgBack: String? var imgBack: String?
var passportType: Int = -1 var passportType: Int = 0
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case id = "id" case id = "id"
...@@ -942,20 +727,6 @@ class YHCNIdentityCard: SmartCodable { ...@@ -942,20 +727,6 @@ class YHCNIdentityCard: SmartCodable {
} }
} }
// MARK: - YHPurpleChild
class YHPurpleChild: SmartCodable {
required init() {
}
var has: String?
enum CodingKeys: String, CodingKey {
case has = "has"
}
}
// MARK: - YHHasDegreeJson // MARK: - YHHasDegreeJson
class YHHasDegreeJson: SmartCodable { class YHHasDegreeJson: SmartCodable {
......
...@@ -6,6 +6,24 @@ ...@@ -6,6 +6,24 @@
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved. // Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
// //
// 【 用法 Usage】
/*
// (1) 直接传type
YHFormPickerView.show(type: .certificate, selectType: .certificate(.otherStatelessTravelPassport)) { selectType in
// 选择类型的标题
print(selectType.title)
}
// (2) 直接传字符串值
YHFormPickerView.show(type: .certificate, selectTitle: "公务通行证") { selectType in
// 选择类型的标题
print(selectType.title)
}
*/
import UIKit import UIKit
enum YHFormPickerViewType: Int { enum YHFormPickerViewType: Int {
...@@ -21,6 +39,8 @@ enum YHFormPickerViewType: Int { ...@@ -21,6 +39,8 @@ enum YHFormPickerViewType: Int {
case occupation = 4 case occupation = 4
// 性别 // 性别
case gender = 5 case gender = 5
// 证件
case certificate = 6
} }
enum YHFormPickerViewSubType { enum YHFormPickerViewSubType {
...@@ -31,54 +51,70 @@ enum YHFormPickerViewSubType { ...@@ -31,54 +51,70 @@ enum YHFormPickerViewSubType {
case education(YHPickerViewEducationType) case education(YHPickerViewEducationType)
case occupation(YHPickerViewOccupationType) case occupation(YHPickerViewOccupationType)
case gender(YHPickerViewGenderType) case gender(YHPickerViewGenderType)
case certificate(YHPickerViewCertificateType)
var title:String { var title:String {
switch self { switch self {
case .none: case .none:
return "".local return "".local
case .marriage(.unmarriage):
return "未婚".local
case .marriage(.marriaged):
return "已婚".local
case .marriage(.separated):
return "分居".local
case .marriage(.divorced):
return "离婚".local
case .marriage(.widowed):
return "丧偶".local
case .degree(.bachelor):
return "学士学位".local
case .degree(.master):
return "硕士学位".local
case .degree(.doctor):
return "博士学位".local
case .education(.fullTime): case .marriage(.unmarriage):
return "全日制".local return "未婚".local
case .education(.partTime): case .marriage(.marriaged):
return "兼职制".local return "已婚".local
case.education(.distanceCourses): case .marriage(.separated):
return "遥距课程".local return "分居".local
case .marriage(.divorced):
return "离婚".local
case .marriage(.widowed):
return "丧偶".local
case .occupation(.onTheJob): case .degree(.bachelor):
return "在职".local return "学士学位".local
case .occupation(.retire): case .degree(.master):
return "退休".local return "硕士学位".local
case .occupation(.unemployed): case .degree(.doctor):
return "无业".local return "博士学位".local
case .occupation(.student):
return "学生".local case .education(.fullTime):
return "全日制".local
case .education(.partTime):
return "兼职制".local
case.education(.distanceCourses):
return "遥距课程".local
case .occupation(.onTheJob):
return "在职".local
case .occupation(.retire):
return "退休".local
case .occupation(.unemployed):
return "无业".local
case .occupation(.student):
return "学生".local
case .gender(.male):
return "男".local
case .gender(.female):
return "女".local
case .gender(.male): case .certificate(.passport):
return "男".local return "护照".local
case .gender(.female): case .certificate(.travelPassport):
return "女".local return "旅游通行证".local
case .certificate(.diplomaticPassport):
return "外交护照".local
case .certificate(.chineseStatelessTravelPassport):
return "中国发无国籍旅游证件".local
case .certificate(.otherStatelessTravelPassport):
return "其他无国籍旅行证件".local
case .certificate(.unitedNationsPassport):
return "联合国通行证".local
case .certificate(.officialPassport):
return "公务护照".local
} }
} }
static func getType(_ title: String?) -> YHFormPickerViewSubType { static func getType(_ title: String?) -> YHFormPickerViewSubType {
...@@ -124,6 +160,21 @@ enum YHFormPickerViewSubType { ...@@ -124,6 +160,21 @@ enum YHFormPickerViewSubType {
return .gender(.male) return .gender(.male)
} else if title == "女".local { } else if title == "女".local {
return .gender(.female) return .gender(.female)
} else if title == "护照".local {
return .certificate(.passport)
} else if title == "外交护照".local {
return .certificate(.diplomaticPassport)
} else if title == "旅游通行证".local {
return .certificate(.travelPassport)
} else if title == "公务护照".local {
return .certificate(.officialPassport)
} else if title == "中国发无国籍旅游证件".local {
return .certificate(.chineseStatelessTravelPassport)
} else if title == "其他无国籍旅行证件".local {
return .certificate(.otherStatelessTravelPassport)
} else if title == "联合国通行证".local {
return .certificate(.unitedNationsPassport)
} }
return .none return .none
...@@ -180,6 +231,24 @@ enum YHPickerViewGenderType { ...@@ -180,6 +231,24 @@ enum YHPickerViewGenderType {
case female case female
} }
enum YHPickerViewCertificateType {
// 护照
case passport
// 外交护照
case diplomaticPassport
// 公务护照
case officialPassport
// 中国发无国籍旅游证件
case chineseStatelessTravelPassport
// 旅游通行证
case travelPassport
// 联合国通行证
case unitedNationsPassport
// 其他无国籍旅行证件
case otherStatelessTravelPassport
}
class YHFormPickerViewItem { class YHFormPickerViewItem {
...@@ -319,6 +388,15 @@ class YHFormPickerView: UIView { ...@@ -319,6 +388,15 @@ class YHFormPickerView: UIView {
[YHFormPickerViewItem(type: .gender(.male)), [YHFormPickerViewItem(type: .gender(.male)),
YHFormPickerViewItem(type: .gender(.female))], YHFormPickerViewItem(type: .gender(.female))],
// 证件
.certificate:
[YHFormPickerViewItem(type: .certificate(.passport)),
YHFormPickerViewItem(type: .certificate(.diplomaticPassport)),
YHFormPickerViewItem(type: .certificate(.officialPassport)),
YHFormPickerViewItem(type: .certificate(.chineseStatelessTravelPassport)),
YHFormPickerViewItem(type: .certificate(.travelPassport)),
YHFormPickerViewItem(type: .certificate(.unitedNationsPassport)),
YHFormPickerViewItem(type: .certificate(.otherStatelessTravelPassport))],
] ]
}() }()
...@@ -338,6 +416,24 @@ class YHFormPickerView: UIView { ...@@ -338,6 +416,24 @@ class YHFormPickerView: UIView {
UIApplication.shared.yhKeyWindow()?.addSubview(self) UIApplication.shared.yhKeyWindow()?.addSubview(self)
} }
static func show(type:YHFormPickerViewType, selectType:YHFormPickerViewSubType, callBack: @escaping ((YHFormPickerViewSubType)->Void)) {
let picker = YHFormPickerView(type: type)
picker.selectType = selectType
picker.selectBlock = callBack
picker.show()
}
static func show(type:YHFormPickerViewType, selectTitle:String?, callBack: @escaping ((YHFormPickerViewSubType)->Void)) {
let picker = YHFormPickerView(type: type)
picker.selectTitle = selectTitle
picker.selectBlock = callBack
picker.show()
}
@objc func dismiss() { @objc func dismiss() {
self.removeFromSuperview() self.removeFromSuperview()
} }
...@@ -431,19 +527,21 @@ class YHFormPickerView: UIView { ...@@ -431,19 +527,21 @@ class YHFormPickerView: UIView {
func getTitle(type: YHFormPickerViewType)-> String { func getTitle(type: YHFormPickerViewType)-> String {
switch type { switch type {
case .none: case .none:
return "" return ""
case .degree: case .degree:
return "选择学位" return "选择学位"
case .marriage: case .marriage:
return "选择婚姻状况" return "选择婚姻状况"
case .edution: case .edution:
return "选择学位" return "选择学位"
case .occupation: case .occupation:
return "选择职业" return "选择职业"
case .gender: case .gender:
return "选择性别" return "选择性别"
} case .certificate:
return "选择证件"
}
} }
} }
......
...@@ -36,6 +36,7 @@ class YHMainApplicantInformationViewController: YHBaseViewController { ...@@ -36,6 +36,7 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
dataSource = viewModel.getDetailDataSource() dataSource = viewModel.getDetailDataSource()
} }
tableView.reloadData() tableView.reloadData()
} }
func setView() { func setView() {
...@@ -89,16 +90,6 @@ class YHMainApplicantInformationViewController: YHBaseViewController { ...@@ -89,16 +90,6 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
make.left.right.bottom.equalTo(view) make.left.right.bottom.equalTo(view)
make.height.equalTo(k_Height_safeAreaInsetsBottom() + 64) make.height.equalTo(k_Height_safeAreaInsetsBottom() + 64)
} }
stepView.isHidden = true
tableView.isHidden = true
bottomView.isHidden = true
let datePicker = UIDatePicker(frame: CGRect(x: 0, y: 150, width: self.view.bounds.width, height: 200))
datePicker.datePickerMode = .dateAndTime
// datePicker.addTarget(self, action: #selector(handleDateChange), for: .valueChanged)
// 将日期选择器添加到视图上
self.view.addSubview(datePicker)
} }
} }
...@@ -126,7 +117,7 @@ extension YHMainApplicantInformationViewController: UITableViewDelegate, UITable ...@@ -126,7 +117,7 @@ extension YHMainApplicantInformationViewController: UITableViewDelegate, UITable
if stepView.currentIndex == 1 { if stepView.currentIndex == 1 {
return 217.0 return 217.0
} else { } else {
return CGFloat(count * 52 + 52 + 14) return CGFloat(count * 52 + 52 + 14)
} }
} }
} }
//
// YHDatePickView.swift
// galaxy
//
// Created by EDY on 2024/1/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
struct YHCountryModel {
var provincesArray: [YHProvincesModel] = []
init(dic: [String:[String:[String]]]) {
for (key,value) in dic {
let model = YHProvincesModel(name: key, dic: value)
provincesArray.append(model)
provincesArray.sort { a, b in
a.provincesName < b.provincesName
}
}
}
}
struct YHProvincesModel {
var provincesName: String = ""
var cityArray: [YHCityModel] = []
init(name : String ,dic:[String: [String]]) {
provincesName = name
for (key,value) in dic {
let model = YHCityModel(name: key, Arr: value)
cityArray.append(model)
cityArray.sort { a, b in
a.cityName < b.cityName
}
}
}
}
struct YHCityModel {
var cityName: String = ""
var areaArray: [String] = []
init(name: String,Arr: [String]) {
cityName = name
for str in Arr {
areaArray.append(str)
}
areaArray.sort(by: <)
}
}
//
// YHDatePickView.swift
// galaxy
//
// Created by EDY on 2024/1/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
/// view的三种状态,控制tableView展示效果与数据
enum YHLocationPickViewTableViewType {
case provinces //省份
case city //城市
case area //地区
}
class YHAddressPickView: UIView {
/// 返回数据回调
public var backLocationString: ((String,String,String,String) -> Void)?
/// 退出回调
public var backOnClickCancel: (() -> Void)?
/// title选中以及下滑线颜色
public var selectColor: UIColor
private var tableViewType: YHLocationPickViewTableViewType = .provinces {
didSet {
switch tableViewType {
case .provinces:
/// 选择省份时,有上面的热门城市view.没有滚动选择type的titleScrollView.没有已选择label.
self.tableView.tableHeaderView = tableViewHeaderView
self.tableView.frame = CGRect(x: 0, y: 42, width: UIScreen.main.bounds.width, height: 458)
self.titleSV.isHidden = true
self.leftLabel.isHidden = true
/// 将所有选中数据清空
self.provincesModel = nil
self.selectedProvince = ""
self.selectedCity = ""
self.selectedArea = ""
self.cityModel = nil
// 将titleSV中所有button的title重置
// 并将第一个button设置为选中状态,已保证选择城市后button下的横线有滚动效果.
for button in buttonArr {
button.setTitle("请选择", for: .normal)
button.isSelected = false
if button.tag == 0 {
button.isSelected = true
}
}
self.underLine.center = CGPoint(x: self.buttonArr[1].center.x, y: self.underLine.center.y)
self.dataArray = locationModel?.provincesArray.map({ model in
model.provincesName
})
self.tableView.reloadData()
case .city:
/// 选择城市时没有热门城市view,并将titleSV显示出来
self.tableView.tableHeaderView = UIView()
self.tableView.frame = CGRect(x: 0, y: 136, width: UIScreen.main.bounds.width, height: 367)
self.titleSV.isHidden = false
self.leftLabel.isHidden = false
/// 将省份选择保留,将城市与地区数据清空
self.selectedCity = ""
self.selectedArea = ""
self.cityModel = nil
/// 通过修改titleSV中button的选中状态来修改它的颜色
for button in buttonArr {
button.isSelected = false
if button.tag != 0 {
button.setTitle("请选择", for: .normal)
}
if button.tag == 1 {
button.isSelected = true
}
}
/// 滚动titleSV中button下滚动的Line
UIView.animate(withDuration: 0.3, animations: {() -> Void in
self.underLine.center = CGPoint(x: self.buttonArr[1].center.x, y: self.underLine.center.y)
})
self.dataArray = provincesModel?.cityArray.map({ model in
model.cityName
})
self.tableView.reloadData()
case .area:
/// 选择地区时没有上方热门城市View,有titleSV
self.tableView.tableHeaderView = UIView()
self.tableView.frame = CGRect(x: 0, y: 136, width: UIScreen.main.bounds.width, height: 367)
self.titleSV.isHidden = false
self.leftLabel.isHidden = false
/// 通过修改titleSV中button的选中状态来修改它的颜色
for button in buttonArr {
button.isSelected = false
if button.tag == 2 {
button.isSelected = true
}
}
/// 滚动titleSV中button下滚动的Line
UIView.animate(withDuration: 0.3, animations: {() -> Void in
self.underLine.center = CGPoint(x: self.buttonArr[2].center.x, y: self.underLine.center.y)
})
self.dataArray = cityModel?.areaArray
self.tableView.reloadData()
}
}
}
/// titleSV上的三个button,通过array保存,更好操作
private var buttonArr = [UIButton]()
/// 已选中的省份
private var selectedProvince = ""{
didSet {
/// 当选中赋值时,将titleSV上第一个button.title改为省份名
for button in buttonArr where button.tag == 0 {
button.setTitle(selectedProvince, for: .normal)
}
}
}
/// 已选中城市
private var selectedCity = ""{
didSet {
/// 当选中赋值时,将titleSV上第二个button.title改为城市名
for button in buttonArr where button.tag == 1 {
button.setTitle(selectedCity, for: .normal)
}
}
}
private var selectedArea = ""
/// 总城市数据
private var locationModel: YHCountryModel?
/// 省份数据
private var provincesModel: YHProvincesModel?
/// 城市数据
private var cityModel: YHCityModel?
/// 当前tableView使用的数据源
private var dataArray: [String]?
private let titleLabel: UILabel = {
let label = UILabel(frame: CGRect(x: (UIScreen.main.bounds.width - 100) / 2, y: 9, width: 100, height: 24))
label.textColor = UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1)
label.text = "选择国家地区"
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 16)
return label
}()
private let rightCancelButton: UIButton = {
let button = UIButton(frame: CGRect(x: UIScreen.main.bounds.width - 42, y: 11, width: 18, height: 18))
button.setImage(UIImage(named: "BaseVC_cancel"), for: .normal)
return button
}()
private let leftLabel: UILabel = {
let label = UILabel(frame: CGRect(x: 24, y: 43, width: 40, height: 18))
label.text = "已选择"
label.textColor = UIColor(red: 102/255, green: 102/255, blue: 102/255, alpha: 1)
label.font = UIFont.systemFont(ofSize: 12)
label.isHidden = true
return label
}()
/// 热门城市数组,可修改,若修改数量需要修改下方tableViewHeaderView.frame;若修改城市需要修改onClickHotCity()方法来实现点击跳转功能
private let hotCityArray = ["北京","上海","广州","深圳","杭州","南京","苏州","天津","武汉","长沙","重庆","成都"]
private lazy var tableViewHeaderView: UIView = {
let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 160))
let label = UILabel(frame: CGRect(x: 24, y: 0, width: 50, height: 18))
label.textColor = UIColor(red: 102/255, green: 102/255, blue: 102/255, alpha: 1)
label.font = UIFont.systemFont(ofSize: 12)
label.text = "热门城市"
view.addSubview(label)
for i in 0..<12 {
let button: UIButton = UIButton(frame: CGRect(x: CGFloat(24 + 80 * (i % 4)), y: CGFloat(28 + 40 * (i / 4)), width: 80, height: 40))
button.setTitle(hotCityArray[i], for: .normal)
button.setTitleColor(UIColor(red: 102/255, green: 102/255, blue: 102/255, alpha: 1), for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 12)
button.addTarget(self, action: #selector(onClickHotCity(sender:)), for: .touchUpInside)
button.tag = i
view.addSubview(button)
}
return view
}()
/// 上方选择省份城市地区的滚动scrollView
private var titleSV: UIScrollView!
/// titleSV上button下的滚动线
private var underLine = UIView()
private var tableView = UITableView(frame: CGRect(x: 0, y:42 , width: UIScreen.main.bounds.width, height: 458))
init(frame: CGRect, selectColor: UIColor, selectedProvince: String? = nil, selectedCity: String? = nil) {
self.selectColor = selectColor
super.init(frame: frame)
initLocationData()
drawMyView()
setHotCityData(province: selectedProvince, city: selectedCity)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func drawMyView() {
self.backgroundColor = UIColor.white
buildTitleScrollView()
drawTableView()
self.addSubview(titleLabel)
self.addSubview(rightCancelButton)
rightCancelButton.addTarget(self, action: #selector(onClickCancelButton), for: .touchUpInside)
self.addSubview(leftLabel)
}
private func buildTitleScrollView() {
if titleSV != nil {
titleSV.removeFromSuperview()
}
buttonArr = []
titleSV = UIScrollView(frame: CGRect(x: 0, y: 72, width: UIScreen.main.bounds.width, height: 44))
self.underLine = UIView(frame: CGRect(x: 0, y: 40, width: 30, height: 2))
self.underLine.backgroundColor = selectColor
for i in 0..<3 {
let button = UIButton(frame: CGRect(x: 24 + CGFloat(i) * (UIScreen.main.bounds.width - 47) / 3, y: 0, width: UIScreen.main.bounds.width / 3, height: 44))
button.tag = Int(i)
if i == 1 {
button.isSelected = true
underLine.center.x = button.center.x
}
button.setTitle("请选择", for: .normal)
button.setTitleColor(UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1), for: .normal)
button.setTitleColor(selectColor, for: .selected)
button.titleLabel?.font = UIFont.systemFont(ofSize: 12)
button.titleLabel?.adjustsFontSizeToFitWidth = true
button.addTarget(self, action: #selector(onClickTitlebutton(sender:)), for: .touchUpInside)
buttonArr.append(button)
titleSV.addSubview(button)
}
titleSV.showsVerticalScrollIndicator = false
titleSV.addSubview(self.underLine)
titleSV.contentSize = CGSize(width: UIScreen.main.bounds.width, height: 44)
titleSV.isHidden = true
self.addSubview(titleSV)
}
private func drawTableView() {
self.addSubview(tableView)
tableView.delegate = self
tableView.dataSource = self
tableView.separatorStyle = .none
tableView.tableHeaderView = tableViewHeaderView
tableView.showsVerticalScrollIndicator = false
tableView.register(YHAddressPickViewTableViewCell.self, forCellReuseIdentifier: YHAddressPickViewTableViewCell.identifier)
tableView.register(YHAddressPickViewFirstTableViewCell.self, forCellReuseIdentifier: YHAddressPickViewFirstTableViewCell.identifier)
}
/// 退出
@objc private func onClickCancelButton() {
if self.backOnClickCancel != nil {
backOnClickCancel!()
}
}
@objc private func onClickHotCity(sender: UIButton) {
let hotProvince = ["北京市","上海市","广东省","广东省","浙江省","江苏省","江苏省","天津市","湖北省","湖南省","重庆市","四川省"]
let hotCity = ["北京市","上海市","广州市","深圳市","杭州市","南京市","苏州市","天津市","武汉市","长沙市","重庆市","成都市"]
let tag = sender.tag
setHotCityData(province: hotProvince[tag], city: hotCity[tag])
self.tableViewType = .area
}
/// 选择view.type
@objc private func onClickTitlebutton(sender: UIButton) {
guard !sender.isSelected else { return }
switch sender.tag {
case 0:
self.tableViewType = .provinces
case 1:
self.tableViewType = .city
default:
break
}
}
/// 点击热门城市中的城市
private func setHotCityData(province: String?,city: String?) {
if let province = province {
if let provincesModel = self.locationModel?.provincesArray.first(where: { model in
model.provincesName == province
}) {
self.provincesModel = provincesModel
self.selectedProvince = province
self.tableViewType = .city
if let city = city {
if let cityModel = self.provincesModel?.cityArray.first(where: { model in
model.cityName == city
}) {
self.cityModel = cityModel
self.selectedCity = city
self.tableViewType = .area
}
}
}
}
}
/// 从area.plist获取全部地区数据
private func initLocationData() {
guard let dic = NSDictionary(contentsOfFile: Bundle.main.path(forResource: "area", ofType: "plist") ?? "") as? [String:[String:[String]]] else {
return
}
locationModel = YHCountryModel(dic: dic)
dataArray = locationModel?.provincesArray.map({$0.provincesName})
}
}
// MARK: - tableViewDelegate
extension YHAddressPickView: UITableViewDelegate,UITableViewDataSource {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 40
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return (self.dataArray?.count)! + 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAddressPickViewFirstTableViewCell.identifier) as? YHAddressPickViewFirstTableViewCell else {
return YHAddressPickViewFirstTableViewCell()
}
cell.label.text = "请选择"
return cell
}
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAddressPickViewTableViewCell.identifier) as? YHAddressPickViewTableViewCell else {
return YHAddressPickViewTableViewCell()
}
cell.label.text = self.dataArray?[indexPath.row - 1]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard indexPath.row != 0 else { return }
switch tableViewType {
case .provinces:
/// 当前为选择省份状态时,保存选中省份,刷新状态为选择城市
selectedProvince = self.locationModel?.provincesArray[indexPath.row - 1].provincesName ?? ""
self.provincesModel = self.locationModel?.provincesArray.first(where: {$0.provincesName == selectedProvince})
self.tableViewType = .city
case .city:
/// 当前为选择城市状态时,保存选中城市,刷新状态为选择地区
selectedCity = (self.provincesModel?.cityArray[indexPath.row - 1])?.cityName ?? ""
self.cityModel = self.provincesModel?.cityArray.first(where: {$0.cityName == selectedCity})
self.tableViewType = .area
case .area:
/// 当前为选择地区状态时,保存选中地区,执行回调block.将选中数据回调
selectedArea = self.dataArray![indexPath.row - 1]
let selectLocation = selectedProvince + " " + selectedCity + " " + selectedArea
if backLocationString != nil {
backLocationString!(selectLocation,selectedProvince,selectedCity,selectedArea)
}
}
}
}
//
// YHDatePickView.swift
// galaxy
//
// Created by EDY on 2024/1/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHAddressPickViewTableViewCell: UITableViewCell {
static let identifier = "YHAddressPickViewTableViewCell"
let label: UILabel = {
let label = UILabel(frame: CGRect(x: 42, y: 8, width: 200, height: 24))
label.font = UIFont.systemFont(ofSize: 14)
label.textColor = UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1)
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
drawMyView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func drawMyView() {
self.addSubview(label)
}
}
class YHAddressPickViewFirstTableViewCell: UITableViewCell {
static let identifier = "YHAddressPickViewFirstTableViewCell"
let label: UILabel = {
let label = UILabel(frame: CGRect(x: 24, y: 11.5, width: 100, height: 17))
label.font = UIFont.systemFont(ofSize: 12)
label.textColor = UIColor(red: 102/255, green: 102/255, blue: 102/255, alpha: 1)
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
drawMyView()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func drawMyView() {
self.addSubview(label)
}
}
//
// YHDatePickView.swift
// galaxy
//
// Created by EDY on 2024/1/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
enum YHAddressPickerPresentAnimateType {
case present//被推出时
case dismiss//取消时
}
//EWAddressPickerViewController的推出和取消动画
class YHAddressPickerPresentAnimated: NSObject,UIViewControllerAnimatedTransitioning {
var type: YHAddressPickerPresentAnimateType = .present
init(type: YHAddressPickerPresentAnimateType) {
self.type = type
}
/// 动画时间
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.3
}
/// 动画效果
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
switch type {
case .present:
guard let toVC: YHAddressViewController = transitionContext.viewController(forKey: .to) as? YHAddressViewController else {
return
}
let toView = toVC.view
let containerView = transitionContext.containerView
containerView.addSubview(toView!)
toVC.containV.transform = CGAffineTransform(translationX: 0, y: (toVC.containV.frame.height))
UIView.animate(withDuration: 0.25, animations: {
/// 背景变色
toVC.backgroundView.alpha = 1.0
/// addresspicker向上推出
toVC.containV.transform = CGAffineTransform(translationX: 0, y: -10)
}) { (_) in
UIView.animate(withDuration: 0.2, animations: {
/// transform初始化
toVC.containV.transform = CGAffineTransform.identity
}, completion: { (_) in
transitionContext.completeTransition(true)
})
}
case .dismiss:
guard let toVC: YHAddressViewController = transitionContext.viewController(forKey: .from) as? YHAddressViewController else {
return
}
UIView.animate(withDuration: 0.25, animations: {
toVC.backgroundView.alpha = 0.0
/// addresspicker向下推回
toVC.containV.transform = CGAffineTransform(translationX: 0, y: (toVC.containV.frame.height))
}) { (_) in
transitionContext.completeTransition(true)
}
}
}
}
//
// YHDatePickView.swift
// galaxy
//
// Created by EDY on 2024/1/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
/*
let addressPicker = YHAddressViewController( selectProvince: "上海市", selectCity: "" )
/*** 可使用这种init方法自定制选中颜色,不填写selectColor默认颜色为UIColor(red: 79/255, green: 176/255, blue: 255/255, alpha: 1),蓝色
let addressPicker = EWAddressViewController(selectColor: UIColor.yellow)
*/
// 返回选择数据,地址,省,市,区
addressPicker.backLocationStringController = { (address,province,city,area) in
}
self.present(addressPicker, animated: true, completion: nil)
*/
import UIKit
///默认选中颜色
let defaultColor = UIColor(red: 79/255, green: 176/255, blue: 255/255, alpha: 1)
class YHAddressViewController: UIViewController {
public var backLocationStringController: ((String,String,String,String) -> Void)?
///title选中颜色
public var selectColor: UIColor
public var selectProvince: String?
public var selectCity: String?
public lazy var containV: YHAddressPickView = {
let view = YHAddressPickView(frame: CGRect(x: 0, y: UIScreen.main.bounds.height - 550, width: UIScreen.main.bounds.width, height: 550),selectColor: selectColor,selectedProvince: selectProvince,selectedCity: selectCity)
view.backOnClickCancel = {
[weak self] in
self?.onClickCancel()
}
/// 成功选择后将数据回调,并推出视图
view.backLocationString = {[weak self] (address,province,city,area) in
if self?.backLocationStringController != nil {
self?.backLocationStringController!(address,province,city,area)
self?.onClickCancel()
}
}
return view
}()
public var backgroundView:UIView = {
let view = UIView()
view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.4)
return view
}()
init(selectColor: UIColor = defaultColor,selectProvince: String? = nil, selectCity: String? = nil) {
self.selectColor = selectColor
self.selectProvince = selectProvince
self.selectCity = selectCity
super.init(nibName: nil, bundle: nil)
self.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.3)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
drawMyView()
// Do any additional setup after loading the view.
}
private func drawMyView() {
self.view.insertSubview(self.backgroundView, at: 0)
self.providesPresentationContextTransitionStyle = true
self.definesPresentationContext = true
self.modalPresentationStyle = .custom//viewcontroller弹出后之前控制器页面不隐藏 .custom代表自定义
self.view.addSubview(self.containV)
// 转场动画代理
self.transitioningDelegate = self
}
///点击推出
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
let currentPoint = touches.first?.location(in: self.view)
if !self.containV.frame.contains(currentPoint ?? CGPoint()) {
self.dismiss(animated: true, completion: nil)
}
}
// MARK: onClick
@objc private func onClickCancel() {
self.dismiss(animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
// MARK: - 转场动画delegate
extension YHAddressViewController: UIViewControllerTransitioningDelegate {
/// 推入动画
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
let animated = YHAddressPickerPresentAnimated(type: .present)
return animated
}
/// 推出动画
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
let animated = YHAddressPickerPresentAnimated(type: .dismiss)
return animated
}
}
//
// YHDatePickView.swift
// galaxy
//
// Created by EDY on 2024/1/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
/* 使用例子
YHDatePickView.show(type: .yyyymmdd) { date in
let arr = date.components(separatedBy: YHDatePickView.separator)
// [yyyy, mm, dd] eg ["2024", "01", "20"]
print(date)
}
*/
import UIKit
enum YHDateType: Int {
case yyyymmdd = 0
case yyyymm = 1
case yyyy = 2
}
class YHDatePickView: UIView {
var backDate: ((String) -> Void)?
var centerView: UIView!
var titleLabel: UILabel!
var closeButton: UIButton!
var sureButton: UIButton!
var lineView: UIView!
var pickerView: UIPickerView!
private var currentDateCom: DateComponents = Calendar.current.dateComponents([.year, .month, .day], from: Date())
// 日期分割符 eg: 2024-01-01
static let separator: String = "-"
var type: YHDateType? {
didSet {
guard let type = type else { return }
switch type {
case .yyyymmdd:
pickerView.reloadAllComponents()
case .yyyymm:
pickerView.reloadAllComponents()
case .yyyy:
pickerView.reloadAllComponents()
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(white: 0.5, alpha: 0.1)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tap.delegate = self
addGestureRecognizer(tap)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = 16
return view
}()
addSubview(centerView)
centerView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(322)
}
titleLabel = {
let label = UILabel()
label.text = "选择出生日期"
label.font = kFont(size: 17)
label.textColor = UIColor(hex:0x222222)
label.textAlignment = .center
return label
}()
centerView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.height.equalTo(21)
make.width.equalTo(200)
make.centerX.equalToSuperview()
}
closeButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = kBoldFont(size: 14)
button.contentHorizontalAlignment = .center
button.setTitle("取消", for: .normal)
button.setTitleColor( UIColor(hex:0x222222), for: .normal)
button.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
return button
}()
centerView.addSubview(closeButton)
closeButton.snp.makeConstraints { make in
make.left.equalTo(21)
make.height.equalTo(20)
make.width.equalTo(30)
make.top.equalTo(18)
}
sureButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = kBoldFont(size: 14)
button.contentHorizontalAlignment = .center
button.setTitle("确定", for: .normal)
button.setTitleColor( UIColor(hex:0x4487f9), for: .normal)
button.addTarget(self, action: #selector(sure), for: .touchUpInside)
return button
}()
centerView.addSubview(sureButton)
sureButton.snp.makeConstraints { make in
make.right.equalTo(-21)
make.height.equalTo(20)
make.width.equalTo(30)
make.top.equalTo(18)
}
lineView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0xf0f0f0)
return view
}()
centerView.addSubview(lineView)
lineView.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(52)
make.height.equalTo(1)
make.right.equalTo(-18)
}
pickerView = {
let picker = UIPickerView()
picker.delegate = self
picker.dataSource = self
picker.backgroundColor = UIColor.clear
picker.clipsToBounds = true
return picker
}()
centerView.addSubview(pickerView)
pickerView.snp.makeConstraints { make in
make.left.equalTo(16)
make.top.equalTo(68)
make.height.equalTo(220)
make.right.equalTo(-16)
}
}
@objc private func handleTap(_ sender: AnyObject?) {
print("处理点击手势")
dismiss()
}
static func show(type:YHDateType, callBack: @escaping ((String) -> Void)) {
let view = YHDatePickView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.type = type
view.backDate = callBack
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
}
@objc func dismiss() {
removeFromSuperview()
}
@objc func sure() {
guard let type = type else { return }
var date = ""
switch type {
case .yyyymmdd:
date = String(format: "%02ld%@%02ld%@%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0),Self.separator, self.pickerView.selectedRow(inComponent: 1) + 1,Self.separator, self.pickerView.selectedRow(inComponent: 2) + 1)
case .yyyymm:
date = String(format: "%02ld%@%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0),Self.separator, self.pickerView.selectedRow(inComponent: 1) + 1)
case .yyyy:
date = String(format: "%02ld", (self.currentDateCom.year!) - self.pickerView.selectedRow(inComponent: 0))
}
if self.backDate != nil {
self.backDate!(date)
}
}
}
extension YHDatePickView: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer:UIGestureRecognizer, shouldReceive touch:UITouch) -> Bool {
if touch.view == self {
return true
}
return false
}
}
extension YHDatePickView: UIPickerViewDelegate,UIPickerViewDataSource {
func numberOfComponents(in pickerView: UIPickerView) -> Int {
guard let type = type else { return 3 }
switch type {
case .yyyymmdd:
return 3
case .yyyymm:
return 2
case .yyyy:
return 1
}
}
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
if component == 0 {
return 100
} else if component == 1 {
return 12
} else {
let year: Int = pickerView.selectedRow(inComponent: 0) + currentDateCom.year!
let month: Int = pickerView.selectedRow(inComponent: 1) + 1
let days: Int = howManyDays(inThisYear: year, withMonth: month)
return days
}
}
private func howManyDays(inThisYear year: Int, withMonth month: Int) -> Int {
if (month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12) {
return 31
}
if (month == 4) || (month == 6) || (month == 9) || (month == 11) {
return 30
}
if (year % 4 == 1) || (year % 4 == 2) || (year % 4 == 3) {
return 28
}
if year % 400 == 0 {
return 29
}
if year % 100 == 0 {
return 28
}
return 29
}
func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat {
guard let type = type else { return KScreenWidth / 3 }
switch type {
case .yyyymmdd:
return KScreenWidth / 3
case .yyyymm:
return KScreenWidth / 2
case .yyyy:
return KScreenWidth
}
}
func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat {
return 44
}
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
if component == 0 {
return "\((currentDateCom.year!) - row)"
} else if component == 1 {
return "\(row + 1)"
} else {
return "\(row + 1)"
}
}
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
if component == 1, self.type == .yyyymmdd {
pickerView.reloadComponent(2)
}
}
}
//
// YHImagePickerView.swift
// galaxy
//
// Created by EDY on 2024/1/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
/*
let view = YHImagePickerView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.backImage = { [weak self] image in
guard let self = self else { return }
}
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
*/
import UIKit
class YHImagePickerView: UIView {
var backImage: ((UIImage) -> Void)?
var centerView: UIView!
var titleLabel: UILabel!
var closeButton: UIButton!
var takePhotoBtton: UIButton!
var selectPhotoButton: UIButton!
var cannalButton: UIButton!
var lineView: UIView!
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor(white: 0.5, alpha: 0.1)
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap))
tap.delegate = self
addGestureRecognizer(tap)
setView()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setView() {
backgroundColor = UIColor(hex: 0x0000, alpha: 0.5)
centerView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = 16
return view
}()
addSubview(centerView)
centerView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(244)
}
titleLabel = {
let label = UILabel()
label.text = "请选择上传方式"
label.font = kFont(size: 17)
label.textColor = UIColor(hex:0x222222)
label.textAlignment = .left
return label
}()
centerView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(16)
make.left.height.equalTo(21)
make.right.equalTo(-21)
}
closeButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_card_close"), for: .normal)
button.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
return button
}()
centerView.addSubview(closeButton)
closeButton.snp.makeConstraints { make in
make.right.equalTo(-21)
make.width.height.equalTo(24)
make.top.equalTo(16)
}
takePhotoBtton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = kBoldFont(size: 14)
button.contentHorizontalAlignment = .center
button.setTitle("拍照上传", for: .normal)
button.setTitleColor( UIColor(hex:0x222222), for: .normal)
button.addTarget(self, action: #selector(takePhoto), for: .touchUpInside)
return button
}()
centerView.addSubview(takePhotoBtton)
takePhotoBtton.snp.makeConstraints { make in
make.right.equalTo(-21)
make.height.equalTo(51)
make.left.equalTo(21)
make.top.equalTo(53)
}
selectPhotoButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = kBoldFont(size: 14)
button.contentHorizontalAlignment = .center
button.setTitle("相册上传", for: .normal)
button.setTitleColor( UIColor(hex:0x222222), for: .normal)
button.addTarget(self, action: #selector(selectPhoto), for: .touchUpInside)
return button
}()
centerView.addSubview(selectPhotoButton)
selectPhotoButton.snp.makeConstraints { make in
make.right.equalTo(-21)
make.height.equalTo(51)
make.left.equalTo(21)
make.top.equalTo(105)
}
cannalButton = {
let button = UIButton(type: .custom)
button.titleLabel?.font = kBoldFont(size: 14)
button.contentHorizontalAlignment = .center
button.setTitle("取消", for: .normal)
button.setTitleColor( UIColor(hex:0x909090), for: .normal)
button.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
return button
}()
centerView.addSubview(cannalButton)
cannalButton.snp.makeConstraints { make in
make.right.equalTo(-21)
make.height.equalTo(51)
make.left.equalTo(21)
make.top.equalTo(156)
}
for i in 0..<3 {
let view = UIView()
view.backgroundColor = UIColor(hex: 0xf0f0f0)
centerView.addSubview(view)
view.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(52 + 52 * i)
make.height.equalTo(1)
make.right.equalTo(-18)
}
}
}
@objc private func handleTap(_ sender: AnyObject?) {
print("处理点击手势")
dismiss()
}
@objc func dismiss() {
removeFromSuperview()
}
@objc func takePhoto() {
if UIImagePickerController.isSourceTypeAvailable(.camera){
//创建图片控制器
let imagePicker = UIImagePickerController()
//设置代理
imagePicker.delegate = self
//设置来源
imagePicker.sourceType = .camera
//允许编辑
imagePicker.allowsEditing = true
//打开相机
UIViewController.current?.present(imagePicker, animated: true, completion: { () -> Void in
})
} else {
printLog("找不到相机")
}
}
@objc func selectPhoto() {
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary){
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
// 这一句,开始调用图库
UIViewController.current?.present(imagePicker,animated: true)
}
}
}
extension YHImagePickerView: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer:UIGestureRecognizer, shouldReceive touch:UITouch) -> Bool {
if touch.view == self {
return true
}
return false
}
}
extension YHImagePickerView: UINavigationControllerDelegate, UIImagePickerControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
// 将图片显示给UIImageView
if let block = backImage {
block(image)
self.dismiss()
}
} else {
printLog("pick image wrong")
}
// 收回图库选择界面
picker.dismiss(animated: true, completion: nil)
}
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
}
}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict/> <dict>
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photoLibraryDesciption</string>
</dict>
</plist> </plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment