         }
     }
     
-    func checkUAM() ->Promise<Bool> {
+    func checkUAM() ->Promise<(Bool,String)> {
         return Promise{ fulfill, reject in
             let url = passport_authuam
+            //TODO
+            //$.jc_getcookie("tk");
             
             let params = ["appid":passport_appId]
+            
+            var headers:[String:String] = [:]
+            headers[referKey] = referValueForLoginInit
+            
+            Service.Manager.request(url, method:.post, parameters: params, headers:headers).responseJSON(completionHandler:{response in
+                switch (response.result){
+                case .failure(let error):
+                    reject(error)
+                case .success(let data):
+                    if let result_code = JSON(data)["result_code"].int  {
+                        var hasLogin = false
+                        var tk = ""
+                        if result_code == 0 {
+                            if let apptk = JSON(data)["apptk"].string {
+                                tk = apptk
+                            }
+                            if let newapptk = JSON(data)["newapptk"].string {
+                                tk = newapptk
+                            }
+                            
+                            hasLogin = true
+                        }
+                        else {
+                            hasLogin = false
+                        }
+                        fulfill((hasLogin,tk))
+                    }
+                    else{
+                        let error = ServiceError.errorWithCode(.loginFailed, failureReason: "checkUAM")
+                        reject(error)
+                    }
+                }})
+        }
+        
+    }
+    
+    func uampassport(tk:String) ->Promise<Bool>  {
+        return Promise{ fulfill, reject in
+            let url = "https://kyfw.12306.cn/otn/" + passport_authclient
+            //TODO
+            //$.jc_getcookie("tk");
+            
+            let params = ["tk":tk]
             
             var headers:[String:String] = [:]
             headers[referKey] = referValueForLoginInit

                        fulfill(hasLogin)
                    }
                    else{
                        let error = ServiceError.errorWithCode(.loginFailed, failureReason: "checkUAM")
                        reject(error)
                    }
                }})
        }
        
    }
    
    func uampassport() {
        
    }
    
    func checkRandCodeForLogin(_ randCodeStr:String)->Promise<Void>{
        return Promise{ fulfill, reject in
            let url = "https://kyfw.12306.cn/otn/passcodeNew/checkRandCodeAnsyn"
            let params = ["randCode":randCodeStr,"rand":"sjrand"]
            let headers = ["refer": "https://kyfw.12306.cn/otn/login/init"]
            Service.Manager.request(url, method:.post, parameters: params, headers:headers).responseJSON(completionHandler:{response in
                switch (response.result){
                case .failure(let error):
                    reject(error)
                case .success(let data):
                    if let msg = JSON(data)["data"]["msg"].string , msg == "TRUE"{
                        fulfill()
                    }
                    else{

    
    func loginUserWith(_ user:String, passWord:String, randCodeStr:String)->Promise<Void>{
        return Promise{ fulfill, reject in
            let url = passport_login
            let params = ["user_name":user,"password":passWord,"appid":passport_appId]
            let headers = ["refer": "https://kyfw.12306.cn/otn/login/init"]
            Service.Manager.request(url, method:.post, parameters: params, headers:headers).responseJSON(completionHandler:{response in
                switch (response.result){
                case .failure(let error):
                    reject(error)
                case .success(let data):
                    if let result_code = JSON(data)["result_code"].int ,result_code == 0{
                        fulfill()
                    }
                    else{
                        let error:NSError
                        if let errorStr = JSON(data)["result_message"].string{
                            error = ServiceError.errorWithCode(.loginUserFailed, failureReason: errorStr)
                        }
                        else{
