Commit 048c4131 authored by pete谢兆麟's avatar pete谢兆麟

主申请人高才文件目录

parent ab85ec1c
...@@ -512,6 +512,9 @@ ...@@ -512,6 +512,9 @@
0485DFDA2C660EFA00B50293 /* YHPrincipleRequestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0485DFD92C660EFA00B50293 /* YHPrincipleRequestModel.swift */; }; 0485DFDA2C660EFA00B50293 /* YHPrincipleRequestModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0485DFD92C660EFA00B50293 /* YHPrincipleRequestModel.swift */; };
0485DFDC2C670C7200B50293 /* YHPrincipleSendMailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0485DFDB2C670C7200B50293 /* YHPrincipleSendMailView.swift */; }; 0485DFDC2C670C7200B50293 /* YHPrincipleSendMailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0485DFDB2C670C7200B50293 /* YHPrincipleSendMailView.swift */; };
0485DFE12C6A0B6200B50293 /* YHPrincipleApprovedResultVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0485DFE02C6A0B6200B50293 /* YHPrincipleApprovedResultVC.swift */; }; 0485DFE12C6A0B6200B50293 /* YHPrincipleApprovedResultVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0485DFE02C6A0B6200B50293 /* YHPrincipleApprovedResultVC.swift */; };
04864C212CE496C900C01765 /* YHGCMainApplicantInformationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04864C202CE496C900C01765 /* YHGCMainApplicantInformationViewController.swift */; };
04864C232CE4971A00C01765 /* YHGCMainApplicantInformationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04864C222CE4971A00C01765 /* YHGCMainApplicantInformationViewModel.swift */; };
04864C252CE4978400C01765 /* YHGCInformationCardTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04864C242CE4978400C01765 /* YHGCInformationCardTableViewCell.swift */; };
048787D12BCE61B20036E221 /* YHServiceNoOrderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048787D02BCE61B20036E221 /* YHServiceNoOrderView.swift */; }; 048787D12BCE61B20036E221 /* YHServiceNoOrderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048787D02BCE61B20036E221 /* YHServiceNoOrderView.swift */; };
048787D52BCE880B0036E221 /* YHServiceOrderListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048787D42BCE880B0036E221 /* YHServiceOrderListViewController.swift */; }; 048787D52BCE880B0036E221 /* YHServiceOrderListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048787D42BCE880B0036E221 /* YHServiceOrderListViewController.swift */; };
048787D72BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048787D62BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift */; }; 048787D72BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048787D62BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift */; };
...@@ -1509,6 +1512,9 @@ ...@@ -1509,6 +1512,9 @@
0485DFD92C660EFA00B50293 /* YHPrincipleRequestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleRequestModel.swift; sourceTree = "<group>"; }; 0485DFD92C660EFA00B50293 /* YHPrincipleRequestModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleRequestModel.swift; sourceTree = "<group>"; };
0485DFDB2C670C7200B50293 /* YHPrincipleSendMailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleSendMailView.swift; sourceTree = "<group>"; }; 0485DFDB2C670C7200B50293 /* YHPrincipleSendMailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleSendMailView.swift; sourceTree = "<group>"; };
0485DFE02C6A0B6200B50293 /* YHPrincipleApprovedResultVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleApprovedResultVC.swift; sourceTree = "<group>"; }; 0485DFE02C6A0B6200B50293 /* YHPrincipleApprovedResultVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrincipleApprovedResultVC.swift; sourceTree = "<group>"; };
04864C202CE496C900C01765 /* YHGCMainApplicantInformationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCMainApplicantInformationViewController.swift; sourceTree = "<group>"; };
04864C222CE4971A00C01765 /* YHGCMainApplicantInformationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCMainApplicantInformationViewModel.swift; sourceTree = "<group>"; };
04864C242CE4978400C01765 /* YHGCInformationCardTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGCInformationCardTableViewCell.swift; sourceTree = "<group>"; };
048787D02BCE61B20036E221 /* YHServiceNoOrderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceNoOrderView.swift; sourceTree = "<group>"; }; 048787D02BCE61B20036E221 /* YHServiceNoOrderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceNoOrderView.swift; sourceTree = "<group>"; };
048787D42BCE880B0036E221 /* YHServiceOrderListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceOrderListViewController.swift; sourceTree = "<group>"; }; 048787D42BCE880B0036E221 /* YHServiceOrderListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceOrderListViewController.swift; sourceTree = "<group>"; };
048787D62BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceOrderProgressTableViewCell.swift; sourceTree = "<group>"; }; 048787D62BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceOrderProgressTableViewCell.swift; sourceTree = "<group>"; };
...@@ -3584,6 +3590,7 @@ ...@@ -3584,6 +3590,7 @@
047F3DAF2CDF36CE001B2A6D /* TTPS(高才) */ = { 047F3DAF2CDF36CE001B2A6D /* TTPS(高才) */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
04864C1B2CE4909600C01765 /* MainApplicantInformation(主申请人信息) */,
04B4019C2CE3212B005C61A9 /* MyScheme(我的方案) */, 04B4019C2CE3212B005C61A9 /* MyScheme(我的方案) */,
047F3DCB2CDF3F3C001B2A6D /* MyCertificates(我的证书) */, 047F3DCB2CDF3F3C001B2A6D /* MyCertificates(我的证书) */,
047F3DB02CDF36DE001B2A6D /* ServiceProcess(我的信息流程) */, 047F3DB02CDF36DE001B2A6D /* ServiceProcess(我的信息流程) */,
...@@ -3730,6 +3737,48 @@ ...@@ -3730,6 +3737,48 @@
path = Frameworks; path = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
04864C1B2CE4909600C01765 /* MainApplicantInformation(主申请人信息) */ = {
isa = PBXGroup;
children = (
04864C1F2CE490C800C01765 /* M */,
04864C1E2CE490BE00C01765 /* C */,
04864C1D2CE490B700C01765 /* VM */,
04864C1C2CE490B000C01765 /* V */,
);
path = "MainApplicantInformation(主申请人信息)";
sourceTree = "<group>";
};
04864C1C2CE490B000C01765 /* V */ = {
isa = PBXGroup;
children = (
04864C242CE4978400C01765 /* YHGCInformationCardTableViewCell.swift */,
);
path = V;
sourceTree = "<group>";
};
04864C1D2CE490B700C01765 /* VM */ = {
isa = PBXGroup;
children = (
04864C222CE4971A00C01765 /* YHGCMainApplicantInformationViewModel.swift */,
);
path = VM;
sourceTree = "<group>";
};
04864C1E2CE490BE00C01765 /* C */ = {
isa = PBXGroup;
children = (
04864C202CE496C900C01765 /* YHGCMainApplicantInformationViewController.swift */,
);
path = C;
sourceTree = "<group>";
};
04864C1F2CE490C800C01765 /* M */ = {
isa = PBXGroup;
children = (
);
path = M;
sourceTree = "<group>";
};
0488518B2BF5FAA800C4E32D /* Upload */ = { 0488518B2BF5FAA800C4E32D /* Upload */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -5822,6 +5871,7 @@ ...@@ -5822,6 +5871,7 @@
04B401952CE257DC005C61A9 /* YHGCApplicationTypeResultController.swift in Sources */, 04B401952CE257DC005C61A9 /* YHGCApplicationTypeResultController.swift in Sources */,
A598E9E22C7CB32D00F84739 /* YHTravelDocsPreparationListModel.swift in Sources */, A598E9E22C7CB32D00F84739 /* YHTravelDocsPreparationListModel.swift in Sources */,
047F3DC62CDF3E19001B2A6D /* YHGCChildPrimaryInfoVC.swift in Sources */, 047F3DC62CDF3E19001B2A6D /* YHGCChildPrimaryInfoVC.swift in Sources */,
04864C232CE4971A00C01765 /* YHGCMainApplicantInformationViewModel.swift in Sources */,
A598E9D72C7C9EF300F84739 /* YHTravelDocsPreparationListViewController.swift in Sources */, A598E9D72C7C9EF300F84739 /* YHTravelDocsPreparationListViewController.swift in Sources */,
A520124F2BABCE05008655EA /* YHFileListContentView.swift in Sources */, A520124F2BABCE05008655EA /* YHFileListContentView.swift in Sources */,
04CA2BFF2CB7C9A000F36DE7 /* YHResignUploadSuccessDocListCell.swift in Sources */, 04CA2BFF2CB7C9A000F36DE7 /* YHResignUploadSuccessDocListCell.swift in Sources */,
...@@ -5874,6 +5924,7 @@ ...@@ -5874,6 +5924,7 @@
045EEE992B9F171A0022A143 /* YHPreviewInfoHoldView.swift in Sources */, 045EEE992B9F171A0022A143 /* YHPreviewInfoHoldView.swift in Sources */,
045EEE7E2B9F171A0022A143 /* YHPersonInfoCellModel1.swift in Sources */, 045EEE7E2B9F171A0022A143 /* YHPersonInfoCellModel1.swift in Sources */,
047AA3DD2C4A6126009C4554 /* YHLifeViewController.swift in Sources */, 047AA3DD2C4A6126009C4554 /* YHLifeViewController.swift in Sources */,
04864C252CE4978400C01765 /* YHGCInformationCardTableViewCell.swift in Sources */,
04FD856C2C2153F000BEF9C5 /* YHMyEducationCell.swift in Sources */, 04FD856C2C2153F000BEF9C5 /* YHMyEducationCell.swift in Sources */,
A5DE0D3C2BB9016200976FE1 /* YHEmailInputAlertView.swift in Sources */, A5DE0D3C2BB9016200976FE1 /* YHEmailInputAlertView.swift in Sources */,
04CCEDFD2CA150ED0026EA70 /* YHHKImmigrationRecordsSingleModel.swift in Sources */, 04CCEDFD2CA150ED0026EA70 /* YHHKImmigrationRecordsSingleModel.swift in Sources */,
...@@ -6265,6 +6316,7 @@ ...@@ -6265,6 +6316,7 @@
044EE2402C92E6C000A2FE3A /* YHResignCertificateDetailViewModel.swift in Sources */, 044EE2402C92E6C000A2FE3A /* YHResignCertificateDetailViewModel.swift in Sources */,
045EEECE2B9F171A0022A143 /* YHScoreDetailViewController.swift in Sources */, 045EEECE2B9F171A0022A143 /* YHScoreDetailViewController.swift in Sources */,
04ADBCA42C36906000C37F10 /* YHHeadImageViewController.swift in Sources */, 04ADBCA42C36906000C37F10 /* YHHeadImageViewController.swift in Sources */,
04864C212CE496C900C01765 /* YHGCMainApplicantInformationViewController.swift in Sources */,
045EEE852B9F171A0022A143 /* YHPreviewFamilyMemberViewController.swift in Sources */, 045EEE852B9F171A0022A143 /* YHPreviewFamilyMemberViewController.swift in Sources */,
04FA8B332C0880A100ABE43F /* YHAppleLoginViewModel.swift in Sources */, 04FA8B332C0880A100ABE43F /* YHAppleLoginViewModel.swift in Sources */,
045EEE7F2B9F171A0022A143 /* YHWorkExpInfoPreviewModel.swift in Sources */, 045EEE7F2B9F171A0022A143 /* YHWorkExpInfoPreviewModel.swift in Sources */,
......
...@@ -496,7 +496,10 @@ extension YHServiceOrderListView : UITableViewDelegate,UITableViewDataSource { ...@@ -496,7 +496,10 @@ extension YHServiceOrderListView : UITableViewDelegate,UITableViewDataSource {
if model.status == 1 || model.status == 4 { if model.status == 1 || model.status == 4 {
return return
} else { } else {
YHServiceOrderListView.jumpToMessageController(type: model.type, orderId: orderID, stepID) let vc = YHGCMainApplicantInformationViewController()
vc.orderId = orderID
UIViewController.current?.navigationController?.pushViewController(vc)
// YHServiceOrderListView.jumpToMessageController(type: model.type, orderId: orderID, stepID)
if model.type == 3 { if model.type == 3 {
//我的评分 //我的评分
handleRedPointFor(key: kMyScoreRedPointInfoKey, model: model) handleRedPointFor(key: kMyScoreRedPointInfoKey, model: model)
......
//
// YHGCMainApplicantInformationViewController.swift
// galaxy
//
// Created by EDY on 2024/11/13.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCMainApplicantInformationViewController: YHBaseViewController {
var stepView: YHStepView!
var bottomView: YHBottomNextView!
var tableView: UITableView!
var viewModel: YHGCMainApplicantInformationViewModel!
var dataSource: [YHSectionItemModel]?
var isShowPrompt: Bool = false
var orderId: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
viewModel = YHGCMainApplicantInformationViewModel()
gk_navTitle = "主申请人信息填写"
gk_navBackgroundColor = .white
gk_navBarAlpha = 1
setView()
getData()
// Do any additional setup after loading the view.
}
func getData() {
viewModel.requestMainInformation("\(orderId)") {[weak self] success, error in
guard let self = self else { return }
self.stepView.maxIndex = self.viewModel.mainModel.step
self.stepView.currentIndex = self.viewModel.mainModel.step
self.updateDataSource()
if self.stepView.currentIndex == 3 {
self.bottomView.nextButton.setTitle("提交", for: .normal)
} else {
self.bottomView.nextButton.setTitle("下一步", for: .normal)
}
}
}
func updateDataSource() {
if self.stepView.currentIndex == 0 {
self.dataSource = self.viewModel.getBaseDataSource(isShowPrompt)
self.bottomView.nextButton.setTitle("下一步", for: .normal)
} else if self.stepView.currentIndex == 1 {
self.dataSource = self.viewModel.getIDCardDataSource(isShowPrompt)
self.bottomView.nextButton.setTitle("下一步", for: .normal)
} else if self.stepView.currentIndex == 2 {
self.dataSource = self.viewModel.getDocumentInformation(isShowPrompt)
self.bottomView.nextButton.setTitle("下一步", for: .normal)
} else if self.stepView.currentIndex == 3 {
self.dataSource = self.viewModel.getDetailDataSource(isShowPrompt)
self.bottomView.nextButton.setTitle("提交", for: .normal)
}
self.tableView.reloadData()
}
func setView() {
view.backgroundColor = .contentBkgColor
stepView = {
let step = YHStepView()
step.dataSource = ["初始信息", "证件上传", "证件信息", "基本信息"]
step.block = { [weak self] (index) in
guard let self = self else { return }
self.updateDataSource()
}
return step
}()
view.addSubview(stepView)
stepView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.equalTo(view)
make.height.equalTo(104)
}
tableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.register(cellWithClass: YHMainInformationTableViewCell.self)
tableView.register(cellWithClass: YHGCInformationCardTableViewCell.self)
return tableView
}()
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar + YHStepView.height)
make.bottom.equalTo(-k_Height_safeAreaInsetsBottom() - 64)
make.left.right.bottom.equalTo(view)
}
bottomView = {
let bottom = YHBottomNextView()
bottom.nextblock = { [weak self] in
bottom.nextButton.isEnabled = false
guard let self = self else { return }
if self.viewModel.isCanNext(self.stepView.currentIndex) {
self.viewModel.mainModel.step = self.stepView.currentIndex
self.viewModel.updateMainInformation(.submit, self.orderId, self.stepView.currentIndex) {[weak self] success, error in
guard let self = self else { return }
bottom.nextButton.isEnabled = true
if let error = error {
YHHUD.flash(message: error.errorMsg )
} else {
YHHUD.hideFlashMessage()
self.stepView.currentIndex = self.stepView.currentIndex + 1
self.isShowPrompt = false
self.stepView.currentIndex = self.stepView.currentIndex
if self.stepView.currentIndex == 3 {
self.bottomView.nextButton.setTitle("提交", for: .normal)
} else {
self.bottomView.nextButton.setTitle("下一步", for: .normal)
}
if self.stepView.currentIndex == self.stepView.dataSource?.count {
YHHUD.flash(message: "提交成功")
self.navigationController?.popViewController()
} else {
self.updateDataSource()
}
}
}
} else {
bottom.nextButton.isEnabled = true
self.isShowPrompt = true
self.updateDataSource()
YHHUD.flash(message: "您还有信息未填写")
}
}
bottom.saveBlock = { [weak self] in
guard let self = self else { return }
self.viewModel.updateMainInformation(.save, self.orderId, self.stepView.currentIndex) {[weak self] success, error in
guard let _ = self else { return }
if let error = error {
YHHUD.flash(message: error.errorMsg )
} else {
YHHUD.flash(message: "保存成功")
}
}
}
return bottom
}()
view.addSubview(bottomView)
bottomView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(k_Height_safeAreaInsetsBottom() + 64)
}
bottomView.layoutIfNeeded()
bottomView.nextButton.addYinHeGradualLayer()
}
}
extension YHGCMainApplicantInformationViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataSource?.count ?? 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if stepView.currentIndex == 1 {
let cell = tableView.dequeueReusableCell(withClass: YHGCInformationCardTableViewCell.self)
cell.type = YHCardType(rawValue: indexPath.row) ?? .identity
cell.viewModel = viewModel
cell.backSurfaceDeleteButton.isHidden = true
cell.frontDeleteButton.isHidden = true
cell.informationBlock = {[weak self] type, image, isLeft in
guard let self = self else { return }
}
return cell
} else {
let cell = tableView.dequeueReusableCell(withClass: YHMainInformationTableViewCell.self)
cell.country = self.viewModel.mainModel.address.country
cell.dataSource = dataSource?[indexPath.row]
cell.informationBlock = {[weak self] model in
guard let self = self else { return }
self.viewModel.updateModel(model)
let id = model.id
if id != .id32 && id != .id4 && id != .id8 && id != .id9 && id != .id12 && id != .id13 && id != .id17 && id != .id18 && id != .id21 && id != .id22 && id != .id23 && id != .id34 && id != .id29 && id != .id30 && id != .id35 {
self.updateDataSource()
}
}
return cell
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if stepView.currentIndex == 1 {
return 227.0
} else {
let array = dataSource?[indexPath.row].models ?? []
var h = 0
for i in 0..<array.count {
let data = array[i]
let isShow = data.isShowPrompts ?? false
let message = data.message ?? ""
let isNeed = data.isNeed ?? false
if data.id == .id3 || data.id == .id4 || data.id == .id32 || data.id == .id33 {
if isShow && message.count == 0 && isNeed {
h = h + 72 + 20
} else {
h = h + 72
}
} else {
if isShow && message.count == 0 && isNeed {
h = h + 52 + 20
} else {
h = h + 52
}
}
}
return CGFloat(h + 52 + 14)
}
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 7))
return view
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 7
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
}
//
// YHGCInformationCardTableViewCell.swift
// galaxy
//
// Created by EDY on 2024/11/13.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCInformationCardTableViewCell: UITableViewCell {
typealias InformationBlock = (_ type: YHCardType, _ image: UIImage, _ isleft: Bool) -> ()
var informationBlock: InformationBlock?
var centerView: UIView!
var titleLabel: UILabel!
var exampleButton: UIButton!
var frontLabel: UILabel!
var backSurfaceLabel: UILabel!
var frontImageButton: YHCardButton!
var backSurfaceImageButton: YHCardButton!
var frontDeleteButton: UIButton!
var backSurfaceDeleteButton: UIButton!
var activityIndicator: UIActivityIndicatorView!
var viewModel: YHGCMainApplicantInformationViewModel! {
didSet {
if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_front.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.cn_identity_card.img_front) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.frontImageButton.kf.setBackgroundImage(with: URL(string: url), for: .normal, completionHandler: { _ in
self.frontDeleteButton.isHidden = false
})
self.frontImageButton.setContent("", "")
}
}
if viewModel.mainModel.certificates.cn_identity_card.img_back.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.cn_identity_card.img_back) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.backSurfaceImageButton.kf.setBackgroundImage(with: URL(string: url), for: .normal, completionHandler: { _ in
self.backSurfaceDeleteButton.isHidden = false
})
self.backSurfaceImageButton.setContent("", "")
}
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_front.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.hk_macao_pass.img_front) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.frontImageButton.kf.setBackgroundImage(with: URL(string: url), for: .normal, completionHandler: { _ in
self.frontDeleteButton.isHidden = false
})
self.frontImageButton.setContent("", "")
}
}
if viewModel.mainModel.certificates.hk_macao_pass.img_back.count != 0 {
self.viewModel.getPublicImageUrl(viewModel.mainModel.certificates.hk_macao_pass.img_back) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
self.backSurfaceImageButton.kf.setBackgroundImage(with: URL(string: url), for: .normal, completionHandler: { _ in
self.backSurfaceDeleteButton.isHidden = false
})
self.backSurfaceImageButton.setContent("", "")
}
}
}
}
}
var type: YHCardType = .identity {
didSet {
switch type {
case .identity:
titleLabel.text = "中国身份证(选填)"
frontLabel.text = "身份证人像面"
backSurfaceLabel.text = "身份证国徽面"
frontImageButton.setBackgroundImage(UIImage(named: "service_cn_card_front"), for: .normal)
backSurfaceImageButton.setBackgroundImage(UIImage(named: "service_cn_card_back"), for: .normal)
case .passport:
titleLabel.text = "港澳通行证(选填)"
frontLabel.text = "港澳通行证正面"
backSurfaceLabel.text = "港澳通行证反面"
frontImageButton.setBackgroundImage(UIImage(named: "service_hk_card_front"), for: .normal)
backSurfaceImageButton.setBackgroundImage(UIImage(named: "service_hk_card_back"), for: .normal)
}
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
setupUI()
}
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
centerView = {
let view = UIView()
view.backgroundColor = .white
view.layer.cornerRadius = kCornerRadius6
return view
}()
contentView.addSubview(centerView)
centerView.snp.makeConstraints { make in
make.left.equalTo(16)
make.right.equalTo(-16)
make.top.equalTo(7)
make.bottom.equalTo(-16)
}
titleLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 17)
label.textColor = UIColor.mainTextColor
return label
}()
centerView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(16)
make.height.equalTo(20)
}
exampleButton = {
let button = UIButton(type: .custom)
button.backgroundColor = UIColor.brandMainColor.withAlphaComponent(0.08)
button.titleLabel?.font = UIFont.PFSC_M(ofSize: 10)
button.contentHorizontalAlignment = .center
button.setTitle("示例模板", for: .normal)
button.setTitleColor( UIColor.brandMainColor, for: .normal)
button.layer.cornerRadius = kCornerRadius3
button.addTarget(self, action: #selector(exampleClick), for: .touchUpInside)
return button
}()
centerView.addSubview(exampleButton)
exampleButton.snp.makeConstraints { make in
make.left.equalTo(titleLabel.snp.right).offset(8)
make.centerY.equalTo(titleLabel.snp.centerY)
make.height.equalTo(14)
make.width.equalTo(48)
}
let lineView = {
let view = UIView()
view.backgroundColor = UIColor.separatorColor
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)
}
frontLabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = UIColor.subTextColor
label.textAlignment = .center
return label
}()
centerView.addSubview(frontLabel)
frontLabel.snp.makeConstraints { make in
make.left.equalTo(18)
make.right.equalTo(centerView.snp.centerX)
make.top.equalTo(64)
make.height.equalTo(20)
}
backSurfaceLabel = {
let label = UILabel()
label.font = UIFont.PFSC_R(ofSize: 12)
label.textColor = UIColor.subTextColor
label.textAlignment = .center
return label
}()
centerView.addSubview(backSurfaceLabel)
backSurfaceLabel.snp.makeConstraints { make in
make.right.equalTo(-18)
make.left.equalTo(centerView.snp.centerX)
make.top.equalTo(64)
make.height.equalTo(20)
}
frontImageButton = {
let button = YHCardButton()
button.setContent("card_upload", "点击上传")
button.setBackgroundImage(UIImage(named: "service_cn_card_front"), for: .normal)
button.addTarget(self, action: #selector(frontImageClick), for: .touchUpInside)
button.layer.cornerRadius = 4
button.clipsToBounds = true
return button
}()
centerView.addSubview(frontImageButton)
frontImageButton.snp.makeConstraints { make in
make.left.equalTo(18)
make.top.equalTo(96)
make.height.equalTo(91)
make.width.equalTo(147)
}
frontDeleteButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_card_delete"), for: .normal)
button.addTarget(self, action: #selector(frontDeleteClick), for: .touchUpInside)
button.isHidden = true
return button
}()
centerView.addSubview(frontDeleteButton)
frontDeleteButton.snp.makeConstraints { make in
make.centerX.equalTo(frontImageButton.snp.right)
make.centerY.equalTo(frontImageButton.snp.top)
make.height.equalTo(21)
make.width.equalTo(21)
}
backSurfaceImageButton = {
let button = YHCardButton()
button.setContent("card_upload", "点击上传")
button.setBackgroundImage(UIImage(named: "service_cn_card_back"), for: .normal)
button.addTarget(self, action: #selector(backSurfaceImageClick), for: .touchUpInside)
button.layer.cornerRadius = 4
button.clipsToBounds = true
return button
}()
centerView.addSubview(backSurfaceImageButton)
backSurfaceImageButton.snp.makeConstraints { make in
make.right.equalTo(-18)
make.top.equalTo(96)
make.height.equalTo(91)
make.width.equalTo(147)
}
backSurfaceDeleteButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "service_card_delete"), for: .normal)
button.addTarget(self, action: #selector(backSurfaceDeleteClick), for: .touchUpInside)
button.isHidden = true
return button
}()
centerView.addSubview(backSurfaceDeleteButton)
backSurfaceDeleteButton.snp.makeConstraints { make in
make.centerX.equalTo(backSurfaceImageButton.snp.right)
make.centerY.equalTo(backSurfaceImageButton.snp.top)
make.height.equalTo(21)
make.width.equalTo(21)
}
activityIndicator = {
let view = UIActivityIndicatorView()
view.style = .medium
return view
}()
centerView.addSubview(activityIndicator)
activityIndicator.snp.makeConstraints { make in
make.center.equalTo(backSurfaceImageButton.snp.center)
make.height.equalTo(25)
make.width.equalTo(25)
}
exampleButton.YH_clickEdgeInsets = UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50)
}
@objc func exampleClick() {
let view = YHCardExampleView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
view.type = type
let window = UIApplication.shared.yhKeyWindow()
window?.addSubview(view)
}
@objc func frontImageClick() {
if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_front.count != 0 {
// let vc = YHImageViewController()
// vc.imgString = viewModel.mainModel.certificates.cn_identity_card.img_front
// UIViewController.current?.navigationController?.pushViewController(vc)
if viewModel.mainModel.certificates.cn_identity_card.img_front.isEmpty == false {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.cn_identity_card.img_front
UIViewController.current?.navigationController?.pushViewController(vc)
}
return
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_front.count != 0 {
// let vc = YHImageViewController()
// vc.imgString = viewModel.mainModel.certificates.hk_macao_pass.img_front
// UIViewController.current?.navigationController?.pushViewController(vc)
if viewModel.mainModel.certificates.hk_macao_pass.img_front.isEmpty == false {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.hk_macao_pass.img_front
UIViewController.current?.navigationController?.pushViewController(vc)
}
return
}
}
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
self.frontImageButton.setContent("card_loading", "上传中")
self.frontImageButton.startRotationAnimation()
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
self.frontImageButton.stopRotationAnimation()
self.frontImageButton.setContent("", "")
guard let url = success else { return }
self.viewModel.updateModel(self.type, isFront: true, url: url)
self.frontImageButton.setBackgroundImage(image, for: .normal)
self.frontDeleteButton.isHidden = false
self.viewModel.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
if self.type == .identity {
self.viewModel.requestCnIDCardMessage(url, isBack: 0) {[weak self] success, error in
}
} else {
self.viewModel.requestHkIDCardMessage(url, isBack: 0) {[weak self] success, error in
}
}
}
}
}
}
@objc func backSurfaceImageClick() {
if type == .identity {
if viewModel.mainModel.certificates.cn_identity_card.img_back.count != 0 {
// let vc = YHImageViewController()
// vc.imgString = viewModel.mainModel.certificates.cn_identity_card.img_back
// UIViewController.current?.navigationController?.pushViewController(vc)
if viewModel.mainModel.certificates.cn_identity_card.img_back.isEmpty == false {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.cn_identity_card.img_back
UIViewController.current?.navigationController?.pushViewController(vc)
}
return
}
} else {
if viewModel.mainModel.certificates.hk_macao_pass.img_back.count != 0 {
// let vc = YHImageViewController()
// vc.imgString = viewModel.mainModel.certificates.hk_macao_pass.img_back
// UIViewController.current?.navigationController?.pushViewController(vc)
if viewModel.mainModel.certificates.hk_macao_pass.img_back.isEmpty == false {
let vc = YHImageViewController()
vc.imgString = viewModel.mainModel.certificates.hk_macao_pass.img_back
UIViewController.current?.navigationController?.pushViewController(vc)
}
return
}
}
YHImagePickerView.show() {[weak self] image in
guard let self = self else { return }
self.backSurfaceImageButton.setContent("card_loading", "上传中")
self.backSurfaceImageButton.startRotationAnimation()
self.viewModel.uploadImage(image) {[weak self] success, error in
guard let self = self else { return }
self.backSurfaceImageButton.stopRotationAnimation()
self.backSurfaceImageButton.setContent("", "")
guard let url = success else { return }
self.backSurfaceImageButton.setBackgroundImage(image, for: .normal)
self.viewModel.updateModel(self.type, isFront: false, url: url)
self.backSurfaceDeleteButton.isHidden = false
self.viewModel.getPublicImageUrl(url) {[weak self] success, error in
guard let self = self else { return }
guard let url = success else { return }
if self.type == .identity {
self.viewModel.requestCnIDCardMessage(url, isBack: 1) {[weak self] success, error in
}
} else {
self.viewModel.requestHkIDCardMessage(url, isBack: 1 ) {[weak self] success, error in
}
}
}
}
}
}
func updataData() {
titleLabel.text = "中国身份证(选填)"
frontLabel.text = "身份证人像面"
backSurfaceLabel.text = "身份证国徽面"
}
@objc func frontDeleteClick() {
viewModel.updateModel(self.type, isFront: true, url: "")
frontDeleteButton.isHidden = true
switch type {
case .identity:
frontImageButton.setBackgroundImage(UIImage(named: "service_cn_card_front"), for: .normal)
case .passport:
frontImageButton.setBackgroundImage(UIImage(named: "service_hk_card_front"), for: .normal)
}
frontImageButton.setContent("card_upload", "点击上传")
}
@objc func backSurfaceDeleteClick() {
viewModel.updateModel(self.type, isFront: false, url: "")
backSurfaceDeleteButton.isHidden = true
switch type {
case .identity:
backSurfaceImageButton.setBackgroundImage(UIImage(named: "service_cn_card_back"), for: .normal)
case .passport:
backSurfaceImageButton.setBackgroundImage(UIImage(named: "service_hk_card_back"), for: .normal)
}
backSurfaceImageButton.setContent("card_upload", "点击上传")
}
}
//
// YHGCMainApplicantInformationViewModel.swift
// galaxy
//
// Created by EDY on 2024/11/13.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGCMainApplicantInformationViewModel: YHBaseViewModel {
var mainModel: YHMainInformationModel = YHMainInformationModel()
override init() {
super.init()
}
func getBaseDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] {
let item = YHItemModel(id: .id1, isNeed: true, title: "国家/地区", isUserKeyBoard: false, prompts: "请选择", message: mainModel.nationality, type: .country, isShowPrompts: isShowPrompt, alertMessage:"请选择国家/地区")
let section = YHSectionItemModel(title: "国籍", models: [item])
let item4 = YHItemModel(id: .id2, isNeed: true, title: "国家/地区", isUserKeyBoard: false, prompts: "请选择", message: mainModel.address.country, type: .country, isShowPrompts: isShowPrompt, alertMessage:"请选择国家/地区")
var string = ""
let array = mainModel.address.area
for item in array {
if string.count != 0 {
string = string + "/" + item
} else {
string = string + item
}
}
let item1 = YHItemModel(id: .id3, isNeed: true, title: "省市地区", isUserKeyBoard: false, prompts: "请选择", message: string, type: .address, isShowPrompts: isShowPrompt, alertMessage:"请选择省市地区")
let item2 = YHItemModel(id: .id4, isNeed: true, title: "详细地址", isUserKeyBoard: true, prompts: "请填写小区、楼栋、单元室等", message: mainModel.address.details, isShowPrompts: isShowPrompt, alertMessage:"请填写小区、楼栋、单元室等")
let item11 = YHItemModel(id: .id32, isNeed: true, title: "详细地址", isUserKeyBoard: true, prompts: "请填写国外居住地", message: mainModel.address.foreign, isShowPrompts: isShowPrompt, alertMessage:"请填写国外居住地")
let item22 = YHItemModel(id: .id33, isNeed: true, title: "是否在海外居住一年及以上", isUserKeyBoard: false, prompts: "", message: "\(mainModel.is_live_oversea_year)", leftButtonString: "是", rightButtonString: "否", isShowPrompts: isShowPrompt, alertMessage:"请选择是否在海外居住满1年及以上")
let section1 = YHSectionItemModel(title: "现居住地址", models: [item4, item1, item2])
let section11 = YHSectionItemModel(title: "现居住地址", models: [item4, item11, item22])
let item3 = YHItemModel(id: .id5, isNeed: true, title: "是否办理过", isUserKeyBoard: false, prompts: "", message: "\(mainModel.is_handled)", leftButtonString: "是", rightButtonString: "否", isShowPrompts: isShowPrompt, alertMessage:"请选择是否办理过港澳通行证")
let section2 = YHSectionItemModel(title: "港澳通行证", models: [item3])
let addressCountry = mainModel.address.country
if addressCountry.contains("中国") || addressCountry == "" {
return [section, section1, section2]
} else {
return [section, section11, section2]
}
}
func getDocumentInformation(_ isShowPrompt: Bool) -> [YHSectionItemModel] {
var flag = false
let nationality = mainModel.nationality
if nationality.contains("China") {
flag = true
}
let item = YHItemModel(id: .id8, isNeed: flag, title: "身份证号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.cn_identity_card.number, isShowPrompts: isShowPrompt, alertMessage:"请输入正确的身份证号码")
let item1 = YHItemModel(id: .id9, isNeed: flag, title: "签发地", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.cn_identity_card.issue_at, isShowPrompts: isShowPrompt, alertMessage:"请输入签发地")
let item2 = YHItemModel(id: .id10, isNeed: flag, title: "签发日期", isUserKeyBoard: false, prompts: "请选择", message: mainModel.certificates.cn_identity_card.issue_date_start_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择签发日期")
let item3 = YHItemModel(id: .id11, isNeed: flag, title: "届满日期", isUserKeyBoard: false, prompts: "请选择", message: mainModel.certificates.cn_identity_card.issue_date_end_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择届满日期")
var section1String = ""
if flag {
section1String = "中国身份证"
} else {
section1String = "中国身份证(选填)"
}
let section = YHSectionItemModel(title: section1String, models: [item, item1, item2, item3])
let item10 = YHItemModel(id: .id12, isNeed: true, title: "证件号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.hk_macao_pass.number, isShowPrompts: isShowPrompt, alertMessage:"请输入旅行证件号码")
let item11 = YHItemModel(id: .id13, isNeed: true, title: "签发地", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.hk_macao_pass.issue_at, isShowPrompts: isShowPrompt, alertMessage:"请输入签发地")
let item12 = YHItemModel(id: .id14, isNeed: true, title: "签发日期", isUserKeyBoard: false, prompts: "请选择", message: mainModel.certificates.hk_macao_pass.issue_date_start_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择签发日期")
let item13 = YHItemModel(id: .id15, isNeed: true, title: "届满日期", isUserKeyBoard: false, prompts: "请选择", message: mainModel.certificates.hk_macao_pass.issue_date_end_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择届满日期")
let section1 = YHSectionItemModel(title: "港澳通行证", models: [item10, item11, item12, item13])
let item4 = YHItemModel(id: .id16, isNeed: !flag, title: "证件类别", isUserKeyBoard: false, prompts: "请选择", message: "\(mainModel.certificates.passport.passport_type)", type: .id, isShowPrompts: isShowPrompt, alertMessage:"请选择件类别")
let item5 = YHItemModel(id: .id17, isNeed: !flag, title: "证件号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.passport.number, isShowPrompts: isShowPrompt, alertMessage:"请输入证件号码")
let item6 = YHItemModel(id: .id18, isNeed: !flag, title: "签发地", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.passport.issue_at, isShowPrompts: isShowPrompt, alertMessage:"请输入签发地")
let item7 = YHItemModel(id: .id19, isNeed: !flag, title: "签发日期", isUserKeyBoard: false, prompts: "请选择", message: mainModel.certificates.passport.issue_date_start_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择签发日期")
let item8 = YHItemModel(id: .id20, isNeed: !flag, title: "届满日期", isUserKeyBoard: false, prompts: "请选择", message: mainModel.certificates.passport.issue_date_end_at, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择届满日期")
var section2String = ""
if flag {
section2String = "护照及其他旅行证件(选填)"
} else {
section2String = "护照及其他旅行证件"
}
let section2 = YHSectionItemModel(title: section2String, models: [item4, item5, item6, item7, item8])
if mainModel.is_handled == 1 {
return [section, section1, section2]
} else {
return [section, section2]
}
}
func getDetailDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] {
let item = YHItemModel(id: .id21, isNeed: true, title: "主申请人姓名", isUserKeyBoard: true, prompts: "请输入", message: mainModel.username, isShowPrompts: isShowPrompt, alertMessage:"请输入主申请人姓名")
let item1 = YHItemModel(id: .id22, isNeed: false, title: "曾用名", isUserKeyBoard: true, prompts: "请与户口本一致,若无则不填", message: mainModel.used_name, isShowPrompts: isShowPrompt)
let item2 = YHItemModel(id: .id23, isNeed: false, title: "婚前姓氏", isUserKeyBoard: true, prompts: "如有则填写,仅支持输入字母", message: mainModel.surname, isShowPrompts: isShowPrompt)
let item3 = YHItemModel(id: .id24, isNeed: true, title: "出生日期", isUserKeyBoard: false, prompts: "请选择", message: mainModel.birthday, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择出生日期")
let item4 = YHItemModel(id: .id25, isNeed: true, title: "出生国家/地区", isUserKeyBoard: false, prompts: nil, message: "\(mainModel.birth_place_aboard)", leftButtonString: "国内", rightButtonString: "国外", isShowPrompts: isShowPrompt, alertMessage:"请选择出生国家/地区")
var string = ""
let array = mainModel.birth_place.area
for item in array {
if string.count != 0 {
string = string + "/" + item
} else {
string = string + item
}
}
let item5 = YHItemModel(id: .id26, isNeed: true, title: "出生城市", isUserKeyBoard: false, prompts: "请选择", message: string, type: .address, isShowPrompts: isShowPrompt, alertMessage:"请选择出生城市;")
let item55 = YHItemModel(id: .id34, isNeed: true, title: "出生城市", isUserKeyBoard: true, prompts: "请输入", message: mainModel.birth_place.foreign, isShowPrompts: isShowPrompt, alertMessage:"请输入出生城市")
let item6 = YHItemModel(id: .id27, isNeed: true, title: "性别", isUserKeyBoard: false, prompts: "请选择", message: "\(mainModel.sex )", type: .sex, alertMessage:"请选择性别")
let item7 = YHItemModel(id: .id28, isNeed: true, title: "婚姻状况", isUserKeyBoard: false, prompts: "请选择", message: "\(mainModel.married )", type: .marry, isShowPrompts: isShowPrompt, alertMessage:"请选择婚姻状况")
var item555 = item5
if mainModel.birth_place_aboard == 1 {
item555 = item55
}
let section = YHSectionItemModel(title: "主申请人信息", models: [item, item1, item2, item3, item4, item555, item6, item7])
let item8 = YHItemModel(id: .id29, isNeed: true, title: "手机号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.mobile, isShowPrompts: isShowPrompt, alertMessage:"请输入手机号码")
let item9 = YHItemModel(id: .id30, isNeed: false, title: "电子邮箱", isUserKeyBoard: true, prompts: "请输入", message: mainModel.email, isShowPrompts: isShowPrompt, alertMessage:"")
let section1 = YHSectionItemModel(title: "联系方式", models: [item8, item9])
let item10 = YHItemModel(id: .id31, isNeed: true, title: "是否办理过", isUserKeyBoard: false, prompts: nil, message: "\(mainModel.has_hk_id )", leftButtonString: "是", rightButtonString: "否", isShowPrompts: isShowPrompt, alertMessage:"请选择")
let item11 = YHItemModel(id: .id35, isNeed: true, title: "香港身份证号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.hk_id_number, isShowPrompts: isShowPrompt, alertMessage:"请输入香港身份证号码")
let section2 = YHSectionItemModel(title: "香港身份证", models: [item10])
let section22 = YHSectionItemModel(title: "香港身份证", models: [item10, item11])
var section222 = section2
if mainModel.has_hk_id == 1 {
section222 = section22
}
return [section, section1, section222]
}
func getIDCardDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] {
let item = YHItemModel(id: .id5, isNeed: true, title: "身份证", isUserKeyBoard: false, prompts: "请输入", message: nil, isShowPrompts: isShowPrompt)
let section = YHSectionItemModel(title: "中国身份证(选填)", models: [item])
let item1 = YHItemModel(id: .id6, isNeed: true, title: "港澳通行证(选填)", isUserKeyBoard: false, prompts: "请输入", message: nil, isShowPrompts: isShowPrompt)
let section1 = YHSectionItemModel(title: "中国身份证(选填)", models: [item1])
if mainModel.is_handled == 1 {
return [section, section1]
} else {
return [section]
}
}
func updateModel(_ item: YHItemModel) {
guard let type = item.id else { return }
switch type {
case .id1:
mainModel.nationality = item.message ?? ""
case .id2:
mainModel.address.country = item.message ?? ""
case .id3:
mainModel.address.area = item.value ?? []
case .id4:
mainModel.address.details = item.message ?? ""
case .id5:
mainModel.is_handled = item.value?.first?.int ?? 0
case .id6:
printLog("1")
case .id7:
printLog("1")
case .id8:
mainModel.certificates.cn_identity_card.number = item.message ?? ""
case .id9:
mainModel.certificates.cn_identity_card.issue_at = item.message ?? ""
case .id10:
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"
if let selectDate = format.date(from:item.message ?? "") {
let selectTimeInterval = selectDate.timeIntervalSince1970
let currentTimeInterval = Date().timeIntervalSince1970
if selectTimeInterval > currentTimeInterval {
YHHUD.flash(message: "签发日期不能晚于当前日期")
} else {
guard let endDate = format.date(from: mainModel.certificates.cn_identity_card.issue_date_end_at) else {
mainModel.certificates.cn_identity_card.issue_date_start_at = item.message ?? ""
return
}
let endTimeInterval = endDate.timeIntervalSince1970
if selectTimeInterval > endTimeInterval {
YHHUD.flash(message: "签发日期不能晚于届满日期")
} else {
mainModel.certificates.cn_identity_card.issue_date_start_at = item.message ?? ""
}
}
}
case .id11:
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"
if let selectDate = format.date(from:item.message ?? ""), let startDate = format.date(from:mainModel.certificates.cn_identity_card.issue_date_start_at) {
let selectTimeInterval = selectDate.timeIntervalSince1970
let startTimeInterval = startDate.timeIntervalSince1970
if selectTimeInterval < startTimeInterval {
YHHUD.flash(message: "届满日期不能早于签发日期")
} else {
mainModel.certificates.cn_identity_card.issue_date_end_at = item.message ?? ""
}
} else {
mainModel.certificates.cn_identity_card.issue_date_end_at = item.message ?? ""
}
case .id12:
mainModel.certificates.hk_macao_pass.number = item.message ?? ""
case .id13:
mainModel.certificates.hk_macao_pass.issue_at = item.message ?? ""
case .id14:
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"
if let selectDate = format.date(from:item.message ?? "") {
let selectTimeInterval = selectDate.timeIntervalSince1970
let currentTimeInterval = Date().timeIntervalSince1970
if selectTimeInterval > currentTimeInterval {
YHHUD.flash(message: "签发日期不能晚于当前日期")
} else {
guard let endDate = format.date(from: mainModel.certificates.hk_macao_pass.issue_date_end_at) else {
mainModel.certificates.hk_macao_pass.issue_date_start_at = item.message ?? ""
return
}
let endTimeInterval = endDate.timeIntervalSince1970
if selectTimeInterval > endTimeInterval {
YHHUD.flash(message: "签发日期不能晚于届满日期")
} else {
mainModel.certificates.hk_macao_pass.issue_date_start_at = item.message ?? ""
}
}
}
case .id15:
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"
if let selectDate = format.date(from:item.message ?? ""), let startDate = format.date(from:mainModel.certificates.hk_macao_pass.issue_date_start_at) {
let selectTimeInterval = selectDate.timeIntervalSince1970
let startTimeInterval = startDate.timeIntervalSince1970
if selectTimeInterval < startTimeInterval {
YHHUD.flash(message: "届满日期不能早于签发日期")
} else {
mainModel.certificates.hk_macao_pass.issue_date_end_at = item.message ?? ""
}
}
case .id16:
mainModel.certificates.passport.passport_type = item.value?.first?.int ?? 0
case .id17:
mainModel.certificates.passport.number = item.message ?? ""
case .id18:
mainModel.certificates.passport.issue_at = item.message ?? ""
case .id19:
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"
if let selectDate = format.date(from:item.message ?? "") {
let selectTimeInterval = selectDate.timeIntervalSince1970
let currentTimeInterval = Date().timeIntervalSince1970
if selectTimeInterval > currentTimeInterval {
YHHUD.flash(message: "签发日期不能晚于当前日期")
} else {
guard let endDate = format.date(from: mainModel.certificates.passport.issue_date_end_at) else {
mainModel.certificates.passport.issue_date_start_at = item.message ?? ""
return
}
let endTimeInterval = endDate.timeIntervalSince1970
if selectTimeInterval > endTimeInterval {
YHHUD.flash(message: "签发日期不能晚于届满日期")
} else {
mainModel.certificates.passport.issue_date_start_at = item.message ?? ""
}
}
}
case .id20:
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"
if let selectDate = format.date(from:item.message ?? ""), let startDate = format.date(from:mainModel.certificates.passport.issue_date_start_at) {
let selectTimeInterval = selectDate.timeIntervalSince1970
let startTimeInterval = startDate.timeIntervalSince1970
if selectTimeInterval < startTimeInterval {
YHHUD.flash(message: "届满日期不能早于签发日期")
} else {
mainModel.certificates.passport.issue_date_end_at = item.message ?? ""
}
}
case .id21:
mainModel.username = item.message ?? ""
case .id22:
mainModel.used_name = item.message ?? ""
case .id23:
mainModel.surname = item.message ?? ""
case .id24:
let format = DateFormatter()
format.dateFormat = "yyyy-MM-dd"
if let selectDate = format.date(from:item.message ?? "") {
let selectTimeInterval = selectDate.timeIntervalSince1970
let currentTimeInterval = Date().timeIntervalSince1970
if selectTimeInterval > currentTimeInterval {
YHHUD.flash(message: "入学日期不能晚于当前日期")
} else {
mainModel.birthday = item.message ?? ""
}
}
case .id25:
mainModel.birth_place_aboard = item.value?.first?.int ?? 0
case .id26:
mainModel.birth_place.area = item.value ?? []
case .id27:
mainModel.sex = item.value?.first?.int ?? 0
case .id28:
mainModel.married = item.value?.first?.int ?? 0
case .id29:
mainModel.mobile = item.message ?? ""
case .id30:
mainModel.email = item.message ?? ""
case .id31:
mainModel.has_hk_id = item.value?.first?.int ?? 0
case .id32:
mainModel.address.foreign = item.message ?? ""
case .id33:
mainModel.is_live_oversea_year = item.value?.first?.int ?? 0
case .id34:
mainModel.birth_place.foreign = item.message ?? ""
case .id35:
mainModel.hk_id_number = item.message ?? ""
case .id36:
printLog("不需要")
case .id37:
printLog("不需要")
case .id38:
printLog("不需要")
case .id39:
printLog("不需要")
}
}
func updateModel(_ type: YHCardType, isFront: Bool, url: String) {
switch type {
case .identity:
if isFront {
mainModel.certificates.cn_identity_card.img_front = url
} else {
mainModel.certificates.cn_identity_card.img_back = url
}
case .passport:
if isFront {
mainModel.certificates.hk_macao_pass.img_front = url
} else {
mainModel.certificates.hk_macao_pass.img_back = url
}
}
}
func updateModel(_ model: YHHKIDCardModel) {
if model.name.count != 0 {
mainModel.username = model.name
}
if model.birth.count != 0 {
mainModel.birthday = model.birth
}
if model.gender.count != 0 {
if model.gender == "女" {
mainModel.sex = 2
} else {
mainModel.sex = 1
}
}
if model.term_begins.count != 0 {
mainModel.certificates.hk_macao_pass.issue_date_start_at = model.term_begins
}
if model.end_of_term.count != 0 {
mainModel.certificates.hk_macao_pass.issue_date_end_at = model.end_of_term
}
if model.IssueAddress.count != 0 {
mainModel.certificates.hk_macao_pass.issue_at = model.IssueAddress
}
if model.card_num.count != 0 {
mainModel.certificates.hk_macao_pass.number = model.card_num
}
}
func updateModel(_ model: YHCNIDCardModel) {
if model.name.count != 0 {
mainModel.username = model.name
}
if model.birth.count != 0 {
mainModel.birthday = model.birth
}
if model.gender.count != 0 {
if model.gender == "女" {
mainModel.sex = 2
} else {
mainModel.sex = 1
}
}
if model.term_begins.count != 0 {
mainModel.certificates.cn_identity_card.issue_date_start_at = model.term_begins
}
if model.end_of_term.count != 0 {
mainModel.certificates.cn_identity_card.issue_date_end_at = model.end_of_term
}
if model.issuing_authority.count != 0 {
mainModel.certificates.cn_identity_card.issue_at = model.issuing_authority
}
if model.card_num.count != 0 {
mainModel.certificates.cn_identity_card.number = model.card_num
}
}
func requestMainInformation(_ orderID: String, callBackBlock:@escaping (_ success: YHMainInformationModel?, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.getInformation
let param: [String: Any] = ["order_id": orderID]
let _ = YHNetRequest.getRequest(url: strUrl, params: param) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let result = YHMainInformationModel.deserialize(from: dic) else {
callBackBlock(nil,nil)
return
}
self.mainModel = result
callBackBlock(result, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil,err)
}
}
func updateMainInformation(_ saveType: YHSaveType, _ orderID: Int, _ step: Int, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
var type = ""
if saveType == .save {
type = "save"
} else {
type = "submit"
}
let area: [String] = mainModel.address.area
let birthArea: [String] = mainModel.birth_place.area
let address = ["area": area,
"country": mainModel.address.country,
"details": mainModel.address.details,
"foreign": mainModel.address.foreign] as [String : Any]
let birthPlace = ["area": birthArea,
"country": mainModel.birth_place.country,
"details": mainModel.birth_place.details,
"foreign": mainModel.birth_place.foreign] as [String : Any]
let cnID = ["img_back": mainModel.certificates.cn_identity_card.img_back,
"img_front": mainModel.certificates.cn_identity_card.img_front,
"issue_at": mainModel.certificates.cn_identity_card.issue_at,
"issue_date_end_at": mainModel.certificates.cn_identity_card.issue_date_end_at,
"issue_date_start_at": mainModel.certificates.cn_identity_card.issue_date_start_at,
"number": mainModel.certificates.cn_identity_card.number] as [String : Any]
let hkID = ["img_back": mainModel.certificates.hk_macao_pass.img_back,
"img_front": mainModel.certificates.hk_macao_pass.img_front,
"issue_at": mainModel.certificates.hk_macao_pass.issue_at,
"issue_date_end_at": mainModel.certificates.hk_macao_pass.issue_date_end_at,
"issue_date_start_at": mainModel.certificates.hk_macao_pass.issue_date_start_at,
"number": mainModel.certificates.hk_macao_pass.number] as [String : Any]
let passport = ["img_back": mainModel.certificates.passport.img_back,
"img_front": mainModel.certificates.passport.img_front,
"issue_at": mainModel.certificates.passport.issue_at,
"issue_date_end_at": mainModel.certificates.passport.issue_date_end_at,
"issue_date_start_at": mainModel.certificates.passport.issue_date_start_at,
"number": mainModel.certificates.passport.number,
"passport_type": mainModel.certificates.passport.passport_type] as [String : Any]
let country = mainModel.address.country
if country.contains("中国") {
mainModel.address_aboard = 0
} else {
mainModel.address_aboard = 1
}
let params: [String : Any] = ["address": address,
"address_aboard": mainModel.address_aboard,
"age":mainModel.age,
"birth_place": birthPlace,
"birth_place_aboard": mainModel.birth_place_aboard,
"birthday": mainModel.birthday,
"email": mainModel.email,
"has_hk_id": mainModel.has_hk_id,
"hk_id_number": mainModel.hk_id_number,
"id": mainModel.id,
"is_handled": mainModel.is_handled,
"is_live_oversea_year": mainModel.is_live_oversea_year,
"married": mainModel.married,
"mobile": mainModel.mobile,
"nationality": mainModel.nationality,
"order_id": orderID,
"sex": mainModel.sex,
"step": step,
"surname": mainModel.surname,
"used_name": mainModel.used_name,
"username": mainModel.username,
"save_type": type,
"username_pinyin": ["family_name": mainModel.username_pinyin.family_name,
"given_name": mainModel.username_pinyin.given_name],
"certificates":["cn_identity_card": cnID,
"hk_macao_pass": hkID,
"passport": passport]
]
// let strUrl = "http://192.168.25.48:18088/" + YHAllApiName.OrderInformation.updateInformation
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.updateInformation
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
func requestCnIDCardMessage(_ url: String, isBack: Int, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curOssURL() + YHAllApiName.OCR.cn
let params: [String : Any] = ["url": url,
"is_back": isBack]
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let result = YHCNIDCardModel.deserialize(from: dic) else {
callBackBlock(false, nil)
return
}
self.updateModel(result)
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func requestHkIDCardMessage(_ url: String, isBack: Int, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curOssURL() + YHAllApiName.OCR.hk
let params: [String : Any] = ["url": url,
"is_back": isBack]
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
guard let dic = json.data?.peel as? [String : Any], let result = YHHKIDCardModel.deserialize(from: dic) else {
callBackBlock(false, nil)
return
}
self.updateModel(result)
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func isCanNext(_ step: Int) -> Bool {
if step == 0 {
let nationality = mainModel.nationality
let country = mainModel.address.country
let area = mainModel.address.area
let details = mainModel.address.details
let foreign = mainModel.address.foreign
guard nationality.count > 0 else { return false }
guard country.count > 0 else { return false }
if country.contains("中国") {
guard area.count > 0 else { return false }
guard details.count > 0 else { return false }
return true
} else {
guard foreign.count > 0 else { return false }
return true
}
} else if step == 1 {
return true
} else if step == 2 {
let cn_identity_card_number = mainModel.certificates.cn_identity_card.number
let cn_identity_card_issue_at = mainModel.certificates.cn_identity_card.issue_at
let cn_identity_card_issue_date_start_at = mainModel.certificates.cn_identity_card.issue_date_start_at
let cn_identity_card_issue_date_end_at = mainModel.certificates.cn_identity_card.issue_date_end_at
let hk_macao_pass_number = mainModel.certificates.hk_macao_pass.number
let hk_macao_pass_issue_at = mainModel.certificates.hk_macao_pass.issue_at
let hk_macao_pass_issue_date_start_at = mainModel.certificates.hk_macao_pass.issue_date_start_at
let hk_macao_pass_issue_date_end_at = mainModel.certificates.hk_macao_pass.issue_date_end_at
let passport_type = mainModel.certificates.passport.passport_type
let passport_number = mainModel.certificates.passport.number
let passport_issue_at = mainModel.certificates.passport.issue_at
let passport_issue_date_start_at = mainModel.certificates.passport.issue_date_start_at
let passport_issue_date_end_at = mainModel.certificates.passport.issue_date_end_at
let nationality = mainModel.nationality
if self.mainModel.is_handled == 1 {
guard hk_macao_pass_number.count > 0 else { return false }
guard hk_macao_pass_issue_at.count > 0 else { return false }
guard hk_macao_pass_issue_date_start_at.count > 0 else { return false }
guard hk_macao_pass_issue_date_end_at.count > 0 else { return false }
}
if nationality.contains("China") {
guard cn_identity_card_number.count == 18 else { return false }
guard cn_identity_card_issue_at.count > 0 else { return false }
guard cn_identity_card_issue_date_start_at.count > 0 else { return false }
guard cn_identity_card_issue_date_end_at.count > 0 else { return false }
} else {
guard passport_type > 0 else { return false }
guard passport_number.count > 0 else { return false }
guard passport_issue_at.count > 0 else { return false }
guard passport_issue_date_start_at.count > 0 else { return false }
guard passport_issue_date_end_at.count > 0 else { return false }
}
return true
} else {
let username = mainModel.username
let birthday = mainModel.birthday
let birth_place_aboard = mainModel.birth_place_aboard
let birth_place_area = mainModel.birth_place.area
let birth_place_foreign = mainModel.birth_place.foreign
let sex = mainModel.sex
_ = mainModel.married
let mobile = mainModel.mobile
let has_hk_id = mainModel.has_hk_id
let hk_id_numbe = mainModel.hk_id_number
guard username.count > 0 else { return false }
guard birthday.count > 0 else { return false }
guard sex > 0 else { return false }
guard mobile.count > 0 else { return false }
if birth_place_aboard == 1 {
guard birth_place_foreign.count > 0 else { return false }
} else {
guard birth_place_area.count > 0 else { return false }
}
if has_hk_id == 1 {
guard hk_id_numbe.count > 0 else { return false }
}
return true
}
}
}
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