CNChangePayPasswordController.m 24.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
//
//  CNChangePayPasswordController.m
//  CNLiveNetAdd
//
//  Created by cnliveJunBo on 2018/6/1.
//  Copyright © 2018年 cnlive. All rights reserved.
//

#import "CNChangePayPasswordController.h"
#import "CNMinePayCenterController.h"
#import "CNOrderDetailController.h"
#import "CNPasswordView.h"
#import "CNMineOrderController.h"
#import <CNLiveEncryptSDK/CNLiveEncryptSDK.h>
#import <CNLiveBaseTools/CNLiveTimeTools.h>
#define TIMECOUNT 60;

@interface CNChangePayPasswordController ()

@property (nonatomic, assign) ChangePayPassWordType type;
@property (nonatomic, copy) NSString *vertificationCode;//验证码内容/密码内容
@property (nonatomic, strong) UIButton *completeBtn;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *subTitleLab;
//@property (nonatomic, strong) PZXVerificationCodeView *pzxView;

@property (strong, nonatomic) CNPasswordView * passwordView;

@property (nonatomic, strong) UIButton *sendNoteButton;
@property (nonatomic, strong) UIView *lineV;
@property (nonatomic, strong) UIImageView *tipImgV;
@property (nonatomic, strong) dispatch_source_t timer;

@end

@implementation CNChangePayPasswordController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.timer) {
        dispatch_cancel(self.timer);
        self.timer = nil;
    }
}

- (instancetype)initWithType:(ChangePayPassWordType)type
{
    self = [super init];
    if (self) {
        self.type = type;
    }
    return self;
}

#pragma mark -
#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- (void)sendNoteAction:(UIButton *)sender {
    
    NSLog(@"重发短信");
    self.sendNoteButton.userInteractionEnabled = NO;
    
    NSDictionary *params = @{@"appId":AppId,
                             @"mobile":CNUserShareModel.mobile?CNUserShareModel.mobile:@"",
                             @"content":@"",
                             @"taskId":@"003_02",
                             @"signatureId":@"0",
                             };
    [CNLiveNetworking setAllowRequestDefaultArgument:YES];
    [CNLiveNetworking setupShowDataResult:NO];
    [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNSendSMSSetPasswordUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
        [QMUITips hideAllTipsInView:AppKeyWindow];

        if (error) {
            [QMUITips showError:error.localizedDescription?error.localizedDescription:@"短信发送失败" inView:self.view hideAfterDelay:1.5];
            self.sendNoteButton.userInteractionEnabled = YES;
                //更改发送显示
            NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"请重新发送 验证码 到您的手机"];
            [AttributedStr addAttribute:NSFontAttributeName
                                      value:[UIFont fontWithName:@"PingFangSC-Medium" size:17.0]
                                      range:NSMakeRange(6, 3)];
            [AttributedStr addAttribute:NSForegroundColorAttributeName
                                      value:KBlack51Color
                                      range:NSMakeRange(6, 3)];
            _titleLab.attributedText = AttributedStr;
                               
            return;
            
        }
        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"我们已发送 验证码 到您的手机"];
        [AttributedStr addAttribute:NSFontAttributeName
                              value:[UIFont fontWithName:@"PingFangSC-Medium" size:17.0]
                              range:NSMakeRange(6, 3)];
        [AttributedStr addAttribute:NSForegroundColorAttributeName
                              value:KBlack51Color
                              range:NSMakeRange(6, 3)];
        _titleLab.attributedText = AttributedStr;
        
        [QMUITips showSucceed:@"发送成功" inView:self.view hideAfterDelay:1.5];
        [self countDown];
        
    }];
    
}

