//
//  logNetModel.m
//  Open
//
//  Created by 看看智能 on 2017/2/20.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "logNetModel.h"

#import "lodModel.h"
@implementation logNetModel

//雷俊博
+ (id)getVerificationCodeWithUrl:(NSString *)url Params:(NSDictionary *)params completionHandle:(void(^)(lodModel*, NSError *))complete
{
    return [self  POST:url parameters:params completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"%@",responseObj);
        
        complete( [lodModel mj_objectWithKeyValues:responseObj],error);
        if (error) {
            NSLog(@"打印错误:%@",error);
            complete(nil,error);
        }
    }];
}


+(id)getLogMessage1:(NSString *)path andTelephone:(NSString*)telephoneNumber andTag:(NSInteger)tag completionHandle:(void(^)(lodModel*, NSError *))complete
{
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/getVerificationcode"];
    NSString *pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
      NSDictionary *dictNew =nil;
    NSArray *array = [path componentsSeparatedByString:@"HELLO"]; //从字符A中分隔成2个元素的数组
    if (array.count >1) {
        dictNew =@{
                   @"telphone":[EnercryTool encryptUseDES:telephoneNumber key:DESKEY],
                   
                   @"Id":array.lastObject,
                   @"targetflag":@1004,
                   @"uid":array.firstObject
                   };
    }else{
        dictNew =@{
                   @"telphone":[EnercryTool encryptUseDES:telephoneNumber key:DESKEY],
                   @"targetflag":@(tag)
                   };
    }
    

    NSLog(@"dictNew:%@",dictNew);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"%@",responseObj);
   
        complete( [lodModel mj_objectWithKeyValues:responseObj],error);
        if (error) {
            NSLog(@"打印错误:%@",error);
            complete(nil,error);
        }
    }];


}
+(id)getLogMessage2:(NSString *)path andTelephone:(NSString*)telephoneNumber andValidate:(NSString*)validateCode andCusPassword:(NSString*)cusPassword completionHandle:(void(^)(lodModel*, NSError *))complete
{
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/resetPassword"];
  
    
    
    
        if ([path isEqualToString:pathNew_1])
    {
            NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSDictionary *dictNew =@{
                                 @"telphone":[EnercryTool encryptUseDES:telephoneNumber key:DESKEY],
                                 @"validateCode":[EnercryTool encryptUseDES:validateCode key:DESKEY],
                                 @"resetPassword":[MyMD5 md5:cusPassword]
                                 };
   
        return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
            NSLog(@"%@",responseObj);
            complete( [lodModel mj_objectWithKeyValues:responseObj],error);
            if (error) {
                NSLog(@"打印错误:%@",error);
            }
        }];
    }else
    {
        NSString * pathNew_2 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/register"];
    
        NSString * pathNew1 =  [pathNew_2  stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSDictionary *dictNew =@{
                                 @"telphone":[EnercryTool encryptUseDES:telephoneNumber key:DESKEY],
                                 @"flag":@2,
                                 @"validateCode":[EnercryTool encryptUseDES:validateCode key:DESKEY],
                                 @"cus_password":[MyMD5 md5:cusPassword]
                                 };
        
        return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
            NSLog(@"%@",responseObj);
            complete( [lodModel mj_objectWithKeyValues:responseObj],error);
            if (error) {
                NSLog(@"打印错误:%@",error);
            }
        }];
    }
 
}
+(id)getLogMessage3:(NSString *)path andTelephone:(NSString*)telephoneNumber andLoginpassword:(NSString*)loginpassword andUid:(NSString*)uid andl:(NSInteger)loginType andweixinId:(NSString*)weixinId andPicId:(NSString *)picId completionHandle:(void(^)(lodModel*, NSError *))complete{
    
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/wechatLogin"];

    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //曹妈妈
        NSString *str1= nil;
    if(!path && loginType ==2){
        [SVProgressHUD showErrorWithStatus:@"微信登入失败"];
        return NULL;
    }
    
    if (!telephoneNumber) {
        telephoneNumber = @"";
    }else{
        telephoneNumber =[EnercryTool encryptUseDES:telephoneNumber key:DESKEY];
    }
    
    if (!loginpassword) {
        loginpassword = @"";
    }else{
        loginpassword =[MyMD5 md5:loginpassword ];
    }

    if (!uid) {
        uid = @"";
    }
    if (!picId) {
        picId = @"";
    }
    
    
  
    NSLog(@"%@",str1);
    


    
    NSDictionary *dictNew =nil;

    if (loginType == 2 ) {
        
        if (!path) {
            path = @"";
        }
        
        if ([weixinId isEqualToString:@""] || weixinId == NULL || !weixinId )  {
            
            
            
            str1 = [NSString stringWithFormat:@"authName=kkanface&loginType=2&uid=%@&KkweInfo23255625",path];
            str1 =  [MyMD5 md5:str1];
        }else{
            str1 = [NSString stringWithFormat:@"accountName=%@&authName=kkanface&loginType=2&uid=%@&KkweInfo23255625",weixinId,path];
            str1 =  [MyMD5 md5:str1];
        }
        dictNew =@{
                  
                   @"telphone":telephoneNumber,
                   @"loginpassword":loginpassword,
                   @"loginType":@(loginType),
                   
                   @"uid":path,
                   @"authName":@"kkanface",
                   @"sign":str1,
                   @"accountName":weixinId,
                   @"photoUrl":picId
                   };
        

    }else{
      
        dictNew =@{
                   @"telphone":telephoneNumber,
                   @"loginpassword":loginpassword,
                   @"loginType":@(loginType)
                   
                   };
        
        
    }
    
    
    
    
    
    

    NSLog(@"dictNew:%@",dictNew);
         NSLog(@"path:***********************************%@",pathNew1);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        
        NSError *error1 = nil;
        if ([responseObj isKindOfClass:[NSData class]]) {
            NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObj options:NSJSONReadingMutableContainers error:&error1];
            
            NSLog(@"%@",dic);
        }else {
            NSLog(@"%@",responseObj);
        }
        
        complete( [lodModel mj_objectWithKeyValues:responseObj],error);
        if (error) {
            NSLog(@"打印错误:%@",error);
        }
    }];

}




