更换项目

This commit is contained in:
liyuhua
2023-07-14 18:50:55 +08:00
parent fff67e0aee
commit fc0480ea2c
9340 changed files with 236665 additions and 221827 deletions

View File

@@ -0,0 +1,433 @@
//
// YMLoginVerifBindPhoneViewController.m
// YUMI
//
// Created by YUMI on 2021/9/18.
//
#import "XPLoginVerifBindPhoneViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "YUMIConstant.h"
#import "YUMIMacroUitls.h"
#import "UIImage+Utils.h"
#import "CountDownHelper.h"
///Model
#import "UserInfoModel.h"
///P
#import "XPLoginVerifBindPhoneProtocol.h"
#import "XPLoginVerifBindPhonePresenter.h"
///VC
#import "LoginBindPhoneViewController.h"
#import "XPMineSettingViewController.h"
///View
#import "XPLoginBindSuccessView.h"
@interface XPLoginVerifBindPhoneViewController ()<XPLoginVerifBindPhoneProtocol, CountDownHelperDelegate>
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UILabel *areaLabel;
@property (nonatomic, strong) UIButton *countryBtn;
@property (nonatomic, strong) UIView *areaLineView;
@property (nonatomic, strong) UIView *phoneLineView;
@property (nonatomic, strong) UIView *authLineView;
@property (nonatomic, strong) UILabel *areaCodeLabel;
@property (nonatomic, strong) UIButton *authCodeBtn;
@property (nonatomic, strong) UITextField *phoneNumTextField;
@property (nonatomic, strong) UITextField *authCodeTextField;
@property (nonatomic, strong) UIButton *confirmBtn; //
@property (nonatomic, strong) UILabel *tipsLabel; //
@property (nonatomic, assign) BOOL isResetPhone; //
@end
@implementation XPLoginVerifBindPhoneViewController
- (void)dealloc {
[[CountDownHelper shareHelper] stopCountDown];
}
- (XPLoginVerifBindPhonePresenter *)createPresenter {
return [[XPLoginVerifBindPhonePresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
[self setConfigs];
[self setEvents];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[CountDownHelper shareHelper] stopCountDown];
}
#pragma mark - Private Method
- (void)initSubViews {
[CountDownHelper shareHelper].delegate = self;
[self.view addSubview:self.containerView];
[self.containerView addSubview:self.areaLabel];
[self.containerView addSubview:self.countryBtn];
[self.containerView addSubview:self.areaLineView];
[self.containerView addSubview:self.areaCodeLabel];
[self.containerView addSubview:self.phoneNumTextField];
[self.containerView addSubview:self.phoneLineView];
[self.containerView addSubview:self.authCodeBtn];
[self.containerView addSubview:self.authCodeTextField];
[self.containerView addSubview:self.authLineView];
[self.containerView addSubview:self.confirmBtn];
[self.containerView addSubview:self.tipsLabel];
}
- (void)initSubViewConstraints {
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(0);
make.left.right.bottom.mas_equalTo(0);
}];
[self.areaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(32);
make.top.mas_equalTo(20);
}];
[self.countryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-32);
make.centerY.mas_equalTo(self.areaLabel);
}];
[self.areaLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.areaLabel.mas_bottom).offset(18);
make.left.right.mas_equalTo(0).inset(32);
make.height.mas_equalTo(1);
}];
[self.areaCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.areaLineView.mas_bottom).offset(18);
make.left.mas_equalTo(self.areaLabel);
}];
[self.phoneNumTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(80);
make.centerY.mas_equalTo(self.areaCodeLabel);
make.right.mas_equalTo(self.authCodeBtn.mas_left).offset(-20);
}];
[self.authCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-32);
make.centerY.mas_equalTo(self.areaCodeLabel);
}];
[self.phoneLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.height.mas_equalTo(self.areaLineView);
make.top.mas_equalTo(self.areaCodeLabel.mas_bottom).offset(18);
}];
[self.authCodeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0).inset(32);
make.height.mas_equalTo(48);
make.top.mas_equalTo(self.phoneLineView.mas_bottom);
}];
[self.authLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.left.right.mas_equalTo(self.areaLineView);
make.top.mas_equalTo(self.authCodeTextField.mas_bottom);
}];
[self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(0).inset(32);
make.top.mas_equalTo(self.authLineView.mas_bottom).offset(70);
make.height.mas_equalTo(45);
}];
[self.tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.confirmBtn.mas_bottom).offset(36);
make.centerX.mas_equalTo(0);
}];
}
#pragma mark -
- (void)setConfigs {
switch (self.bindingPhoneNumType) {
case XPBindingPhoneNumTypeEdit:{
self.navigationItem.title = YMLocalizedString(@"XPLoginVerifBindPhoneViewController0");
}
break;
case XPBindingPhoneNumTypeNormal:{
self.navigationItem.title = YMLocalizedString(@"XPLoginVerifBindPhoneViewController1");
}
break;
case XPBindingPhoneNumTypeConfirm:{
self.tipsLabel.hidden = NO;
self.navigationItem.title = YMLocalizedString(@"XPLoginVerifBindPhoneViewController2");
[self.confirmBtn setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController3") forState:UIControlStateNormal];
if (self.userInfo.isBindPhone) {
self.phoneNumTextField.enabled = NO;
self.phoneNumTextField.text = self.userInfo.phone;
}
}
break;
default:
break;
}
RAC(self.confirmBtn,enabled) = [RACSignal combineLatest:@[self.phoneNumTextField.rac_textSignal,self.authCodeTextField.rac_textSignal] reduce:^(NSString *phone,NSString *code){
return @(phone.length == 11 && code.length == 5);
}];
}
#pragma mark
- (void)setEvents {
@weakify(self)
//
[[[self.authCodeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] filter:^BOOL(__kindof UIControl * _Nullable value) {
//
if (self.phoneNumTextField.text.length == 0) {
[self showErrorToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController4")];
return NO;
}else if (self.phoneNumTextField.text.length < 11) {
[self showErrorToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController5")];
return NO;
}else {
return YES;
}
}] subscribeNext:^(id _Nullable x) {
@strongify(self);
[self.presenter phoneSmsCode:self.phoneNumTextField.text type:self.bindingPhoneNumType == XPBindingPhoneNumTypeConfirm ? GetSmsType_Unbind_Phone : GetSmsType_Bind_Phone phoneAreaCode:@""];
}];
//
[[[self.confirmBtn rac_signalForControlEvents:UIControlEventTouchUpInside] filter:^BOOL(__kindof UIControl * _Nullable value) {
@strongify(self)
//
if (self.phoneNumTextField.text.length == 0) {
[self showErrorToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController6")];
return NO;
}else if (self.authCodeTextField.text.length == 0) {
[self showErrorToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController7")];
return NO;
}else {
return YES;
}
}] subscribeNext:^(id _Nullable x) {
@strongify(self)
if (self.bindingPhoneNumType == XPBindingPhoneNumTypeConfirm) {
[self.presenter checkMoblieCodeWithMoblie:self.phoneNumTextField.text code:self.authCodeTextField.text];
} else {
[self.presenter bindkMoblieCodeWithMoblie:self.phoneNumTextField.text code:self.authCodeTextField.text];
}
} error:^(NSError * _Nullable error) {
}];
}
#pragma mark - XPLoginVerifBindPhoneProtocol
- (void)phoneSmsCodeSuccess {
self.authCodeBtn.enabled = NO;
[self showSuccessToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController8")];
[[CountDownHelper shareHelper] openCountdownWithTime:60];
}
- (void)checkMoblieCodeWithMoblieSuccess {
[self showSuccessToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController9")];
[[CountDownHelper shareHelper] stopCountDown];
XPLoginVerifBindPhoneViewController *vc = [[XPLoginVerifBindPhoneViewController alloc] init];
vc.bindingPhoneNumType = XPBindingPhoneNumTypeEdit;
vc.userInfo = self.userInfo;
[self.navigationController pushViewController:vc animated:YES];
}
- (void)bindMoblieCodeWithMoblieSuccess {
[[CountDownHelper shareHelper] stopCountDown];
//
if (self.bindingPhoneNumType == XPBindingPhoneNumTypeEdit) {
@weakify(self);
[XPLoginBindSuccessView showBindSuccessViewWithHandler:^{
@strongify(self);
//
__block __kindof UIViewController *vc;
[self.navigationController.childViewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPMineSettingViewController class]]) {
vc = obj; // VC
}
}];
if ([self.navigationController.childViewControllers containsObject:vc]) {
[self.navigationController popToViewController:vc animated:YES];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}];
} else if (self.bindingPhoneNumType == XPBindingPhoneNumTypeNormal) {
@weakify(self);
[XPLoginBindSuccessView showBindSuccessViewWithHandler:^{
@strongify(self);
[self.navigationController popViewControllerAnimated:YES];
}];
}
self.confirmBtn.enabled = YES; //
}
#pragma mark - CountDownHelperDelegate
///
- (void)onCountdownOpen:(int)time {
[self.authCodeBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPLoginVerifBindPhoneViewController10"), time] forState:UIControlStateDisabled];
}
///
- (void)onCountdownFinish {
self.authCodeBtn.enabled= YES;
[self.authCodeBtn setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController11") forState:UIControlStateNormal];
}
#pragma mark - Getters And Setters
- (UIView *)containerView{
if (!_containerView) {
_containerView = [[UIView alloc] init];
_containerView.backgroundColor = [DJDKMIMOMColor appBackgroundColor];
}
return _containerView;
}
- (UILabel *)areaLabel{
if (!_areaLabel) {
_areaLabel = [[UILabel alloc] init];
_areaLabel.text = YMLocalizedString(@"XPLoginVerifBindPhoneViewController12");
_areaLabel.textColor = [DJDKMIMOMColor secondTextColor];
_areaLabel.font = [UIFont systemFontOfSize:14.f];
_areaLabel.adjustsFontSizeToFitWidth = YES;
}
return _areaLabel;
}
- (UILabel *)areaCodeLabel{
if (!_areaCodeLabel) {
_areaCodeLabel = [[UILabel alloc] init];
_areaCodeLabel.text = @"+852";
_areaCodeLabel.textColor = [DJDKMIMOMColor secondTextColor];
_areaCodeLabel.font = [UIFont systemFontOfSize:14.f];
_areaCodeLabel.adjustsFontSizeToFitWidth = YES;
}
return _areaCodeLabel;
}
- (UIButton *)countryBtn {
if (!_countryBtn) {
_countryBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_countryBtn setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController13") forState:UIControlStateNormal];
[_countryBtn setImage:[UIImage imageNamed:@"mine_item_arrow"] forState:UIControlStateNormal];
_countryBtn.transform = CGAffineTransformMakeScale(-1.0, 1.0);
_countryBtn.titleLabel.transform = CGAffineTransformMakeScale(-1.0, 1.0);
_countryBtn.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
_countryBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
[_countryBtn setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal];
[_countryBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
}
return _countryBtn;
}
- (UIButton *)confirmBtn {
if (!_confirmBtn) {
_confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_confirmBtn setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController14") forState:UIControlStateNormal];
[_confirmBtn setTitleColor:[DJDKMIMOMColor confirmButtonTextColor] forState:UIControlStateNormal];
[_confirmBtn setTitleColor:[DJDKMIMOMColor disableButtonTextColor] forState:UIControlStateDisabled];
[_confirmBtn.titleLabel setFont:[UIFont fontWithName:@"PingFang-SC-Medium" size:18]];
_confirmBtn.layer.cornerRadius = 22.5f;
_confirmBtn.layer.masksToBounds = YES;
_confirmBtn.enabled = NO;
[_confirmBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_confirmBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor disableButtonColor], [DJDKMIMOMColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
}
return _confirmBtn;
}
- (UIButton *)authCodeBtn {
if (!_authCodeBtn) {
_authCodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_authCodeBtn setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController15") forState:UIControlStateNormal];
[_authCodeBtn setTitleColor:[DJDKMIMOMColor appMainColor] forState:UIControlStateNormal];
[_authCodeBtn setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateDisabled];
[_authCodeBtn.titleLabel setFont:[UIFont systemFontOfSize:12.f]];
}
return _authCodeBtn;
}
- (UITextField *)phoneNumTextField {
if (!_phoneNumTextField) {
_phoneNumTextField = [[UITextField alloc] init];
_phoneNumTextField.textColor = [DJDKMIMOMColor mainTextColor];
_phoneNumTextField.font = [UIFont systemFontOfSize:14.f];
_phoneNumTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginVerifBindPhoneViewController16")attributes:@{NSForegroundColorAttributeName: [DJDKMIMOMColor secondTextColor]}];
_phoneNumTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
_phoneNumTextField.borderStyle = UITextBorderStyleNone;
_phoneNumTextField.keyboardType = UIKeyboardTypeNumberPad;
_phoneNumTextField.tintColor = [DJDKMIMOMColor mainTextColor];
}
return _phoneNumTextField;
}
- (UITextField *)authCodeTextField {
if (!_authCodeTextField) {
_authCodeTextField = [[UITextField alloc] init];
_authCodeTextField.textColor = [DJDKMIMOMColor mainTextColor];
_authCodeTextField.font = [UIFont systemFontOfSize:14.f];
_authCodeTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginVerifBindPhoneViewController17")attributes:@{NSForegroundColorAttributeName: [DJDKMIMOMColor secondTextColor]}];
_authCodeTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
_authCodeTextField.borderStyle = UITextBorderStyleNone;
_authCodeTextField.keyboardType = UIKeyboardTypeNumberPad;
_authCodeTextField.tintColor = [DJDKMIMOMColor mainTextColor];
}
return _authCodeTextField;
}
- (UIView *)areaLineView {
if (!_areaLineView) {
_areaLineView = [[UIView alloc] init];
_areaLineView.backgroundColor = [DJDKMIMOMColor dividerColor];
}
return _areaLineView;
}
- (UIView *)phoneLineView {
if (!_phoneLineView) {
_phoneLineView = [[UIView alloc] init];
_phoneLineView.backgroundColor = [DJDKMIMOMColor dividerColor];
}
return _phoneLineView;
}
- (UIView *)authLineView {
if (!_authLineView) {
_authLineView = [[UIView alloc] init];
_authLineView.backgroundColor = [DJDKMIMOMColor dividerColor];
}
return _authLineView;
}
- (UILabel *)tipsLabel{
if (!_tipsLabel) {
_tipsLabel = [[UILabel alloc] init];
_tipsLabel.text = [NSString stringWithFormat:@"如果您的手机号已丢失\n请咨询客服ID%@", @"88001"];
_tipsLabel.textColor = [DJDKMIMOMColor textThirdColor];
_tipsLabel.font = [UIFont systemFontOfSize:14.f];
_tipsLabel.adjustsFontSizeToFitWidth = YES;
_tipsLabel.numberOfLines = 0;
_tipsLabel.hidden = YES;
}
return _tipsLabel;
}
@end