- (void)compleBtnAction:(UIButton *)sender {
    
    NSLog(@"完成");
    //前面输够6位密码调更改密码接口 / 此处调密码接口 ✔️
    // show loading
    NSString *PasswordIsExistingKey = [@"CNPayPasswordIsExisting_" stringByAppendingString:CNUserShareModel.uid];
    
    NSString *password = @"";
    if (![NSString isEmpty:self.vertificationCode]) {
        password = [self.vertificationCode md5String];
    }
    [[CNLiveCMineService shareMineProtocol] responseCroupActiveViewModelRequestType:CNGroupActiveRequestTypeForPrivate reponseBlock:^(id  _Nonnull objective) {
        NSDictionary *dict = objective;
        NSDictionary * signDict = @{
                                    @"userId":CNUserShareModel.uid,
                                    @"platFormId":[[NSBundle mainBundle] bundleIdentifier],
                                    @"timestamp":[NSString stringWithFormat:@"%ld",(long)[CNLiveTimeTools getNow10NumTimestamp]],
                                    @"type":@"1",
                                    @"password":password
                                    };
        NSMutableDictionary * params =  [[CNLiveEncryptManager manager] validationEncryptWithParams:signDict preValiDic:dict].mutableCopy;

        [params addEntriesFromDictionary:@{@"appId":AppId}];

//        CNChangePayPasswordController
        __block NSMutableArray * vcs = self.navigationController.viewControllers.mutableCopy;
        for (UIViewController * vc in self.navigationController.viewControllers) {
            if ([vc isKindOfClass:[CNChangePayPasswordController class]]) {
                [vcs removeObject:vc];
            }
        }
        [CNLiveNetworking setAllowRequestDefaultArgument:YES];
        [CNLiveNetworking setupShowDataResult:NO];
        [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNSetPasswordUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
            if (error) {
//                NSLog(@"error:%@",error.localizedDescription);
                [[NSUserDefaults standardUserDefaults] setObject:@"NotExisting" forKey:PasswordIsExistingKey];
                [[NSUserDefaults standardUserDefaults] synchronize];
                if (error.code==-1009) {
                    [QMUITips showError:@"无网络连接,设置失败" inView:AppKeyWindow hideAfterDelay:1.5f];
                } else {
                    [QMUITips showError:@"设置失败" inView:AppKeyWindow hideAfterDelay:1.5f];
                }
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    for (UIViewController *temp in vcs) {
                        if ([temp isKindOfClass:[CNMinePayCenterController class]]) {
                            CNMinePayCenterController *changePasswordVC = (CNMinePayCenterController *)temp;
                            if (changePasswordVC.type==PayManageType) {
                                [[BaseAppDelegate sharedAppDelegate] popToViewController:changePasswordVC];
                                return;
                            }
                        }
                        if ([temp isKindOfClass:NSClassFromString(@"CNActiveContentViewController")] || [temp isKindOfClass:NSClassFromString(@"CNScanAmountViewController")] || [temp isKindOfClass:NSClassFromString(@"CNChatViewController")] || [temp isKindOfClass:NSClassFromString(@"CNCodeScanViewController")] || [temp isKindOfClass:[CNMineOrderController class]] || [temp isKindOfClass:[CNOrderDetailController class]]) {
                            [[BaseAppDelegate sharedAppDelegate] popToViewController:temp];
                            return;
                        }
                       
                    }
                    [[BaseAppDelegate sharedAppDelegate] popViewControllerWithoutAnimation];
                });
                return;
            }
            NSLog(@"data:%@",responseObject);
            [self.passwordView.textField resignFirstResponder];
            [[NSUserDefaults standardUserDefaults] setObject:@"Existing" forKey:PasswordIsExistingKey];
            [[NSUserDefaults standardUserDefaults] synchronize];
            [self showSuccessImgWithDelay:1.0];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                for (UIViewController *temp in vcs) {
                    if ([temp isKindOfClass:[CNMinePayCenterController class]]) {
                        CNMinePayCenterController *changePasswordVC = (CNMinePayCenterController *)temp;
                        if (changePasswordVC.type==PayManageType) {
                            [[BaseAppDelegate sharedAppDelegate] popToViewController:changePasswordVC];
                            return;
                        }
                    }
                    if ([temp isKindOfClass:NSClassFromString(@"CNScanAmountViewController")] || [temp isKindOfClass:NSClassFromString(@"CNCodeScanViewController")] || [temp isKindOfClass:NSClassFromString(@"CNChatViewController")] || [temp isKindOfClass:[CNOrderDetailController class]] || [temp isKindOfClass:[CNMineOrderController class]]) {
                        [[BaseAppDelegate sharedAppDelegate] popToViewController:temp];
                        return;
                    }
                    if ([temp isKindOfClass:NSClassFromString(@"CNActiveContentViewController")]) {
                        [[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"showPayResultView"];
                        [[NSUserDefaults standardUserDefaults] synchronize];
                        [[BaseAppDelegate sharedAppDelegate] popToViewController:temp];
                        return;
                    }
                }
                [[BaseAppDelegate sharedAppDelegate] popToViewController:vcs.lastObject];
            });
        }];
    }];
}

