123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614 |
- //
- // YMRegisterView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/5.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMRegisterView.h"
- #import "YMRegisterViewModel.h"
- #import "YMCaptchaPopupView.h"
- #import "CaptchaCenter.h"
- @interface YMRegisterView ()
- /// 注册VM
- @property (nonatomic, strong) YMRegisterViewModel *viewModel;
- /// 背景图
- @property (nonatomic, strong) UIImageView *bgImgv;
- /// 注册提示
- /// 注册提示标签
- @property (nonatomic, strong) UILabel *registerTipsLb1;
- /// 注册提示标签
- @property (nonatomic, strong) UILabel *registerTipsLb2;
- @property (nonatomic, strong) UILabel *titleLb;
- @property (nonatomic, strong) UILabel *titleLine;
- /// 手机视图
- @property (nonatomic, strong) UIView *mobileView;
- /// 手机号标签
- @property (nonatomic, strong) UILabel *mobileLb;
- /// 手机号输入框
- @property (nonatomic, strong) UITextField *mobileInputBox;
- /// 验证码视图
- @property (nonatomic, strong) UIView *verifyCodeView;
- /// 验证码标签
- @property (nonatomic, strong) UILabel *verifyCodeLb;
- /// 验证码输入框
- @property (nonatomic, strong) UITextField *verifyCodeInputBox;
- /// 获取验证码
- @property (nonatomic, strong) YMCaptchaCountdownButton *getVerifyCodeBtn;
- /// 密码视图
- @property (nonatomic, strong) UIView *passwordView;
- /// 密码标签
- @property (nonatomic, strong) UILabel *passwordLb;
- /// 密码输入框
- @property (nonatomic, strong) UITextField *passwordInputBox;
- /// 协议视图
- @property (nonatomic, strong) UIView *agreementView;
- /// 单选按钮
- @property (nonatomic, strong) UIButton *radioBtn;
- /// 协议标签
- @property (nonatomic, strong) YYLabel *agreementLb;
- /// 确定按钮
- @property (nonatomic, strong) UIButton *registerBtn;
- @end
- @implementation YMRegisterView
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
-
- }
- return self;
- }
- - (void)ym_setupViews{
- [self addSubview:self.bgImgv];
- [self addSubview:self.registerTipsLb1];
- [self addSubview:self.registerTipsLb2];
- [self addSubview:self.titleLb];
- [self addSubview:self.titleLine];
- [self addSubview:self.mobileLb];
- [self addSubview:self.mobileView];
- [self addSubview:self.mobileInputBox];
-
- [self addSubview:self.verifyCodeView];
- [self addSubview:self.verifyCodeLb];
- [self addSubview:self.verifyCodeInputBox];
- [self addSubview:self.getVerifyCodeBtn];
-
- [self addSubview:self.passwordView];
- [self addSubview:self.passwordLb];
- [self addSubview:self.passwordInputBox];
-
- [self addSubview:self.agreementView];
- [self.agreementView addSubview:self.radioBtn];
- [self.agreementView addSubview:self.agreementLb];
-
- [self addSubview:self.registerBtn];
-
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
-
- [self.registerTipsLb1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(96));
- make.left.equalTo(self).offset(adapt(30));
- make.right.equalTo(self).offset(adapt(-30));
- }];
- [self.registerTipsLb2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.registerTipsLb1.mas_bottom).offset(adapt(5));
- make.left.equalTo(self).offset(adapt(30));
- make.right.equalTo(self).offset(adapt(-30));
- }];
-
- [self.bgImgv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(193));
- make.left.right.equalTo(self).inset(adapt(20));
- make.height.mas_equalTo(adapt(277));
- }];
-
- [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgImgv).offset(adapt(10));
- make.centerX.equalTo(self.bgImgv);
- }];
- [self.titleLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.titleLb.mas_bottom).offset(adapt(5));
- make.centerX.equalTo(self.bgImgv);
- make.width.mas_equalTo(adapt(28));
- make.height.mas_equalTo(adapt(2));
- }];
-
- [self.mobileLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgImgv).offset(adapt(67));
- make.left.equalTo(self.bgImgv).offset(adapt(20));
- make.right.equalTo(self.bgImgv).offset(adapt(-20));
- }];
-
- [self.mobileView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.mobileLb.mas_bottom).offset(adapt(5));
- make.left.equalTo(self.bgImgv).offset(adapt(20));
- make.right.equalTo(self.bgImgv).offset(adapt(-20));
- make.height.mas_equalTo(adapt(48));
- }];
-
- [self.mobileInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.mobileView);
- make.left.equalTo(self.mobileView).offset(adapt(30));
- make.right.equalTo(self.mobileView);
- make.bottom.equalTo(self.mobileView);
- }];
-
- [self.verifyCodeLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.mobileView.mas_bottom).offset(adapt(20));
- make.left.equalTo(self.bgImgv).offset(adapt(20));
- make.right.equalTo(self.bgImgv).offset(adapt(-20));
- }];
-
- [self.verifyCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.verifyCodeLb.mas_bottom).offset(adapt(5));
- make.left.equalTo(self.bgImgv).offset(adapt(20));
- make.right.equalTo(self.bgImgv).offset(adapt(-20));
- make.height.mas_equalTo(adapt(48));
- }];
-
- [self.verifyCodeInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.verifyCodeView);
- make.left.equalTo(self.verifyCodeView).offset(adapt(30));
- make.bottom.equalTo(self.verifyCodeView);
- }];
- [self.verifyCodeInputBox setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
-
- [self.getVerifyCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.verifyCodeInputBox.mas_right).offset(adapt(10));
- make.right.equalTo(self.verifyCodeView).offset(-20);
- make.top.equalTo(self.verifyCodeView);
- make.bottom.equalTo(self.verifyCodeView);
- }];
-
- [self.passwordLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.verifyCodeView.mas_bottom).offset(adapt(20));
- make.left.equalTo(self.bgImgv).offset(adapt(20));
- make.right.equalTo(self.bgImgv).offset(adapt(-20));
- }];
- [self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.passwordLb.mas_bottom).offset(adapt(5));
- make.left.equalTo(self.bgImgv).offset(adapt(20));
- make.right.equalTo(self.bgImgv).offset(adapt(-20));
- make.height.mas_equalTo(adapt(48));
- }];
-
- [self.passwordInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.passwordView);
- make.left.equalTo(self.passwordView).offset(adapt(30));
- make.right.equalTo(self.passwordView);
- make.bottom.equalTo(self.passwordView);
- }];
-
- [self.registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.passwordView.mas_bottom).offset(adapt(40));
- make.left.equalTo(self.bgImgv).offset(adapt(20));
- make.right.equalTo(self.bgImgv).offset(adapt(-20));
- make.height.mas_equalTo(adapt(48));
- }];
-
- [self.agreementView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.mas_centerX);
- make.bottom.equalTo(self).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
- }];
-
- [self.radioBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.agreementLb.mas_centerY);
- make.left.equalTo(self.agreementView).offset(adapt(5));
- make.width.height.mas_equalTo(adapt(17));
- }];
-
- [self.agreementLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.agreementView).offset(adapt(10));
- make.left.equalTo(self.radioBtn.mas_right).offset(adapt(5));
- make.right.equalTo(self.agreementView).offset(adapt(-5));
- make.bottom.equalTo(self.agreementView).offset(adapt(-10));
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMRegisterViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- RAC(self.viewModel , mobile) = [[RACSignal merge:@[RACObserve(self.mobileInputBox, text),self.mobileInputBox.rac_textSignal]] takeUntil:self.rac_willDeallocSignal];
-
- RAC(self.viewModel , verifyCode) = [[RACSignal merge:@[RACObserve(self.verifyCodeInputBox, text),self.verifyCodeInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
-
- RAC(self.viewModel , password) = [[RACSignal merge:@[RACObserve(self.passwordInputBox, text),self.passwordInputBox.rac_textSignal]]takeUntil:self.rac_willDeallocSignal];
-
- [self.viewModel.validRegisterSignal subscribeNext:^(id _Nullable value) {
- self.registerBtn.enabled = [value boolValue];
- if ([value boolValue]) {
- self.registerBtn.alpha = 1;
- } else {
- self.registerBtn.alpha = 0.5;
- }
- }];
- }
- - (UIImageView *)bgImgv {
- if (!_bgImgv) {
- _bgImgv = [[UIImageView alloc] init];
- _bgImgv.backgroundColor = HexColorFromRGB(0xFFFFFF);
- _bgImgv.layer.masksToBounds = YES;
- _bgImgv.layer.cornerRadius = adapt(20);
- }
- return _bgImgv;
- }
- - (UIView *)mobileView{
- if (!_mobileView) {
- _mobileView = [[UIView alloc]init];
- _mobileView.backgroundColor = HexColorFromRGB(0xF2F5FF);
- _mobileView.layer.masksToBounds = YES;
- _mobileView.layer.cornerRadius = adapt(16);
- }
- return _mobileView;
- }
- - (UILabel *)registerTipsLb1 {
- if (!_registerTipsLb1) {
- _registerTipsLb1 = [[UILabel alloc]init];
- _registerTipsLb1.font = LCBoldFont(32);
- _registerTipsLb1.textColor = HexColorFromRGB(0x333333);
- _registerTipsLb1.textAlignment = NSTextAlignmentLeft;
- _registerTipsLb1.text = @"欢迎注册👏";
- _registerTipsLb1.numberOfLines = 0;
- }
- return _registerTipsLb1;
- }
- - (UILabel *)registerTipsLb2 {
- if (!_registerTipsLb2) {
- _registerTipsLb2 = [[UILabel alloc]init];
- _registerTipsLb2.font = LCBoldFont(15);
- _registerTipsLb2.textColor = HexColorFromRGB(0x545D79);
- _registerTipsLb2.textAlignment = NSTextAlignmentLeft;
- _registerTipsLb2.text = @"注册登录,开启精彩之旅";
- _registerTipsLb2.numberOfLines = 0;
- }
- return _registerTipsLb2;
- }
- - (UILabel *)titleLb {
- if (!_titleLb) {
- _titleLb = [[UILabel alloc] init];
- _titleLb.font = LCBoldFont(15);
- _titleLb.textColor = rgba(252, 94, 158, 1);
- _titleLb.textAlignment = NSTextAlignmentLeft;
- _titleLb.text = @"账号注册";
- }
- return _titleLb;
- }
- - (UILabel *)titleLine {
- if (!_titleLine) {
- _titleLine = [[UILabel alloc] init];
- [_titleLine ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- }
- return _titleLine;
- }
- - (UILabel *)mobileLb{
- if (!_mobileLb) {
- _mobileLb = [[UILabel alloc]init];
- _mobileLb.font = LCBoldFont(13);
- _mobileLb.textColor = HexColorFromRGB(0x333333);
- _mobileLb.textAlignment = NSTextAlignmentLeft;
- _mobileLb.text = @"手机号";
- }
- return _mobileLb;
- }
- - (UITextField *)mobileInputBox{
- if (!_mobileInputBox) {
- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
- style.minimumLineHeight = 0;
- NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入手机号"];
- placeholderAttributed.yy_paragraphStyle = style;
- placeholderAttributed.yy_font = LCFont(14);
- placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
- _mobileInputBox = [[UITextField alloc]init];
- _mobileInputBox.attributedPlaceholder = placeholderAttributed;
- _mobileInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
- _mobileInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
- _mobileInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
- _mobileInputBox.keyboardType = UIKeyboardTypePhonePad;
- _mobileInputBox.ba_maxLength = 11;
- // @weakify(self)
- [[[_mobileInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- // @strongify(self)
-
- }];
- }
- return _mobileInputBox;
- }
- - (UIView *)verifyCodeView{
- if (!_verifyCodeView) {
- _verifyCodeView = [[UIView alloc]init];
- _verifyCodeView.backgroundColor = HexColorFromRGB(0xF2F5FF);
- _verifyCodeView.layer.masksToBounds = YES;
- _verifyCodeView.layer.cornerRadius = adapt(16);
- }
- return _verifyCodeView;
- }
- - (UILabel *)verifyCodeLb{
- if (!_verifyCodeLb) {
- _verifyCodeLb = [[UILabel alloc]init];
- _verifyCodeLb.font = LCBoldFont(13);
- _verifyCodeLb.textColor = HexColorFromRGB(0x333333);
- _verifyCodeLb.textAlignment = NSTextAlignmentLeft;
- _verifyCodeLb.text = @"验证码";
- }
- return _verifyCodeLb;
- }
- - (UITextField *)verifyCodeInputBox{
- if (!_verifyCodeInputBox) {
- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
- style.minimumLineHeight = 0;
- NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入验证码"];
- placeholderAttributed.yy_paragraphStyle = style;
- placeholderAttributed.yy_font = LCFont(14);
- placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
- _verifyCodeInputBox = [[UITextField alloc]init];
- _verifyCodeInputBox.attributedPlaceholder = placeholderAttributed;
- _verifyCodeInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
- _verifyCodeInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
- _verifyCodeInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
- _verifyCodeInputBox.keyboardType = UIKeyboardTypeDecimalPad;
- // @weakify(self)
- [[[_verifyCodeInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- // @strongify(self)
-
- }];
- }
- return _verifyCodeInputBox;
- }
- - (YMCaptchaCountdownButton *)getVerifyCodeBtn{
- if (!_getVerifyCodeBtn) {
- _getVerifyCodeBtn = [YMCaptchaCountdownButton buttonWithType:UIButtonTypeCustom];
- _getVerifyCodeBtn.titleLabel.font = LCFont(14);
- [_getVerifyCodeBtn setTitleColor:HexColorFromRGB(0xFF6893) forState:UIControlStateNormal];
- [_getVerifyCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
- @weakify(self)
- [_getVerifyCodeBtn countDownButtonHandler:^(YMCaptchaCountdownButton *sender, NSInteger tag) {
- @strongify(self)
- if (OCStringIsEmpty(self.mobileInputBox.text)) {
- [ZCHUDHelper showTitle:@"请输入手机号"];
- return;
- }
-
- [self.mobileInputBox resignFirstResponder];
- [self.verifyCodeInputBox resignFirstResponder];
- [self.passwordInputBox resignFirstResponder];
-
-
- [CaptchaCenter.defaultCenter getCaptchaType:^(NSNumber * _Nullable type, NSError * _Nullable error) {
- if (error) {
- [ZCHUDHelper showTitle:@"获取验证码失败"];
- return;
- }
- if ([type isEqualToNumber:@1]) { // 原生
- YMCaptchaPopupView *view = [[YMCaptchaPopupView alloc] init];
- view.cancelButtonTappedBlock = ^{};
- @weakify(self)
- view.confirmButtonTappedBlock = ^(NSString * _Nonnull input) {
- @strongify(self)
- [self getVerifyCodeWithCaptcha:input sender:sender];
- };
- UIView *currentVCView = [LCTools getCurrentVC].view;
- if (currentVCView != nil && ![currentVCView isEqual:NSNull.null]) {
- [view showInView:currentVCView];
- }
- } else { // 阿里
- @weakify(self)
- [CaptchaCenter.defaultCenter verifyCompletion:^(NSString * _Nonnull status, NSDictionary * _Nonnull result) {
- @strongify(self)
- [self getVerifyCodeWithCaptcha:result sender:sender];
- }];
- }
- }];
-
- }];
- }
- return _getVerifyCodeBtn;
- }
- - (void)getVerifyCodeWithCaptcha:(id)captcha sender:(YMCaptchaCountdownButton *)sender {
- @weakify(self)
- [self.viewModel getVerifyCodeWithCaptcha:captcha handler:^(NSDictionary * _Nonnull dic, NSError * _Nullable error) {
- @strongify(self)
- sender.enabled = NO;
-
- [sender startCountDownWithSecond:59];
- [sender countDownChanging:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
- NSString *title = [NSString stringWithFormat:@"重新发送(%zds)",second];
- return title;
- }];
-
- [sender countDownFinished:^NSString *(YMCaptchaCountdownButton *countDownButton, NSUInteger second) {
- countDownButton.enabled = YES;
- return @"重新发送";
- }];
- }];
- }
- - (UIView *)passwordView{
- if (!_passwordView) {
- _passwordView = [[UIView alloc]init];
- _passwordView.backgroundColor = HexColorFromRGB(0xF2F5FF);
- _passwordView.layer.masksToBounds = YES;
- _passwordView.layer.cornerRadius = adapt(16);
- }
- return _passwordView;
- }
- - (UILabel *)passwordLb{
- if (!_passwordLb) {
- _passwordLb = [[UILabel alloc]init];
- _passwordLb.font = LCBoldFont(13);
- _passwordLb.textColor = HexColorFromRGB(0x333333);
- _passwordLb.textAlignment = NSTextAlignmentLeft;
- _passwordLb.text = @"密 码";
- }
- return _passwordLb;
- }
- - (UITextField *)passwordInputBox{
- if (!_passwordInputBox) {
- NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
- style.minimumLineHeight = 0;
- NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入密码"];
- placeholderAttributed.yy_paragraphStyle = style;
- placeholderAttributed.yy_font = LCFont(14);
- placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
- _passwordInputBox = [[UITextField alloc]init];
- _passwordInputBox.attributedPlaceholder = placeholderAttributed;
- _passwordInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
- _passwordInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
- _passwordInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
- _passwordInputBox.keyboardType = UIKeyboardTypeDefault;
- _passwordInputBox.secureTextEntry = YES;
- // @weakify(self)
- [[[_passwordInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- // @strongify(self)
-
- }];
- }
- return _passwordInputBox;
- }
- - (UIView *)agreementView{
- if (!_agreementView) {
- _agreementView = [[UIView alloc]init];
- }
- return _agreementView;
- }
- - (UIButton *)radioBtn{
- if (!_radioBtn) {
- _radioBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_normal_icon") forState:UIControlStateNormal];
- [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_selected_icon") forState:UIControlStateSelected];
- [[[_radioBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
- sender.selected = !sender.selected;
- }];
- }
- return _radioBtn;
- }
- - (YYLabel *)agreementLb{
- if (!_agreementLb) {
- _agreementLb = [[YYLabel alloc] init];
- _agreementLb.numberOfLines = 0;
- _agreementLb.preferredMaxLayoutWidth = kFrameWidth - 55;
- NSString *agreementText = @"同意《用户协议》与《隐私政策》";
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
- paragraphStyle.alignment = NSTextAlignmentLeft;
-
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:agreementText];
- attributedString.yy_font = LCFont(12);
- attributedString.yy_color = HexColorFromRGBA(0x000000,0.65);
- attributedString.yy_paragraphStyle = paragraphStyle;
- //设置高亮色和点击事件
- [attributedString yy_setTextHighlightRange:[agreementText rangeOfString:@"《用户协议》"] color:AGREEMENTColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
- YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
- ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserProtocolH5]
- }];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
- RouterViewModel:webArticleVM
- } completion:nil];
- }];
- //设置高亮色和点击事件
- [attributedString yy_setTextHighlightRange:[[attributedString string] rangeOfString:@"《隐私政策》"] color:AGREEMENTColor backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
- YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
- ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserPrivacyH5]
- }];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
- RouterViewModel:webArticleVM
- } completion:nil];
- }];
- _agreementLb.attributedText = attributedString;
- }
- return _agreementLb;
- }
- - (UIButton *)registerBtn{
- if (!_registerBtn) {
- _registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _registerBtn.titleLabel.font = LCBoldFont(15);
- [_registerBtn setTitle:@"注册" forState:UIControlStateNormal];
- [_registerBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
- [_registerBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- _registerBtn.layer.masksToBounds = YES;
- _registerBtn.layer.cornerRadius = adapt(16);
- WS(weakSelf)
- [[[_registerBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
- if (OCStringIsEmpty(weakSelf.mobileInputBox.text)) {
- [ZCHUDHelper showTitle:@"请输入手机号"];
- return;
- }
- if (OCStringIsEmpty(weakSelf.verifyCodeInputBox.text)) {
- [ZCHUDHelper showTitle:@"请输入手机号"];
- return;
- }
- if (OCStringIsEmpty(weakSelf.passwordInputBox.text)) {
- [ZCHUDHelper showTitle:@"请输入密码"];
- return;
- }
- if (!weakSelf.radioBtn.selected) {
- YMLoginRegistrAgreementPopupView *customView = [[YMLoginRegistrAgreementPopupView alloc]init];
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerAllCorners;
- popupView.positionStyle = YMPositionStyleCenter;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.3;
- [popupView pop];
-
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm) {
- @strongify(popupView)
- if (isConfirm) {
- weakSelf.radioBtn.selected = YES;
- [weakSelf.viewModel registerRequest];
- }
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- customView.dismissBlock = ^{
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- return;
- }
- [weakSelf.viewModel registerRequest];
- }];
- }
- return _registerBtn;
- }
- @end
|