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

字段校验

parent 8d3e8913
......@@ -93,27 +93,36 @@ class YHMainApplicantInformationViewController: YHBaseViewController {
guard let self = self else { return }
if self.viewModel.isCanNext(self.stepView.currentIndex) {
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 }
self.isShowPrompt = false
self.stepView.currentIndex = self.stepView.currentIndex
if self.stepView.currentIndex == self.stepView.dataSource?.count {
YHHUD.flash(message: "提交成功")
self.navigationController?.popViewController()
if let error = error {
YHHUD.flash(message: error.errorMsg )
} 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 {
self.isShowPrompt = true
self.updateDataSource()
YHHUD.flash(message: "请完善信息")
YHHUD.flash(message: "您还有信息未填写")
}
}
bottom.saveBlock = { [weak self] in
guard let self = self else { return }
self.viewModel.updateMainInformation(.save, self.orderId) {[weak self] success in
guard let self = self else { return }
self.viewModel.updateMainInformation(.save, self.orderId) {[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
......
......@@ -70,8 +70,9 @@ struct YHItemModel {
var type: YHItemSelectType?
var value: [String]?
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.isNeed = isNeed
self.title = title
......@@ -83,6 +84,7 @@ struct YHItemModel {
self.type = type
self.value = value
self.isShowPrompts = isShowPrompts
self.alertMessage = alertMessage
}
}
......
......@@ -155,7 +155,7 @@ class YHItemView: UIView {
}
messageTextField.placeholder = dataSource.prompts
messageTextField.text = dataSource.message
showPromptLabel.text = "\(dataSource.prompts ?? "")" + "\(dataSource.title ?? "")"
showPromptLabel.text = dataSource.alertMessage
if dataSource.isUserKeyBoard ?? false {
nextStepImageView.isHidden = true
centerButton.isHidden = true
......@@ -381,6 +381,26 @@ extension YHItemView: UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
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()
data.message = newText
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