YMSelectedLoginViewController.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. //
  2. // YMSelectedLoginViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/4.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMSelectedLoginViewController.h"
  9. #import "YMSelectedLoginViewModel.h"
  10. @interface YMSelectedLoginViewController ()
  11. /// 选择登录VM
  12. @property (nonatomic, strong) YMSelectedLoginViewModel *viewModel;
  13. /// 启动图
  14. @property (nonatomic, strong) UIImageView *launchscreenImage;
  15. /// 验证码登录
  16. @property (nonatomic, strong) UIButton *verifyCodeLoginBtn;
  17. /// 密码登录
  18. @property (nonatomic, strong) UIButton *passwordLoginBtn;
  19. /// 协议视图
  20. @property (nonatomic, strong) UIView *agreementView;
  21. /// 单选按钮
  22. @property (nonatomic, strong) UIButton *radioBtn;
  23. /// 协议标签
  24. @property (nonatomic, strong) YYLabel *agreementLb;
  25. @end
  26. @implementation YMSelectedLoginViewController
  27. @dynamic viewModel;
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. }
  31. - (void)viewWillAppear:(BOOL)animated{
  32. [super viewWillAppear:YES];
  33. [self.navigationController setNavigationBarHidden:YES animated:YES];
  34. }
  35. - (void)viewWillDisappear:(BOOL)animated{
  36. [super viewWillDisappear:YES];
  37. [self.navigationController setNavigationBarHidden:NO animated:YES];
  38. }
  39. - (void)ym_setupViews{
  40. [self.view addSubview:self.launchscreenImage];
  41. [self.launchscreenImage addSubview:self.verifyCodeLoginBtn];
  42. [self.launchscreenImage addSubview:self.passwordLoginBtn];
  43. [self.launchscreenImage addSubview:self.agreementView];
  44. [self.agreementView addSubview:self.radioBtn];
  45. [self.agreementView addSubview:self.agreementLb];
  46. [self.view setNeedsUpdateConstraints];
  47. [self.view updateConstraintsIfNeeded];
  48. }
  49. - (void)updateViewConstraints{
  50. [self.launchscreenImage mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.equalTo(self.view).priority(1000);
  52. make.left.right.equalTo(self.view);
  53. make.bottom.equalTo(self.view).priority(1000);
  54. }];
  55. [self.verifyCodeLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.centerX.equalTo(self.launchscreenImage.mas_centerX);
  57. make.bottom.equalTo(self.launchscreenImage.mas_centerY).offset(adapt(-20));
  58. make.left.mas_equalTo(self.launchscreenImage).offset(adapt(25));
  59. make.right.mas_equalTo(self.launchscreenImage).offset(adapt(-25));
  60. make.height.mas_equalTo(adapt(45));
  61. }];
  62. [self.passwordLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.centerX.equalTo(self.launchscreenImage.mas_centerX);
  64. make.top.equalTo(self.launchscreenImage.mas_centerY).offset(adapt(20));
  65. make.left.mas_equalTo(self.launchscreenImage).offset(adapt(25));
  66. make.right.mas_equalTo(self.launchscreenImage).offset(adapt(-25));
  67. make.height.mas_equalTo(45);
  68. }];
  69. [self.agreementView mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.centerX.equalTo(self.launchscreenImage.mas_centerX);
  71. make.bottom.equalTo(self.launchscreenImage).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
  72. }];
  73. [self.radioBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.centerY.equalTo(self.agreementLb.mas_centerY);
  75. make.left.equalTo(self.agreementView).offset(adapt(5));
  76. make.width.height.mas_equalTo(adapt(12));
  77. }];
  78. [self.agreementLb mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.top.equalTo(self.agreementView).offset(adapt(10));
  80. make.left.equalTo(self.radioBtn.mas_right).offset(adapt(5));
  81. make.right.equalTo(self.agreementView).offset(adapt(-5));
  82. make.bottom.equalTo(self.agreementView).offset(adapt(-10));
  83. }];
  84. [super updateViewConstraints];
  85. }
  86. - (void)ym_bindViewModel{
  87. }
  88. - (UIImageView *)launchscreenImage{
  89. if (!_launchscreenImage) {
  90. _launchscreenImage = [[UIImageView alloc]init];
  91. _launchscreenImage.contentMode = UIViewContentModeScaleAspectFill;
  92. _launchscreenImage.image = ImageByName(@"vqu_images_ic_login_bg");
  93. _launchscreenImage.userInteractionEnabled = YES;
  94. }
  95. return _launchscreenImage;
  96. }
  97. - (UIButton *)verifyCodeLoginBtn{
  98. if (!_verifyCodeLoginBtn) {
  99. _verifyCodeLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  100. _verifyCodeLoginBtn.backgroundColor = HexColorFromRGB(0xF888E7);
  101. _verifyCodeLoginBtn.titleLabel.font = LCFont(15);
  102. [_verifyCodeLoginBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  103. [_verifyCodeLoginBtn setTitle:@"手机号登录" forState:UIControlStateNormal];
  104. _verifyCodeLoginBtn.layer.cornerRadius = adapt(8);
  105. WS(weakSelf)
  106. [[[_verifyCodeLoginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  107. if (!weakSelf.radioBtn.selected) {
  108. YMLoginRegistrAgreementPopupView *customView = [[YMLoginRegistrAgreementPopupView alloc]init];
  109. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  110. popupView.priority = 999;
  111. popupView.cornerRadius = adapt(10);
  112. popupView.rectCorners = UIRectCornerAllCorners;
  113. popupView.positionStyle = YMPositionStyleCenter;
  114. popupView.isHideBg = NO;
  115. popupView.bgAlpha = 0.3;
  116. [popupView pop];
  117. @weakify(popupView)
  118. customView.buttonBlock = ^(BOOL isConfirm) {
  119. @strongify(popupView)
  120. if (isConfirm) {
  121. weakSelf.radioBtn.selected = YES;
  122. [weakSelf.viewModel gotoLoginVC:LoginCategoryTypeVerifyCode];
  123. }
  124. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  125. };
  126. customView.dismissBlock = ^{
  127. @strongify(popupView)
  128. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  129. };
  130. return;
  131. }
  132. [weakSelf.viewModel gotoLoginVC:LoginCategoryTypeVerifyCode];
  133. }];
  134. }
  135. return _verifyCodeLoginBtn;
  136. }
  137. - (UIButton *)passwordLoginBtn{
  138. if (!_passwordLoginBtn) {
  139. _passwordLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  140. _passwordLoginBtn.backgroundColor = HexColorFromRGB(0xF888E7);
  141. _passwordLoginBtn.titleLabel.font = LCFont(15);
  142. [_passwordLoginBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  143. [_passwordLoginBtn setTitle:@"密码登录" forState:UIControlStateNormal];
  144. _passwordLoginBtn.layer.cornerRadius = adapt(8);
  145. WS(weakSelf)
  146. [[[_passwordLoginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  147. if (!weakSelf.radioBtn.selected) {
  148. YMLoginRegistrAgreementPopupView *customView = [[YMLoginRegistrAgreementPopupView alloc]init];
  149. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  150. popupView.priority = 999;
  151. popupView.cornerRadius = adapt(10);
  152. popupView.rectCorners = UIRectCornerAllCorners;
  153. popupView.positionStyle = YMPositionStyleCenter;
  154. popupView.isHideBg = NO;
  155. popupView.bgAlpha = 0.3;
  156. [popupView pop];
  157. @weakify(popupView)
  158. customView.buttonBlock = ^(BOOL isConfirm) {
  159. @strongify(popupView)
  160. if (isConfirm) {
  161. weakSelf.radioBtn.selected = YES;
  162. [weakSelf.viewModel gotoLoginVC:LoginCategoryTypePassword];
  163. }
  164. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  165. };
  166. customView.dismissBlock = ^{
  167. @strongify(popupView)
  168. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  169. };
  170. return;
  171. }
  172. [weakSelf.viewModel gotoLoginVC:LoginCategoryTypePassword];
  173. }];
  174. }
  175. return _passwordLoginBtn;
  176. }
  177. - (UIView *)agreementView{
  178. if (!_agreementView) {
  179. _agreementView = [[UIView alloc]init];
  180. }
  181. return _agreementView;
  182. }
  183. - (UIButton *)radioBtn{
  184. if (!_radioBtn) {
  185. _radioBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  186. [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_normal_icon") forState:UIControlStateNormal];
  187. [_radioBtn setBackgroundImage:ImageByName(@"ym_login_auth_selected_icon") forState:UIControlStateSelected];
  188. [[[_radioBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
  189. sender.selected = !sender.selected;
  190. }];
  191. }
  192. return _radioBtn;
  193. }
  194. - (YYLabel *)agreementLb{
  195. if (!_agreementLb) {
  196. _agreementLb = [[YYLabel alloc] init];
  197. _agreementLb.numberOfLines = 0;
  198. _agreementLb.preferredMaxLayoutWidth = kFrameWidth - adapt(55);
  199. NSString *agreementText = @"我已阅读并同意《用户协议》和《隐私协议》";
  200. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
  201. paragraphStyle.alignment = NSTextAlignmentLeft;
  202. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:agreementText];
  203. attributedString.yy_font = LCFont(11);
  204. attributedString.yy_color = HexColorFromRGB(0x7E848D);
  205. attributedString.yy_paragraphStyle = paragraphStyle;
  206. //设置高亮色和点击事件
  207. [attributedString yy_setTextHighlightRange:[agreementText rangeOfString:@"《用户协议》"] color:HexColorFromRGB(0xB26AFD) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  208. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  209. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserProtocolH5]
  210. }];
  211. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  212. RouterViewModel:webArticleVM
  213. } completion:nil];
  214. }];
  215. //设置高亮色和点击事件
  216. [attributedString yy_setTextHighlightRange:[[attributedString string] rangeOfString:@"《隐私协议》"] color:HexColorFromRGB(0xB26AFD) backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
  217. YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  218. ParamsUrl:[NSString stringWithFormat:@"%@%@",[LCSaveData getBaseURL]?[LCSaveData getBaseURL]:BaseURL,UserPrivacyH5]
  219. }];
  220. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  221. RouterViewModel:webArticleVM
  222. } completion:nil];
  223. }];
  224. _agreementLb.attributedText = attributedString;
  225. }
  226. return _agreementLb;
  227. }
  228. @end