|
@@ -25,6 +25,7 @@ final class LoginViewController: BaseViewController {
|
|
|
@IBOutlet weak var pwdshow_button: QMUIButton!
|
|
|
//定位arrow
|
|
|
@IBOutlet weak var location_button: QMUIButton!
|
|
|
+ @IBOutlet weak var location_button_btn: UIButton!
|
|
|
//区域
|
|
|
@IBOutlet weak var userlocation_textField: QMUITextField!
|
|
|
//登录按钮
|
|
@@ -36,14 +37,23 @@ final class LoginViewController: BaseViewController {
|
|
|
//隐私政策
|
|
|
@IBOutlet weak var userprivacy_button: UIButton!
|
|
|
|
|
|
- let city = "3501"
|
|
|
-
|
|
|
-
|
|
|
+ var city:String = ""
|
|
|
+ var cityItems:[CityItem] = []
|
|
|
+ var citys: [String:String] = [:]
|
|
|
+ var selectedItemIndex = 0
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
setupUI()
|
|
|
//biand绑定
|
|
|
biandView()
|
|
|
+ //获取字典数据
|
|
|
+ loginService.dictRequest(dictType: "coach_city").subscribe(onSuccess: { [unowned self] cityItems in
|
|
|
+ self.cityItems = cityItems
|
|
|
+ for cityItem in cityItems {
|
|
|
+ self.citys[cityItem.dictLabel] = cityItem.dictValue
|
|
|
+ }
|
|
|
+ },onError: { Error in
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
}
|
|
|
// MARK: 私有方法
|
|
|
func setupUI(){
|
|
@@ -108,32 +118,10 @@ final class LoginViewController: BaseViewController {
|
|
|
//选择区域
|
|
|
location_button.rx.tap.subscribe ({ [unowned self] (_) in
|
|
|
NSLog("点击了:选择区域- \(Thread.isMainThread)")
|
|
|
-// //登录api RX 订阅 观察 销毁 三部曲
|
|
|
-// self.loginService.loginRequest(user_name: "350102199001182416", user_password: "123456",city: "3501")
|
|
|
-// .subscribe(onSuccess: { userinfo in
|
|
|
-// print("登录成功:%@", userinfo)
|
|
|
-// self.navigationController?.popViewController(animated: true)
|
|
|
-// }, onError: { error in
|
|
|
-// print("%@",error)
|
|
|
-// })
|
|
|
-// .disposed(by: disposeBag)
|
|
|
-// self.loginService.updateRequest(user_name: "350102199001182416", user_password: "1234567", new_password: "123456", city: "3501")
|
|
|
-// .subscribe(onSuccess: { userinfo in
|
|
|
-// print("修改成功 \(userinfo)")
|
|
|
-// }, onError: { error in
|
|
|
-// print("%@",error.localizedDescription)
|
|
|
-// }).disposed(by: disposeBag)
|
|
|
-// self.loginService.dictRequest(dictType: "coach_city")
|
|
|
-// .subscribe(onSuccess: { userinfo in
|
|
|
-// print("%@",userinfo)
|
|
|
-// }, onError: { error in
|
|
|
-// print("%@",error)
|
|
|
-// }).disposed(by: disposeBag)
|
|
|
-
|
|
|
-// self.cocahService.coachInfoRequest(id: "3501033735", city: "3501").subscribe(onSuccess: { userinfo in
|
|
|
-//
|
|
|
-// },onError: { error in }).disposed(by: disposeBag)
|
|
|
-
|
|
|
+ self.showDialog()
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ location_button_btn.rx.tap.subscribe ({ [unowned self] (_) in
|
|
|
+ self.showDialog()
|
|
|
}).disposed(by: disposeBag)
|
|
|
//登录
|
|
|
login_button.rx.tap
|
|
@@ -149,6 +137,10 @@ final class LoginViewController: BaseViewController {
|
|
|
//保存用户信息
|
|
|
var account:String = self.username_textField.text!
|
|
|
var password:String = self.userpassword_textField.text!
|
|
|
+ if city=="" {
|
|
|
+ NYTips.showMsg(txt: "请选择地区!")
|
|
|
+ return
|
|
|
+ }
|
|
|
LocalManager.userInfo.userAccount = account
|
|
|
LocalManager.userInfo.password = password
|
|
|
self.login_button.isEnabled = true
|
|
@@ -181,7 +173,29 @@ final class LoginViewController: BaseViewController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ func showDialog(){
|
|
|
+
|
|
|
+ let dialogViewController = QMUIDialogSelectionViewController()
|
|
|
+ dialogViewController.title = "请选择地区"
|
|
|
+ dialogViewController.items = Array(citys.keys)
|
|
|
+ dialogViewController.selectedItemIndex = selectedItemIndex
|
|
|
+ dialogViewController.addCancelButton(withText: "取消", block: nil)
|
|
|
+ dialogViewController.addSubmitButton(withText: "确定") { [weak self] dialogViewController in
|
|
|
+ guard let dialogViewController:QMUIDialogSelectionViewController = dialogViewController as? QMUIDialogSelectionViewController else { return }
|
|
|
+ if dialogViewController.selectedItemIndex == QMUIDialogSelectionViewControllerSelectedItemIndexNone {
|
|
|
+ NYTips.showErr(txt: "请至少选一个")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self?.selectedItemIndex = dialogViewController.selectedItemIndex
|
|
|
+ let item = self!.cityItems[dialogViewController.selectedItemIndex]
|
|
|
+ self?.city = item.dictValue //编码
|
|
|
+ self?.userlocation_textField.text = item.dictLabel
|
|
|
+ dialogViewController.hide()
|
|
|
+ }
|
|
|
+ dialogViewController.show()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|