+(id)getLogMessage4:(NSString *)path andTelephone:(NSString*)telephoneNumber andLoginpassword:(NSString*)loginpassword andUid:(NSString*)uid andl:(NSInteger)loginType andweixinId:(NSString*)weixinId andPicId:(NSString *)picId cus_name:(NSString *)cus_name completionHandle:(void(^)(lodModel*, NSError *))complete{
    
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/bindTelphone"];
    
    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSString *str1= nil;
    if(!path ){
        path =@"";
    }
    
    if (!telephoneNumber) {
        telephoneNumber = @"";
    }else{
        telephoneNumber =[EnercryTool encryptUseDES:telephoneNumber key:DESKEY];
    }
    
    if (!loginpassword) {
        loginpassword =@"";
    }else{
        loginpassword =[MyMD5 md5:loginpassword ];
    }
    
    if (!uid) {
        uid =@"";
    }
    
    if (!weixinId) {
        weixinId = @"";
    }
    if (!picId) {
        picId = @"";
        
    }else{
         picId =[EnercryTool encryptUseDES:picId key:DESKEY];
    }
    
    NSLog(@"%@",str1);
    
    
    //老左要求新加的!!
    
    
    NSDictionary *dictNew =nil;
        dictNew =@{
                   @"telphone":telephoneNumber,
                   @"id":weixinId,
                   @"uid":path,
                   @"validateCode":picId,
                   @"flag":@2,
                   @"cus_name":cus_name
                   };
    

    NSLog(@"dictNew:%@",dictNew);
    NSLog(@"path:***********************************%@",pathNew1);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"%@",responseObj);
        complete( [lodModel mj_objectWithKeyValues:responseObj],error);
        if (error) {
            NSLog(@"打印错误:%@",error);
        }
    }];
    
}


