Commit 3a5869d9 authored by Steven杜宇's avatar Steven杜宇

// 身份证上传

parent c861ba37
......@@ -81,6 +81,8 @@
04A7BC8F2B6B2BC2000E8D47 /* YHFamilyRequestViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A7BC8E2B6B2BC2000E8D47 /* YHFamilyRequestViewModel.swift */; };
04A7BC912B6B7B89000E8D47 /* YHTwoOptionAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A7BC902B6B7B89000E8D47 /* YHTwoOptionAlertView.swift */; };
04AF58C42B4FC51C0066011A /* YHLocalizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AF58C32B4FC51C0066011A /* YHLocalizable.swift */; };
04B0239C2B91F3EF00B83629 /* YHIdentityCardCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B0239B2B91F3EF00B83629 /* YHIdentityCardCell.swift */; };
04B0239E2B92C27C00B83629 /* YHFamilyMemberViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04B0239D2B92C27C00B83629 /* YHFamilyMemberViewModel.swift */; };
04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693612B723AB8004C1758 /* YHMySettingViewController.swift */; };
04C693642B723B56004C1758 /* YHMySettingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693632B723B56004C1758 /* YHMySettingCell.swift */; };
04C693692B73191A004C1758 /* YHEducationInfoListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04C693682B73191A004C1758 /* YHEducationInfoListVC.swift */; };
......@@ -380,6 +382,8 @@
04A7BC8E2B6B2BC2000E8D47 /* YHFamilyRequestViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFamilyRequestViewModel.swift; sourceTree = "<group>"; };
04A7BC902B6B7B89000E8D47 /* YHTwoOptionAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTwoOptionAlertView.swift; sourceTree = "<group>"; };
04AF58C32B4FC51C0066011A /* YHLocalizable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLocalizable.swift; sourceTree = "<group>"; };
04B0239B2B91F3EF00B83629 /* YHIdentityCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHIdentityCardCell.swift; sourceTree = "<group>"; };
04B0239D2B92C27C00B83629 /* YHFamilyMemberViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFamilyMemberViewModel.swift; sourceTree = "<group>"; };
04C693612B723AB8004C1758 /* YHMySettingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingViewController.swift; sourceTree = "<group>"; };
04C693632B723B56004C1758 /* YHMySettingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMySettingCell.swift; sourceTree = "<group>"; };
04C693682B73191A004C1758 /* YHEducationInfoListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHEducationInfoListVC.swift; sourceTree = "<group>"; };
......@@ -641,6 +645,7 @@
042FBBC02B63B21700F9DE23 /* YHFormItemDegreeInfoCell.swift */,
042FBBC42B64AE3D00F9DE23 /* YHFormItemOnlyDoubleChoiceCell.swift */,
042FBBC82B64DC8900F9DE23 /* YHFormItemExpireDateCell.swift */,
04B0239B2B91F3EF00B83629 /* YHIdentityCardCell.swift */,
04010B942B6A1DE90093F3BB /* YHSaveAndSubmitView.swift */,
);
path = V;
......@@ -664,6 +669,7 @@
children = (
041B52DA2B5FDF8E007EBCEB /* YHFamilyInitialInfo.swift */,
04A7BC8E2B6B2BC2000E8D47 /* YHFamilyRequestViewModel.swift */,
04B0239D2B92C27C00B83629 /* YHFamilyMemberViewModel.swift */,
041B52DC2B60A889007EBCEB /* YHTest.swift */,
);
path = M;
......@@ -1960,6 +1966,7 @@
A5C5B2EA2B4ECA4D00A7C5D1 /* YHDavidModel0.swift in Sources */,
04E86E512B847D1B00A35F4B /* YHWorkMessageSelectTableViewCell.swift in Sources */,
A5ACE9572B4564F7002C94D2 /* YHBasicContentView.swift in Sources */,
04B0239C2B91F3EF00B83629 /* YHIdentityCardCell.swift in Sources */,
04E86E3E2B834FC100A35F4B /* YHWorkExperienceTextItemView.swift in Sources */,
042FBBC92B64DC8900F9DE23 /* YHFormItemExpireDateCell.swift in Sources */,
A5234E2E2B6E43EA00A33433 /* YHBasicInfoFillView.swift in Sources */,
......@@ -1979,6 +1986,7 @@
042FBBCB2B65058000F9DE23 /* YHChildBasicInfoVC.swift in Sources */,
04E86E6A2B87352700A35F4B /* YHCompanySelectViewController.swift in Sources */,
A5191F602B89E6FA001069F7 /* YHPreviewInfoQuestionAndAnswerItemView.swift in Sources */,
04B0239E2B92C27C00B83629 /* YHFamilyMemberViewModel.swift in Sources */,
04E86E452B8357EC00A35F4B /* YHItemModel.swift in Sources */,
A5ACE9302B4564F7002C94D2 /* Algorithm.swift in Sources */,
A5C5B32B2B57D17600A7C5D1 /* YHDavidCell5.swift in Sources */,
......
......@@ -10,14 +10,67 @@ import UIKit
class YHCertificateUploadVC: YHBaseViewController, YHFamilyMemberProtol {
var tableView: UITableView!
var familyMember:YHFamilyMember? {
didSet {
if let familyMember = familyMember {
viewModel.mainModel = familyMember
}
}
}
var viewModel: YHFamilyMemberViewModel = YHFamilyMemberViewModel()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .systemPink
// Do any additional setup after loading the view.
self.view.backgroundColor = .white
createUI()
}
func nextStep()->Bool {
return true
}
func createUI() {
tableView = {
let tableView = UITableView(frame:.zero, style:.plain)
if #available(iOS 11.0, *) {
tableView.contentInsetAdjustmentBehavior = .never
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.register(cellWithClass: YHIdentityCardCell.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)
}
}
}
extension YHCertificateUploadVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return viewModel.getIDCardDataSource(false).count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHIdentityCardCell.self)
cell.type = YHCardType(rawValue: indexPath.row) ?? .identity
cell.viewModel = viewModel
cell.informationBlock = {[weak self] type, image, isLeft in
guard let self = self else { return }
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 217.0
}
}
......@@ -42,6 +42,7 @@ class YHSpouseInfoContainerVC: YHBaseViewController, YHSpouseInfoVCProtocol {
didSet {
if let spouse = spouse {
primaryInfoVC.spouse = spouse
uploadVC.familyMember = spouse
certificateVC.familyMember = spouse
basicInfoVC.spouse = spouse
}
......
......@@ -63,25 +63,18 @@ class YHSpousePrimaryInfoVC: YHBaseViewController, YHFamilyMemberProtol {
if spouse.isFollow() { // 随行才加后面的信息
// 国籍
let title1 = YHFormTitleItem(type: .nationality)
let item10 = YHFormDetailItem(type: .nationOrArea)
item10.value = spouse.nationality
item10.placeHolder = "请选择".local
item10.tips = "请选择国家/地区".local
let item10 = YHFormDetailItem(type:.nationOrArea, value:spouse.nationality, placeHolder:"请选择".local, tips:"请选择国籍".local)
let arr1:[YHFormItemProtocol] = [title1, item10]
// 居住信息
var arr2 = [YHFormItemProtocol]()
let title2 = YHFormTitleItem(type: .liveInfo)
let item20 = YHFormDetailItem(type: .isLiveTother)
item20.value = String(spouse.isLiveTother())
let item20 = YHFormDetailItem(type:.isLiveTother, value:String(spouse.isLiveTother()))
arr2.append(title2)
arr2.append(item20)
if !spouse.isLiveTother() { // 不同住 才需填写国家/地区
let item21 = YHFormDetailItem(type: .nationOrArea)
item21.value = spouse.address.country
item21.placeHolder = "请选择".local
item21.tips = "请选择国家/地区".local
let item21 = YHFormDetailItem(type:.nationOrArea, value:spouse.address.country, placeHolder:"请选择".local, tips:"请选择国家/地区".local)
arr2.append(item21)
// 国家/地区已填写 才显示现居住城市和详细地址两行
......@@ -91,19 +84,17 @@ class YHSpousePrimaryInfoVC: YHBaseViewController, YHFamilyMemberProtol {
// 居住信息中选择中国才会显示现居住城市
let isLiveInChina = spouse.address.country.contains("中国".local)
if isLiveInChina {
let item22 = YHFormDetailItem(type: .liveCity)
var value:String? = ""
if !spouse.address.area.isEmpty {
item22.value = spouse.address.area.joined(separator: "/")
value = spouse.address.area.joined(separator: "/")
}
item22.placeHolder = "请选择城市".local
item22.tips = "请请选择城市".local
let item22 = YHFormDetailItem(type:.liveCity, value:value, placeHolder:"请选择城市".local, tips:"请请选择城市".local)
arr2.append(item22)
}
let item23 = YHFormDetailItem(type: .detailAddress)
item23.value = spouse.address.details
item23.placeHolder = (isLiveInChina ? "请填写小区、楼栋、单元室等".local : "请填写国外居住地".local)
item23.tips = (isLiveInChina ? "请填写小区、楼栋、单元室等".local : "请填写国外居住地".local)
let placeHolder = (isLiveInChina ? "请填写小区、楼栋、单元室等".local : "请填写国外居住地".local)
let tips = (isLiveInChina ? "请填写小区、楼栋、单元室等".local : "请填写国外居住地".local)
let item23 = YHFormDetailItem(type:.detailAddress, value:spouse.address.details, placeHolder:placeHolder, tips:tips)
arr2.append(item23)
if !isLiveInChina {// 在国外
......
......@@ -12,9 +12,6 @@ class YHCertificateInfoController: YHBaseViewController, YHFamilyMemberProtol {
var familyMember:YHFamilyMember?
weak var delegate:YHSpouseInfoVCProtocol?
var certificates:YHCertificates = YHCertificates()
var items:[[YHFormItemProtocol]] = [[YHFormItemProtocol]]()
lazy var tableView: UITableView = {
......@@ -63,16 +60,6 @@ class YHCertificateInfoController: YHBaseViewController, YHFamilyMemberProtol {
}
guard let familyMember = familyMember else { return }
if let cer = familyMember.certificates {
certificates = cer
} else {
certificates.cnIdentityCard = YHCNIdentityCard()
certificates.passport = YHCNIdentityCard()
if familyMember.isHandled == 1 { // 要办理港澳通行证
certificates.hkMacaoPass = YHCNIdentityCard()
}
}
loadCertificateInfo()
}
......@@ -89,15 +76,13 @@ class YHCertificateInfoController: YHBaseViewController, YHFamilyMemberProtol {
let item04 = YHFormDetailItem(type: .certificateValidDate)
let arr0:[YHFormItemProtocol] = [title0, item01, item02, item03, item04]
items.append(arr0)
if let cnIdentityCard = certificates.cnIdentityCard {
item01.value = cnIdentityCard.number
item02.value = cnIdentityCard.issueAt
item03.value = cnIdentityCard.issueDateStartAt
item04.value = cnIdentityCard.issueDateEndAt
}
item01.value = familyMember.certificates.cnIdentityCard.number
item02.value = familyMember.certificates.cnIdentityCard.issueAt
item03.value = familyMember.certificates.cnIdentityCard.issueDateStartAt
item04.value = familyMember.certificates.cnIdentityCard.issueDateEndAt
// 港澳通行证 非必须
if certificates.hkMacaoPass != nil {
if familyMember.isNeedHandleHKPassPort() {
let title1 = YHFormTitleItem(type: .hkAndMacaoPassport)
let item10 = YHFormDetailItem(type: .traverlPassportNumber)
let item11 = YHFormDetailItem(type: .certificateSignPlace)
......@@ -105,12 +90,12 @@ class YHCertificateInfoController: YHBaseViewController, YHFamilyMemberProtol {
let item13 = YHFormDetailItem(type: .certificateValidDate)
let arr1:[YHFormItemProtocol] = [title1, item10, item11, item12, item13]
items.append(arr1)
if let hkMacaoPass = certificates.hkMacaoPass {
item10.value = hkMacaoPass.number
item11.value = hkMacaoPass.issueAt
item12.value = hkMacaoPass.issueDateStartAt
item13.value = hkMacaoPass.issueDateEndAt
}
item10.value = familyMember.certificates.hkMacaoPass.number
item11.value = familyMember.certificates.hkMacaoPass.issueAt
item12.value = familyMember.certificates.hkMacaoPass.issueDateStartAt
item13.value = familyMember.certificates.hkMacaoPass.issueDateEndAt
}
// 护照及其他旅行证件 信息必有
......@@ -122,17 +107,15 @@ class YHCertificateInfoController: YHBaseViewController, YHFamilyMemberProtol {
let item24 = YHFormDetailItem(type: .certificateValidDate, isNeed: false)
let arr2:[YHFormItemProtocol] = [title2, item20, item21, item22, item23, item24]
items.append(arr2)
if let passport = certificates.passport {
item20.value = String(passport.passportType)
item21.value = passport.number
item22.value = passport.issueAt
item23.value = passport.issueDateStartAt
item24.value = passport.issueDateEndAt
}
item20.value = String(familyMember.certificates.passport.passportType)
item21.value = familyMember.certificates.passport.number
item22.value = familyMember.certificates.passport.issueAt
item23.value = familyMember.certificates.passport.issueDateStartAt
item24.value = familyMember.certificates.passport.issueDateEndAt
// 证件类别名称
var selectType:YHFormPickerViewSubType = .certificate(.passport)
if let passPortType = self.familyMember?.certificates?.passport?.passportType,
if let passPortType = self.familyMember?.certificates.passport.passportType,
let subType = YHPickerViewCertificateType(rawValue: passPortType)
{
selectType = YHFormPickerViewSubType.certificate(subType)
......@@ -187,24 +170,24 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
guard let self = self else { return }
if detailItem.type == .chinaIdentityCardNumber {
self.familyMember?.certificates?.cnIdentityCard?.number = text
self.familyMember?.certificates.cnIdentityCard.number = text ?? ""
} else if detailItem.type == .traverlPassportNumber {
self.familyMember?.certificates?.hkMacaoPass?.number = text
self.familyMember?.certificates.hkMacaoPass.number = text ?? ""
} else if detailItem.type == .certificateNumber {
self.familyMember?.certificates?.passport?.number = text
self.familyMember?.certificates.passport.number = text ?? ""
} else if detailItem.type == .certificateSignPlace { // 签发地
if title.type == .chinaIdCardInfo {
self.familyMember?.certificates?.cnIdentityCard?.issueAt = text
self.familyMember?.certificates.cnIdentityCard.issueAt = text ?? ""
} else if title.type == .hkAndMacaoPassport {
self.familyMember?.certificates?.hkMacaoPass?.issueAt = text
self.familyMember?.certificates.hkMacaoPass.issueAt = text ?? ""
} else if title.type == .passPortOrTravelInfo {
self.familyMember?.certificates?.passport?.issueAt = text
self.familyMember?.certificates.passport.issueAt = text ?? ""
}
}
if isEditEnd {
......@@ -306,15 +289,15 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
guard let self = self else { return }
guard let familyMember = self.familyMember else { return }
var certificate = familyMember.certificates?.cnIdentityCard
var certificate = familyMember.certificates.cnIdentityCard
if title.type == .chinaIdCardInfo {
certificate = familyMember.certificates?.cnIdentityCard
certificate = familyMember.certificates.cnIdentityCard
} else if title.type == .hkAndMacaoPassport {
certificate = familyMember.certificates?.hkMacaoPass
certificate = familyMember.certificates.hkMacaoPass
} else if title.type == .passPortOrTravelInfo {
certificate = familyMember.certificates?.passport
certificate = familyMember.certificates.passport
}
changeCertificateDate(certificate, type: detailItem.type, date: date)
self.loadCertificateInfo()
......@@ -323,7 +306,7 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
} else if detailItem.type == .certificateType { // 选择证件类别
var selectType:YHFormPickerViewSubType = .certificate(.passport)
if let passPortType = self.familyMember?.certificates?.passport?.passportType,
if let passPortType = self.familyMember?.certificates.passport.passportType,
let subType = YHPickerViewCertificateType(rawValue: passPortType)
{
selectType = YHFormPickerViewSubType.certificate(subType)
......@@ -332,7 +315,7 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
YHFormPickerView.show(type: .certificate, selectType:selectType) {
[weak self] selectType in
guard let self = self else { return }
self.familyMember?.certificates?.passport?.passportType = selectType.index
self.familyMember?.certificates.passport.passportType = selectType.index
self.loadCertificateInfo()
self.save()
}
......@@ -343,9 +326,9 @@ extension YHCertificateInfoController : UITableViewDelegate, UITableViewDataSour
func changeCertificateDate(_ certificate:YHCNIdentityCard?, type:YHFormDetailItemType, date:String?) {
if type == .certificateSignDate {
certificate?.issueDateStartAt = date
certificate?.issueDateStartAt = date ?? ""
} else if type == .certificateValidDate {
certificate?.issueDateEndAt = date
certificate?.issueDateEndAt = date ?? ""
}
}
......
......@@ -399,9 +399,12 @@ class YHFormDetailItem : YHFormItemProtocol {
return true
}
init(type: YHFormDetailItemType, isNeed:Bool = true) {
init(type: YHFormDetailItemType, isNeed:Bool = true, value:String? = "", placeHolder:String? = "", tips:String? = "") {
self.type = type
self.isNeed = isNeed
self.value = value
self.placeHolder = placeHolder
self.tips = tips
}
......@@ -912,7 +915,7 @@ class YHFamilyMember: SmartCodable, YHFormItemProtocol {
var step: Int = 0
var isHandled: Int = 0
var notFillNumber: Int = -1
var certificates: YHCertificates?
var certificates: YHCertificates = YHCertificates()
var usedName: String = ""
var hkIdentityOther: String = ""
var isHkHandled: Int = 0
......@@ -1218,9 +1221,9 @@ class YHSubsetNamePinyin: SmartCodable {
// MARK: - YHCertificates
class YHCertificates: SmartCodable {
var cnIdentityCard: YHCNIdentityCard?
var passport: YHCNIdentityCard?
var hkMacaoPass: YHCNIdentityCard?
var cnIdentityCard: YHCNIdentityCard = YHCNIdentityCard()
var passport: YHCNIdentityCard = YHCNIdentityCard()
var hkMacaoPass: YHCNIdentityCard = YHCNIdentityCard()
enum CodingKeys: String, CodingKey {
case cnIdentityCard = "cnIdentityCard"
......@@ -1231,24 +1234,18 @@ class YHCertificates: SmartCodable {
required init() {
}
init(cnIdentityCard: YHCNIdentityCard?, passport: YHCNIdentityCard?, hkMacaoPass: YHCNIdentityCard?) {
self.cnIdentityCard = cnIdentityCard
self.passport = passport
self.hkMacaoPass = hkMacaoPass
}
}
// MARK: - YHCNIdentityCard
class YHCNIdentityCard: SmartCodable {
var id: Int = 0
var number: String?
var issueAt: String?
var issueDateStartAt: String?
var issueDateEndAt: String?
var imgFront: String?
var imgBack: String?
var number: String = ""
var issueAt: String = ""
var issueDateStartAt: String = ""
var issueDateEndAt: String = ""
var imgFront: String = ""
var imgBack: String = ""
var passportType: Int = 0
enum CodingKeys: String, CodingKey {
......@@ -1265,16 +1262,6 @@ class YHCNIdentityCard: SmartCodable {
required init() {
}
init(id:Int, number: String?, issueAt:String?, issueDateStartAt: String?, imgFront: String?, imgBack: String?, passportType: Int) {
self.id = id
self.number = number
self.issueAt = issueAt
self.issueDateStartAt = issueDateStartAt
self.imgFront = imgFront
self.imgBack = imgBack
self.passportType = passportType
}
}
// MARK: - YHHasDegreeJson
......
//
// YHFamilyMemberViewModel.swift
// galaxy
//
// Created by edy on 2024/3/2.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import Alamofire
class YHFamilyMemberViewModel {
var mainModel: YHFamilyMember = YHFamilyMember()
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.isNeedHandleHKPassPort() {
return [section, section1]
} else {
return [section]
}
}
func updateModel(_ item: YHItemModel) {
guard let type = item.id else { return }
if item.id == .id8 {
mainModel.certificates.cnIdentityCard.number = item.message ?? ""
} else if item.id == .id9 {
mainModel.certificates.cnIdentityCard.issueAt = item.message ?? ""
} else if item.id == .id10 {
mainModel.certificates.cnIdentityCard.issueDateStartAt = item.message ?? ""
} else if item.id == .id11 {
mainModel.certificates.cnIdentityCard.issueDateEndAt = item.message ?? ""
} else if item.id == .id12 {
mainModel.certificates.hkMacaoPass.number = item.message ?? ""
} else if item.id == .id13 {
mainModel.certificates.hkMacaoPass.issueAt = item.message ?? ""
} else if item.id == .id14 {
mainModel.certificates.hkMacaoPass.issueDateStartAt = item.message ?? ""
} else if item.id == .id15 {
mainModel.certificates.hkMacaoPass.issueDateEndAt = item.message ?? ""
} else if item.id == .id16 {
// mainModel.certificates.passport.passportType = item.value?.first ?? ""
} else if item.id == .id17 {
mainModel.certificates.passport.number = item.message ?? ""
} else if item.id == .id18 {
mainModel.certificates.passport.issueAt = item.message ?? ""
} else if item.id == .id19 {
mainModel.certificates.passport.issueDateStartAt = item.message ?? ""
} else if item.id == .id20 {
mainModel.certificates.passport.issueDateEndAt = item.message ?? ""
}
}
// 更新身份证
func updateModel(_ model: YHCNIDCardModel) {
if model.name.count != 0 {
mainModel.subsetName = model.name
}
if model.birth.count != 0 {
mainModel.birthday = model.birth.toTimeString()
}
if model.gender.count != 0 {
if model.gender == "女" {
mainModel.setMale(false)
} else {
mainModel.setMale(true)
}
}
if model.term_begins.count != 0 {
mainModel.certificates.hkMacaoPass.issueDateStartAt = model.term_begins.toTimeString()
}
if model.end_of_term.count != 0 {
mainModel.certificates.hkMacaoPass.issueDateEndAt = model.end_of_term.toTimeString()
}
if model.issuing_authority.count != 0 {
mainModel.certificates.hkMacaoPass.issueAt = model.issuing_authority
}
if model.card_num.count != 0 {
mainModel.certificates.hkMacaoPass.number = model.card_num
}
}
// 更新港澳通行证
func updateModel(_ model: YHHKIDCardModel) {
if model.name.count != 0 {
mainModel.subsetName = model.name
}
if model.birth.count != 0 {
mainModel.birthday = model.birth.toTimeString()
}
if model.gender.count != 0 {
if model.gender == "女" {
mainModel.setMale(false)
} else {
mainModel.setMale(true)
}
}
if model.term_begins.count != 0 {
mainModel.certificates.hkMacaoPass.issueDateStartAt = model.term_begins.toTimeString()
}
if model.end_of_term.count != 0 {
mainModel.certificates.hkMacaoPass.issueDateEndAt = model.end_of_term.toTimeString()
}
if model.issuing_authority.count != 0 {
mainModel.certificates.hkMacaoPass.issueAt = model.issuing_authority
}
if model.card_num.count != 0 {
mainModel.certificates.hkMacaoPass.number = model.card_num
}
}
func updateModel(_ type: YHCardType, isFront: Bool, url: String) {
switch type {
case .identity:
if isFront {
mainModel.certificates.cnIdentityCard.imgFront = url
} else {
mainModel.certificates.cnIdentityCard.imgBack = url
}
case .passport:
if isFront {
mainModel.certificates.hkMacaoPass.imgFront = url
} else {
mainModel.certificates.hkMacaoPass.imgBack = url
}
}
}
// 上传方法
func uploadImage(_ image: UIImage, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/upload/storage"
let boundary = UUID().uuidString
let headers: HTTPHeaders = [
"Content-type": "multipart/form-data; boundary=\(boundary)",
"businessCode": "4001001"
]
let _ = YHNetRequest.uplaodRequest(url: strUrl, headers: headers, image: image) { [weak self] json, code in
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil, err)
}
}
func getPublicImageUrl(_ url: String, callBackBlock:@escaping (_ success: String?, _ error:YHErrorModel?)->()) {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/storage/convertToPublicURL" + "?fileUrl=\(url)"
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象
guard let _ = self else { return }
if json.code == 200 {
callBackBlock(json.data as? String, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
}
} failBlock: { err in
callBackBlock(nil,err)
}
}
func requestCnIDCardMessage(_ url: String, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.cnIdCard
let params: [String : Any] = ["url": url]
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHCNIDCardModel.deserialize(from: dic as? Dictionary) 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, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.hkIdCard
let params: [String : Any] = ["url": url]
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
//1. json字符串 转 对象
guard let self = self else { return }
if json.code == 200 {
let dic = json.data
guard let result = YHHKIDCardModel.deserialize(from: dic as? Dictionary) 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)
}
}
}
......@@ -14,8 +14,8 @@ class YHFamilyRequestViewModel {
//请求所有家庭成员信息
func getFamilyInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
// let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Family.familyInfoApi
let strUrl = "http://192.168.34.187:8808/" + YHAllApiName.Family.familyInfoApi
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Family.familyInfoApi
// let strUrl = "http://192.168.34.187:8808/" + YHAllApiName.Family.familyInfoApi
YHHUD.show(.progress(message: "数据加载中..."))
......
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