//
//  NetworkTokenRequest.m
//  Open
//
//  Created by 雷俊博 on 2019/12/12.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "NetworkTokenRequest.h"
#import "SocialInsurancePayUserModel.h"


@implementation NetworkTokenRequest
+ (void)getTokenSuccess:(void (^)(BOOL))success
{
    NSString *urlString = [NSString stringWithFormat:@"%@%@",[NetworkConfig ipMySocialInsuranceConfig],SocialInsurancePayLoginRequest];
    
    NSLog(@"社保缴费登录注册的urlString:%@",urlString);
    NSLog(@"params:%@",[[self alloc] requestPara]);
    
    [NetworkRequest Post:urlString Params:[[self alloc] requestPara] Success:^(id _Nonnull responseObject) {
        NSLog(@"responseObject:%@",responseObject);
        if ([responseObject isKindOfClass:[NSDictionary class]]) {
            NSString *code = [NSString stringWithFormat:@"%@",responseObject[@"code"]];
            if ([code isEqualToString:@"200"]) {
                SocialInsurancePayUserModel *model = [SocialInsurancePayUserModel mj_objectWithKeyValues:responseObject[@"data"]];
                [PayUserInfoManager sharedManager].model = model;
                NSLog(@"model.uid=%@ model.key=%@",model.uid,model.key);
                success(YES);
            }else{
                success(NO);
            }
        }else{
            success(NO);
        }
    } Failure:^(NSError* error) {
        NSLog(@"error:%@",error);
         success(NO);
    }];
}
- (NSDictionary *)requestPara
{
    NSString *phone = [getPeopleID PeopleIphoneNmber];
    //先拼接
    NSString *sign = [NSString stringWithFormat:@"%@%@",SocialInsurancePayLoginKey,phone];
    sign = [MyMD5 md5:sign];
    
    NSDictionary *dicPara = @{
        @"phone":phone,
        @"sign":sign,
        @"reg_channel":SocialInsuranceReg_Channel
    };
    return dicPara;
}



@end