+(id)getLogMessage5:(NSString *)path andTelephone:(NSString*)telephoneNumber andLoginpassword:(NSString*)loginpassword andUid:(NSString*)uid andl:(NSInteger)loginType andweixinId:(NSString*)weixinId andPicId:(NSString *)picId completionHandle:(void(^)(lodModel*, NSError *))complete{
    
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/login"];

    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //曹妈妈
        NSString *str1= nil;
    if(!path && loginType ==2){
        [SVProgressHUD showErrorWithStatus:@"微信登入失败"];
        return NULL;
    }
    
    if (!telephoneNumber) {
        telephoneNumber = @"";
    }else{
        telephoneNumber =[EnercryTool encryptUseDES:telephoneNumber key:DESKEY];
    }
    
    if (!loginpassword) {
        loginpassword = @"";
    }else{
        loginpassword =[MyMD5 md5:loginpassword ];
    }

    if (!uid) {
        uid = @"";
    }
    if (!picId) {
        picId = @"";
    }
    
    
  
    NSLog(@"%@",str1);
    


    
    NSDictionary *dictNew =nil;

    if (loginType == 2 ) {
        
        if (!path) {
            path = @"";
        }
        
        if ([weixinId isEqualToString:@""] || weixinId == NULL || !weixinId )  {
            
            
            
            str1 = [NSString stringWithFormat:@"authName=kkanface&loginType=2&uid=%@&KkweInfo23255625",path];
            str1 =  [MyMD5 md5:str1];
        }else{
            str1 = [NSString stringWithFormat:@"accountName=%@&authName=kkanface&loginType=2&uid=%@&KkweInfo23255625",weixinId,path];
            str1 =  [MyMD5 md5:str1];
        }
        dictNew =@{
                  
                   @"telphone":telephoneNumber,
                   @"loginpassword":loginpassword,
                   @"loginType":@(loginType),
                   
                   @"uid":path,
                   @"authName":@"kkanface",
                   @"sign":str1,
                   @"accountName":weixinId,
                   @"photoUrl":picId
                   };
        

    }else{
      
        dictNew =@{
                   @"telphone":telephoneNumber,
                   @"loginpassword":loginpassword,
                   @"loginType":@(loginType)
                   
                   };
        
        
    }
    
    
    
    
    
    

    NSLog(@"dictNew:%@",dictNew);
         NSLog(@"path:***********************************%@",pathNew1);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        
//        NSError *error1 = nil;
        
    
        complete( [lodModel mj_objectWithKeyValues:responseObj],error);
        
    
        if (error) {
            NSLog(@"打印错误:%@",error);
        }
    }];

}

