| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- //
- // YMSelectedLoginViewController.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/4.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMSelectedLoginViewController.h"
- #import "YMSelectedLoginViewModel.h"
- @interface YMSelectedLoginViewController ()
- /// 选择登录VM
- @property (nonatomic, strong) YMSelectedLoginViewModel *viewModel;
- /// 启动图
- @property (nonatomic, strong) UIImageView *launchscreenImage;
- /// 验证码登录
- @property (nonatomic, strong) UIButton *verifyCodeLoginBtn;
- /// 密码登录
- @property (nonatomic, strong) UIButton *passwordLoginBtn;
- /// 协议视图
- @property (nonatomic, strong) UIView *agreementView;
- /// 单选按钮
- @property (nonatomic, strong) UIButton *radioBtn;
- /// 协议标签
- @property (nonatomic, strong) YYLabel *agreementLb;
- @end
- @implementation YMSelectedLoginViewController
- @dynamic viewModel;
- - (void)viewDidLoad {
- [super viewDidLoad];
- }
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:YES];
- [self.navigationController setNavigationBarHidden:YES animated:YES];
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:YES];
- [self.navigationController setNavigationBarHidden:NO animated:YES];
- }
- - (void)ym_setupViews{
-
- [self.view addSubview:self.launchscreenImage];
- [self.launchscreenImage addSubview:self.verifyCodeLoginBtn];
- [self.launchscreenImage addSubview:self.passwordLoginBtn];
-
- [self.launchscreenImage addSubview:self.agreementView];
- [self.agreementView addSubview:self.radioBtn];
- [self.agreementView addSubview:self.agreementLb];
- [self.view setNeedsUpdateConstraints];
- [self.view updateConstraintsIfNeeded];
- }
- - (void)updateViewConstraints{
-
- [self.launchscreenImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view).priority(1000);
- make.left.right.equalTo(self.view);
- make.bottom.equalTo(self.view).priority(1000);
- }];
-
- [self.verifyCodeLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.launchscreenImage.mas_centerX);
- make.bottom.equalTo(self.launchscreenImage.mas_centerY).offset(adapt(-20));
- make.left.mas_equalTo(self.launchscreenImage).offset(adapt(25));
- make.right.mas_equalTo(self.launchscreenImage).offset(adapt(-25));
- make.height.mas_equalTo(adapt(45));
- }];
-
- [self.passwordLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.launchscreenImage.mas_centerX);
- make.top.equalTo(self.launchscreenImage.mas_centerY).offset(adapt(20));
- make.left.mas_equalTo(self.launchscreenImage).offset(adapt(25));
- make.right.mas_equalTo(self.launchscreenImage).offset(adapt(-25));
- make.height.mas_equalTo(45);
- }];
-
- [self.agreementView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.launchscreenImage.mas_centerX);
- make.bottom.equalTo(self.launchscreenImage).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(12));
- }];
-
- [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 updateViewConstraints];
- }
- - (void)ym_bindViewModel{
-
- }
- - (UIImageView *)launchscreenImage{
- if (!_launchscreenImage) {
- _launchscreenImage = [[UIImageView alloc]init];
- _launchscreenImage.contentMode = UIViewContentModeScaleAspectFill;
- _launchscreenImage.image = ImageByName(@"vqu_images_ic_login_bg");
- _launchscreenImage.userInteractionEnabled = YES;
- }
- return _launchscreenImage;
- }
- - (UIButton *)verifyCodeLoginBtn{
- if (!_verifyCodeLoginBtn) {
- _verifyCodeLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _verifyCodeLoginBtn.backgroundColor = HexColorFromRGB(0xF888E7);
- _verifyCodeLoginBtn.titleLabel.font = LCFont(15);
- [_verifyCodeLoginBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
- [_verifyCodeLoginBtn setTitle:@"手机号登录" forState:UIControlStateNormal];
- _verifyCodeLoginBtn.layer.cornerRadius = adapt(8);
- WS(weakSelf)
- [[[_verifyCodeLoginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- 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 gotoLoginVC:LoginCategoryTypeVerifyCode];
- }
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- customView.dismissBlock = ^{
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- return;
- }
- [weakSelf.viewModel gotoLoginVC:LoginCategoryTypeVerifyCode];
-
- }];
- }
- return _verifyCodeLoginBtn;
- }
- - (UIButton *)passwordLoginBtn{
- if (!_passwordLoginBtn) {
- _passwordLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _passwordLoginBtn.backgroundColor = HexColorFromRGB(0xF888E7);
- _passwordLoginBtn.titleLabel.font = LCFont(15);
- [_passwordLoginBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
- [_passwordLoginBtn setTitle:@"密码登录" forState:UIControlStateNormal];
- _passwordLoginBtn.layer.cornerRadius = adapt(8);
- WS(weakSelf)
- [[[_passwordLoginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- 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 gotoLoginVC:LoginCategoryTypePassword];
- }
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- customView.dismissBlock = ^{
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- return;
- }
- [weakSelf.viewModel gotoLoginVC:LoginCategoryTypePassword];
- }];
- }
- return _passwordLoginBtn;
- }
- - (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 - adapt(55);
- NSString *agreementText = @"我已阅读并同意《用户协议》和《隐私协议》";
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
- paragraphStyle.alignment = NSTextAlignmentLeft;
-
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:agreementText];
- attributedString.yy_font = LCFont(11);
- attributedString.yy_color = HexColorFromRGB(0x7E848D);
- attributedString.yy_paragraphStyle = paragraphStyle;
- //设置高亮色和点击事件
- [attributedString yy_setTextHighlightRange:[agreementText rangeOfString:@"《用户协议》"] color:HexColorFromRGB(0xB26AFD) 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:HexColorFromRGB(0xB26AFD) 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;
- }
- @end
|