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

字段校验

parent 8d3e8913
...@@ -93,27 +93,36 @@ class YHMainApplicantInformationViewController: YHBaseViewController { ...@@ -93,27 +93,36 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
guard let self = self else { return } guard let self = self else { return }
if self.viewModel.isCanNext(self.stepView.currentIndex) { if self.viewModel.isCanNext(self.stepView.currentIndex) {
self.stepView.currentIndex = self.stepView.currentIndex + 1 self.stepView.currentIndex = self.stepView.currentIndex + 1
self.viewModel.updateMainInformation(.submit, self.orderId) {[weak self] success in self.viewModel.updateMainInformation(.submit, self.orderId) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.isShowPrompt = false if let error = error {
self.stepView.currentIndex = self.stepView.currentIndex YHHUD.flash(message: error.errorMsg )
if self.stepView.currentIndex == self.stepView.dataSource?.count {
YHHUD.flash(message: "提交成功")
self.navigationController?.popViewController()
} else { } else {
self.updateDataSource() self.isShowPrompt = false
self.stepView.currentIndex = self.stepView.currentIndex
if self.stepView.currentIndex == self.stepView.dataSource?.count {
YHHUD.flash(message: "提交成功")
self.navigationController?.popViewController()
} else {
self.updateDataSource()
}
} }
} }
} else { } else {
self.isShowPrompt = true self.isShowPrompt = true
self.updateDataSource() self.updateDataSource()
YHHUD.flash(message: "请完善信息") YHHUD.flash(message: "您还有信息未填写")
} }
} }
bottom.saveBlock = { [weak self] in bottom.saveBlock = { [weak self] in
guard let self = self else { return } guard let self = self else { return }
self.viewModel.updateMainInformation(.save, self.orderId) {[weak self] success in self.viewModel.updateMainInformation(.save, self.orderId) {[weak self] success, error in
guard let self = self else { return } guard let _ = self else { return }
if let error = error {
YHHUD.flash(message: error.errorMsg )
} else {
YHHUD.flash(message: "保存成功")
}
} }
} }
return bottom return bottom
......
...@@ -70,8 +70,9 @@ struct YHItemModel { ...@@ -70,8 +70,9 @@ struct YHItemModel {
var type: YHItemSelectType? var type: YHItemSelectType?
var value: [String]? var value: [String]?
var isShowPrompts: Bool? var isShowPrompts: Bool?
var alertMessage: String?
init(id: YHItemID? = nil, isNeed: Bool? = nil, title: String? = nil, isUserKeyBoard: Bool? = nil, prompts: String? = nil, message: String? = nil, leftButtonString: String? = nil, rightButtonString: String? = nil, type: YHItemSelectType? = nil, value: [String]? = nil, isShowPrompts: Bool? = nil) { init(id: YHItemID? = nil, isNeed: Bool? = nil, title: String? = nil, isUserKeyBoard: Bool? = nil, prompts: String? = nil, message: String? = nil, leftButtonString: String? = nil, rightButtonString: String? = nil, type: YHItemSelectType? = nil, value: [String]? = nil, isShowPrompts: Bool? = nil, alertMessage: String? = nil) {
self.id = id self.id = id
self.isNeed = isNeed self.isNeed = isNeed
self.title = title self.title = title
...@@ -83,6 +84,7 @@ struct YHItemModel { ...@@ -83,6 +84,7 @@ struct YHItemModel {
self.type = type self.type = type
self.value = value self.value = value
self.isShowPrompts = isShowPrompts self.isShowPrompts = isShowPrompts
self.alertMessage = alertMessage
} }
} }
......
...@@ -155,7 +155,7 @@ class YHItemView: UIView { ...@@ -155,7 +155,7 @@ class YHItemView: UIView {
} }
messageTextField.placeholder = dataSource.prompts messageTextField.placeholder = dataSource.prompts
messageTextField.text = dataSource.message messageTextField.text = dataSource.message
showPromptLabel.text = "\(dataSource.prompts ?? "")" + "\(dataSource.title ?? "")" showPromptLabel.text = dataSource.alertMessage
if dataSource.isUserKeyBoard ?? false { if dataSource.isUserKeyBoard ?? false {
nextStepImageView.isHidden = true nextStepImageView.isHidden = true
centerButton.isHidden = true centerButton.isHidden = true
...@@ -381,6 +381,26 @@ extension YHItemView: UITextFieldDelegate { ...@@ -381,6 +381,26 @@ extension YHItemView: UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let newText = (textField.text! as NSString).replacingCharacters(in: range, with: string) let newText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
if (dataSource?.id == .id9 || dataSource?.id == .id21 || dataSource?.id == .id22 || dataSource?.id == .id23) && newText.count > 30 {
return false
}
if (dataSource?.id == .id4 || dataSource?.id == .id32 || dataSource?.id == .id13 || dataSource?.id == .id18 || dataSource?.id == .id32 ) && newText.count > 100 {
return false
}
if (dataSource?.id == .id12 || dataSource?.id == .id17 || dataSource?.id == .id30) && newText.count > 50 {
return false
}
if (dataSource?.id == .id8) && newText.count > 20 {
return false
}
if (dataSource?.id == .id29 || dataSource?.id == .id35) && newText.count > 18 {
return false
}
var data = dataSource ?? YHItemModel() var data = dataSource ?? YHItemModel()
data.message = newText data.message = newText
if let block = block { if let block = block {
......
...@@ -23,23 +23,22 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -23,23 +23,22 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
} }
func getBaseDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] { func getBaseDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] {
let item = YHItemModel(id: .id1, isNeed: true, title: "国家/地区", isUserKeyBoard: false, prompts: "请选择", message: mainModel.nationality, type: .country, isShowPrompts: isShowPrompt) 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 section = YHSectionItemModel(title: "国籍", models: [item])
let item4 = YHItemModel(id: .id2, isNeed: true, title: "国家/地区", isUserKeyBoard: false, prompts: "请选择", message: mainModel.address.country, type: .country, isShowPrompts: isShowPrompt) let item4 = YHItemModel(id: .id2, isNeed: true, title: "国家/地区", isUserKeyBoard: false, prompts: "请选择", message: mainModel.address.country, type: .country, isShowPrompts: isShowPrompt, alertMessage:"请选择国家/地区")
var string = "" var string = ""
let array = mainModel.address.area let array = mainModel.address.area
for item in array { for item in array {
string = string + item string = string + item
} }
let item1 = YHItemModel(id: .id3, isNeed: true, title: "省市地区", isUserKeyBoard: false, prompts: "请选择", message: string, type: .address, isShowPrompts: isShowPrompt) 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 item2 = YHItemModel(id: .id4, isNeed: true, title: "详细地址", isUserKeyBoard: true, prompts: "请填写小区、楼栋、单元室等", message: mainModel.address.details, isShowPrompts: isShowPrompt) 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) 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)
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 item3 = YHItemModel(id: .id5, isNeed: true, title: "是否办理", isUserKeyBoard: false, prompts: "", message: "\(mainModel.has_hk_id)", leftButtonString: "是", rightButtonString: "否", isShowPrompts: isShowPrompt) 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
if addressCountry.contains("中国") { if addressCountry.contains("中国") {
...@@ -55,23 +54,24 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -55,23 +54,24 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
if nationality.contains("中国") { if nationality.contains("中国") {
flag = true flag = true
} }
let item = YHItemModel(id: .id8, isNeed: flag, title: "身份证号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.cn_identity_card.number, isShowPrompts: isShowPrompt)
let item1 = YHItemModel(id: .id9, isNeed: flag, title: "签发地", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.cn_identity_card.issue_at, isShowPrompts: isShowPrompt) let item = YHItemModel(id: .id8, isNeed: flag, title: "身份证号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.cn_identity_card.number, 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) let item1 = YHItemModel(id: .id9, isNeed: flag, title: "签发地", isUserKeyBoard: true, prompts: "请输入", message: mainModel.certificates.cn_identity_card.issue_at, 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) 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:"请选择届满日期")
let section = YHSectionItemModel(title: "中国身份证", models: [item, item1, item2, item3]) let section = YHSectionItemModel(title: "中国身份证", 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) 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) 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) 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) 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 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) 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) 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) 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) 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) 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 = "" var section2String = ""
if flag { if flag {
section2String = "护照及其他旅行证件(选填)" section2String = "护照及其他旅行证件(选填)"
...@@ -87,33 +87,33 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -87,33 +87,33 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
} }
func getDetailDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] { func getDetailDataSource(_ isShowPrompt: Bool) -> [YHSectionItemModel] {
let item = YHItemModel(id: .id21, isNeed: true, title: "主申请人姓名", isUserKeyBoard: true, prompts: "请输入", message: mainModel.username, isShowPrompts: isShowPrompt) 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 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 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) 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) let item4 = YHItemModel(id: .id25, isNeed: true, title: "出生国家/地区", isUserKeyBoard: false, prompts: nil, message: "\(mainModel.birth_place_aboard )", leftButtonString: "国外", rightButtonString: "国内", isShowPrompts: isShowPrompt, alertMessage:"请选择出生国家/地区")
var string = "" var string = ""
let array = mainModel.birth_place.area let array = mainModel.birth_place.area
for item in array { for item in array {
string = string + item string = string + item
} }
let item5 = YHItemModel(id: .id26, isNeed: true, title: "出生城市", isUserKeyBoard: false, prompts: "请选择", message: string, type: .address, isShowPrompts: isShowPrompt) 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) 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) 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) let item7 = YHItemModel(id: .id28, isNeed: true, title: "婚姻状况", isUserKeyBoard: false, prompts: "请选择", message: "\(mainModel.married )", type: .marry, isShowPrompts: isShowPrompt, alertMessage:"请选择婚姻状况")
var item555 = item5 var item555 = item5
if mainModel.birth_place_aboard == 1 { if mainModel.birth_place_aboard == 1 {
item555 = item55 item555 = item55
} }
let section = YHSectionItemModel(title: "主申请人信息", models: [item, item1, item2, item3, item4, item555, item6, item7]) 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) let item8 = YHItemModel(id: .id29, isNeed: true, title: "手机号码", isUserKeyBoard: true, prompts: "请输入", message: mainModel.mobile, isShowPrompts: isShowPrompt, alertMessage:"请输入手机号码")
let item9 = YHItemModel(id: .id30, isNeed: true, title: "电子邮箱", isUserKeyBoard: true, prompts: "请输入", message: mainModel.email, isShowPrompts: isShowPrompt) let item9 = YHItemModel(id: .id30, isNeed: true, title: "电子邮箱", isUserKeyBoard: true, prompts: "请输入", message: mainModel.email, isShowPrompts: isShowPrompt, alertMessage:"请输入电子邮箱")
let section1 = YHSectionItemModel(title: "联系方式", models: [item8, item9]) 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) 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) 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 section2 = YHSectionItemModel(title: "香港身份证", models: [item10])
let section22 = YHSectionItemModel(title: "香港身份证", models: [item10, item11]) let section22 = YHSectionItemModel(title: "香港身份证", models: [item10, item11])
var section222 = section2 var section222 = section2
...@@ -148,7 +148,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -148,7 +148,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
case .id4: case .id4:
mainModel.address.details = item.message ?? "" mainModel.address.details = item.message ?? ""
case .id5: case .id5:
mainModel.has_hk_id = item.value?.first?.int ?? 0 mainModel.is_handled = item.value?.first?.int ?? 0
case .id6: case .id6:
printLog("1") printLog("1")
case .id7: case .id7:
...@@ -292,20 +292,24 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -292,20 +292,24 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象 //1. json字符串 转 对象
guard let self = self else { return } guard let self = self else { return }
if json.code == 200 {
let dic = json.data let dic = json.data
guard let result = YHMainInformationModel.deserialize(from: dic as? Dictionary) else { guard let result = YHMainInformationModel.deserialize(from: dic as? Dictionary) else {
callBackBlock(nil,nil) callBackBlock(nil,nil)
return return
}
self.mainModel = result
callBackBlock(result, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(nil, error)
} }
self.mainModel = result
callBackBlock(result, nil)
} failBlock: { err in } failBlock: { err in
callBackBlock(nil,err) callBackBlock(nil,err)
} }
} }
func updateMainInformation(_ saveType: YHSaveType,_ orderID: Int, callBackBlock:@escaping (_ success: Bool)->()) { func updateMainInformation(_ saveType: YHSaveType,_ orderID: Int, callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
var type = "" var type = ""
if saveType == .save { if saveType == .save {
type = "save" type = "save"
...@@ -372,10 +376,15 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -372,10 +376,15 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
// let strUrl = "http://192.168.25.48:18088/" + YHAllApiName.OrderInformation.updateInformation // let strUrl = "http://192.168.25.48:18088/" + YHAllApiName.OrderInformation.updateInformation
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.updateInformation let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.updateInformation
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in let _ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, code in
guard let self = self else { return } guard let _ = self else { return }
callBackBlock(true) 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 } failBlock: { err in
callBackBlock(false) callBackBlock(false, err)
} }
} }
...@@ -388,7 +397,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -388,7 +397,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
"businessCode": "4001001" "businessCode": "4001001"
] ]
let _ = YHNetRequest.uplaodRequest(url: strUrl, headers: headers, image: image) { [weak self] json, code in let _ = YHNetRequest.uplaodRequest(url: strUrl, headers: headers, image: image) { [weak self] json, code in
guard let self = self else { return } guard let _ = self else { return }
if json.code == 200 { if json.code == 200 {
callBackBlock(json.data as? String, nil) callBackBlock(json.data as? String, nil)
} else { } else {
...@@ -405,7 +414,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -405,7 +414,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
let strUrl = "https://test-comserver.galaxy-immi.com/oss/storage/convertToPublicURL" + "?fileUrl=\(url)" let strUrl = "https://test-comserver.galaxy-immi.com/oss/storage/convertToPublicURL" + "?fileUrl=\(url)"
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
//1. json字符串 转 对象 //1. json字符串 转 对象
guard let self = self else { return } guard let _ = self else { return }
if json.code == 200 { if json.code == 200 {
callBackBlock(json.data as? String, nil) callBackBlock(json.data as? String, nil)
} else { } else {
...@@ -538,7 +547,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -538,7 +547,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
if birth_place_aboard == 1 { if birth_place_aboard == 1 {
if username.count != 0 && birthday.count != 0 && birth_place_foreign.count != 0 && mobile.count != 0 && email.count != 0 { if username.count != 0 && birthday.count != 0 && birth_place_foreign.count != 0 && mobile.count != 0 && email.count != 0 {
if has_hk_id == 1 { if has_hk_id == 1 {
if hk_id_numbe.count != 0 { if hk_id_numbe.isHKIdentityCardNumber() {
return true return true
} else { } else {
return false return false
...@@ -552,7 +561,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel { ...@@ -552,7 +561,7 @@ class YHMainApplicantInformationViewModel: YHBaseViewModel {
} else { } else {
if username.count != 0 && birthday.count != 0 && birth_place_area.count != 0 && mobile.count != 0 && email.count != 0 { if username.count != 0 && birthday.count != 0 && birth_place_area.count != 0 && mobile.count != 0 && email.count != 0 {
if has_hk_id == 1 { if has_hk_id == 1 {
if hk_id_numbe.count != 0 { if hk_id_numbe.isHKIdentityCardNumber() {
return true return true
} else { } else {
return false return false
......
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