Commit 4211ecc2 authored by David黄金龙's avatar David黄金龙

Merge branch 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS into youhua-dev

* 'youhua-dev' of http://gitlab.galaxy-immi.com/mobile-group/galaxy-iOS:
  //  学校名称搜索bug修复
parents ee528e54 6cf62c3e
...@@ -14,7 +14,6 @@ class YHCollegeSearchViewController: YHBaseViewController { ...@@ -14,7 +14,6 @@ class YHCollegeSearchViewController: YHBaseViewController {
var searchCollegeName:String? var searchCollegeName:String?
var selectBlock:((String?)->Void)? var selectBlock:((String?)->Void)?
var colleges:[YHCollegeInfo] = [] var colleges:[YHCollegeInfo] = []
var lastSearchTime:TimeInterval = 0.0
let educationRequest:YHEducationRequestViewModel = YHEducationRequestViewModel() let educationRequest:YHEducationRequestViewModel = YHEducationRequestViewModel()
lazy var searchBar: YHCollegeSearchBar = { lazy var searchBar: YHCollegeSearchBar = {
...@@ -91,10 +90,7 @@ class YHCollegeSearchViewController: YHBaseViewController { ...@@ -91,10 +90,7 @@ class YHCollegeSearchViewController: YHBaseViewController {
[weak self] text in [weak self] text in
guard let self = self else { return } guard let self = self else { return }
searchCollegeName = text searchCollegeName = text
if Date().timeIntervalSince1970 - lastSearchTime >= 1.0 { self.searchCollege()
lastSearchTime = Date().timeIntervalSince1970
searchCollege()
}
} }
searchBar.confirmBlock = { searchBar.confirmBlock = {
[weak self] in [weak self] in
......
...@@ -273,8 +273,6 @@ class YHEducationRequestViewModel { ...@@ -273,8 +273,6 @@ class YHEducationRequestViewModel {
// 搜索学校 // 搜索学校
func searchCollegeInfoList(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) { func searchCollegeInfoList(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
YHHUD.show(.progress(message: "数据加载中..."))
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.searchCollegeNameApi let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Education.searchCollegeNameApi
let _ = YHNetRequest.getRequest(url: strUrl, params:params) {[weak self] json, code in let _ = YHNetRequest.getRequest(url: strUrl, params:params) {[weak self] json, code in
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import UIKit import UIKit
class YHCollegeSearchBar: UIView { class YHCollegeSearchBar: UIView, UITextFieldDelegate {
static let height = 40.0 static let height = 40.0
static let confirmBtnHeight = height-8.0 static let confirmBtnHeight = height-8.0
...@@ -37,7 +37,7 @@ class YHCollegeSearchBar: UIView { ...@@ -37,7 +37,7 @@ class YHCollegeSearchBar: UIView {
textField.font = UIFont.PFSC_M(ofSize: 12) textField.font = UIFont.PFSC_M(ofSize: 12)
textField.tintColor = UIColor.brandMainColor textField.tintColor = UIColor.brandMainColor
textField.textColor = UIColor.mainTextColor textField.textColor = UIColor.mainTextColor
textField.addTarget(self, action: #selector(textFieldChanged(textField:)), for: .editingChanged) textField.delegate = self
return textField return textField
}() }()
...@@ -96,13 +96,20 @@ class YHCollegeSearchBar: UIView { ...@@ -96,13 +96,20 @@ class YHCollegeSearchBar: UIView {
make.right.equalToSuperview().offset(-4) make.right.equalToSuperview().offset(-4)
} }
} }
@objc func textFieldChanged(textField:UITextField) { func textFieldDidChangeSelection(_ textField: UITextField) {
let text = textField.text ?? "" let text = textField.text ?? ""
let max = 100 textChange?(textField.text)
textField.text = (text.count > max ? text[safe: ..<max] : text)
if let textChange = textChange { }
textChange(textField.text)
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if string.count > 0 {
let newText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
if newText.count > 100 {
return false
}
} }
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