Commit 1516e20a0d7d3525e5617e62c68973027277781a
1 parent
d4aa381b
no message
Showing
11 changed files
with
681 additions
and
9 deletions
CNLiveBalanceModule/Classes/Controller/CNLiveChangePayPasswordController.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveChangePayPasswordController.h | ||
| 3 | +// CNLiveBalanceModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 修改支付密码 | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +#import <UIKit/UIKit.h> | ||
| 14 | +#import "CNCommonViewController.h" | ||
| 15 | + | ||
| 16 | +NS_ASSUME_NONNULL_BEGIN | ||
| 17 | + | ||
| 18 | +@interface CNLiveChangePayPasswordController : CNCommonViewController | ||
| 19 | + | ||
| 20 | +@end | ||
| 21 | + | ||
| 22 | +NS_ASSUME_NONNULL_END |
CNLiveBalanceModule/Classes/Controller/CNLiveChangePayPasswordController.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveChangePayPasswordController.m | ||
| 3 | +// CNLiveBalanceModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveChangePayPasswordController.h" | ||
| 10 | +#import "MJExtension.h" | ||
| 11 | +#import <SDWebImage/SDWebImage.h> | ||
| 12 | +#import "QMUIKit.h" | ||
| 13 | + | ||
| 14 | +#import "CNUserInfoManager.h" | ||
| 15 | +#import "CNLiveBaseKit.h" | ||
| 16 | +#import "CNLiveServices.h" | ||
| 17 | +#import "CNLiveCategory.h" | ||
| 18 | + | ||
| 19 | +#import "CNLiveBalanceRequest.h" | ||
| 20 | +#import "CNLiveBalanceNavigationBar.h" | ||
| 21 | +#import "CNLiveChangePayPasswordView.h" | ||
| 22 | +#import "CNLivePayCenterController.h" | ||
| 23 | + | ||
| 24 | +@interface CNLiveChangePayPasswordController ()<CNLiveBalanceNavigationBarDelegate> | ||
| 25 | +@property (nonatomic, strong) CNLiveBalanceNavigationBar *navigationBar; | ||
| 26 | +@property (nonatomic, strong) CNLiveChangePayPasswordView *changePayPasswordView; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | +@end | ||
| 30 | + | ||
| 31 | +@implementation CNLiveChangePayPasswordController | ||
| 32 | +#pragma mark - 加载数据 | ||
| 33 | +- (void)loadData { | ||
| 34 | +// [CNLiveBalanceRequest getBalance:self.type ID:self.ID block:^(BOOL isSuccess, NSString * _Nonnull number) { | ||
| 35 | +// if(isSuccess){ | ||
| 36 | +// self.balanceView.number = number; | ||
| 37 | +// } | ||
| 38 | +// }]; | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +#pragma mark - 生命周期 | ||
| 42 | +- (void)viewWillAppear:(BOOL)animated{ | ||
| 43 | + [super viewWillAppear:animated]; | ||
| 44 | + self.navigationController.navigationBarHidden = YES; | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +- (void)viewDidLoad { | ||
| 48 | + [super viewDidLoad]; | ||
| 49 | + self.view.backgroundColor = [UIColor whiteColor]; | ||
| 50 | + if (@available(iOS 11, *)) { | ||
| 51 | + } | ||
| 52 | + else { | ||
| 53 | + self.automaticallyAdjustsScrollViewInsets = NO; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + [self createSubViews]; | ||
| 57 | + [self loadData]; | ||
| 58 | + | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +- (void)createSubViews { | ||
| 62 | + [self.view addSubview:self.changePayPasswordView]; | ||
| 63 | + [self.view addSubview:self.navigationBar]; | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +#pragma mark - 懒加载 | ||
| 67 | +- (CNLiveBalanceNavigationBar *)navigationBar { | ||
| 68 | + if (!_navigationBar) { | ||
| 69 | + _navigationBar = [[CNLiveBalanceNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)]; | ||
| 70 | + _navigationBar.delegate = self; | ||
| 71 | + _navigationBar.backgroundColor = [UIColor whiteColor]; | ||
| 72 | + _navigationBar.title.text = @"修改支付密码"; | ||
| 73 | + _navigationBar.title.textColor = [UIColor blackColor]; | ||
| 74 | + UIImage *image = [self getImageWithImageName:@"mine_back_black_b" bundleName:@"CNLiveBalanceModule" targetClass:[self class]]; | ||
| 75 | + [_navigationBar.left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; | ||
| 76 | + _navigationBar.right = nil; | ||
| 77 | + } | ||
| 78 | + return _navigationBar; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +- (CNLiveChangePayPasswordView *)changePayPasswordView{ | ||
| 82 | + if(!_changePayPasswordView){ | ||
| 83 | + _changePayPasswordView = [[CNLiveChangePayPasswordView alloc]initWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, 170)]; | ||
| 84 | + } | ||
| 85 | + return _changePayPasswordView; | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +#pragma mark - 响应方法 | ||
| 89 | +- (void)goBack { | ||
| 90 | + if (self.presentingViewController != nil) { | ||
| 91 | + [self dismissViewControllerAnimated:YES completion:nil]; | ||
| 92 | + } | ||
| 93 | + else { | ||
| 94 | + [self.navigationController popViewControllerAnimated:YES]; | ||
| 95 | + } | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +#pragma mark - CNLiveBalanceNavigationBarDelegate | ||
| 99 | +- (void)navigationBar:(CNLiveBalanceNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | ||
| 100 | + if ([actionEvents isEqualToString:@"1"]) { | ||
| 101 | + [self goBack]; | ||
| 102 | + } | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +@end |
CNLiveBalanceModule/Classes/Controller/CNLivePayCenterController.m
| @@ -8,20 +8,15 @@ | @@ -8,20 +8,15 @@ | ||
| 8 | 8 | ||
| 9 | #import "CNLivePayCenterController.h" | 9 | #import "CNLivePayCenterController.h" |
| 10 | #import "MJExtension.h" | 10 | #import "MJExtension.h" |
| 11 | -#import <SDWebImage/SDWebImage.h> | ||
| 12 | #import "QMUIKit.h" | 11 | #import "QMUIKit.h" |
| 13 | 12 | ||
| 14 | -#import "CNUserInfoManager.h" | ||
| 15 | -#import "CNLiveBaseKit.h" | ||
| 16 | #import "CNLiveCategory.h" | 13 | #import "CNLiveCategory.h" |
| 17 | 14 | ||
| 15 | +#import "CNLiveBalanceNavigationBar.h" | ||
| 18 | #import "CNLiveBalanceModel.h" | 16 | #import "CNLiveBalanceModel.h" |
| 19 | #import "CNLivePayCenterCell.h" | 17 | #import "CNLivePayCenterCell.h" |
| 20 | -#import "CNLiveServices.h" | ||
| 21 | -#import "CNLiveBalanceNavigationBar.h" | ||
| 22 | -#import "CNLiveBalanceView.h" | ||
| 23 | - | ||
| 24 | #import "CNLiveTradingRecordController.h" // 交易记录 | 18 | #import "CNLiveTradingRecordController.h" // 交易记录 |
| 19 | +#import "CNLivePayManagerController.h"// 支付管理 | ||
| 25 | 20 | ||
| 26 | @interface CNLivePayCenterController ()<UITableViewDelegate, UITableViewDataSource,CNLiveBalanceNavigationBarDelegate> | 21 | @interface CNLivePayCenterController ()<UITableViewDelegate, UITableViewDataSource,CNLiveBalanceNavigationBarDelegate> |
| 27 | @property (nonatomic, strong) CNLiveBalanceNavigationBar *navigationBar; | 22 | @property (nonatomic, strong) CNLiveBalanceNavigationBar *navigationBar; |
| @@ -106,7 +101,8 @@ | @@ -106,7 +101,8 @@ | ||
| 106 | CNLiveTradingRecordController *vc = [[CNLiveTradingRecordController alloc]init]; | 101 | CNLiveTradingRecordController *vc = [[CNLiveTradingRecordController alloc]init]; |
| 107 | [self.navigationController pushViewController:vc animated:YES]; | 102 | [self.navigationController pushViewController:vc animated:YES]; |
| 108 | }else if(indexPath.row == 1){//支付管理 | 103 | }else if(indexPath.row == 1){//支付管理 |
| 109 | - | 104 | + CNLivePayManagerController *vc = [[CNLivePayManagerController alloc]init]; |
| 105 | + [self.navigationController pushViewController:vc animated:YES]; | ||
| 110 | } | 106 | } |
| 111 | } | 107 | } |
| 112 | 108 |
CNLiveBalanceModule/Classes/Controller/CNLivePayManagerController.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLivePayManagerController.h | ||
| 3 | +// CNLiveBalanceModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 支付管理 | ||
| 11 | + */ | ||
| 12 | + | ||
| 13 | +#import <UIKit/UIKit.h> | ||
| 14 | +#import "CNCommonViewController.h" | ||
| 15 | + | ||
| 16 | +NS_ASSUME_NONNULL_BEGIN | ||
| 17 | + | ||
| 18 | +@interface CNLivePayManagerController : CNCommonViewController | ||
| 19 | + | ||
| 20 | +@end | ||
| 21 | + | ||
| 22 | +NS_ASSUME_NONNULL_END |
CNLiveBalanceModule/Classes/Controller/CNLivePayManagerController.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLivePayManagerController.m | ||
| 3 | +// CNLiveBalanceModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLivePayManagerController.h" | ||
| 10 | +#import "MJExtension.h" | ||
| 11 | +#import "QMUIKit.h" | ||
| 12 | + | ||
| 13 | +#import "CNLiveCategory.h" | ||
| 14 | + | ||
| 15 | +#import "CNLiveBalanceNavigationBar.h" | ||
| 16 | +#import "CNLiveBalanceModel.h" | ||
| 17 | +#import "CNLivePayCenterCell.h" | ||
| 18 | +#import "CNLiveChangePayPasswordController.h" | ||
| 19 | + | ||
| 20 | +@interface CNLivePayManagerController ()<UITableViewDelegate, UITableViewDataSource,CNLiveBalanceNavigationBarDelegate> | ||
| 21 | +@property (nonatomic, strong) CNLiveBalanceNavigationBar *navigationBar; | ||
| 22 | +@property (nonatomic, strong) UITableView *tableView; | ||
| 23 | + | ||
| 24 | +@property (nonatomic, strong) NSMutableArray *data; | ||
| 25 | + | ||
| 26 | +@end | ||
| 27 | + | ||
| 28 | +@implementation CNLivePayManagerController | ||
| 29 | +#pragma mark - 加载数据 | ||
| 30 | +- (void)loadData { | ||
| 31 | + NSArray *data = @[ | ||
| 32 | + @{ | ||
| 33 | + @"title":@"修改支付密码", | ||
| 34 | + @"height":@"60", | ||
| 35 | + @"lineHeight":@"10" | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + ]; | ||
| 39 | + for(NSDictionary *dic in data){ | ||
| 40 | + [self.data addObject:[CNLiveBalanceModel mj_objectWithKeyValues:dic]]; | ||
| 41 | + } | ||
| 42 | + [self.tableView reloadData]; | ||
| 43 | + | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +#pragma mark - 生命周期 | ||
| 47 | +- (void)viewWillAppear:(BOOL)animated{ | ||
| 48 | + [super viewWillAppear:animated]; | ||
| 49 | + self.navigationController.navigationBarHidden = YES; | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +- (void)viewDidLoad { | ||
| 53 | + [super viewDidLoad]; | ||
| 54 | + self.view.backgroundColor = [UIColor whiteColor]; | ||
| 55 | + if (@available(iOS 11, *)) { | ||
| 56 | + self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; | ||
| 57 | + } | ||
| 58 | + else { | ||
| 59 | + self.automaticallyAdjustsScrollViewInsets = NO; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + [self createSubViews]; | ||
| 63 | + [self loadData]; | ||
| 64 | + | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +- (void)createSubViews { | ||
| 68 | + [self.view addSubview:self.navigationBar]; | ||
| 69 | + [self.view addSubview:self.tableView]; | ||
| 70 | + | ||
| 71 | +} | ||
| 72 | + | ||
| 73 | +#pragma mark - UITableViewDelegate | ||
| 74 | +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ | ||
| 75 | + CNLiveBalanceModel *model = self.data[indexPath.row]; | ||
| 76 | + return model.height; | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +#pragma mark - UITableViewDataSource | ||
| 80 | +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | ||
| 81 | + return self.data.count; | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
| 85 | + CNLivePayCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:kCNLivePayCenterCell]; | ||
| 86 | + cell.selectionStyle = UITableViewCellSelectionStyleNone; | ||
| 87 | + CNLiveBalanceModel *model = self.data[indexPath.row]; | ||
| 88 | + cell.model = model; | ||
| 89 | + return cell; | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | ||
| 93 | + if(indexPath.row == 0){// 修改密码 | ||
| 94 | + CNLiveChangePayPasswordController *vc = [[CNLiveChangePayPasswordController alloc]init]; | ||
| 95 | + [self.navigationController pushViewController:vc animated:YES]; | ||
| 96 | + } | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +#pragma mark - 懒加载 | ||
| 100 | +- (NSMutableArray *)data { | ||
| 101 | + if (!_data) { | ||
| 102 | + _data = [[NSMutableArray alloc] init]; | ||
| 103 | + } | ||
| 104 | + return _data; | ||
| 105 | +} | ||
| 106 | +- (CNLiveBalanceNavigationBar *)navigationBar { | ||
| 107 | + if (!_navigationBar) { | ||
| 108 | + _navigationBar = [[CNLiveBalanceNavigationBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, NavigationContentTop)]; | ||
| 109 | + _navigationBar.backgroundColor = [UIColor whiteColor]; | ||
| 110 | + _navigationBar.delegate = self; | ||
| 111 | + _navigationBar.title.text = @"支付管理"; | ||
| 112 | + _navigationBar.title.textColor = [UIColor blackColor]; | ||
| 113 | + UIImage *image = [self getImageWithImageName:@"mine_back_black_b" bundleName:@"CNLiveBalanceModule" targetClass:[self class]]; | ||
| 114 | + [_navigationBar.left setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal]; | ||
| 115 | + _navigationBar.right = nil; | ||
| 116 | + | ||
| 117 | + } | ||
| 118 | + return _navigationBar; | ||
| 119 | +} | ||
| 120 | +- (UITableView *)tableView{ | ||
| 121 | + if(!_tableView){ | ||
| 122 | + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavigationContentTop, SCREEN_WIDTH, SCREEN_HEIGHT-NavigationContentTop) style:UITableViewStylePlain]; | ||
| 123 | + _tableView.delegate = self; | ||
| 124 | + _tableView.dataSource = self; | ||
| 125 | + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; | ||
| 126 | + _tableView.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1.0]; | ||
| 127 | + _tableView.estimatedRowHeight = 0; | ||
| 128 | + _tableView.estimatedSectionHeaderHeight = 0; | ||
| 129 | + _tableView.estimatedSectionFooterHeight = 0; | ||
| 130 | + [_tableView registerClass:[CNLivePayCenterCell class] forCellReuseIdentifier:kCNLivePayCenterCell]; | ||
| 131 | + } | ||
| 132 | + return _tableView; | ||
| 133 | +} | ||
| 134 | +#pragma mark - 响应方法 | ||
| 135 | +- (void)goBack { | ||
| 136 | + if (self.presentingViewController != nil) { | ||
| 137 | + [self dismissViewControllerAnimated:YES completion:nil]; | ||
| 138 | + } | ||
| 139 | + else { | ||
| 140 | + [self.navigationController popViewControllerAnimated:YES]; | ||
| 141 | + } | ||
| 142 | +} | ||
| 143 | + | ||
| 144 | +#pragma mark - CNLiveBalanceNavigationBarDelegate | ||
| 145 | +- (void)navigationBar:(CNLiveBalanceNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | ||
| 146 | + if ([actionEvents isEqualToString:@"1"]) { | ||
| 147 | + [self goBack]; | ||
| 148 | + }else if ([actionEvents isEqualToString:@"2"]){ | ||
| 149 | + | ||
| 150 | + } | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +@end |
CNLiveBalanceModule/Classes/Model/CNLiveBalanceRequest.h
| @@ -11,17 +11,21 @@ | @@ -11,17 +11,21 @@ | ||
| 11 | NS_ASSUME_NONNULL_BEGIN | 11 | NS_ASSUME_NONNULL_BEGIN |
| 12 | typedef void(^GetBalanceBlock)(BOOL isSuccess, NSString *number); | 12 | typedef void(^GetBalanceBlock)(BOOL isSuccess, NSString *number); |
| 13 | typedef void(^GetTradingRecordBlock)(BOOL isSuccess, NSDictionary *data, NSError *error); | 13 | typedef void(^GetTradingRecordBlock)(BOOL isSuccess, NSDictionary *data, NSError *error); |
| 14 | +typedef void(^GetCodeBlock)(BOOL isSuccess, NSMutableAttributedString *string); | ||
| 14 | 15 | ||
| 15 | @interface CNLiveBalanceRequest : NSObject | 16 | @interface CNLiveBalanceRequest : NSObject |
| 16 | 17 | ||
| 17 | // 获取余额 | 18 | // 获取余额 |
| 18 | + (void)getBalance:(NSString *)type ID:(NSString *)ID block:(GetBalanceBlock)block; | 19 | + (void)getBalance:(NSString *)type ID:(NSString *)ID block:(GetBalanceBlock)block; |
| 19 | 20 | ||
| 20 | -// | 21 | +// 获取交易记录 |
| 21 | + (void)getTradingRecordWithType:(NSString *)type startTime:(NSString *)startTime endTime:(NSString *)endTime block:(GetTradingRecordBlock)block; | 22 | + (void)getTradingRecordWithType:(NSString *)type startTime:(NSString *)startTime endTime:(NSString *)endTime block:(GetTradingRecordBlock)block; |
| 22 | 23 | ||
| 23 | + (NSArray *)getMonthFirstAndLastDayWithDate:(NSDate *)date; | 24 | + (NSArray *)getMonthFirstAndLastDayWithDate:(NSDate *)date; |
| 24 | 25 | ||
| 26 | +// 获取验证码 | ||
| 27 | ++ (void)getCodeWithTaskId:(NSString *)taskId signatureId:(NSString *)signatureId block:(GetCodeBlock)block; | ||
| 28 | + | ||
| 25 | 29 | ||
| 26 | @end | 30 | @end |
| 27 | 31 |
CNLiveBalanceModule/Classes/Model/CNLiveBalanceRequest.m
| @@ -77,4 +77,44 @@ | @@ -77,4 +77,44 @@ | ||
| 77 | 77 | ||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | +// 获取验证码 | ||
| 81 | ++ (void)getCodeWithTaskId:(NSString *)taskId signatureId:(NSString *)signatureId block:(GetCodeBlock)block{ | ||
| 82 | + NSDictionary *params = @{@"appId":AppId, | ||
| 83 | + @"mobile":CNUserShareModel.mobile?CNUserShareModel.mobile:@"", | ||
| 84 | + @"content":@"", | ||
| 85 | + @"taskId":taskId, | ||
| 86 | + @"signatureId":signatureId, | ||
| 87 | + }; | ||
| 88 | + [CNLiveNetworking setAllowRequestDefaultArgument:YES]; | ||
| 89 | + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNSendSMSSetPasswordUrl Param:params CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { | ||
| 90 | + | ||
| 91 | + if (responseObject && [responseObject isKindOfClass:[NSDictionary class]] && responseObject[@"data"] && [responseObject[@"data"] isKindOfClass:[NSDictionary class]]) { | ||
| 92 | + NSString *errorCode = [NSString stringWithFormat:@"%@", responseObject[@"errorCode"]]; | ||
| 93 | + if([errorCode isEqualToString:@"0"]){ | ||
| 94 | + //更改发送显示 | ||
| 95 | + NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:@"我们已发送 验证码 到您的手机"]; | ||
| 96 | + [string addAttribute:NSFontAttributeName | ||
| 97 | + value:[UIFont fontWithName:@"PingFangSC-Medium" size:17.0] | ||
| 98 | + range:NSMakeRange(6, 3)]; | ||
| 99 | + [string addAttribute:NSForegroundColorAttributeName | ||
| 100 | + value:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] | ||
| 101 | + range:NSMakeRange(6, 3)]; | ||
| 102 | + block?block(YES, string):@""; | ||
| 103 | + return ; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + } | ||
| 107 | + NSMutableAttributedString *string = [[NSMutableAttributedString alloc]initWithString:@"请重新发送 验证码 到您的手机"]; | ||
| 108 | + [string addAttribute:NSFontAttributeName | ||
| 109 | + value:[UIFont fontWithName:@"PingFangSC-Medium" size:17.0] | ||
| 110 | + range:NSMakeRange(6, 3)]; | ||
| 111 | + [string addAttribute:NSForegroundColorAttributeName | ||
| 112 | + value:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0] | ||
| 113 | + range:NSMakeRange(6, 3)]; | ||
| 114 | + block?block(NO, string):@""; | ||
| 115 | + | ||
| 116 | + }]; | ||
| 117 | + | ||
| 118 | +} | ||
| 119 | + | ||
| 80 | @end | 120 | @end |
CNLiveBalanceModule/Classes/View/CNLiveChangePayPasswordView.h
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveChangePayPasswordView.m | ||
| 3 | +// CNLiveBalanceModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import <UIKit/UIKit.h> | ||
| 10 | + | ||
| 11 | +NS_ASSUME_NONNULL_BEGIN | ||
| 12 | +@class CNLiveChangePayPasswordView; | ||
| 13 | + | ||
| 14 | +@protocol CNLiveChangePayPasswordViewDelegate <NSObject> | ||
| 15 | + | ||
| 16 | +@end | ||
| 17 | + | ||
| 18 | +@interface CNLiveChangePayPasswordView : UIView | ||
| 19 | +@property (nonatomic, weak) id<CNLiveChangePayPasswordViewDelegate> delegate; | ||
| 20 | + | ||
| 21 | +@end | ||
| 22 | + | ||
| 23 | +NS_ASSUME_NONNULL_END |
CNLiveBalanceModule/Classes/View/CNLiveChangePayPasswordView.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveChangePayPasswordView.m | ||
| 3 | +// CNLiveBalanceModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright © 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveChangePayPasswordView.h" | ||
| 10 | +#import "QMUIKit.h" | ||
| 11 | +#import <Masonry/Masonry.h> | ||
| 12 | +#import "CNLiveCategory.h" | ||
| 13 | +#import "CNLiveBaseKit.h" | ||
| 14 | +#import "CNUserInfoManager.h" | ||
| 15 | +#import "CNLiveNetworking.h" | ||
| 16 | +#import "CNLiveEnvironment.h" | ||
| 17 | +#import "CNLiveBalanceRequest.h" | ||
| 18 | + | ||
| 19 | +#import "CNLiveCountDownButton.h" | ||
| 20 | + | ||
| 21 | +@interface CNLiveChangePayPasswordView ()<CNLiveCountDownButtonDataSource, CNLiveCountDownButtonDelegate> | ||
| 22 | +@property (nonatomic, strong) UILabel *tips; | ||
| 23 | +@property (nonatomic, strong) UILabel *tel; | ||
| 24 | +@property (nonatomic, strong) CNLiveCountDownButton *code; | ||
| 25 | +@property (nonatomic, strong) UIView *line; | ||
| 26 | + | ||
| 27 | +@end | ||
| 28 | + | ||
| 29 | +@implementation CNLiveChangePayPasswordView | ||
| 30 | +static const NSInteger timeValue = 1.5; | ||
| 31 | +static const NSInteger margin = 10; | ||
| 32 | +static const CGFloat height = 50; | ||
| 33 | + | ||
| 34 | +- (instancetype)initWithFrame:(CGRect)frame{ | ||
| 35 | + self = [super initWithFrame:frame]; | ||
| 36 | + if(self){ | ||
| 37 | + self.userInteractionEnabled = YES; | ||
| 38 | + self.backgroundColor = [UIColor clearColor]; | ||
| 39 | + [self createSubViews]; | ||
| 40 | + } | ||
| 41 | + return self; | ||
| 42 | +} | ||
| 43 | +- (void)dealloc{ | ||
| 44 | + [_code releaseTimer]; | ||
| 45 | +} | ||
| 46 | +- (void)createSubViews { | ||
| 47 | + [self addSubview:self.tips]; | ||
| 48 | + [self addSubview:self.tel]; | ||
| 49 | + [self addSubview:self.code]; | ||
| 50 | + [self addSubview:self.line]; | ||
| 51 | + | ||
| 52 | + [_tips mas_updateConstraints:^(MASConstraintMaker *make) { | ||
| 53 | + make.left.equalTo(self.mas_left).with.offset(margin); | ||
| 54 | + make.right.equalTo(self.mas_right).with.offset(-margin); | ||
| 55 | + make.top.equalTo(self.mas_top).with.offset(margin); | ||
| 56 | + make.height.offset(height); | ||
| 57 | + | ||
| 58 | + }]; | ||
| 59 | + [_tel mas_updateConstraints:^(MASConstraintMaker *make) { | ||
| 60 | + make.left.equalTo(self.tips.mas_left); | ||
| 61 | + make.right.equalTo(self.tips.mas_right); | ||
| 62 | + make.top.equalTo(self.tips.mas_bottom).with.offset(0); | ||
| 63 | + make.height.offset(height); | ||
| 64 | + | ||
| 65 | + }]; | ||
| 66 | + [_code mas_updateConstraints:^(MASConstraintMaker *make) { | ||
| 67 | + make.centerX.equalTo(self.mas_centerX); | ||
| 68 | + make.top.equalTo(self.tel.mas_bottom).with.offset(0); | ||
| 69 | + make.width.offset(120); | ||
| 70 | + make.height.offset(height); | ||
| 71 | + | ||
| 72 | + }]; | ||
| 73 | + [_line mas_updateConstraints:^(MASConstraintMaker *make) { | ||
| 74 | + make.left.equalTo(self.mas_left); | ||
| 75 | + make.right.equalTo(self.mas_right); | ||
| 76 | + make.bottom.equalTo(self.mas_bottom); | ||
| 77 | + make.height.offset(0.5); | ||
| 78 | + }]; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +/* | ||
| 82 | + // Only override drawRect: if you perform custom drawing. | ||
| 83 | + // An empty implementation adversely affects performance during animation. | ||
| 84 | + - (void)drawRect:(CGRect)rect { | ||
| 85 | + // Drawing code | ||
| 86 | + } | ||
| 87 | + */ | ||
| 88 | + | ||
| 89 | +#pragma mark - 响应方法 | ||
| 90 | +- (void)codeDidClicked:(UIButton *)btn{ | ||
| 91 | + | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +#pragma mark - 懒加载 | ||
| 95 | +- (UILabel *)tips{ | ||
| 96 | + if (!_tips) { | ||
| 97 | + _tips = [[UILabel alloc] init]; | ||
| 98 | + [_tips setFont:UIFontCNMake(12.0)]; | ||
| 99 | + _tips.textColor = [UIColor blackColor]; | ||
| 100 | + _tips.textAlignment = NSTextAlignmentCenter; | ||
| 101 | + _tips.font = [UIFont fontWithName:@"PingFangSC-Regular" size:17.0f]; | ||
| 102 | + _tips.textColor = RGB(119, 119, 119); | ||
| 103 | + | ||
| 104 | + NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:@"请发送 验证码 到您的手机"]; | ||
| 105 | + [AttributedStr addAttribute:NSFontAttributeName | ||
| 106 | + value:[UIFont fontWithName:@"PingFangSC-Medium" size:17.0] | ||
| 107 | + range:NSMakeRange(4, 3)]; | ||
| 108 | + [AttributedStr addAttribute:NSForegroundColorAttributeName | ||
| 109 | + value:KBlack51Color | ||
| 110 | + range:NSMakeRange(4, 3)]; | ||
| 111 | + _tips.attributedText = AttributedStr; | ||
| 112 | + } | ||
| 113 | + return _tips; | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +- (UILabel *)tel{ | ||
| 117 | + if (!_tel) { | ||
| 118 | + _tel = [[UILabel alloc] init]; | ||
| 119 | + [_tel setFont:UIFontCNMake(15.0)]; | ||
| 120 | + _tel.textColor = [UIColor blackColor]; | ||
| 121 | + _tel.textAlignment = NSTextAlignmentCenter; | ||
| 122 | + NSMutableString *phone = [[NSMutableString alloc] initWithString:CNUserShareModel.mobile]; | ||
| 123 | + [phone replaceCharactersInRange:NSMakeRange(3, 4) withString:@"****"]; | ||
| 124 | + _tel.text = phone; | ||
| 125 | + _tel.font = [UIFont fontWithName:@"PingFangHK-Medium" size:23.0f]; | ||
| 126 | + } | ||
| 127 | + return _tel; | ||
| 128 | +} | ||
| 129 | + | ||
| 130 | +- (CNLiveCountDownButton *)code { | ||
| 131 | + if (!_code) { | ||
| 132 | + _code = [CNLiveCountDownButton buttonWithType:UIButtonTypeCustom]; | ||
| 133 | + _code.adjustsImageWhenHighlighted = NO; | ||
| 134 | + [_code setTitle:@"发送短信" forState:UIControlStateNormal]; | ||
| 135 | + [_code setTitleColor:RGB(0, 201, 0) forState:UIControlStateNormal]; | ||
| 136 | + _code.titleLabel.font = [UIFont fontWithName:@"PingFangHK-Regular" size:14.0f]; | ||
| 137 | + _code.dataSource = self; | ||
| 138 | + _code.delegate = self; | ||
| 139 | + } | ||
| 140 | + return _code; | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +- (UIView *)line { | ||
| 144 | + if (!_line) { | ||
| 145 | + _line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; | ||
| 146 | + _line.backgroundColor = RGB(229, 229, 229); | ||
| 147 | + } | ||
| 148 | + return _line; | ||
| 149 | +} | ||
| 150 | + | ||
| 151 | +#pragma mark - CNLiveCountdownButton DataSource | ||
| 152 | +// 设置倒计时总秒数 | ||
| 153 | +- (NSInteger)startCountDownNumOfCountDownButton:(CNLiveCountDownButton *)countdownButton { | ||
| 154 | + return 60; | ||
| 155 | +} | ||
| 156 | + | ||
| 157 | +#pragma mark - CNLiveCountdownButton Delegate | ||
| 158 | +// 倒计时按钮点击 | ||
| 159 | +- (void)countDownButtonDidClick:(CNLiveCountDownButton *)button { | ||
| 160 | + // 按钮点击后将enabled设置为NO | ||
| 161 | + self.code.userInteractionEnabled = NO; | ||
| 162 | + __weak typeof(self) weakSelf = self; | ||
| 163 | + [CNLiveBalanceRequest getCodeWithTaskId:@"003_02" signatureId:@"0" block:^(BOOL isSuccess, NSMutableAttributedString * _Nonnull string) { | ||
| 164 | + weakSelf.code.userInteractionEnabled = YES; | ||
| 165 | + if(isSuccess){ | ||
| 166 | + [weakSelf.code startCountDown]; | ||
| 167 | + } | ||
| 168 | + [QMUITips showSucceed:isSuccess?@"发送成功":@"发送失败" inView:[UIApplication sharedApplication].delegate.window hideAfterDelay:timeValue]; | ||
| 169 | + weakSelf.tips.attributedText = string; | ||
| 170 | + }]; | ||
| 171 | + | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +// 倒计时进行中 | ||
| 175 | +- (void)countDownButtonDidCountDown:(CNLiveCountDownButton *)button countDownNum:(NSInteger)countDownNum { | ||
| 176 | + NSString *title = [NSString stringWithFormat:@"%ld秒后重新发送", countDownNum]; | ||
| 177 | + [button setTitle:title forState:UIControlStateNormal]; | ||
| 178 | + | ||
| 179 | +} | ||
| 180 | + | ||
| 181 | +// 倒计时结束 | ||
| 182 | +- (void)countDownButtonDidEndCountDown:(CNLiveCountDownButton *)button { | ||
| 183 | + [button setTitle:@"发送短信" forState:UIControlStateNormal]; | ||
| 184 | + [self.code releaseTimer]; | ||
| 185 | +} | ||
| 186 | + | ||
| 187 | +@end |
CNLiveBalanceModule/Classes/View/CNLiveCountDownButton.h
0 → 100644
| 1 | +// | ||
| 2 | +// XWCountDownButton.h | ||
| 3 | +// CNLiveLoginModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 倒计时按钮 | ||
| 11 | + */ | ||
| 12 | +#import <UIKit/UIKit.h> | ||
| 13 | + | ||
| 14 | +NS_ASSUME_NONNULL_BEGIN | ||
| 15 | + | ||
| 16 | +@class CNLiveCountDownButton; | ||
| 17 | + | ||
| 18 | +@protocol CNLiveCountDownButtonDataSource <NSObject> | ||
| 19 | +// 设置起始倒计时秒数 | ||
| 20 | +- (NSInteger)startCountDownNumOfCountDownButton:(CNLiveCountDownButton *)button; | ||
| 21 | + | ||
| 22 | +@end | ||
| 23 | + | ||
| 24 | +@protocol CNLiveCountDownButtonDelegate <NSObject> | ||
| 25 | +// 倒计时按钮点击时回调 | ||
| 26 | +- (void)countDownButtonDidClick:(CNLiveCountDownButton *)button; | ||
| 27 | +// 倒计时进行中的回调 | ||
| 28 | +- (void)countDownButtonDidCountDown:(CNLiveCountDownButton *)button countDownNum:(NSInteger)countDownNum; | ||
| 29 | +// 倒计时结束时的回调 | ||
| 30 | +- (void)countDownButtonDidEndCountDown:(CNLiveCountDownButton *)button; | ||
| 31 | + | ||
| 32 | +@end | ||
| 33 | + | ||
| 34 | +@interface CNLiveCountDownButton : UIButton | ||
| 35 | + | ||
| 36 | +@property (nonatomic, weak) id <CNLiveCountDownButtonDataSource> dataSource; | ||
| 37 | +@property (nonatomic, weak) id <CNLiveCountDownButtonDelegate> delegate; | ||
| 38 | + | ||
| 39 | +/** 开始倒计时 */ | ||
| 40 | +- (void)startCountDown; | ||
| 41 | +/** 释放timer */ | ||
| 42 | +- (void)releaseTimer; | ||
| 43 | + | ||
| 44 | +@end | ||
| 45 | + | ||
| 46 | +NS_ASSUME_NONNULL_END |
CNLiveBalanceModule/Classes/View/CNLiveCountDownButton.m
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveCountDownButton.m | ||
| 3 | +// CNLiveLoginModule | ||
| 4 | +// | ||
| 5 | +// Created by 153993236@qq.com on 11/12/2019. | ||
| 6 | +// Copyright (c) 2019 153993236@qq.com. All rights reserved. | ||
| 7 | +// | ||
| 8 | + | ||
| 9 | +#import "CNLiveCountDownButton.h" | ||
| 10 | +@interface CNLiveCountDownButton() | ||
| 11 | +@property (nonatomic, strong) NSTimer *timer; | ||
| 12 | + | ||
| 13 | +@end | ||
| 14 | + | ||
| 15 | +@implementation CNLiveCountDownButton{ | ||
| 16 | + // 剩余倒计时 | ||
| 17 | + NSInteger _countDownNum; | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +- (instancetype)initWithFrame:(CGRect)frame { | ||
| 21 | + if (self = [super initWithFrame:frame]) { | ||
| 22 | + [self addTarget:self action:@selector(onClick) forControlEvents:UIControlEventTouchUpInside]; | ||
| 23 | + } | ||
| 24 | + return self; | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +// 按钮点击 | ||
| 28 | +- (void)onClick { | ||
| 29 | + if ([self.dataSource respondsToSelector:@selector(startCountDownNumOfCountDownButton:)]) { | ||
| 30 | + _countDownNum = [self.dataSource startCountDownNumOfCountDownButton:self]; | ||
| 31 | + } | ||
| 32 | + if ([self.delegate respondsToSelector:@selector(countDownButtonDidClick:)]) { | ||
| 33 | + [self.delegate countDownButtonDidClick:self]; | ||
| 34 | + } | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// 开始倒计时 | ||
| 38 | +- (void)startCountDown { | ||
| 39 | + if (self.timer) { | ||
| 40 | + [self releaseTimer]; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(refreshButton) userInfo:nil repeats:YES]; | ||
| 44 | + [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +// 刷新按钮 | ||
| 48 | +- (void)refreshButton { | ||
| 49 | + _countDownNum --; | ||
| 50 | + | ||
| 51 | + if ([self.delegate respondsToSelector:@selector(countDownButtonDidCountDown:countDownNum:)]) { | ||
| 52 | + [self.delegate countDownButtonDidCountDown:self countDownNum:_countDownNum]; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + if (_countDownNum == 0) { | ||
| 56 | + [self releaseTimer]; | ||
| 57 | + if ([self.delegate respondsToSelector:@selector(countDownButtonDidEndCountDown:)]) { | ||
| 58 | + [self.delegate countDownButtonDidEndCountDown:self]; | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +- (void)releaseTimer { | ||
| 64 | + if (self.timer) { | ||
| 65 | + [self.timer invalidate]; | ||
| 66 | + self.timer = nil; | ||
| 67 | + } | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +- (void)dealloc { | ||
| 71 | + NSLog(@"倒计时按钮已释放"); | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +@end |