123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- //
- // LoginViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/3/22.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class RegViewController2: BaseViewController, UITextFieldDelegate {
- @IBOutlet weak var viewContent: UIView!
- @IBOutlet weak var btnReView: UIButton!
- @IBOutlet weak var txtRePassword: UITextField!
- @IBOutlet weak var btnAngree: UIButton!
- @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!
- var recCode = ""
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "注册账号"
- initNavLeftBackButton()
- txtPhone.setContentMarginLeft(leftWidth: 15)
- txtPassword.setContentMarginLeft(leftWidth: 15)
- txtCode.setContentMarginLeft(leftWidth: 15)
- txtRePassword.setContentMarginLeft(leftWidth: 15)
- txtPhone.setCornerRadius(size: 4)
- txtPassword.setCornerRadius(size: 4)
- txtRePassword.setCornerRadius(size: 4)
- txtCode.setCornerRadius(size: 4)
- txtCode.delegate = self
- btnAngree.setAttributedTitle(CommonViewUntils.getAttributedString(str: " 我已阅读并同意《服务协议》", left: [8, 14], color: [CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), CommonUntils.getUIColorFromRGB(rgbValue: 0x37A6FF, alpha: 1.0)]), for: .normal)
- //37A6FF
- }
- override func KeyboardHidden(gestureRecognizer: UIGestureRecognizer) {
- txtPhone.resignFirstResponder()
- txtPassword.resignFirstResponder()
- txtCode.resignFirstResponder()
- txtRePassword.resignFirstResponder()
- viewContent.marginTop(top: 0)
- }
- //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 txtPassword.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入您的密码")
- return
- }
- if txtRePassword.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入您的确认密码")
- return
- }
- if txtPassword.text! != txtRePassword.text! {
- SVProgressHUD.showError(withStatus: "确认密码不一致,请重新输入")
- return
- }
- if txtCode.text!.length() < 1 {
- SVProgressHUD.showError(withStatus: "请输入验证码")
- return
- }
- if !btnAngree.isSelected {
- SVProgressHUD.showError(withStatus: "请先阅读并同意《服务协议》")
- return
- }
- submitData()
- break
- case 1005: // 同意协议
- btnAngree.isSelected = !btnAngree.isSelected
- break
- case 1006: // 忘记密码
- break
- case 1007: // 显示隐藏确认密码
- if btnReView.isSelected {
- txtRePassword.isSecureTextEntry = true
- } else {
- txtRePassword.isSecureTextEntry = false
- }
- btnReView.isSelected = !btnReView.isSelected
- break
- case 1008: // 服务协议
- let vcWeb = CommonWebViewViewController()
- vcWeb.strTitle = "服务协议"
- vcWeb.url = RequestURL.systemSetting
- toViewController(viewController: vcWeb)
- break
- default:
- break
- }
- }
- // MARK: =============加载数据===============
- func submitData() {
- let url = RequestURL.register
- let params = NSMutableDictionary()
- params.setValue(txtPhone.text!, forKey: "mobile")
- params.setValue(txtPassword.text!, forKey: "password")
- params.setValue(txtCode.text!, forKey: "code")
- params.setValue(recCode, forKey: "recCode")
- submitData(url: url, params: params, tag: 1001)
- }
- func getCode() {
- let url = RequestURL.getCode
- let params = NSMutableDictionary()
- params.setValue(txtPhone.text!, forKey: "phone")
- params.setValue(1, forKey: "type")
- submitData(url: url, params: params, tag: 1002)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- CommonValue.setLoginUserAccountInfo(userName: txtPhone.text!, password: txtPassword.text!, type: "2")
- let dic = NSMutableDictionary()
- CommonValue.setLoginUserInfo(loginUser: dicBackData)
- CommonUntils.AlertView(controller: self, title: "提示", message: "是否进行实名认证", buttons: ["确定"], style: .alert, actionHandler: {[weak self] (_, _) in
- let viewWeb = RealNameAuthViewController()
- self!.toViewController(viewController: viewWeb)
- }) {[weak self] in
- self!.navigationController?.popToRootViewController(animated: true)
- }
- } else if tag == 1002 {
- btnCode.startGetCode()
- }
- }
- override func returnError(tag: Int, type: String) {
- }
- func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
- viewContent.marginTop(top: -30)
- return true
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "RegViewController2", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|