- (void)cancelButtonClick:(UIButton *)sender {
    [[BaseAppDelegate sharedAppDelegate] popViewControllerWithoutAnimation];
}

#pragma mark - PZXVerificationCodeViewDelegate !!!!!!!!!!!!!!!!!!!!!!!!!!!
- (void)textFieldContentChangedWithCode:(NSString *)code {
    
    NSLog(@"验证码:%@",code);
    
    if (code.length != 6) {
        self.completeBtn.hidden = YES;
        
    } else if (code.length == 6) {
        
        if (self.type==ChangePassWordNoteType) {  //短信
            
            // 验证短信是否正确
            NSDictionary *paramDict = @{@"appId":AppId,
                                        @"mobile":CNUserShareModel.mobile?CNUserShareModel.mobile:@"",
                                        @"verifyCode":code?code:@"",
                                        };
            
            [CNLiveNetworking setAllowRequestDefaultArgument:YES];
            [CNLiveNetworking setupShowDataResult:YES];
            [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNCheckVerifyCodeSetPasswordUrl Param:paramDict CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
                if (error) {
                    [QMUITips showError:@"验证验证码失败" inView:self.view hideAfterDelay:1.5];
//                    self.sendNoteButton.userInteractionEnabled = YES;
                    return;
                }
                NSLog(@"data:%@",responseObject);
                CNChangePayPasswordController *passwordVC = [[CNChangePayPasswordController alloc] initWithType:SettingPassWordType];
                [[BaseAppDelegate sharedAppDelegate] pushViewController:passwordVC withBackTitle:@" "];
            }];
            
        } else if (self.type==SettingPassWordType) {  //设置密码
            CNChangePayPasswordController *passwordVC = [[CNChangePayPasswordController alloc] initWithType:ConfirmChangePassWordType];
            passwordVC.previousPassword = code;
            passwordVC.differentLab.hidden = YES;
            [[BaseAppDelegate sharedAppDelegate] pushViewController:passwordVC withBackTitle:@" "];
        } else if (self.type==ConfirmChangePassWordType) {  //确认密码
            // 直接掉更改接口 / 把完成显示出来,点完成再掉更改接口
            if ([code isEqualToString:self.previousPassword]) {
                NSLog(@"两次一样");
                self.vertificationCode = code;
                self.completeBtn.hidden = NO;
                
            } else {
                
                CNChangePayPasswordController *passwordVC = [[CNChangePayPasswordController alloc] initWithType:SettingPassWordType];
                passwordVC.differentLab.hidden = NO;
                [[BaseAppDelegate sharedAppDelegate] pushViewController:passwordVC withBackTitle:@" "];
            }
            
        }
    }
}

#pragma mark - setupUI !!!!!!!!!!!!!!!!!!!!!!!!!!!
- (void)setupNavButton {
    
    UIButton *completeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    completeBtn.frame = CGRectMake(8, 0, 47, 30);
    
    [completeBtn setTitle:@"完成" forState:UIControlStateNormal];
    [completeBtn setTitleColor:RGB(26, 173, 25) forState:UIControlStateNormal];
    completeBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15];
    completeBtn.hidden = YES;
    self.completeBtn = completeBtn;
    [completeBtn addTarget:self action:@selector(compleBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * completeItem = [[UIBarButtonItem alloc]initWithCustomView:completeBtn];
    UIBarButtonItem *nagetiveSpacerright = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                                                        target:nil action:nil];
    nagetiveSpacerright.width = -16;//这个值可以根据自己需要自己调整
    self.navigationItem.rightBarButtonItems = @[nagetiveSpacerright, completeItem];
    
    UIButton *cancleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    cancleBtn.frame = CGRectMake(0, 0, 47, 30);
    [cancleBtn setImage:[UIImage imageNamed:@"c_mine_skip_push_back"] forState:UIControlStateNormal];
    cancleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [cancleBtn addTarget:self action:@selector(cancelButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem * cancleItem = [[UIBarButtonItem alloc]initWithCustomView:cancleBtn];
    UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                                                                   target:nil action:nil];
    nagetiveSpacer.width = -8;//这个值可以根据自己需要自己调整
    self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, cancleItem];
}

