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

字段校验

parent 8d3e8913
...@@ -93,8 +93,11 @@ class YHMainApplicantInformationViewController: YHBaseViewController { ...@@ -93,8 +93,11 @@ 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 }
if let error = error {
YHHUD.flash(message: error.errorMsg )
} else {
self.isShowPrompt = false self.isShowPrompt = false
self.stepView.currentIndex = self.stepView.currentIndex self.stepView.currentIndex = self.stepView.currentIndex
if self.stepView.currentIndex == self.stepView.dataSource?.count { if self.stepView.currentIndex == self.stepView.dataSource?.count {
...@@ -104,16 +107,22 @@ class YHMainApplicantInformationViewController: YHBaseViewController { ...@@ -104,16 +107,22 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
self.updateDataSource() 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 {
......
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