123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- //
- // LoginViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/22.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class ForgetPasswordViewController: BaseViewController {
- @IBOutlet weak var btnLogin: UIButton!
- @IBOutlet weak var btnCode: CusButtonGetCode!
- @IBOutlet weak var btnView: UIButton!
- @IBOutlet weak var btnClose: UIButton!
- @IBOutlet weak var txtCode: UITextField!
- @IBOutlet weak var txtPassword: UITextField!
- @IBOutlet weak var txtPhone: UITextField!
- ///0:找回密码 1:修改密码
- var type = 0
- override func viewDidLoad() {
- super.viewDidLoad()
- if type == 0 {
- self.title = "找回密码"
- } else {
- self.title = "修改密码"
- btnClose.isHidden = true
- txtPhone.text = CommonValue.getLoginUserName()
- txtPhone.isEnabled = true
- }
- initNavLeftBackButton()
- txtPhone.setContentMarginLeft(leftWidth: 15)
- txtPassword.setContentMarginLeft(leftWidth: 15)
- txtCode.setContentMarginLeft(leftWidth: 15)
- txtPhone.setCornerRadius(size: 4)
- txtPassword.setCornerRadius(size: 4)
- txtCode.setCornerRadius(size: 4)
- }
- override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
- txtPhone.resignFirstResponder()
- txtPassword.resignFirstResponder()
- txtCode.resignFirstResponder()
- }
- //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: // 清空手机号
- txtPhone.text = ""
- break
- case 1002: // 显示隐藏密码
- if btnView.isSelected {
- txtPassword.isSecureTextEntry = true
- } else {
- txtPassword.isSecureTextEntry = false
- }
- btnView.isSelected = !btnView.isSelected
- break
- case 1003: // 获取验证码
- if txtPhone.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入您的手机号")
- return
- }
- getCode()
- break
- case 1004: // 确定
- if txtPhone.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入您的手机号")
- return
- }
- if txtCode.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入验证码")
- return
- }
- if txtPassword.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入您的密码")
- return
- }
- submitData()
- //toViewController(viewController: GuesturePasswordViewController());
- break
- case 1005: //
- break
- case 1006: //
- break
- default:
- break
- }
- }
- func submitData() {
- var url = RequestURL.findPassword
- let params = NSMutableDictionary()
- if type == 0 {
- url = RequestURL.findPassword
- } else {
- url = RequestURL.updatePassword
- }
- params.setValue(txtPhone.text!, forKey: "phone")
- params.setValue(txtPassword.text!, forKey: "password")
- params.setValue(txtCode.text!, forKey: "code")
- submitData(url: url, params: params, tag: 1001)
- }
- func getCode() {
- let url = RequestURL.getCode
- let params = NSMutableDictionary()
- params.setValue(txtPhone.text!, forKey: "phone")
- params.setValue(3, forKey: "type")
- submitData(url: url, params: params, tag: 1002)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- SVProgressHUD.showSuccess(withStatus: "密码修改成功!")
- handleBack()
- } else if tag == 1002 {
- btnCode.startGetCode()
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "ForgetPasswordViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|