- (void)showSuccessImgWithDelay:(NSTimeInterval)delay {
    
    [[BaseAppDelegate sharedAppDelegate].window addSubview:self.tipImgV];
    [UIView animateWithDuration:0.25 animations:^{
        self.tipImgV.alpha = 1;
    } completion:^(BOOL finished) {
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [UIView animateWithDuration:0.25 animations:^{
                self.tipImgV.alpha = 0;
            } completion:^(BOOL finished) {
                [self.tipImgV removeFromSuperview];
                self.tipImgV = nil;
            }];
        });
    }];
}

- (void)initSubviews
{
    [super initSubviews];
    [self setupNavButton];
    [self.view addSubview:self.titleLab];
    [self.view addSubview:self.subTitleLab];
    [self.view addSubview:self.lineV];
    [self.view addSubview:self.passwordView];
    if (self.type==ChangePassWordNoteType) {
        [self.view addSubview:self.sendNoteButton];
    }
    [self.view addSubview:self.differentLab];
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(kNavigationBarHeight+34);
        make.centerX.equalTo(self.view);
    }];
    [self.subTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLab.mas_bottom).offset(15);
        make.centerX.equalTo(self.view);
    }];
    if (self.type==ChangePassWordNoteType) {
        [self.sendNoteButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.subTitleLab.mas_bottom).offset(18);
            make.centerX.equalTo(self.view);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(14);
        }];
        [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.view);
            make.top.equalTo(self.sendNoteButton.mas_bottom).offset(26);
            make.height.mas_equalTo(1);
        }];
    } else {
        [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.view);
            make.top.equalTo(self.subTitleLab.mas_bottom).offset(30);
            make.height.mas_equalTo(1);
        }];
    }
    [self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.top.equalTo(self.lineV.mas_bottom).offset(32);
        make.height.mas_equalTo(40);
    }];
    
    [self.differentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.passwordView.mas_bottom).offset(20);
        make.centerX.equalTo(self.passwordView);
        make.height.mas_equalTo(20);
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"修改支付密码";
    self.view.backgroundColor = [UIColor whiteColor];
}

#pragma mark - Subviews !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-(CNPasswordView *)passwordView
{
    if (!_passwordView) {
        MJWeakSelf
        CNLiveActivePayInputType type;
        if (self.type == ChangePassWordNoteType) {
            type = CNLiveActivePayInputTypeVerification;
        }else{
            type = CNLiveActivePayInputTypePassword;
        }
        _passwordView = [[CNPasswordView alloc] initWithCNLiveActivePayInputType:type];
        [_passwordView.textField becomeFirstResponder];
        _passwordView.passwordResultBlock = ^(NSString *password) {
            [weakSelf textFieldContentChangedWithCode:password];
        };
    }
    return _passwordView;
}
- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.font = [UIFont fontWithName:@"PingFangSC-Regular" size:17.0f];
        _titleLab.textColor = RGB(119, 119, 119);
        if (self.type==ChangePassWordNoteType) {
            NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"请发送 验证码 到您的手机"];
            [AttributedStr addAttribute:NSFontAttributeName
                                  value:[UIFont fontWithName:@"PingFangSC-Medium" size:17.0]
                                  range:NSMakeRange(4, 3)];
            [AttributedStr addAttribute:NSForegroundColorAttributeName
                                  value:KBlack51Color
                                  range:NSMakeRange(4, 3)];
            _titleLab.attributedText = AttributedStr;
        } else {
            _titleLab.text = @"设置输入支付密码";
        }
    }
    return _titleLab;
}

