//
//  SMSViewController.swift
//  SocketChat
//
//  Created by Justine on 16/5/31.
//  Copyright © 2016年 AppCoda. All rights reserved.
//

import UIKit
import Alamofire
class SMSViewController: UIViewController {
    @IBOutlet weak var mobile: UITextField!
    @IBOutlet weak var smscode: UITextField!
    let serverid = USER_SERVER_ID as! String
    let userid = DEFAULT_USER_ID as! Int
    let loginname = DEFAULT_USER_NAME as! String
    @IBAction func requireCode(sender: UIButton) {
        var remainingSeconds: Int = 60
        sender.enabled = false
        sender.setTitle(String(remainingSeconds), forState: UIControlState.Disabled)
        
        //请求验证码
        let mobile = trimstring(self.mobile.text!,trimchar: " ")
        let param:[String:AnyObject] = ["serverID":serverid,
                     "loginName":loginname,
                     "userID":userid,
                     "mobile":mobile
                     ]
        request(.POST, RequireSMSURL, parameters: param).responseJSON { (R) in
            guard R.result.error == nil else{
                return
            }
        }
        
        
        
    }
    @IBAction func checkCode(sender: UIButton) {
        //获取手机号  未校验
        //mobile
        //获取验证码
        //验证。。。。
        //mobile.text
        
    }

    func timer(times:Int){
        
    }
    
    

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
