Commit d5db5837 authored by pete谢兆麟's avatar pete谢兆麟

主申请人信息模块完善

parent 68aabe60
...@@ -65,6 +65,8 @@ enum YHItemID: Int { ...@@ -65,6 +65,8 @@ enum YHItemID: Int {
case id37 = 36 // 证件签发地 case id37 = 36 // 证件签发地
case id38 = 37 // 卡片有效期签发日期 case id38 = 37 // 卡片有效期签发日期
case id39 = 38 // 卡片有效期届满日期 case id39 = 38 // 卡片有效期届满日期
case id40 = 39 // 是否拥有现时定居国家/地区的永久居留身份
case id41 = 40 // 海外居留开始时间
} }
......
...@@ -36,6 +36,8 @@ class YHMainInformationModel: SmartCodable { ...@@ -36,6 +36,8 @@ class YHMainInformationModel: SmartCodable {
var live_address: String = "" var live_address: String = ""
var live_address_detail: String = "" var live_address_detail: String = ""
var have_permanent_residency: Int = 2
var residence_time: String = ""
required init() { required init() {
} }
} }
......
...@@ -107,7 +107,7 @@ class YHMainInformationTableViewCell: UITableViewCell { ...@@ -107,7 +107,7 @@ class YHMainInformationTableViewCell: UITableViewCell {
let isShow = data.isShowPrompts ?? false let isShow = data.isShowPrompts ?? false
let message = data.message ?? "" let message = data.message ?? ""
let isNeed = data.isNeed ?? false let isNeed = data.isNeed ?? false
if data.id == .id3 || data.id == .id4 || data.id == .id32 || data.id == .id33 { if data.id == .id3 || data.id == .id4 || data.id == .id32 || data.id == .id33 || data.id == .id40 {
if isShow && message.count == 0 && isNeed { if isShow && message.count == 0 && isNeed {
h = 71 + 20 h = 71 + 20
} else { } else {
......
...@@ -364,6 +364,10 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -364,6 +364,10 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
printLog("不需要") printLog("不需要")
case .id40:
break
case .id41:
break
} }
} }
......
...@@ -206,7 +206,7 @@ extension YHGCMainApplicantInformationViewController: UITableViewDelegate, UITab ...@@ -206,7 +206,7 @@ extension YHGCMainApplicantInformationViewController: UITableViewDelegate, UITab
let isShow = data.isShowPrompts ?? false let isShow = data.isShowPrompts ?? false
let message = data.message ?? "" let message = data.message ?? ""
let isNeed = data.isNeed ?? false let isNeed = data.isNeed ?? false
if data.id == .id3 || data.id == .id4 || data.id == .id32 || data.id == .id33 { if data.id == .id3 || data.id == .id4 || data.id == .id32 || data.id == .id33 || data.id == .id40 {
if isShow && message.count == 0 && isNeed { if isShow && message.count == 0 && isNeed {
h = h + 72 + 20 h = h + 72 + 20
} else { } else {
......
...@@ -33,14 +33,32 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -33,14 +33,32 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel {
let item2 = YHItemModel(id: .id4, isNeed: true, title: "详细地址", isUserKeyBoard: true, prompts: "请填写小区、楼栋、单元室等", message: mainModel.address.details, 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 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 item22 = YHItemModel(id: .id33, isNeed: true, title: "是否在海外居住一年及以上", isUserKeyBoard: false, prompts: "", message: "\(mainModel.is_live_oversea_year)", leftButtonString: "是", rightButtonString: "否", isShowPrompts: isShowPrompt, alertMessage:"请选择是否在海外居住满1年及以上")
let item222 = YHItemModel(id: .id40, isNeed: true, title: "是否拥有现时定居国家/地区的永久居留身份", isUserKeyBoard: false, prompts: "", message: "\(mainModel.have_permanent_residency)", leftButtonString: "是", rightButtonString: "否", isShowPrompts: isShowPrompt, alertMessage:"请选择是否拥有现时定居国家/地区的永久居留身份")
let item2222 = YHItemModel(id: .id41, isNeed: true, title: "海外居留开始时间", isUserKeyBoard: false, prompts: "请选择", message: mainModel.residence_time, type: .time, isShowPrompts: isShowPrompt, alertMessage:"请选择海外居留开始时间")
let section1 = YHSectionItemModel(title: "现居住地址", models: [item4, item1, item2]) let section1 = YHSectionItemModel(title: "现居住地址", models: [item4, item1, item2])
let section11 = YHSectionItemModel(title: "现居住地址", models: [item4, item11, item22]) let section11 = YHSectionItemModel(title: "现居住地址", models: [item4, item11, item22])
let section111 = YHSectionItemModel(title: "现居住地址", models: [item4, item11, item222])
let section1111 = YHSectionItemModel(title: "现居住地址", models: [item4, item11, item222, item2222])
let item3 = YHItemModel(id: .id5, isNeed: true, title: "是否办理过", isUserKeyBoard: false, prompts: "", message: "\(mainModel.is_handled)", leftButtonString: "是", rightButtonString: "否", isShowPrompts: isShowPrompt, alertMessage:"请选择是否办理过港澳通行证") 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 section2 = YHSectionItemModel(title: "港澳通行证", models: [item3])
let addressCountry = mainModel.address.country let addressCountry = mainModel.address.country
let nationality = mainModel.nationality let nationality = mainModel.nationality
let is_live_oversea_year = mainModel.is_live_oversea_year let is_live_oversea_year = mainModel.is_live_oversea_year
if (nationality.contains("中国") && addressCountry.contains("中国")) || (nationality.contains("中国") && is_live_oversea_year == 0) { let have_permanent_residency = mainModel.have_permanent_residency
if nationality.contains("中国") && !addressCountry.contains("中国") {
if have_permanent_residency == 1 {
return [section, section111, section2]
} else if have_permanent_residency == 0 {
if isOneYearAgo(yearMonth: mainModel.residence_time) {
return [section, section1111, section2]
} else {
return [section, section1111]
}
} else {
return [section, section111]
}
} else if (nationality.contains("中国") && addressCountry.contains("中国")) || (nationality.contains("中国") && is_live_oversea_year == 0) {
if addressCountry.contains("中国") || addressCountry == "" { if addressCountry.contains("中国") || addressCountry == "" {
return [section, section1, section2] return [section, section1, section2]
} else { } else {
...@@ -355,9 +373,45 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -355,9 +373,45 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel {
printLog("不需要") printLog("不需要")
case .id39: case .id39:
printLog("不需要") printLog("不需要")
case .id40:
mainModel.have_permanent_residency = item.value?.first?.int ?? 0
if mainModel.have_permanent_residency == 1 {
mainModel.is_live_oversea_year = 1
} else {
if isOneYearAgo(yearMonth: mainModel.residence_time) {
mainModel.is_live_oversea_year = 1
} else {
mainModel.is_live_oversea_year = 0
}
}
case .id41:
mainModel.residence_time = item.message ?? ""
if isOneYearAgo(yearMonth: mainModel.residence_time) {
mainModel.is_live_oversea_year = 1
} else {
mainModel.is_live_oversea_year = 0
}
}
}
func isOneYearAgo(yearMonth: String) -> Bool {
// 创建日期格式化器
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM"
// 将字符串转换为日期
guard let inputDate = dateFormatter.date(from: yearMonth) else {
return false // 如果转换失败,返回 false
} }
let calendar = Calendar.current
let oneYearAgo = calendar.date(byAdding: .year, value: -1, to: Date())!
// 获取输入日期的年份和月份
let inputYearMonth = calendar.date(from: calendar.dateComponents([.year, .month], from: inputDate))!
// 比较输入日期与一年前的日期
return calendar.isDate(inputYearMonth, inSameDayAs: oneYearAgo)
} }
func updateModel(_ type: YHCardType, isFront: Bool, url: String) { func updateModel(_ type: YHCardType, isFront: Bool, url: String) {
...@@ -521,6 +575,8 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -521,6 +575,8 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel {
"used_name": mainModel.used_name, "used_name": mainModel.used_name,
"username": mainModel.username, "username": mainModel.username,
"save_type": type, "save_type": type,
"have_permanent_residency": mainModel.have_permanent_residency,
"residence_time": mainModel.residence_time,
"username_pinyin": ["family_name": mainModel.username_pinyin.family_name, "username_pinyin": ["family_name": mainModel.username_pinyin.family_name,
"given_name": mainModel.username_pinyin.given_name], "given_name": mainModel.username_pinyin.given_name],
"certificates":["cn_identity_card": cnID, "certificates":["cn_identity_card": cnID,
...@@ -595,12 +651,22 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -595,12 +651,22 @@ class YHGCMainApplicantInformationViewModel: YHBaseViewModel {
let area = mainModel.address.area let area = mainModel.address.area
let details = mainModel.address.details let details = mainModel.address.details
let foreign = mainModel.address.foreign let foreign = mainModel.address.foreign
let residence_time = mainModel.residence_time
let have_permanent_residency = mainModel.have_permanent_residency
guard nationality.count > 0 else { return false } guard nationality.count > 0 else { return false }
guard country.count > 0 else { return false } guard country.count > 0 else { return false }
if country.contains("中国") { if country.contains("中国") {
guard area.count > 0 else { return false } if nationality.contains("中国") {
guard details.count > 0 else { return false } guard area.count > 0 else { return false }
return true guard details.count > 0 else { return false }
return true
} else {
guard have_permanent_residency > 0 else { return false }
if have_permanent_residency == 0 {
guard residence_time.count > 0 else { return false }
}
return true
}
} else { } else {
guard foreign.count > 0 else { return false } guard foreign.count > 0 else { return false }
return true 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