- (UILabel *)subTitleLab {
    if (!_subTitleLab) {
        _subTitleLab = [[UILabel alloc] init];
        if (self.type==ChangePassWordNoteType) {
            NSMutableString *phoneStr = nil;
            if ([NSString isEmpty:CNUserShareModel.mobile]) {
                phoneStr = [[NSMutableString alloc] initWithString:@"未绑定手机号"];
            } else {
                phoneStr = [[NSMutableString alloc] initWithString:CNUserShareModel.mobile];
                [phoneStr replaceCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
            }
            _subTitleLab.text = phoneStr.copy;
            _subTitleLab.font = [UIFont fontWithName:@"PingFangHK-Medium" size:23.0f];
        } else if (self.type==SettingPassWordType) {
            _subTitleLab.text = @"设置6位支付密码,用于支付验证";
            _subTitleLab.font = [UIFont fontWithName:@"PingFangHK-Medium" size:17.0f];
        } else if (self.type==ConfirmChangePassWordType) {
            _subTitleLab.text = @"请再次输入密码以确认";
            _subTitleLab.font = [UIFont fontWithName:@"PingFangHK-Medium" size:17.0f];
        }
        _subTitleLab.textColor = KBlack51Color;
    }
    return _subTitleLab;
}

- (UILabel *)differentLab {
    if (!_differentLab) {
        _differentLab = [[UILabel alloc] init];
        _differentLab.text = @"两次密码输入不一致";
        _differentLab.textColor = kRedColor;
        _differentLab.font = [UIFont fontWithName:@"PingFangHK-Medium" size:14.0f];
        _differentLab.hidden = YES;
    }
    return _differentLab;
}

- (UIButton *)sendNoteButton {
    if (!_sendNoteButton) {
        _sendNoteButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 14)];
        [_sendNoteButton setTitle:@"发送短信" forState:UIControlStateNormal];
        [_sendNoteButton setTitleColor:RGB(0, 201, 0) forState:UIControlStateNormal];
        _sendNoteButton.titleLabel.font = [UIFont fontWithName:@"PingFangHK-Regular" size:14.0f];
        _sendNoteButton.touchAreaInsets = UIEdgeInsetsMake(15, 15, 15, 15);
        [_sendNoteButton addTarget:self action:@selector(sendNoteAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _sendNoteButton;
}

- (UIImageView *)tipImgV {
    if (!_tipImgV) {
        _tipImgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 160.0+kNavigationBarHeight, 104, 104)];
        _tipImgV.centerX = self.view.centerX;
//        _tipImgV.center = self.view.center;
        _tipImgV.image = [UIImage imageNamed:@"ye_szcg"];
        _tipImgV.alpha = 0;
    }
    return _tipImgV;
}

- (UIView *)lineV {
    if (!_lineV) {
        _lineV = [[UIView alloc] init];
        _lineV.backgroundColor = RGB(229, 229, 229);
    }
    return _lineV;
}

- (void)dealloc {
    NSLog(@"Change dealloc");
    
}

- (BOOL)forceEnableInteractivePopGestureRecognizer {
    return NO;
}

#pragma mark - 倒计时
- (void)countDown {

    __block NSInteger second = TIMECOUNT;
    //(1)
    dispatch_queue_t quene = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    //(2)
    dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, quene);
    self.timer = timer;
    //(3)
    dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
    //(4)
    dispatch_source_set_event_handler(timer, ^{
        dispatch_async(dispatch_get_main_queue(), ^{
            if (second == 0) {
                [self.sendNoteButton setTitle:@"重新发送" forState:UIControlStateNormal];
                [self.sendNoteButton setTitleColor:RGB(0, 201, 0) forState:UIControlStateNormal];
                self.sendNoteButton.userInteractionEnabled = YES;
                
                //更改发送显示
                NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"请重新发送 验证码 到您的手机"];
                [AttributedStr addAttribute:NSFontAttributeName
                                      value:[UIFont fontWithName:@"PingFangSC-Medium" size:17.0]
                                      range:NSMakeRange(6, 3)];
                [AttributedStr addAttribute:NSForegroundColorAttributeName
                                      value:KBlack51Color
                                      range:NSMakeRange(6, 3)];
               self -> _titleLab.attributedText = AttributedStr;
                
                second = TIMECOUNT;
                //(6)
                dispatch_cancel(timer);
                self.timer = nil;
            } else {
                [self.sendNoteButton setTitle:[NSString stringWithFormat:@"%lds后重新发送",second] forState:UIControlStateNormal];
                [self.sendNoteButton setTitleColor:KGray153Color forState:UIControlStateNormal];
                second--;
            }
        });
    });
    //(5)
    dispatch_resume(timer);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

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

@end