+(id)getLogMessage6:(NSString *)path andTelephone:(NSString*)telephoneNumber andLoginpassword:(NSString*)loginpassword andUid:(NSString*)uid andl:(NSInteger)loginType andweixinId:(NSString*)weixinId andPicId:(NSString *)picId completionHandle:(void(^)(lodModel*, NSError *))complete{
    
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/login"];

    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    //曹妈妈
        NSString *str1= nil;
    if(!path && loginType ==2){
        [SVProgressHUD showErrorWithStatus:@"微信登入失败"];
        return NULL;
    }
    
    if (!telephoneNumber) {
        telephoneNumber = @"";
    }else{
        
    }
    
    if (!loginpassword) {
        loginpassword = @"";
    }else{
    }

    if (!uid) {
        uid = @"";
    }
    if (!picId) {
        picId = @"";
    }
    
    
  
    NSLog(@"%@",str1);
    


    
    NSDictionary *dictNew =nil;

    if (loginType == 2 ) {
        
        if (!path) {
            path = @"";
        }
        
        if ([weixinId isEqualToString:@""] || weixinId == NULL || !weixinId )  {
            
            
            
            str1 = [NSString stringWithFormat:@"authName=kkanface&loginType=2&uid=%@&KkweInfo23255625",path];
            str1 =  [MyMD5 md5:str1];
        }else{
            str1 = [NSString stringWithFormat:@"accountName=%@&authName=kkanface&loginType=2&uid=%@&KkweInfo23255625",weixinId,path];
            str1 =  [MyMD5 md5:str1];
        }
        dictNew =@{
                  
                   @"telphone":telephoneNumber,
                   @"loginpassword":loginpassword,
                   @"loginType":@(loginType),
                   
                   @"uid":path,
                   @"authName":@"kkanface",
                   @"sign":str1,
                   @"accountName":weixinId,
                   @"photoUrl":picId
                   };
        

    }else{
      
        dictNew =@{
                   @"telphone":telephoneNumber,
                   @"loginpassword":loginpassword,
                   @"loginType":@(loginType)
                   
                   };
        
        
    }
    
    
    
    
    
    

    NSLog(@"dictNew:%@",dictNew);
         NSLog(@"path:***********************************%@",pathNew1);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        
//        NSError *error1 = nil;
        
        if ([responseObj isKindOfClass:[NSData class]]) {
             NSLog(@"responseObj:%@",[NSJSONSerialization JSONObjectWithData:responseObj options:NSJSONReadingMutableContainers error:nil]);
        }
        
        complete( [lodModel mj_objectWithKeyValues:responseObj],error);
        if (error) {
            NSLog(@"打印错误:%@",error);
        }
    }];

}


+(id)getDidLogMessage:(NSInteger)ID andTelephone:(NSString *)telphone andcusName:(NSString *)cusName andOldCusName:(NSString *)oldCusName andnowCusName:(NSString *)nowCusNmae andphoto:(id)image completionHandle:(void (^)(lodModel *, NSError *))complete{
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/updateUserInfo"];
    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *dictNew =@{
                             @"flag":@2,
                             @"id":@(ID),
                             @"telphone":telphone,
                             @"cus_name":cusName,
                             @"oldCus_password":oldCusName,
                             @"nowCus_password":nowCusNmae,
                             @"image":image ? image :[NSNull null]
                             };
    NSLog(@"dictNew:%@",dictNew);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"%@",responseObj);
        complete( [lodModel mj_objectWithKeyValues:responseObj],error);
        if (error) {
            NSLog(@"打印错误:%@",error);
        }
    }];
}



+(id)test:(NSInteger)ID acompletionHandle:(void (^)(lodModel *, NSError *))complete
{
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/updateUserInfo"];
    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSDictionary *dictNew =@{
                            
                             };
    NSLog(@"dictNew:%@",dictNew);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"%@",responseObj);
       
        if (error) {
            NSLog(@"打印错误:%@",error);
        }
    }];
}

+(id)convenientLogin:(NSString *)telephone andValidateCode:(NSString *)validateCode andKankanId:(NSString*)ID andUid:(NSString*)uid completionHandle:(void (^)(logModel_2 *, NSError *))complete
{
    NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/convenientLogin"];
    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSDictionary *dictNew =nil;
    
    if (ID && uid ) {
        if (!uid) {
            uid= @"";
        }
 
        if ([ID isEqualToString:@""]) {
            return NULL;
        }
        
        dictNew =@{
                   @"telephone":[EnercryTool encryptUseDES:telephone key:DESKEY],
                   @"validateCode":[EnercryTool encryptUseDES:validateCode key:DESKEY],
                   @"Id":ID,
                   @"targetflag":@1004,
                   @"uid":uid
                   };
    }else{
        dictNew =@{
                   @"telephone":[EnercryTool encryptUseDES:telephone key:DESKEY],
                   @"validateCode":[EnercryTool encryptUseDES:validateCode key:DESKEY]
                   };
        
    }
    
    

    NSLog(@"dictNew:%@",dictNew);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        NSLog(@"%@",responseObj);
        if ([responseObj isKindOfClass:[NSData class]]) {
            NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObj options:NSJSONReadingMutableContainers error:nil];
            
            complete( [logModel_2 mj_objectWithKeyValues:dic],error);
        }else{
            complete( [logModel_2 mj_objectWithKeyValues:responseObj],error);
        }
        
        if (error) {
            NSLog(@"打印错误:%@",error);
        }
    }];




}

+(id)QuickLogin:(NSString*)appId andAccessToken:(NSString *)accessToken andTelecom:(NSString*)Telecom andTimeStamp:(NSString*)timeStamp andRandoms:(NSString*)randoms andVersion:(NSString*)version andDevice:(NSString*)device andSign:(NSString*)sign completionHandle:(void(^)(logModel_2*, NSError *))complete{
    //NSString * pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/convenientLogin"];
    NSString* pathNew_1 = nil;
//     pathNew_1 =@"http://172.16.10.215:8080/socialsecurity/kankan/sharkLogin";//左
//    pathNew_1 = @"http://172.16.10.18:8081/socialsecurity/kankan/sharkLogin";//美满
    pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/sharkLogin"];
    NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSDictionary *dictNew =nil;
    
    dictNew =@{
               @"appId":[EnercryTool encryptUseDES:appId key:DESKEY],
               @"accessToken":accessToken,
               @"telecom":Telecom,
               @"timestamp":timeStamp,
               @"randoms":randoms,
               @"version":version,
               @"device":device,
               @"sign":sign,
               };
    
    NSLog(@"dictNew:%@",dictNew);
    return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
        
        if (responseObj) {
            NSDictionary* dic = [NSJSONSerialization JSONObjectWithData:responseObj options:kNilOptions error:nil];
            NSLog(@"responseObj123%@",dic);
            complete( [logModel_2 mj_objectWithKeyValues:responseObj],error);
        }
        
        if (error) {
            NSLog(@"打印错误:%@",error);
            complete(nil,error);
        }
    }];
}

+(id)QucikLogin2:(NSString*)appId andAccessToken:(NSString *)accessToken andTimeStamp:(NSString*)timeStamp completionHandle:(void(^)(logModel_2*, NSError *))complete
{
    NSString* pathNew_1 = nil;
        // pathNew_1 =@"http://172.16.10.215:8080/socialsecurity/kankan/sharkLogin";//左
    //    pathNew_1 = @"http://172.16.10.18:8081/socialsecurity/kankan/sharkLogin";//美满
        pathNew_1 =[IPDIZHI stringByAppendingString:@"/socialsecurity/kankan/sharkLogin"];
        NSString * pathNew1 =  [pathNew_1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSLog(@"url:%@",pathNew1);
        
        NSDictionary *dictNew =nil;
        
        dictNew =@{
                   @"appId":[EnercryTool encryptUseDES:appId key:DESKEY],
                   @"accessToken":accessToken,
                   @"loginBussinessType":@"10011",
                   @"timestamp":timeStamp,
                   @"version":@"CL231"
                   };
        
        NSLog(@"dictNew:%@",dictNew);
        return [self  POST:pathNew1 parameters:dictNew completionHandler:^(id responseObj, NSError *error) {
            
            if (responseObj) {
                if ([responseObj isKindOfClass:[NSData class]]) {
                    NSDictionary* dic = [NSJSONSerialization JSONObjectWithData:responseObj options:kNilOptions error:nil];
                    NSLog(@"responseObj123%@",dic);
                }
               
                complete( [logModel_2 mj_objectWithKeyValues:responseObj],error);
               
            }
            
            if (error) {
                NSLog(@"打印错误:%@",error);
                complete(nil,error);
            }
        }];
    
}


@end
